CHAPTER 13 RS-485 COMMUNICATIONS
13
6. CRC-16
(1) Outline of CRC
CRC (Cyclic Redundancy Check) is a system to check if communications data are correct.
In the CRC calculation, data expressed as a polynomial are divided by a generating polynomial,
and the residue is used as CRC data.
Modbus RTU uses the CRC-16 which performs calculation using X16 + X15 + X2 + 1 as the
generating polynomial.
(2) CRC-16 calculation algorithm
The algorism for calculating CRC-16 on the data (N bytes) from the station number field to the
information field is as follows:
START
Default settings
CRC = FFFFh
POLY = A001h
dtn = 0
sft = 0
CRC
POLY
dtn
sft
DT[dtn]
N
XOR
・・・ Calculated value of CRC-16
・・・ Generating polynomial
・・・ Data counter
・・・ Shift counter
・・・ Nth data (one byte)
・・・ Number of data bytes
・・・ exclusive OR
CRC = CRC XOR DT[dtn]
Shift CRC to the right by one bit
DT[0] is station number, DT[1] is FC, and
DT[2]-DT[N-1] are data in the information
field.
Shift carry available?
No
Yes
CRC = CRC XOR POLY
sft = sft + 1
Yes
sft < 8
No
dtn = dtn + 1
Yes
dtn < N ?
No
END
13-28 Modbus RTU Communications