DKM-411 Modbus Application Manual V3.0
(15.01.2017)
- 9 -
The function 06 (write single register) and the function 16 (write multiple registers) are used for data
writing.
The MODBUS master will send a query containing data to be written. The answer will be one of the below:
-A normal response confirming successful write,
-An exceptional response indicating a write error.
Only some of the available registers are authorized to be written. An attempt to write a write protected
register will result to the exceptional response.
The query message specifies the register address and data. The message structure is below:
Byte
Description
Value
0
Controller address
1 to 240
1
Function code
16
2
Starting address high
See below the description of available registers
3
Starting address low
4
Number of registers high
always 0
5
Number of registers low
max ??
6
Data lenght in
bytes
(L)
number of registers * 2
7
High byte of 1st register
8
Low byte of 1st register
9
High byte of 2nd register
10
Low byte of 2nd register
....
L+5
High byte of the last register
L+6
Low byte of the last register
L+7
CRC low byte
See below for the checksum calculation
L+8
CRC high byte
The normal response is below:
Byte
Description
Value
0
Controller address
1 to 240
1
Function code
16
2
Starting address high
See below the description of available registers
3
Starting address low
4
Number of registers high
always 0
5
Number of registers low
max ??
6
CRC low byte
See below for the checksum calculation
7
CRC high byte
The exceptional response will be:
Byte
Description
Value
0
Controller address
same as in the query
1
Function code
144 (function code + 128)
2
Exception code
2 (illegal address)
or
10 (write protection)
3
CRC low byte
See below for the checksum calculation
4
CRC high byte
DATA WRITING (MULTIPLE REGISTERS)