9
2. COMMUNICATION INTERFACE
2.8: Error check
Transmission frame error check differs by mode.
RTU: CRC-16
ASCII: LRC
2.8.1 CRC-16 calculation
CRC divides the information to be sent with the generating polynomial, adds the remainder
behind the information to send.
Generating polynomial is as follows:
1 + x2 + x15 + x16
Use the following procedure to calculate from slave address to final data.
1. CRC-16 data (if x) initialization (= FFFFH)
2. Exclusive OR (EX-OR) of data 1 and x.
→
x
3. Shift x 1 bit to the right.
→
x
4. If carrier appears, take A001H and EX-OR. Otherwise, go to step 5.
→
x
5. Repeat steps 3 and 4 until shifted 8 times
6. EX-OR of x and following data.
→
x
7. Same as steps 3-5
8. Repeat final data
9. Create a message of the calculated 16-bit data, ordering low to high
Example: if data is [02H] [07H], CRC-16 is 1241H; so error check data will be [41H] [12H].
2.8.2 LRC calculation
Use the following procedure to calculate from slave address to final data.
1. Create message using RTU mode
2. Add up data from heading to end.
→
x
3. Take the complement of x.
→
x
4. Add 1. (x = x+1)
5. Add x to end of message as LRC.
6. Convert in entirety to ASCII characters.
Example: if data is [02H] [07H], LRC is [F7H]; so binary message will be [02H] [07H] [F7H] and
ASCII message will be [30H] [32H] [30H] [37H] [46H] [37H].