- 39 -
6.4.4
Function Code 23 (Read and Write Multiple Holding Registers)
Function code 23 (0x17) is used to perform a combination of one read operation and one write
operation. A block of contiguous data will be written to specified multiple registers, then a block of
contiguous data will be read from specified multiple registers. The write operation is performed
before the read.
Function code 23 (0x17) applies only to Modbus TCP (Ethernet) and it does not
apply to Modbus RTU (RS-485)
Example of request message
The master sends function code = 23 (0x17) to the slave (unit ID = 05). Two words of data (current
gas concentration and F.S. code) starting from register address 41039 (relative address = 1038
(0x040E)) will be read, then two words of data (Test mode ON command and test gas concentration)
will be written to register addresses 40048 (relative address = 47 (0x002F)) and 40049 (relative
address = 48 (0x0030)) respectively.
Test mode ON command = ON (0x0001)
Test gas concentration = 25%F.S. (0x0019)
Message frame
Modbus TCP
Modbus RTU
Remarks
Data item
Data
size
(byte)
No.
Byte
data
Hex
No.
Byte
data
Hex
TRXN
ID
Hi
2
(1)
0
0x00
–
–
–
Lo
(2)
0
0x00
–
–
–
Protocol
ID
Hi
2
(3)
0
0x00
–
–
–
Fixed at “00”.
Lo
(4)
0
0x00
–
–
–
Quantity
of
comm.
data
Hi
2
(5)
11
0x00
–
–
–
Number of data
which follows
unit ID
Lo
(6)
0x0B
–
–
–
Unit ID
1
(7)
3
0x03
–
–
–
Function code
1
(8)
16
0x10
–
–
–
Read
starting
address
Hi
2
(9)
1038
0x00
–
–
–
Lo
(10)
0x2F
–
–
Quantity
of
registers
to be
read
Hi
2
(11)
2
0x00
–
–
–
Range: 1–125
Lo
(12)
0x02
–
–
–
Write
starting
address
Hi
2
(13)
47
0x00
–
–
–
Lo
(14)
0x2F
–
–
–
Quantity
of
registers
to be
written
Hi
2
(15)
2
0x00
–
–
–
Range: 1–121
Lo
(16)
0x02
–
–
–
Quantity of data
1
(17)
4
0x04
–
–
–
Quantity of data
= N x 2 bytes
N: Quantity of
registers
NOTE