I am working in a project that has some MODBUS RTU Slaves but the custumer is using a plataform that doesn't have support for this protocol but this plataform has two RS-485 ports. So I am creating the protocol manually and I had difficulties to create the CRC function Block. I will post the code of this FB and I hope that can be helpful for anyone that having the same difficult that I've had. It's the first version and I am testing it yet. Maybe it has some bugs. If anyone want to test or modify the code please don't forget to post your feedback here .
Thanks for infomation. I get the library from OSCAT, but the values that the blocks returns seems incoherent and I can't find good explanation about these blocks.
Thanks a lot.
Mauricio.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This CRC check is for MODBUS RTU and I get that tables from MODICON page. I don't have any Idea which polynom is that... I've tried to use the OSCAT library before write this fb, that is powerful library, but I got the same problem that you told...
Thanks a lot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
of oscat crc block is a general purpose crc which can only deliver the correct output if its configured with the right parameters. in the oscat manual we mention about 40 different types of CRC's. in praktical terms there is probably around hundreds of different flavours.
without the knowledge of what needs to be done its hard to do the job
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all.
I am working in a project that has some MODBUS RTU Slaves but the custumer is using a plataform that doesn't have support for this protocol but this plataform has two RS-485 ports. So I am creating the protocol manually and I had difficulties to create the CRC function Block. I will post the code of this FB and I hope that can be helpful for anyone that having the same difficult that I've had. It's the first version and I am testing it yet. Maybe it has some bugs. If anyone want to test or modify the code please don't forget to post your feedback here .
Best Regards
FBCRC16MODBUS.zip [1.15 KiB]
Hi mauricio
in the open source library from oscat you can find function blocks for crc encode and crc decode
both in open source and ready to use
w www.oscat.de w
Hi Hugo.
Thanks for infomation. I get the library from OSCAT, but the values that the blocks returns seems incoherent and I can't find good explanation about these blocks.
Thanks a lot.
Mauricio.
do you have a clear description what crc you need? detailes of polynom, and other parameters?
i did look through your code, and cannot find any initial polynom or other setup parameters.
CRC is a general form of cyclic redundancy check.
there is literally hundreds of different CRTC's
you need to find out your specific CRC paramaters like:
polynom,
reverses byte order or not
reversed bits in bytes?
inverse bytes?
starting bits FF or 00
ending bits ff or 00
only with the exact paramaters a crc generator or checker can deliver the correct results
Hi hugo,
This CRC check is for MODBUS RTU and I get that tables from MODICON page. I don't have any Idea which polynom is that... I've tried to use the OSCAT library before write this fb, that is powerful library, but I got the same problem that you told...
Thanks a lot.
Hello Mauricio,
i checked your fb and it works fine.
Your fb calculated exact the same crc like Modscan.
(see the attached hardcopy)
I think your problem is the use of your fb.
Are you shure you call it with the correct length ?
Best Regards
Uwe
Dear Mauricio,
of oscat crc block is a general purpose crc which can only deliver the correct output if its configured with the right parameters. in the oscat manual we mention about 40 different types of CRC's. in praktical terms there is probably around hundreds of different flavours.
without the knowledge of what needs to be done its hard to do the job