
6.6 Error check
Error check differs depending on the type of transmission mode.
[ASCII mode]
After calculating LRC (Longitudinal redundancy check) from slave address to data section,
calculated 8-bit data is converted to ASCII 2 characters and they are added to the end of data.
How LRC is calculated,
(1) Create a message in RTU mode.
(2) Add the start data (slave address) to the end of data. --X
(3) Complement X (bit reverse). --X
(4) Add 1 (X=X+1)
(5) Add X as an LRC to the end of the message.
(6) Convert the whole data to ASCII characters.
[RTU mode]
After calculating CRC-16 (cyclic redundancy checksum) from slave address to data section,
calculated 16-bit data is added to the end of data in the order of LSB and MSD
How CRC is calculated,
In the CRC system, the information to be transmitted is divided by a generating polynomial,
the resulting remainder being added to the data. The generation polynomial is as follows.
(X
16
+ X
15
+ X
2
+ 1)
(1) Initialize the CRC-16 data (assumed as X) (FFFFH)
(2) Exclusive logical sum (EX-OR) between data 1 and X X
(3) Shift X 1 bit to the right X
(4) When a carry is generated, take A001H and EX-OR. If not, go to 5. X
(5) Repeat (3) and (4) until shifting 8 times.
(6) EX-OR between the next data and X X
(7) Same as (3) to (5).
(8) Repeat up to the last data.
(9) Create a message in the sequence from lower to upper orders of the calculated 16-bit data (X).
6.7 Message example
[ASCII mode]
(1) Reading of the instrument number (address) 1 and SV
• A request message from the master side
(Fig. 6.7-1)
• A response message from slave side in normal status
(When SV=100 )
(Fig. 6.7-2)
• A response message from slave side in abnormal status
(When data item is mistaken)
(Fig. 6.7-3)
1 is set to the MSD of function code for response message in abnormal status. (83H)
An abnormal code (02H: Illegal data address) is returned as a content of error.
(2) Setting (Address 1, SV=100 )
• A request message from master side
Slave
address
Function
code
Data item
Error check
LRC
Delimiter
Header
(01H)
(03H)
(0001H)
(0001H)
Number of
data
(FAH)
(CR
・
LF)
(:)
1
2
2
4
4
2
2
Number of
characters
Slave
address
Function
code
Number of
response bytes
Error check
LRC
Delimiter
Header
(01H)
(03H)
(02H)
(0064H)
Data
(96H)
(CR
・
LF)
(:)
1
2
2
2
4
2
2
Number of
characters
Slave
address
Function
code
Abnormal
code
Error check
LRC
Delimiter
Header
(01H)
(83H)
(02H)
(7AH)
(CR
・
LF)
(
:
)
1
2
2
2
4
2
Number of
characters
Slave
address
Function
code
Data item
Error check
LRC
Delimiter
Header
(01H)
(06H)
(0001H)
(0064H)
Data
(94H)
(CR
・
LF)
(
:
)
1
2
2
4
4
2
2
Number of
characters