DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Raw hex data to float

Hello,

I'm having issues getting some data from a PLC through TCP modbus connexion.

The PLC is sending on one register the float value "1.5252", but I didn't manage to get this value directly.

 

By playing on the registers, I managed to get on one output the hex value 3fc3 and on a second one 39c1. (screenshot)

 

Using an hex converter online it confirms that 0x3fc339c1 is a representation of "1.5252".

 

Yoruk_0-1688998726370.png

 

But now I'm looking for a way to convert these two 16 bits registers into the real float value. I tried to look around bit shifting operations, but the actual definition of the float format (https://en.wikipedia.org/wiki/Single-precision_floating-point_format#/media/File:Float_example.svg) is a bit difficult to handle by direct bit shifting (in my opinion).

Of course I tried this :

Yoruk_1-1688999132677.png

 

But it looks like that the "32 bits floating point" is not the good converting convention. (works fine for integers)

 

And I cannot change the format on the PLC side.

Any ideas to solve this ?

Thanks in advance !

 

 

 

0 Kudos
Message 1 of 1
(1,888 Views)