8
(5) Error check of RTU mode
After calculating CRC-16 (Cyclic Redundancy Check) from the slave address to the end of data, the
calculated 16-bit data is appended to the end of message in sequence from low order to high order.
How CRC is calculated
In the CRC system, the information is divided by the polynomial. The remainder is added to the
end of the information and transmitted. The generation of polynomial is as follows.
(Generation of polynomial: X
16
+ X
15
+ X
2
+ 1)
1
Initialize the CRC-16 data (assumed as X) (FFFFH).
2
Calculate exclusive OR (XOR) with the 1st data and X. This is assumed as X.
3
Shift X one bit to the right. This is assumed as X.
4
When a carry is generated as a result of the shift, XOR is calculated by X of
3
and the fixed
value (A001H). This is assumed as X. If a carry is not generated, go to step
5
.
5
Repeat steps
3
and
4
until shifting 8 times.
6
XOR is calculated with the next data and X. This is assumed as X.
7
Repeat steps
3
to
5
.
8
Repeat steps
3
to
5
up to the last data.
9
Set X as CRC-16 to the end of message in sequence from low order to high order.
(6) Message example of
RTU mode
1
Reading (Instrument number 1, SV)
• Request message from the master
(Fig.
6.3-2)
The number of data means the data item to be read, and it is fixed as 0001H.
• Response message from the slave in normal status (When SV=100 )
(Fig.
6.3-3)
The number of response byte means number of bytes of the data which has been read, and it is
fixed as 02H.
• Response message from the slave in abnormal status (When data item is mistaken)
(Fig.
6.3-4)
The function code MSB is set to 1 for the response message in abnormal status (83H).
The abnormal code (02H: Non-existent data address) is returned as contents of error.
2
Setting (Instrument number 1, SV=100 )
• Request message from the master
(Fig.
6.3-5)
• Response message from the slave in normal status
(Fig.
6.3-6)
• Response message from the slave in abnormal status (When a value out of the setting
range is set)
(Fig.
6.3-7)
The function code MSB is set to 1 for the response message in abnormal status (86H).
The abnormal code (03H: Value out of the setting range) is returned as contents of error.
3.5 idle
characters
Slave
address
Function
code
Data item
Error check
CRC
3.5 idle
characters
(01H)
(03H)
(0001H)
Number of
data
(0001H)
(D5CAH)
1
1
2
2
2
Number of
characters
3.5 idle
characters
Slave
address
Function
code
Number of
response bytes
Error check
CRC
3.5 idle
characters
(01H)
(03H)
(02H)
Data
(0064H)
(B9AFH)
1
1
1
2
2
Number of
characters
3.5 idle
characters
Slave
address
Function
code
Abnormal
code
Error check
CRC
3.5 idle
characters
(01H)
(83H)
(02H)
(C0F1H)
1
1
1
2
Number of
characters
3.5 idle
characters
Slave
address
Function
code
Data item
Error check
CRC
3.5 idle
characters
(01H)
(06H)
(0001H)
Data
(0064H)
(D9E1H)
1
1
2
2
2
Number of
characters
3.5 idle
characters
Slave
address
Function
code
Data item
Error check
CRC
3.5 idle
characters
(01H)
(06H)
(0001H)
Data
(0064H)
(D9E1H)
1
1
2
2
2
Number of
characters
3.5 idle
characters
Slave
address
Function
code
Abnormal
code
Error check
CRC
3.5 idle
characters
(01H)
(86H)
(03H)
(0261H)
1
1
1
2
Number of
characters