
32
MODBUS
RS485/RS232 Communications Interface
Example of a CRC Calculation
This example is a request to read from the Slave unit at address 02, the fast read of the status
(07).
Function
16 Bit Register
Carry
LSB
MSB
Flag
Load register with FFFF hex
1111
1111
1111
1111
0
First byte of the message (02)
0000
0010
Exclusive
OR
1111 1111 1111 1101
1st shift right
0111
1111
1111
1110
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1101
1111
1111
1111
2nd shift right
0110
1111
1111
1111
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1100
1111
1111
1110
3rd shift right
0110
0111
1111
1111
0
4th shift right (carry = 0 )
0011
0011
1111
1111
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1001
0011
1111
1110
5th shift right
0100
1001
1111
1111
0
6th shift right (carry = 0 )
0010
0100
1111
1111
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1000
0100
1111
1110
7th shift right
0100
0010
0111
1111
0
8th shift right (carry = 0)
0010
0001
0011
1111
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1000
0001
0011
1110
Next byte of the message (07)
0000
0111
Exclusive OR (shift = 8)
1000
0001
0011
1001
1st shift right
0100
0000
1001
1100
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1110
0000
1001
1101
2nd shift right
0111
0000
0100
1110
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1101
0000
0100
1111
3rd shift right
0110
1000
0010
0111
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1100
1000
0010
0110
4th shift right
0110
0100
0001
0011
0
5th shift right (carry = 0)
0011
0010
0000
1001
1
A001
1010 0000 0000 0001
Exclusive OR (carry = 1)
1001
0010
0000
1000
6th shift right
0100
1001
0000
0100
0
7th shift right (carry = 0)
0010
0100
1000
0010
0
8th shift right (carry = 0)
0001
0010
0100
0001
0
CRC error check code
12h
41h
The final message transmitted including the CRC code is:
Device Address
Function Code
CRC MSB
CRC LSB
02h 07h 41h 12h
0000 0010 0000 0111 0100 0001 0001 0010
↑
First bit
Transmission order
Last bit
↑
Summary of Contents for 6513
Page 7: ......