mcmahoney Posted June 30, 2011 Report Share Posted June 30, 2011 I have a project that reads the 16 bit registers from a slave device and have a problem with reading the unsigned value. I have worked out a way to read the value. if the value is positive, then I read it directly. If the value is negative, I add the value to 65535 and store it in a long location. I was wondering if there was a cleaner way of doing this. Link to comment Share on other sites More sharing options...
MVP 2014 Simon Posted July 1, 2011 MVP 2014 Report Share Posted July 1, 2011 I took a quick look and the Modbus Read Holding Registers function allows you to assign DW as the Master Start of Vector. So you should be able to drop the unsigned 16-bit values directly into DW operands, which are 32-bit unsigned type. That sounds like a solution, but give it a try first. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now