I am kind of new to codesys, and on my project I am reading from a Schneider energy meter over modbus/tcp, but the variables that I get are in FLOAT32 format.
As an example, I read the current frequency on the network, that should be around 50Hz, and I get the 16967 value, or 4247 in Hex, which transformed with an online hex to float converter gives me the 49.75 value.
How can I transform the data in codesys?
check attached files,
thanks in advance,
Originally created by: ph0010421
Create a UNION with members...
AsWord: ARRAY[0..1] OF WORD;
Map your Modbus Words to Array members  and .
Your REAL number will be the Hz.
You may need to swap the map to  and  if the REAL number is wrong.
thanks for the reply!
I tried what I think you mean, but I do still read the 16968 value.
Any other suggestion? or may I be doing it wrong?
Thanks in advance,
A Union is a DUT (Data unit type). See example below. Using the original value you see the float/real value of 49.75
Thanks for the very helpful time you've spent!
Can you please share with me the program for the ieee conversion?
I have always used this one:
I wrote a extensive guide on how to set up MODBUS TCP communication between codesys controllers: http://disorder.dk/wonderware/2020/10/07/modbus-tcp-between-codesys-controllers/
Log in to post a comment.