CRC16 cyclic redundancy detection calculator - easy to use. Detailed modbus RTU Modbus communication protocol

 

start using

http://cht.nahua.com.tw/index.php?url=http://cht.nahua.com.tw/software/crc16/&key=Modbus,%20RTU,%20CRC16&title= calculated% 20Modbus% 20RTU% 20CRC16

Data is written to the register 40125: 0x0066 (hex 0066), 40125-40000-1 = 124, to obtain turn hex: 0x007C, Decimal Hex 7C 124 =

Message: 01 06 00 7C 00 66 8 38
Explanation address function code Register Address Written data

CRC checksum

(From address bits to data bits)

 

Enter the page: 01 06 00 7C 00 66, click on the calculation, you can get C8 38

2. Error checking

   Cyclic redundancy code (CRC) comprises 2 bytes, i.e., 16-bit binary. CRC code calculated by the transmitting device, placed in the tail of the transmission information. Receive information recalculated CRC code of the received message, comparing the calculated CRC code is consistent with the received, if they do not match, it indicates an error.

  The method of calculating the CRC code is 16-bit register is preset to all 1's. And then gradually the information for each 8-bit data processing. CRC code calculation is performed using only 8 data bits, start bits and stop bits, parity bits if it also includes a parity bit, not to the CRC code calculation.

   In calculating the CRC code, and the data of 8-bit data register. The result is obtained in the displacement of a lower byte, the most significant bit padding with zeros. Then check the lowest position, if the lowest bit is 1, the contents of the registers are XORed with a preset number, if the lowest bit is 0, no XOR operation.

   This process is repeated eight times. After the 8th shift, then the next 8-bit register content is now a different phase or, the process is repeated as above 8 times. When all the data processed, the contents of the last register contains the CRC code value. CRC code in the data transmission, when receiving the low byte first.

   The step of calculating the CRC code is:

  • Preset register 16 is FFFF hex (i.e., all ones). This register is called CRC register;
  • The first 8-bit data and lower 16-bit CRC register or different, the results put in the CRC register;
  • The contents of the register right one (towards low), with 0 to fill the highest position, check the lowest position;
  • If the lowest bit is 0: Repeat step 3 (displacement again); If the lowest bit is 1: exclusive CRC polynomial register A001 (1010 0000 0000 0001), or;
  • Repeat steps 3 and 4 until the right eight times, so that the entire 8 bits have been processed;
  • Repeat steps 2 through 5, the processing of the next 8-bit data;
  • The resulting CRC is the CRC code register.

Reference: the Modbus communication protocol detailed

Guess you like

Origin www.cnblogs.com/txwtech/p/11116448.html