Crc-16 calculation example – Rockwell Automation 900 Temperature Controller Communications Functions - Series B User Manual
Page 60
Publication 900-UM004D-EN-E - July 2010
4-2
Modbus Communications Procedure
CRC-16 Calculation Example
Messages are processed one byte at a time in the work memory (a 16-bit
register known as the CRC register).
1. The CRC register is initialized to H’FFFF.
2. An XOR operation is performed on the content of the CRC register and
the first byte of the message, and the result is returned to the CRC
register.
3. The MSB is packed with zeroes and the CRC register is shifted 1 bit to
the right.
4. If the bit shifted from the LSB is 0, step 3 is repeated (next bit-shift
processing).
If the bit shifted from the LSB is 1, an XOR is performed on the
content of the CRC register and A001, and the result is returned to the
CRC register.
5. Steps 3 and 4 are repeated until 8 bits are shifted.
6. CRC processing continues to the end of the message, as XOR
operations are performed on the content of the CRC register and the
next byte of the message, step 3 is repeated, and the result is returned to
the CRC register.
7. The result of the CRC calculation (value in the CRC register) is
appended to the last byte of the message.
Table 4.1
Silent interval of 3.5 character times min.
Slave address
Specify the unit number.
The unit number can be set between H’00 to H’63
hexadecimal (0…99 decimal).
Specify H’00 for a broadcast transmission. No responses will
be returned for broadcast transmissions.
Function code
The function code is a 1-byte hexadecimal code that indicates
the type of command sent from the host device.
Data
This is the text data associated with the specified function
code. Specify the required data, such as the variable address
or setting data (set in hexadecimal).
CRC-16
Cyclical Redundancy Check
This check code is calculated with the data from the slave
address to the end of the data.
The check code is 2-byte hexadecimal.
Silent interval of 3.5 character times min.