Calculation method of CRC check code for Modbus RTU

Source: Internet
Author: User

The CRC is calculated using only 8 data bits, starting bit and stop bit, if parity bit also includes parity bit , do not participate in CRC calculation.

The CRC is calculated by:

1. Load a 16-bit register with a value of 0XFFFF, which is the CRC register.

2, the first 8-bit binary data (that is, the first byte of the communication information frame) and the 16-bit CRC register is different or, the result is still stored in the CRC register.

3, the CRC register the contents of the right one bit, with 0 to fill the highest bit, and detect the shift out of the bit is 0 or 1.

4. If the move-out bit is zero, repeat the third step (move right one bit again), or if the 1,CRC register is different from the 0xa001.

5, repeat steps 3 and 4, until the right shift 8 times, so that the entire 8-bit data are all processed.

6, repeat steps 2 and 5, the processing of the next byte of the communication information frame.

7, the communication information frame all bytes according to the above steps, the resulting 16-bit CRC register high and low byte to Exchange

8, the final CRC register content is: CRC check Code

Calculation method of CRC check code for Modbus RTU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.