Despatch Protocol Plus Modbus Communications User Manual
Page 45

Chromalox Instruments and Controls
A-51643 Rev. 6 10/06/03
39
6.5 Data Field
The data field contains additional information that the slave must use to take action defined by the
function code. If no error occurs, the data field of a response from the slave contains the data requested.
If an error occurs, the filed contains an exception code that the master application can use to determine
the next action to be taken. The data field can be nonexistent in certain kinds of messages. All data
addresses in Modbus messages are referenced to 0.
6.6 Error Checking Field
In RTU mode, the error-checking field contains a 16-bit value implemented as two 8-bit bytes. The error
check value is the result of a CRC calculation performed on the message contents. The CRC field is
appended to the message as the last field in the message. When this is done, the low-order byte of the
field is appended first, followed by the high-order byte. The CRC high-order byte is the last byte to be
sent in the message.
The CRC field checks the entire contents of the message and is applied regardless of any parity check
method chosen. The transmitting device calculates the CRC. The receiving device recalculates the CRC
and compares it to the transmitted CRC value. If the two values are not equal, an error results.
The CRC is initialized by pre-loading a 16-bit register to all 1‘s. Then a process of applying successive 8-
bit bytes of the message to the current contents of the register. Only the 8 bits of the data in each
character are used for generating the CRC. The start and stop bits and the parity bit do not apply to the
CRC. During generation of the CRC, each 8-bit character is XORed with the register contents. Then the
result is shifted right (toward the LSB), with a 0 filled into the MSB position and the previous LSB
loaded into the carry bit. The carry bit is examined. If the carry bit is a 1, the register is then XORed
with the polynomial value $A001. If the carry bit is 0, no action is taken. This process is repeated until
eight shifts have been performed.
After the last (eighth) shift, the next byte is XORed with the register‘s current value, and the process
repeats as described above. The final register contents are the CRC value. The low-order byte is
appended first, followed by the high-order byte. See Figure 6 CRC Flowchart.