DKM-411 Modbus Application Manual V3.0
(15.01.2017)
- 8 -
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
6
2
Register address high
See below the description of available registers
3
Register address low
4
Data high byte
5
Data low byte
6
CRC low byte
See below for the checksum calculation
7
CRC high byte
Here is the sequence to write the value 0010h to the register 40h (64 decimal):
01 06 00 40 00 10 89 D2 (each byte is expressed as 2 hexadecimal characters)
The checksum value in the above message may be used for the verification of checksum calculation
algorithm
The normal response will be the same as the query:
Byte
Description
Value
0
Controller address
1 to 240
1
Function code
6
2
Register address high
See below the description of available registers
3
Register address low
4
Data high byte
5
Data low byte
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
134 (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 (SINGLE REGISTER)