Read floating input registers using MB_RTU_FC4 function block

Hello,
I have a program where I want to read an input register which is a FLOAT data type but I can’t interpret the value correctly unlike other data types like INTEGERS and BOOLEANS. For example, I read an INTEGER register that has the current year stored and after converting it with TO_INT I get the current year unlike reading a FLOAT value and converting it to REAL where I don’t read the correct value. Can anyone help with the interpretation of this input register? Thanks in advance.

image.png

Hello!
Register interpretation depends on how float packed in remote device. One of common situation is that float store it’s value in two consequent registers e.g. DWORD in IEEE 754 standart. You have to get additional info about that from remote device manual or etc. If it is so, you just use TO_REAL() builtin function, and play around word order, to get correct float representation.
DW.W0 := arrReadDataMedidor[1]; DW.W1 := arrReadDataMedidor[2];//[1] & [2] may be switched
reg_convert_to_real := TO_REAL(DW);

Best regards

Hello!</p>Register interpretation depends on how float packed in remote device. One of common situation is that float store it’s value in two consequent registers e.g. DWORD in IEEE 754 standart. You have to get additional info about that from remote device manual or etc. If it is so, you just use TO_REAL() builtin function, and play around word order, to get correct float representation. </p>DW.W0 := arrReadDataMedidor[1]; DW.W1 := arrReadDataMedidor[2];//[1] & [2] may be switched</p>reg_convert_to_real := TO_REAL(DW);</p>Best regards</p>

Thanks, I was able to resolve this by swapping the second register and got the desired value.