I am a Modbus beginner and I need to calculate the CRC for a modbus command to a slave. The CRC examples I found are not very clear to me and they seem to conflict with each other.
1. Can you give a hint where to find a good and valid example how to calculate CRC and how to queue the whole frame, preferably in Ansi C?
With kind regards
Ralf Obertacke
1. Can you give a hint where to find a good and valid example how to calculate CRC and how to queue the whole frame, preferably in Ansi C?
With kind regards
Ralf Obertacke
You will find CRC calculation examples in the free Modbus RTU source code at the ProtoCessor website:
http://www.protocessor.com/techsupport/Free_Modbus_RTU_Source_Code. asp
Eddie Hague, CTO
FieldServer Technologies
http://www.protocessor.com/techsupport/Free_Modbus_RTU_Source_Code. asp
Eddie Hague, CTO
FieldServer Technologies
Page 112 of PI_MBUS_300_J.
Dear Ralf
I have a PDF file of Modbus Master Protocol.
send me your e-mail that i send the document for you.
Evandro Vizicato
evandro.vizicato@uol.com.br
I have a PDF file of Modbus Master Protocol.
send me your e-mail that i send the document for you.
Evandro Vizicato
evandro.vizicato@uol.com.br
http://www.modicon.com/techpubs/crc7.html#0.2..637OJU.KDG87D.4
Yes, I realized two years ago a Modbus communication including the CRC-16 Checksum calculation on a Honeywell IPC620 PLC.
The source for calculation I've found somewhere as C Code. I donīt remember from what website, but I have it still printed on paper. If You send me a fax number I can send You a copy.
With kind regards
Bernd Bauer
bbauerberk@aol.com
The source for calculation I've found somewhere as C Code. I donīt remember from what website, but I have it still printed on paper. If You send me a fax number I can send You a copy.
With kind regards
Bernd Bauer
bbauerberk@aol.com
Hi
On http://www.modbus.pl you can find the CRC function in C and more about modbus protocol.
Regards
Andrzej
On http://www.modbus.pl you can find the CRC function in C and more about modbus protocol.
Regards
Andrzej
This seems pretty straightforward. I typed it all in from memory, so if there are bugs, let me know.
Max<br>
superalpha@yahoo.com
-------------------------------------------------
unsigned int CRC16;
#define SEED 0xFFFF //initialization for CRC16
#define GP 0xA001 //generating polynomial
//for standard CRC16
//(remainder of division)
//to start a new CRC, set CRC16 = SEED
//then for each byte call Calc_CRC(byte, &CRC16);
//CRC16 will contain the result
//(if you calculate all of the incoming data
//INCLUDING the CRC, the result should be 0x0000
//and if you are sending the CRC be sure to
//send the bytes in the correct order)
void Calc_CRC(unsigned byte b, unsigned int* CRC)
{
BOOL carry;
int i;
CRC[0] ^= b & 0xFF;
for (i=0; i<8; i++)
{
carry = CRC[0] & 0x0001;
CRC[0]>>=1;
if (carry) CRC[0] ^= GP;
}
}
-------------------------------------------------
I am also new to MODBUS... i just need to use a limited set of commands.
i want to know if theres a crc calculator available to calculate the same? i don't need the code. a windows application. i tried to use the standard crc calculators available (Hex Workshop) but the generated checksum is different.
i want to know if theres a crc calculator available to calculate the same? i don't need the code. a windows application. i tried to use the standard crc calculators available (Hex Workshop) but the generated checksum is different.
Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2010 Nerds in Control, LLC. All rights reserved.
Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.
Fortune
"For three days after death hair and fingernails continue to grow but
phone calls taper off."
-- Johnny Carson



