User`s manual

6-12
6.5 MODBUS Communication Protocol
INP-TN5A0202-E
Error Check Code (CRC-16) Calculation
CRC-16 is 2-byte (16-bit) error check code. The calculating range is the starting position of the message (station number) to the
end of the data part.
A slave calculates the CRC of the message received, and does not send the response message back, if the result is not the
same as the CRC code received.
The fl ow for CRC-16 calculation is as below.
Start
Set FFFFH (hexadecimal) to CR
Exclusive OR (XDR) is run on each character of J (1 byte)
an in specified message and CR, and that result is set to CR.
Variables
CR: CRC error check data (2 bytes)
J: command message calculation
character digit
K: The number of times to check
CR calculation
(Calculate in order of command
message station No., function code
and data.)
CR calculation result is added to
at the end of command message
in order of LOW, HIGH.
Set J=1
After CR has been justified 1 bit to right, A001H and
exclusive OR (XDR) are run, and that result is set to CR.
Justify CR 1 bit
to right
Set K=1
Is the bit at
the right end of
the CR 1?
Add 1 to J
YES
YES
NO
NO
NO
YES
Has the all characters’
calculation complete?
Add 1 to K
Have 8-time
calculations
completed?
Completed