Modbus RTU checksum error


Thread Starter

Kelly K Moni


I am working on a modbus slave application. I am using RTU message format. For testing purposes I am using ModScan32 software as my Master.

When the ModScan32 software sends a frame with a valid modbus command (ex: read Holding registers) the slave program is able to receive the modbus message frame. The slave successfuly validates the message frame by calculating the Checksum. To calculate the Checksum, I am using the lookup table and the algorithm given in the "Modbus over serial line specification and implementation guide" downloaded from I am using CRC16() function as I am following RTU message format.

The problem comes when I am trying to send a data frame back to the master side (here to the Modscan32 s/w) The ModScan32 says, "Checksum error in response message". I am using the same algorithm (the one used to calculate the checksum of the message received from the master) to calculate the checksum that I needed to attach with the message frame before sending it to the master (modscan32 s/w). I did check the way I am attaching the checksum to the message frame and it is correct. I am not sure what is going on to get the checksum error message.

If anybody has any idea or suggestion, please let me know. Thanks in advance


Compare the frames on both side of the Master and Slave. You can download MODBUS Slave simulators and test the same frame. Compare the Checksums at both sides. Generate the CRC lookup table and check any error is there in the lookup table or not. Please let me know the result after this.

If you are looking for a Slave implementation, check

Warm Regards,
[email protected]

Lynn at Alist

Common problems with Modbus CRC -
1) compiler differences so you need to add or move "()" to get good result
2) don't include 2 bytes of NULL or garbage in your calc - for example a 0x03 req you might calc CRC on 8 bytes, but on 6 to create the CRC.
3) attaching bytes in the incorrect order - the whole issue of big/little endian has spawns arguments on this list once in a while.

Try running ModSim32 to create the exact same response you'll try. In fact, have it create 5 different responses, including a few that have lots of 0xFF inside. Then confirm you slave produces the same 5 responses (do the "view traffic" options to see the actual bytes).

- lynnl,