Modbus - Signed and unsigned numbers
On this page
Signed and unsigned integers can be stored in the registers. The unsigned numbers are read from or written to the Modbus device using simple addressing, like H or R to holding and input registers. To use signed integers, add the suffix “n” to the address. Using tag Hn:5 means that access the holding register at address 5 and the number will be interpreted as the signed integer.
In 32-bit data type numbers, the signed integers are used by default, and the suffix “n” is not used.
Example:
An example of advanced Modbus functionality can be seen on ModbusDemo screen, which can be downloaded as a part of the demo project from:
The current values of inputs and outputs are visible in the upper part of the screen. Further, the current values of holding registers H:0 and H:1 and their data interpretation if the stored numbers are signed integers, float numbers, or 32-bit integers. To set the register, click on the Set or Toggle buttons. Figure 46 shows the storage of a floating point number 376.455 stored using an Hf:0 register, and the floating-point value 2.456 is stored in the input register Rf:0. z
