ModSnmp Manual v3.07 - 6.1. Modbus Variables

Download manual: PDF HTML

6.1. Modbus Variables

The Modbus protocol uses four different types of variable: Holding Registers, Input Registers, Coils and Discrete Inputs.

Each of these variable types has its own address range, using addresses that are integers in the range 0 to 65535.

The manuals for many Modbus devices adopt the confusing convention of adding an offset to Modbus addresses to indicate the type of variable:

Variable type Offset
Coil 1
Discrete Input 10001 or 100001
Input Register 30001 or 300001
Holding Register 40001 or 400001

The manuals for some Modbus devices simply add an offset of 1 to all addresses, so that, for example, "Holding Register 123" would have an address of 122.

ModSnmp requires actual Modbus addresses (as sent in Modbus messages), so you may have to subtract the appropriate offset from the addresses in device manuals.

Holding Registers and Input Registers are normally 16-bit variables, although ModSnmp supports extensions of the Modbus protocol that allow 32-bit and 64-bit variables. Holding Registers may be read or written, whereas Input Registers are read-only.

Coils and Discrete Inputs are 1-bit variables. Coils may be read or written, whereas Discrete Inputs are read-only.

The Modbus protocol places no interpretation on the values of its variables (they are simply bit-patterns to be transported in Modbus messages), although they are typically treated as integers.