Specifications
CRC Calculations
To calculate the Cyclic Redundancy Check value.
Load a word register with 0xFFFF (CRCREG)
Repeat the following for each character in the Modbus
packet
{
XOR the low byte of the word register with the next (or
first) character in the buffer
Repeat the following for the whole character
{
Get the state of the lsb of CRCREG Low byte
Shift the CRCREG right by one bit shifting in a
zero in the msb
If the bit shifted out is a logical 1, XOR
CRCREG with 0xA001
}
}
CRCREG contains the CRC of the buffer
A typical communication 'packet' will be in the form :
[Node Address] [Function] [Byte count, Data etc.] [Error
check].
Because Modbus is a word (2 byte) orientated protocol,
floating point (4 byte) register numbers are counted in
multiples of two.
viz register 1 = start address 0
register 2 = start address 2
register 3 = start address 4
register 4 = start address 6
Formula = (register required -1) x2
This also applies to the number of registers requested. If 2
registers are requested the number of WORDS in the
packet's [Number of registers] slot should equal 4. (See
examples in the following sections.
34
M550MAN.PM5 01/08/101, 12:4834