Jump to content
Sign in to follow this  
mcmahoney

Modbus and Unsigned Ints

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...