Common MODBUS functions • 293
Function code FC23 (Read/Write multiple registers)
Modular I/O System
ETHERNET TCP/IP
6.2.11 Function code FC23 (Read/Write multiple registers)
This function reads the register values and writes the values into a number of
output words (also ”Output Register“).
Request
The first register is addressed with 0.
The inquiry message determines the registers to be read and set. The data is
sent as 2 bytes per register.
Example: The data in register 3 is set to value 0x0123, and values 0x0004 and
0x5678 are read out of the two registers 0 and 1.
Byte
Field name
Example
Byte 0
MODBUS function code
0x17
Byte 1-2
reference number for read
0x0000
Byte 3-4
Word count for read (1-125)
0x0002
Byte 5-6
reference number for write
0x0003
Byte 7-8
Word count for read (1-100)
0x0001
Byte 9
Byte Count
(B = 2 x word count for read)
0x02
Byte
10-(B+9)
Register Values
0x0123
Response
Byte
Field name
Example
Byte 0
MODBUS function code
0x17
Byte 1
Byte Count
(B = 2 x word count for read)
0x04
Byte 2-(B+1)
Register Values
0x0004
0x5678
Exception
Byte
Field name
Example
Byte 0
MODBUS function code
0x97
Byte 1
Exception code
0x01 or 0x02
Note
Should register areas for read and write overlap, the results are undefined.