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

bernie-bbq:

bernie-bbq
2021-07-25
2024-02-21
  • bernie-bbq - 2021-07-25

    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

     
  • sgronchi - 2021-07-25

    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.

     
  • hermsen

    hermsen - 2021-07-25

    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

     

Log in to post a comment.