How to Convert ascii string to real value?

mzychowicz
2023-02-16
2023-02-20
  • mzychowicz - 2023-02-16

    Does anyone know how to convert an ascii string to the real value? I am taking a hex buffer (42,14,8F,5C) and converting to its ascii equivalent using oscat_basic.BUFFER_TO_STRING. I am now stuck on how to convert this value in its real value (37.140) to display on HMI. Thanks.

     
  • ph0010421 - 2023-02-16

    that's the bit pattern for an iee754 floating point number, not a string.
    And it's 3.714 not 37.14

     
  • rickj - 2023-02-20

    If you are starting with IEE754 (a codesys REAL type) then you could use "SomeString := TO_STRING(UrRealVal);" Probably it would be better to put "UrRealVal" into a TextVariable field and a format (i.i. %2.3f) in the Text field of a viosualization element.

     

Log in to post a comment.