Instruction manual
8
Function code
The function code is the command code for the slave to undertake the following action types (Table 6.2-1).
(Table 6.2-1)
Function code Contents
03 (03H) Reading the setting value and information from slaves
06 (06H) Setting to slaves
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, when the master sends a request message setting 10H to function code by mistake,
slave returns 90H by setting the MSB to 1, because the former is an illegal function.)
For negative acknowledgement, abnormal code (Table 6.2-2) below is set to the data of response
message and returned to the master in order to inform it that what kind of error has occurred.
(Table 6.2-2)
Abnormal code Contents
1 (01H) Illegal function (Non-existent function)
2 (02H) Illegal data address (Non-existent data address)
3 (03H) Illegal data value (Value out of the setting range)
17 (11H) Illegal setting (Unsettable status)
18 (12H) Illegal setting (During setting mode by keypad operation, etc)
Data
Data differs depending on the function code.
A request message from the master is composed of data item, number of data and setting data.
A response message from the slave is composed of number of bytes, data and abnormal code
in negative acknowledgement. Effective range of data is –32768 to 32767 (8000H to 7FFFH).
(2) Error check of ASCII mode
After calculating LRC (Longitudinal Redundancy Check) from the slave address to the end of data,
the calculated 8-bit data is converted to two ASCII characters and are appended to the end of the
message.
How LRC is calculated
1
Create a message in RTU mode.
2
Add all the values from the slave address to the end of data. This is assumed as X.
3
Make a complement for X (bit reverse). This is assumed as X.
4
Add a value of 1 to X. This is assumed as X.
5
Set X as an LRC to the end of the message.
6
Convert the whole message to ASCII characters.
(3) Message example of ASCII mode
1
Reading (Address 1, PV)
• A request message from the master
The number of data indicates the data item to be read and it is fixed as (30H 30H 30H 31H).
(Fig. 6.2-2)
• A response message from the slave in normal status [When PV=25
(0019H)]
The number of response bytes indicates the number of bytes of the data which has been read, and
it is fixed as (30H 32H).
(Fig.6.2-3)
Slave
address
Function
code
Data item DelimiterHeader
(30H 31H)
Number of data
(3AH)
12 2 4
42
2
(30H 33H) (30H 30H 30H 31H)(30H 30H 38H 30H) (37H 42H)
(0DH 0AH)
Error check
LRC
Number of
characters
Slave
address
Function
code
Number of
response bytes
Error check
LRC
DelimiterHeader
Data
12 2 2 4 2 2
(3AH)
(30H 31H)
(30H 33H)
(30H 32H)
(30H 30H 31H 39H)
(45H 31H)
(0DH 0AH)
Number of
characters