Information Technology Reference
In-Depth Information
LRC
The ASCII mode uses the LRC method. It basically adds up the values of each of the 8-bit
fields, apart from the starting colon and the end CRLF, and then takes the two's complement
of the result (ignoring any carries). For example, from the previous example the transmitted
values are
Start address (12) 0001 0010
Function (01) 0000 0001
Start address, high (02) 0000 0010
Start address, low (10)
0001 0000
Number, high (00)
0000 0000
Number, low (01)
0000 0001
Total
0010 0110
To convert to 2's complement, invert all the bits, to give
1101 1001
and then add 1, to give
1101 1010
which is DA, in hexadecimal. Thus the transmitted message would be:
:120102100001DA < CRLF >
CRC checking
The RTU mode uses CRC, which is a much stronger error checking method. This method is
outlined in Appendix D. Its operation is as follows:
1. 16-bit register is preloaded with all bits set to 1.
2. The first eight-bit data character is exclusive ORed (XOR) with the higher order-byte in
the register and the result is put in the register.
3. The register is then right shifted by one bit position and a zero filled into the most signifi-
cant bit (MSB) position.
4. If the shifted bit out is a 1, XOR the generator polynomial 1010 0000 0000 0001 with the
16-bit register, else return to Step 3.
5. Repeat steps 3 and 4 for eight right shifts.
6. XOR the next 8-bit value with the 16-bit register.
7. Repeat Steps 3 to 6 until all the bytes in the message have been XOR with the 16-bit reg-
ister and shifted eight times.
8. The resultant content of the 16-bit register is the CRC error check.
Search WWH ::




Custom Search