GE GFK-0804B manual Example CRC±16 Calculation, Address Function CRC±16

Models: GFK-0804B

1 160
Download 160 pages 24.24 Kb
Page 109
Image 109

C

Example CRC±16 Calculation

As an example we will calculate the CRC±16 for RTU message, Read Exception Status

07). The message format is:

Address

Function

CRC±16

 

 

 

01

07

 

The Micro PLC transmits the rightmost byte (of registers or discrete data) first. The first bit of the CRC± 16 transmitted is the MSB. Therefore, in this example the MSB of the CRC polynomial is to the extreme right. The X16 term is dropped because it affects only the quotient (which is discarded) and not the remainder (the CRC characters). The generating polynomial is therefore 1010 0000 0000 0001. The remainder is initialized to all 1s.

In this example we are querying device number 1 (address 01). We need to know the amount of data to be transmitted. This information can be found for every message type on page C-8, RTU Message Length. For this message the data length is 2 bytes.

 

TRANSMITTER

 

 

 

 

CRC±16 ALGORITHM

 

 

MSB2

LSB2

Flag MSB2

 

 

Initial Remainder

1111 1111 1111 1111

XOR 1st data byte

0000 0000 0000 0001

Current CRC

 

1111 1111 1111 1110

Shift 1

 

0111 1111 1111 1111

Shift 2

 

0011 1111 1111 1111

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1001 1111 1111 1110

Shift 3

 

0100 1111 1111 1111

Shift 4

 

0010 0111 1111 1111

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1000 0111 1111 1110

Shift 5

 

0100 0011 1111 1111

Shift 6

 

0010 0001 1111 1111

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1000 0001 1111 1110

Shift 7

 

0100 0000 1111 1111

Shift 8

 

0010 0000 0111 1111

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1000 0000 0111 1110

XOR 2nd data byte

0000 0000 0000 0111

Current CRC

 

1000 0000 0111 1001

Shift 1

 

0100 0000 0011 1100

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1110 0000 0011 1101

Shift 2

 

0111 0000 0001 1110

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1101 0000 0001 1111

Shift 3

 

0110 1000 0000 1111

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1100 1000 0000 1110

Shift 4

 

0110 0100 0000 0111

Shift 5

 

0011 0010 0000 0011

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1001 0010 0000 0010

Shift 6

 

0100 1001 0000 0001

Shift 7

 

0010 0100 1000 0000

XOR Gen. Polynomial

1010 0000 0000 0001

Current CRC

 

1000 0100 1000 0001

Shift 8

 

0100 0010 0100 0000

XOR Gen. Polynomial

1010 0000 0000 0001

Transmitted CRC

 

1110 0010 0100 0001

 

 

E

2

4

1

 

 

RECEIVER1

 

 

 

CRC±16 ALGORITHM

 

 

 

LSB2 Flag

 

 

Rcvr CRC after data

1110 0010 0100 0001

 

 

XOR 1st byte Trns CRC 0000 0000 0100 0001

 

 

Current CRC

1110 0010 0000 0000

 

0

Shift 1

0111 0001 0000 0000

0

1

Shift 2

0011 1000 1000 0000

0

 

Shift

3

0001 1100 0100 0000

0

 

Shift

4

0000 1110 0010 0000

0

0

Shift 5

0000 0111 0001 0000

0

1

Shift 6

0000 0011 1000 1000

0

 

Shift

7

0000 0001 1100 0100

0

 

Shift

8

0000 0000 1110 0010

0

0

XOR 2nd byte trns CRC 0000 0000 1110 0010

 

1

Current CRC

0000 0000 0000 0000

 

 

Shift 1±8 yields

0000 0000 0000 0000

 

 

 

 

ALL ZEROES FOR RECEIVER

0

 

 

FINAL CRC±16 INDICATES

1

 

 

TRANSMISSION CORRECT!

 

1

1Remember, the receiver processes

1incoming data the same way as the

1transmitter. The example for the receiver begins when all data bits but not the

0transmitted CRC have been received

1correctly. Therefore, the receiver CRC

should be equal to the transmitted CRC at 01 this point. When this occurs, the output of the CRC algorithm will be zero indicating

1that the transmission is correct.

The transmitted message with CRC would then be:

 

 

Address

Function

 

CRC±16

 

 

 

01

07

41

 

E2

 

 

2 The MSB and LSB references are to the data bytes only, not the CRC bytes. The CRC

 

MSB and LSB order are the reverse of the data byte order.

GFK±0804B

Appendix C RTU Protocol

 

 

 

 

C-7

Page 109
Image 109
GE GFK-0804B manual Example CRC±16 Calculation, Address Function CRC±16