
5.7 Self-diagnostic Function
In Modbus protocol, the following Self-diagnostic functions are included.
• Echoes back the request message.
• Reads device identification information.
5.7.1 Message Configuration
ASCII mode
Header
(:)
Slave
address
Function
code
Data
Error check
LRC
Delimiter
(CR)
Delimiter
(LF)
RTU mode
3.5 idle
characters
Slave
address
Function
code
Data
Error check
CRC-16
3.5 idle
characters
(1) Slave Address Field
Slave address is an individual instrument number on the slave side, and is set within the range
1 to 95 (01H to 5FH). The master identifies slaves by the slave address of the requested message.
The slave informs the master which slave is responding to the master by placing its own address
in the response message.
The Self-diagnostic function does not work for Broadcast address 0 (00H).
(2) Function Code Field
The function code is the command code for the slave to undertake one of the following actions.
Type
Function
Code
Sub-Function
Code
Contents
08 (08H)
00 (0000H)
Echoes back a request message.
Diagnostics
43 (2BH)
14 (0EH)
Reads device identification information.
The function code is used to discern whether the response is normal (acknowledgement) or if any
error (negative acknowledgement) has occurred when the slave returns the response message to
the master.
When acknowledgement is returned, the slave simply returns the original function code.
When negative acknowledgement is returned, the MSB of the original function code is set as 1 for
the response.
For example, if the master sends request message setting 0FH to the Sub-function code by mistake,
slave returns ABH by setting the MSB to 1, because the former is a non-existent Sub-function code.
For negative acknowledgement, the exception codes below are set to the data of the response
message, and returned to the master in order to inform it of what kind of error has occurred.
Exception Code
Contents
1 (01H)
Illegal function (Non-existent function)
Sub-function code is not correct.
2 (02H)
Illegal data address (Non-existent data address)
For function code 43, Object ID is any value other than 00, 01, 02.
3 (03H)
Illegal data value (Value out of the setting range)
For function code 08, Data is less than 1 or has exceeded 100.
For function code 43, Read Device ID code is any value other than 01, 04.
(3) Data
Data differs depending on the function code.
For Function code 08 (08H), the request message from the master is composed of Sub-function code
2 bytes (0000H) and Data n x 2 bytes [n: Amount of Data (Max. 100)].
In normal status, a response message from the slave is the same as the request message.
Function code
1 byte
08H
Sub-function code
1 byte
0000H fixed
Data
n x 2 bytes
Random value (Max. 100)
Phone: 800.894.0412 - Fax: 888.723.4773 - Web: www.clrwtr.com - Email: [email protected]