Sannin Posted November 3, 2022 Report Posted November 3, 2022 (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 Edited November 3, 2022 by Sannin
pturmel Posted November 3, 2022 Report Posted November 3, 2022 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
Sannin Posted November 3, 2022 Author Report Posted November 3, 2022 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.
photovoltaic Posted November 3, 2022 Report Posted November 3, 2022 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
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