
Modbus Protocol Basics
8
Write single coil (0x05)
Write a single coil
Request
Function code
1 byte 0x05
Coil address
2 bytes 0 to 65535 (0 to 0xFFFF)
Coil value
2 bytes 0x0000 or 0xFF00
Normal
answer
Function code
1 byte 0x05
Coil address
1 byte 0x0000 to 0xFFFF
Coil value
n bytes 0x0000 or 0xFF00
Write single register (0x06)
Write a single hold register
Request
Function code
1 byte 0x06
Register address
2 bytes 0 to 65535 (0 to 0xFFFF)
Register value
2 bytes 0x0000 to 0xFFFF
Normal
answer
Function code
1 byte 0x06
Register address
1 byte 0 to 65535 (0 to 0xFFFF)
Register value
n bytes 0x0000 to 0xFFFF
Write multiple coils (0x0F)
Write multiple consecutive coils (1 to 123)
Request
Function code
1 byte 0x0F
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of outputs
2 bytes 1 to 1968 (1 to 0x07B0)
Byte count
Outputs / 8 1 to 246 (1 to 0xF6)
Normal
answer
Function code
1 byte 0x0F
Starting address
1 byte 0 to 65535 (0 to 0xFFFF)
Quantity of outputs
n bytes 0x0001 to 0x07B0
Write multiple registers (0x10)
Write a block of contiguous registers (1 to 123)
Request
Function code
1 byte 0x10
Starting address
2 bytes 0 to 65535 (0 to 0xFFFF)
Quantity of registers
2 bytes 0x0001 to 0x7B
Byte count
1 byte Registers * 2
Registers value
Registers * 2
Normal
answer
Function code
1 byte 0x10
Starting address
1 byte 0 to 65535 (0 to 0xFFFF)
Quantity of registers
n bytes 0x0001 to 0x7B
Errors
Function code
1 byte
Function code + 0x80
Starting address
2 bytes
01 or 02 or 03 or 04