Crc error check – Basler Electric DGC-2020HD Modbus Protocol User Manual
Page 16
10
9469300991 Rev A
General Information
DGC-2020HD Modbus
™ Protocol
K+3 (Hi Byte)
‘R’
K+3 (Lo Byte)
‘D’
Example: If the above string is changed to “P”, the new string will read as follows:
Holding Register
Value
K (Hi Byte)
‘P’
K (Lo Byte)
hex 00
K+1 (Hi Byte)
hex 00
K+1 (Lo Byte)
hex 00
K+2 (Hi Byte)
hex 00
K+2 (Lo Byte)
hex 00
K+3 (Hi Byte)
hex 00
K+3 (Lo Byte)
hex 00
The same byte alignments are required to write.
CRC Error Check
This field contains a two-byte CRC value for transmission error detection. The master first calculates the
CRC and appends it to the query message. The DGC-2020HD system recalculates the CRC value for the
received query and performs a comparison to the query CRC value to determine if a transmission error
has occurred. If so, no response message is generated. If no transmission error has occurred, the slave
calculates a new CRC value for the response message and appends it to the message for transmission.
The CRC calculation is performed using all bytes of the device address, function code, and data block
fields. A 16-bit CRC-register is initialized to all 1's. Then each eight-bit byte of the message is used in the
following algorithm:
First, exclusive-OR the message byte with the low-order byte of the CRC-register. The result, stored in
the CRC-register, will then be right-shifted eight times. The CRC-register MSB is zero-filled with each
shift. After each shift, the CRC-register LSB is examined. If the LSB IS a 1, the CRC-register is then
exclusive-ORed with the fixed polynomial value A001 (hex) prior to the next shift. Once all bytes of the
message have undergone the above algorithm, the CRC-register will contain the message CRC value to
be placed in the error check field.