8.6 Data Encoding
Modbus data is normally encoded into a 16 bit signed integer representation.
Integer format data, including any value without a decimal point or represented by a textual value (for example ‘off’, or ‘on’), is sent as a simple integer value.
For floating point data, the value is represented as a ‘scaled integer’, in which the value is sent as an integer which gives the result of the value multiplied by 10 to the power of the decimal resolution for that value. This is easiest to understand by reference to examples:
FP Value |
Integer Representation |
9. |
9 |
-1.0 |
10 |
123.5 |
1235 |
9.99 |
999 |
It may be necessary for the Modbus host to insert or remove a decimal point when using these values.
It is possible to read floating point data in a native 32 bit IEEE format. This is described in the Digital Communications Manual which is available from your supplier.
For time data, for example, the length of a dwell, the integer representation depends on the resolution. For ‘hours’ resolution, the value returned is the number of minutes the value represents, so for example a value of 2:03 (2 hours and three minutes) would be returned as an integer value of 123. For ‘minutes’ resolution, the value used is the number of seconds the value represents, so that 12:09 (12 minutes and 9 seconds) would be returned as 729.
It is possible to read time data in a native 32 bit integer format, in which case it returns the number of milliseconds the variable represents regardless of the resolution. This is described in the Digital Communications Manual.