Error check uses the CRC-16 method to detect transmission errors. Use the procedure in this section to calculate CRC-16.
Command Data
When the drive receives data, it will make sure that there are no errors in the data. The drive uses the procedure below to calculate CRC-16, then the drive compares that data with the CRC-16 value in the message. If the CRC-16 values do not agree, the drive will not execute a command message.
When you calculate CRC-16 in MEMOBUS/Modbus communications, make sure that you set the start value as FFFF (Hex.). All 16 bits must be 1.
Use this procedure to calculate CRC-16:
-
Make sure that the start value is FFFF (Hex.).
-
Calculate the FFFF (Hex.) start value and the XOR of the slave address (exclusive OR).
-
Move the step 2 results one column to the right. Do this shift until the carry bit is 1.
-
When the carry bit is 1, calculate XOR via the result from the above step 3 and A001 (Hex.).
-
Do steps 3 and 4 until the 8th shift to the right.
-
Use the result of step 5 to calculate the XOR and the data of the following messages (function code, register address, data). Do steps 3 to 5 until the last data, then calculate.
-
The result of the last right shift or the value of the last XOR calculation is the result for CRC-16.
Table 1 lists examples of the CRC-16 calculation of slave address 02 (Hex.) and function code 03 (Hex.). The calculated results of CRC-16 for this section is D140 (Hex.).
Note:
The calculation example only gives information about some error checks with CRC-16. The drive will do the same error checks for the next data.
Table 1. CRC-16 Calculation Example
|
Description
|
Calculation
|
Overflow
|
Description
|
Calculation
|
Overflow
|
|
Initial value (FFFF (Hex.))
|
1111 1111 1111 1111
|
-
|
Function code 03 (Hex.)
|
0000 0011
|
-
|
|
Address 02 (Hex.)
|
0000 0010
|
-
|
XOR w result
|
1000 0001 0011 1101
|
-
|
|
XOR w initial value
|
1111 1111 1111 1101
|
|
Shift 1
|
0100 0000 1001 1110
|
1
|
|
Shift 1
|
0111 1111 1111 1110
|
1
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
XOR result
|
1110 0000 1001 1111
|
-
|
|
XOR result
|
1101 1111 1111 1111
|
-
|
Shift 2
|
0111 0000 0100 1111
|
1
|
|
Shift 2
|
0110 1111 1111 1111
|
1
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
XOR result
|
1101 0000 0100 1110
|
-
|
|
XOR result
|
1100 1111 1111 1110
|
-
|
Shift 3
|
0110 1000 0010 0111
|
0
|
|
Shift 3
|
0110 0111 1111 1111
|
0
|
Shift 4
|
0011 0100 0001 0011
|
1
|
|
Shift 4
|
0011 0011 1111 1111
|
1
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
XOR result
|
1001 0100 0001 0010
|
-
|
|
XOR result
|
1001 0011 1111 1110
|
-
|
Shift 5
|
0100 1010 0000 1001
|
0
|
|
Shift 5
|
0100 1001 1111 1111
|
0
|
Shift 6
|
0010 0101 0000 0100
|
1
|
|
Shift 6
|
0010 0100 1111 1111
|
1
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
XOR result
|
1000 0101 0000 0101
|
-
|
|
XOR result
|
1000 0100 1111 1110
|
-
|
Shift 7
|
0100 0010 1000 0010
|
1
|
|
Shift 7
|
0100 0010 0111 1111
|
0
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
Shift 8
|
0010 0001 0011 1111
|
1
|
XOR result
|
1110 0010 1000 0011
|
-
|
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
Shift 8
|
0111 0001 0100 0001
|
1
|
|
XOR result
|
1000 0001 0011 1110
|
-
|
XOR w A001 (Hex.)
|
1010 0000 0000 0001
|
-
|
|
Perform operations with next data (function code)
|
XOR result
|
1101 0001 0100 0000
|
-
|
|
CRC-16
|
1101 0001 0100 0000
|
-
|
|
D 1 4 0
(Lower) (Upper)
|
-
|
|
Continue from here with next data.
|
Response Data
The drive does the CRC-16 calculation for the response message and makes sure that the data does not have errors. Make sure that the calculated value is the same value as the CRC-16 in the response message.