[MODBUS/TCP] variable type

aagueda
2018-06-20
6 days ago
  • aagueda

    aagueda - 2018-06-20

    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

    IMG: codesys1.png

    IMG: codesys2.png

    IMG: Data transform.png

     
  • 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

     

    Related

    Talk.ru: 1

  • aagueda

    aagueda - 2018-06-25

    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,

    IMG: forum_codesys1.png

    IMG: forum_codesys.png

     
  • Comingback4u

    Comingback4u - 2018-06-25

    A Union is a DUT (Data unit type). See example below. Using the original value you see the float/real value of 49.75

    IMG: UnionExample.PNG

     
  • aagueda

    aagueda - 2018-06-29

    Correctly read!!

    Thanks for the very helpful time you've spent!

     
  • rojak

    rojak - 2020-07-05

    Hi,
    Can you please share with me the program for the ieee conversion?
    Thanks

     

Log in to post a comment.