From: janka vietzen on 1 Feb 2007 15:06 for the moment I struggle with the modbus protocol checksum what seems to use a quite odd 16 bit CRC polynom 0xA001. I have no idea if my ATmega assembly code works correct becouse its responsible for both directions generation and test same time and for the moment I do not have further modbus certificated devices. Is there any CRC calculator known what allows to comapare reference values?
From: Jonathan Kirwan on 1 Feb 2007 15:16 On Thu, 01 Feb 2007 21:06:53 +0100, janka vietzen <janvi(a)t-online.de> wrote: >for the moment I struggle with the modbus protocol checksum what seems to >use a quite odd 16 bit CRC polynom 0xA001. I have no idea if my ATmega >assembly code works correct becouse its responsible for both directions >generation and test same time and for the moment I do not have further >modbus certificated devices. > >Is there any CRC calculator known what allows to comapare reference values? Isn't there sample code for calculating modbus CRCs included in the documentation on modbus? I seem to recall seeing it near the end of one particular manual. Jon
From: janka vietzen on 1 Feb 2007 15:39 > Isn't there sample code for calculating modbus CRCs included in the I dont have many modbus manuals but there are 2 diffrent code samples for crc written in C. One uses 2 bested byte - bit loops and the other uses 255 byte lookup tables for low and highbyte each. Unfortunately I dont tried any Compilers for Atmels ATmega128 (probably there is a gcc available) and even the cpu family is new for me why i decided to start with assembler
From: Tauno Voipio on 1 Feb 2007 15:49 janka vietzen wrote: >>Isn't there sample code for calculating modbus CRCs included in the > > > I dont have many modbus manuals but there are 2 diffrent code samples for > crc written in C. One uses 2 bested byte - bit loops and the other uses 255 > byte lookup tables for low and highbyte each. Unfortunately I dont tried > any Compilers for Atmels ATmega128 (probably there is a gcc available) and > even the cpu family is new for me why i decided to start with assembler There is GCC available for AVRs (including your chip). I suppose that you mean the binary Modbus encoding, also called Modbus/RTU. (There's a hexadecimal encoding resembling Intel's hex object code, but it does not use CRC at all, but a straight checksum). The Modbus CRC is the old IBM's CRC-16, used e.g. in the early disks and in the Bisync data communication protocol. For eight-bit processors, the simplest way of calculating the CRC is the use of two 256 (not 255) byte tables, if you do not want to do it bit-by-bit. The table-driven method calculates the CRC for each incoming byte, not each bit separately. -- Tauno Voipio tauno voipio (at) iki fi
From: FreeRTOS.org on 1 Feb 2007 15:52
"Jonathan Kirwan" <jkirwan(a)easystreet.com> wrote in message news:5mi4s25krt4qes5j25j5mr2k06sih0utqc(a)4ax.com... > On Thu, 01 Feb 2007 21:06:53 +0100, janka vietzen <janvi(a)t-online.de> > wrote: > >>for the moment I struggle with the modbus protocol checksum what seems to >>use a quite odd 16 bit CRC polynom 0xA001. I have no idea if my ATmega >>assembly code works correct becouse its responsible for both directions >>generation and test same time and for the moment I do not have further >>modbus certificated devices. >> >>Is there any CRC calculator known what allows to comapare reference >>values? > > Isn't there sample code for calculating modbus CRCs included in the > documentation on modbus? I seem to recall seeing it near the end of > one particular manual. > > Jon It is probably 10 years since I used Modbus, and hopefully the manuals have been updated, but I recall the code sample in my Modicon manual being incorrect :-( I still have some hair left though. Regards, Richard. + http://www.FreeRTOS.org + http://www.SafeRTOS.com for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430 Microblaze, Coldfire, AVR, x86, 8051, PIC24 & dsPIC ..... and soon AVR32 |