9/22/2017 9:32 AM | |
Joined: 4/11/2012 Last visit: 10/29/2024 Posts: 181 Rating: (34) |
I have now converted to SCL and tested the function provided in the first page, (the short but CPU heavy function, the one not using tables) and it does not work. One glaring bug is that there is a comparison "if ((crc or $0001)<>0) then..." This will always be <> 0, as the $0001 constant brings the <>0 to the comparison. Even when I tested different variations on that comparison, I did not manage to get the code to work. I compared the results to Lambert online calculator and an existing code I have that works. https://www.lammertbies.nl/comm/info/crc-calculation.html Attached is a test project with the two CRC calculations side by side. In short: I do have a CRC function that works, but I want to understand how come the Delphi code could have ever worked? Is it intended to work for some other CRC and not for the selected polynomial? I'm using CRC-16-IBM (modbus) polynomial. (https://en.wikipedia.org/wiki/Cyclic_redundancy_check) Edit: I found this topic useful when I created the working CRC calculation on my own: https://support.industry.siemens.com/tf/ww/en/posts/ccitt-crc-calculation-in-s7-1200/51128?page=0&pageSize=10 It includes two manuals that describe methods for calculating the modbus CRC, and it also performs the loop only 8 times, not 9 times. Edit2: The source of the manual I mention above: http://www.modbus.org/specs.php AttachmentCRC16.zip (1220 Downloads) |
Last edited by: Elonen at: 9/22/2017 9:57:29 AMEdited to include link to topic including manuals with CRC calculation diagram Last edited by: Elonen at: 9/27/2017 7:22:13 AMEdit2: Added the link to modbus web page for the manual. Last edited by: Elonen at: 11/14/2017 11:55:11 AMAdded note that I had no trouble in creating working CRC calculation using the links I provided |
|
This contribution was helpful to2 thankful Users |
Follow us on