SR05-D1A3-PV manual v1801 75/83
9.10 Appendix on floating point format conversion
For efficient use of microcontroller capacity some registers in the SR05 contain data in a
float or floating point format. In fact, a floating point is an approximation of a real
number represented by a number of significant digits (mantissa) and an exponent. For
implementation of the floating point numbers, Hukseflux follows the IEEE 754 standard.
In this example the floating point of register 0x1029 and 0x102A is converted to the
decimal value it represents. In the Sensor Manager software and other Modbus tools,
floating point data will be converted to decimal data automatically.
Example of the calculation of register 0x1029 + 0x102A representing a floating point for
the sensitivity of the sensor, which is 15.14:
Data in register 0x1029, 16754 (MSW)
Data in register 0x102A, 15729 (LSW)
Double word:
(MSW x 2
16
) + LSW so: (16754 x 2
16
) + 15729 = 1098005873
According to IEEE 754:
Sign bit:
1098005873 < 2147483647 so: sign bit = 1;
The number 2147483647 is defined by IEEE 754
Exponent:
1098005873 / 2
23
= 130 (digits after the decimal point are ignored)
130 – 127 = 3 so: exponent = 3;
The number 127 is a constant defined by IEEE 754
Mantissa:
130 x 2
23
= 1090519040
1098005873 – 1090519040 = 7486833
7486833 / 2
23
= 0.8925
According to IEEE 754, 1 has to be added to get mantissa
0.8925 + 1 = 1.8925 so: mantissa = 1.8925
Calculation of floating point:
float = sign bit x mantissa x (2
exponent
) = 1 x 1.8925 x 2
3
= 15.14
so: floating point = 15.14