Appendix a : modbus crc checksum calculation – KROHNE MFC 010 C Converter User Manual

Page 92

Advertising
background image


90

MFC010 Interface Manual

Appendix A : Modbus CRC Checksum Calculation

The Procedure for calculating the CRC checksum for a Modbus Telegram is as follows (copyright

Modbus-IDA).

1. Load a 16-bit register with FFFF

16

. This is the CRC register

2. Exclusive OR the first byte of the telegram with the low-order byte of the CRC, placing

the result in the CRC register

3. Shift the CRC register one bit to the right (toward the LSB), zero-filling the MSB. Extract

and examine the LSB.

4. If the LSB of the CRC result was 0 : Repeat Step 3 ( another shift)

If the LSB of the CRC result was 1 : Exclusive OR the CRC register with the polynomial

value A001

16

( 1010 0000 0000 0001

2

).

5. Repeat steps 3 and 4 unt il 8 s hifts hav e been per formed. W hen t his i s done, a

complete 8-bit byte will have been processed.

6. Repeat steps 2 through 5 for the next 8 bit character of the message. Continue doing

this until all of the characters in the message have been processed.

7. The final resulting value held in the CRC register is the CRC Checksum value.

The result is a 16 bi t “Unsigned Integer”. T he Least Significant byte of the checksum result is placed in

the first of the telegram CRC characters, the Most significant byte is placed in the second of the telegram

CRC c haracters, t he ov erall l ast c haracter i n t he t elegram. S ee S ection 3. 1 f or t he t elegram f ormat

details. Refer to the Modbus Protocol Reference Guide for more details on calculating the telegram CRC

value.

The following routine, written in the ‘C’ programming language, demonstrates the method for calculating

the checksum.

Advertising