Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
Hi, The Modbus feature in Codesys regards incoming variables as 'WORD' types. My RS485 kWhr meter sends data via two 16 bit REAL numbers which form the 'Hi Byte' & 'Low Byte' of the transmitted value. (Definitely overkill for my application.) I can read the separately received WORDS in Codesys but clearly they are unusable in that format. Can someone show me the way to convert these back to a single REAL variable? Thanks in anticipation,
Regards
Bernie
There are many tricks to shuffle 4 bytes into a REAL. Try reading up on a UNION in which you can declare a REAL, 2 WORDS and 4 BYTE's to occupy the same memory space.
good luck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, The Modbus feature in Codesys regards incoming variables as 'WORD' types. My RS485 kWhr meter sends data via two 16 bit REAL numbers which form the 'Hi Byte' & 'Low Byte' of the transmitted value. (Definitely overkill for my application.) I can read the separately received WORDS in Codesys but clearly they are unusable in that format. Can someone show me the way to convert these back to a single REAL variable? Thanks in anticipation,
Regards
Bernie
Talk Topic about project #bernie-bbq
That's possible, but it involves some ugly hardware-dependent trickery.
Can you share the platform the Codesys runtime is running on? Both OS and processor.
A REAL is 32 bits wide, google for IEE754
There are many tricks to shuffle 4 bytes into a REAL. Try reading up on a UNION in which you can declare a REAL, 2 WORDS and 4 BYTE's to occupy the same memory space.
good luck