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,
Antton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-06-20
Originally created by: ph0010421
Hello
Create a UNION with members...
AsWord: ARRAY[0..1] OF WORD;
AsREAL: REAL;
Map your Modbus Words to Array members [0] and [1].
Your REAL number will be the Hz.
You may need to swap the map to [0] and [1] if the REAL number is wrong.
Regards
Paul
Good morning,
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,
Antton
Originally created by: ph0010421
Hello
Create a UNION with members...
AsWord: ARRAY[0..1] OF WORD;
AsREAL: REAL;
Map your Modbus Words to Array members [0] and [1].
Your REAL number will be the Hz.
You may need to swap the map to [0] and [1] if the REAL number is wrong.
Regards
Paul
Related
Talk.ru: 1
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,
Antton,
A Union is a DUT (Data unit type). See example below. Using the original value you see the float/real value of 49.75
Correctly read!!
Thanks for the very helpful time you've spent!
Hi,
Can you please share with me the program for the ieee conversion?
Thanks
I have always used this one:
https://babbage.cs.qc.cuny.edu/IEEE-754.old/Decimal.html
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/