
7
Modbus Protocol Basics
Retrieving and setting controller parameters
Parameters grouped based on functionality:
• read only – accessed with read inputs and read registers functions (03)
• read & write – accessed with functions related to coils and holding registers
Read coils (0x01)
Read from 1 to 2000 maximum contiguous status of coils
Request
Function code
1 byte 0x01
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of coils
2 bytes 1 to 2000 (1 to 0x7D0)
Normal
answer
Function code
1 byte 0x01
Bytes count
1 byte n
Coil status
n bytes 1 to 2000/8 (maximum 250)
Read discrete inputs (0x02)
Read from 1 to 2000 maximum contiguous status of discrete inputs
Request
Function code
1 byte 0x02
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of discrete inputs
2 bytes 1 to 125 (1 to 0x7D)
Normal
answer
Function code
1 byte 0x02
Bytes count
1 byte n
Discrete inputs – n bytes
n bytes 1 to 2000/8 (max 250)
Read holding registers (0x03)
Read from 1 to 125 maximum contiguous holding registers
Request
Function code
1 byte 0x03
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of holding registers 2 bytes 1 to 125 ( 1 to 0x7D)
Normal
answer
Function code
1 byte 0x03
N
= 1 to 125
Bytes count
1 byte 2*N
Holding register – 2*N bytes n bytes N*2 bytes
Read input registers (0x04)
Read from 1 to 125 maximum contiguous input registers
Request
Function code
1 byte 0x04
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of input registers
2 bytes 1 to 125 (1 to 0x7D)
Normal
answer
Function code
1 byte 0x03
N
= 1 to 125
Bytes count
1 byte 2*N
Input register – 2*N bytes
n bytes N*2 bytes