100% found this document useful (1 vote)
133 views1 page

CRC Calculation

This document describes how to calculate a cyclic redundancy check (CRC) for a hex string of bytes up to 16 bytes in length. It shows the bit-wise operations performed on each byte to calculate the CRC by shifting and XORing bits at each step. The example provided calculates the CRC for a 6 byte hex string of F70302640008, resulting in a CRC value of 10FD.

Uploaded by

krishnakumar G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
133 views1 page

CRC Calculation

This document describes how to calculate a cyclic redundancy check (CRC) for a hex string of bytes up to 16 bytes in length. It shows the bit-wise operations performed on each byte to calculate the CRC by shifting and XORing bits at each step. The example provided calculates the CRC for a 6 byte hex string of F70302640008, resulting in a CRC value of 10FD.

Uploaded by

krishnakumar G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Courtesy of

This sheet requires the Analysis Toolpak to be loaded. Select the Tools Menu > Add-Ins... > check Analysis Toolpack

input hex string #bytes crc


F70302640008 6 10FD
www.simplymodbus.ca
1 2 3 4 5 6 7 8 9 # # # # # # # Rev04 - Mar. 13, 2016
xor constant 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 xor with this constant if the shifted bit was 1

byte# Hex Start with 16 trues 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1


1 F7 0000000011110111 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1
xor the 2 lines above 1 1 1 1 1 1 1 1 0 0 0 0 1 0 0 0 xor means "are they different?"
shift xor 1 0 1 1 1 1 1 1 1 1 0 0 0 0 1 0 0 if the two input bits are different the result is 1 (true).
shift xor 2 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 0 if the two input bits are the same the result is 0 (false).
shift xor 3 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1
shift xor 4 1 0 1 0 1 1 1 1 1 1 1 1 0 0 0 1 shift xor: shift all bits to the right one space. add a 0 at the far left.
shift xor 5 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 If bit16 was 1, xor the result with the xor constant.
shift xor 6 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 1
shift xor 7 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 FE C6
shift xor 8 1 1 0 0 0 1 1 0 1 1 1 1 1 1 1 0 FEC6 crc for a 1 byte string FE C6
2 03 0000000000000011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
shift xor 8 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0781 crc for a 2 byte string 07 81
3 02 0000000000000010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
shift xor 8 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 4103 crc for a 3 byte string 41 03
4 64 0000000001100100 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0
shift xor 8 1 1 0 1 1 0 1 1 1 1 0 0 0 0 1 0 C2DB crc for a 4 byte string C2 DB
5 00 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 0 5A91 crc for a 5 byte string 5A 91
6 08 0000000000001000 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
shift xor 8 1 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 10FD crc for a 6 byte string 10 FD
7 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 crc for a 7 byte string
8 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 1 0 0 0 0 0 1 1 1 0 0 1 1 0 0 crc for a 8 byte string
9 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 crc for a 9 byte string
10 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 0 1 1 0 0 0 0 1 0 0 1 0 1 0 1 crc for a 10 byte string
11 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 crc for a 11 byte string
12 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 1 0 0 0 1 0 0 0 1 1 0 1 1 1 1 crc for a 12 byte string
13 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 crc for a 13 byte string
14 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 1 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 crc for a 14 byte string
15 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 crc for a 15 byte string
16 0000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
shift xor 8 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 crc for a 16 byte string
16 bytes max

You might also like