Menu ▾ ▴

#12 function toPLCfloat

open
nobody
None
5
2008-07-18
2008-07-18
Anonymous
No

The function toPLCfloat does no byte swapping even if DAVE_LITTLE_ENDIAN is defined.
This is caused by the following line in this function:
f.a=ff;
After removing this line, the function works well.

Discussion

  • Marco Mueller

    Marco Mueller - 2009-10-27

    The code have no meaning without the line f.a=ff;.

    Bit i have a problem with this function in .NET.
    When you convert a single with toPLCfloat an the Result is in LittleEndian not a number the .NET framwork change the value.

    For example you convert the value 0.69915 with toPLCfloat() the result is QNAN.
    When you write this value to the PLC you have the value 0.0027 because the .NET default value for QNAN is 0.0027.

    I think i change the toPLCfloat function in .NET that they returns a ByteArray.

    Greets Marco

     
  • Alex Fomenko

    Alex Fomenko - 2010-01-07

    The problem in the function toPLCfloat exists. There are 2 lines with f.a=ff; (line 1921 and 1929) if we remove line 1929 the function will work correct

    to genesis_81 I think you have to use function daveToPLCfloat

     

Log in to post a comment.