Sannin

MODBUS TCP

4 posts in this topic

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

Share this post


Link to post
Share on other sites

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.)

1 person likes this

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

1 person likes this

Share this post


Link to post
Share on other sites

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