Jump to content

Recommended Posts

Posted (edited)

Hello everyone, I have a little problem that will surely be nonsense for you. I have to transmit in modbus tcp with WORD array of the temperatures converted from REAL. The problem is that when they are converted to WORD arrays they lose decimals. How can I do to transmit them also with decimals? Thank you

 

Modbus TCP.jpg

Edited by Sannin

Posted

Words are integers, so have no decimal, by definition.  The most common way to address this is simply to multiply by ten or one hundred, and transmit with an implicit one or two decimal places.  (Multiply before converting to integer.)

  • Like 1
Posted
53 minutes ago, pturmel said:

Words are integers, so have no decimal, by definition.  The most common way to address this is simply to multiply by ten or one hundred, and transmit with an implicit one or two decimal places.  (Multiply before converting to integer.)

Thank you very much, a very simple solution that I hadn't thought of, thank you very much.

Posted
1 hour ago, Sannin said:

Thank you very much, a very simple solution that I hadn't thought of, thank you very much.

If the device you are sending these to can't recombine the words then divide then this method won't work. You may need to use copyRealToDword and then split the DWORD into 2 words.

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...