Modbus Function Code 3
Read Multiple Holding Registers on Modbus
It is used for reading contents on a contiguous block of holding registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15.
Request
Function code | 1 Byte | 0x03 |
Starting Address | 2 Bytes | 0x0000 to 0xFFFF |
Quantity of Registers | 2 Bytes | 1 to 125 (0x7D) |
Response
The register data in the response message is packed in two byte values per register (Table 2). For each register, the first byte contains the high order bits and the second contains the low order bits.
Function code | 1 Byte | 0x03 |
Byte count | 1 Byte | 2 x N* |
Register value | N* x 2 Bytes |
Table 2 - Response structure
Error
Error code | 1 Byte | 0x83 |
Exception code | 1 Byte | 01 or 02 or 03 or 04 |
Example
Request
This command is requesting the content of analog output holding registers # 40112 to 40114 from the slave device with address 11. Each register contains 16 bits.
0B 03 006F 0003 357C |
- 0B: The Slave Address (0B hex = address 11)
- 03: The Function Code 3 (Read Multiple Holding Registers)
- 006F: The Data Address of the first register requested (006F hex = 111, +40001 offset = input #40112).
- 0003: The total number of registers requested (read 3 registers 40112 to 40114).
- 357C: The CRC (Cyclic Redundancy Check) for error checking.
Response
0B 03 06 AE41 5652 4340 FACD |
- 0B: The Slave Address (0B hex = address 11)
- 03: The Function Code 3 (Read Multiple Holding Registers)
- 06: The number of data bytes to follow (3 registers x 2 bytes each = 6 bytes)
- AE41: The contents of register 40112
- 5652: The contents of register 40113
- 4340: The contents of register 40114
- FACD: The CRC (Cyclic Redundancy Check)
Workflow Diagram for Modbus FC 3
Contents retrieved from
- http://modbus.org/
- http://www.simplymodbus.ca/
More information
- Modbus Function Codes
- Mobdbus function code 1 - read coils
- Mobdbus function code 2 - read discrete inputs
- Mobdbus function code 3 - read multiple holding registers
- Mobdbus function code 4 - read input registers
- Mobdbus function code 5 - write single coil
- Mobdbus function code 6 - write single holding register
- Mobdbus function code 15 - write multiple coils
- Mobdbus function code 16 - write multiple holding registers
- Modbus References
- Modbus protocol basics