The FreeForm CAN application does not directly translate IEEE-754 formatted data into a floating point data type. To do the conversion a script routine is used as shown in the attached example.
- Setup the freeform message like normal and assign the variable to four contiguous bytes. If the variable is split across byte boundaries then it must be reconstructed as shown in this article.
- Leave the Freeform variable data type at the default setting.
- Create a new variable in the programming tab set to Float data type
- Create a script routine that puts the freeform message variable into a CAN buffer as a INT32 then extract it out of the buffer as a Float as shown in the example. Do not use the fpFromIEEE function in the math extensions library.
CANMessageBuffer buffer; //create a CAN message buffer instance
buffer.Size = 4; //set the buffer size to the number of bytes in our IEEE variable
buffer.WriteInt32(0, IEEEValue); //write the IEEE variable to the buffer as a INT32 data type
FloatValue = buffer.ReadFloat(0); // read the data back out as a Float data type
- Use a online calculator to determine what the decimal equivalent of the IEEE formated value is and vice-a-versa. Here is a good example calculator.
The example configuration was created in version 2.9.23044 for a PV450