8/2/2019 7:15 PM | |
Joined: 3/14/2010 Last visit: 7/25/2024 Posts: 19 Rating:
|
Tanks Smiffy for the post you made on the first page of this topic! According to this information Modbus CRC has a Polynomial of 16#8005 an a initial value of 16#FFFF. In the code Smiffy provided the initial value was missing. On this page you can also create a lookup table to use for finding the CRC also for other standards. Thanks to Smiffy I created the function block below to successful create a CRC for modbus. Now I am able to send and receive modbus data through a serial server. Here is the source, hope it helps someone in the future.
Best regards, Martijn |
Last edited by: MartijnD at: 08/02/2019 19:18:03DIKS automation - https://diks.am |
|
This contribution was helpful to
2 thankful Users |
8/6/2019 5:32 AM | |
Joined: 7/5/2013 Last visit: 9/10/2024 Posts: 3111 Rating:
|
When using TIA V14 SP1 or higher you may use LGF_CRC16 which can be found in the section Data Handling in the Library of general functions (LGF) for SIMATIC STEP 7 (TIA Portal) and SIMATIC S7-1200 / S7-1500. |
Last edited by: Prof. Frink at: 08/06/2019 05:33:36Pi is exactly three! |
|
This contribution was helpful to
1 thankful Users |
8/13/2019 9:04 AM | |
Joined: 3/14/2010 Last visit: 7/25/2024 Posts: 19 Rating:
|
Please check my attachment, in my case the LGF library gives wrong results. Maybe I do something wrong or maybe it is a bug in in the library The attachment contains a test project and 3 screenshots of the different results. Please do not pay attention to the timeout in the QModbusMaster screenshot, there was no device connected to the comport. QModbusMaster is debug package for me wich is working very well. So I choose this one to prove the correct and working CRC. AttachmentCRC_20190813_0848.zip (640 Downloads) |
DIKS automation - https://diks.am |
|
8/14/2019 10:25 AM | |
Joined: 7/5/2013 Last visit: 9/10/2024 Posts: 3111 Rating:
|
Hello Martijn,
I only found the project. No screenshots. But, I guess, they would help to understand. New: Ok, now I see, it seems the LGF_CRC16 cannot be used to calculate the Modbus-checksum. You expect 0x5AD7 (which is the result when calculating with the online tool on "sunshine2k.de" and others), but you get 0x7853. Online CRC Calculator provides a table which shows RefIn and RefOut - for CRC/Modbus both are true and the LGF_CRC16 returns another value whereas e.g. for CRC-16/CCITT-FALSE both are false and the LGF_CRC16 returns the same value. Regards, Frink |
Last edited by: Prof. Frink at: 08/14/2019 11:29:29New Pi is exactly three! |
|
This contribution was helpful to
1 thankful Users |
Follow us on