Modbus reference

Functions, exceptions, addressing and byte order.

Functions

FunctionNameUse
01Read CoilsDigital outputs (up to 2000 bits)
02Read Discrete InputsDigital inputs
03Read Holding RegistersParameters and values (up to 125 registers)
04Read Input RegistersRead-only measurements
05Write Single CoilSwitch one output
06Write Single RegisterOne 16-bit register
15Write Multiple CoilsSeveral outputs
16Write Multiple Registers32/64-bit values and blocks (up to 123)
43/14Read Device IdentificationManufacturer, model, version

Exceptions

CodeMeaning
01Function not supported
02Address does not exist
03Invalid value or quantity
04Slave failure
05Accepted, processing
06Slave busy
08Memory parity error
0AGateway has no path
0BDevice behind the gateway did not answer

Codes 07 and 09 do not exist.

Addressing: base 0, base 1 and 4xxxx

The protocol sends the offset (0 to 65535). Manuals often use the classic notation, which starts at 1 and gives the table by its first digit: 0xxxx coils, 1xxxx discrete, 3xxxx input, 4xxxx holding. So 40001 is the holding register at offset 0, and 400101 (six digits) is offset 100.

Byte order

The bytes of a 32-bit value are A (most significant), B, C and D. Example with 123.456 as FLOAT32 (0x42F6E979):

OrderRegister 1Register 2
ABCD42F6E979
CDABE97942F6
BADCF64279E9
DCBA79E9F642

For 64 bits, the same rule applies to all four registers.