Paste the bytes of a Modbus RTU frame in hex. Without its CRC you get the two bytes to append; with its CRC you find out whether the frame is intact.
Modbus RTU uses CRC-16 with the reflected polynomial 0xA001 (0x8005 forward) and an initial value of 0xFFFF, with no final XOR. Each byte is XORed into the register, which is then shifted right eight times, XORed with 0xA001 each time the bit shifted out is a 1.
The CRC is the one place in Modbus that goes low byte first. A CRC of 0x0A84 is sent as 84 0A, which is why a request to read one register at address 0 from device 1 ends in 84 0A.
Run the CRC over the whole frame including its last two bytes. An intact frame gives zero, because the CRC was chosen to cancel itself. Any other result means a byte was lost, added or corrupted on the line.
The CRC only proves the frame was received as sent. Check the slave address, the baud rate, parity and stop bits, and the A and B lines, which are easy to swap. A device on a different address ignores the frame silently.
No. Modbus TCP relies on the checks in TCP and Ethernet and carries an MBAP header instead. The CRC belongs to Modbus RTU on a serial line such as RS485.
0x4B37, the standard check value for CRC-16/MODBUS. It is a quick way to confirm that a CRC routine is implemented correctly.
Genesis reads RS485 Modbus sensors, analogue transducers and 1-Wire probes on the same four ports and reports them over cellular. Tell us what you need to read.
Talk to us →