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. Quote 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.