
27
A 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, exception code (Table 8.2.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 8.2.2-2)
Exception code
Contents
1 (01H)
Illegal function (Non-existent function)
2 (02H)
Illegal data address (Non-existent data address)
3 (03H)
Illegal data value (Value outside the setting range)
17 (11H)
Shinko error code 4 (Unsettable status: During AT, 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
exception code in negative acknowledgement.
Only one piece of data can be dealt with per message.
Therefore the number of data for ASCII mode is fixed as (30H 30H 30H 31H).
Effective range of data is –32768 to 32767 (8000H to 7FFFH).
(2) ASCII mode error check
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) ASCII mode message example
1
PV reading (Address 1)
• A request message from the master
The number of data indicates the data item to be read, and it is fixed as 1 (30H
30H 30H 31H).
(Fig.
8.2.2-2)
characters
(3AH)
Slave
address
(30H 31H)
Data item
Error check
LRC
Delimiter
Number of data
1
2
2
4
4
Number of
Header
(30H 30H 38H 30H)
(37H 42H)
(30H 30H 30H 31H)
Function
code
(30H 33H)
(0DH 0AH)
2
2