At 10:14 AM 12/6/2005 -0800, you wrote: >A couple of years ago did a project for a client which included >implementing a Modbus slave (RTU) on a PIC18F252. At the time I remember >it was kind of strange that although Modbus is de facto standard, I >couldn't find any example code for a slave. (There was lots of code for a >Modbus master.) A few things I remember off the top of my head: > >- Data is big endian >- Data is word based (two bytes); there's nothing in the spec about >floating-point values or strings, so I had to use trial and error. >- The freely available documentation isn't very thorough. There were no >examples of byte-for-byte messages including CRC. (This may have improved >since then.) I had to download a free PC-based Modbus master program, and >look at the data with a binary terminal program. My problem was that my >CRC bytes were swapped. Did I mention that modbus is big endian? >- The documentation includes lots of controller (mostly PLC) specific >stuff that doesn't apply for most implementations, so I didn't implement >some of the messages. >- Modbus messages don't include a start-of-message, length field, or >end-of-message. > >Those are just a few of the things I remember at the moment, but I do >remember it was a pain. Anyone else out there who has implemented a Modbus >slave have similar experiences? Did it (ASCII + RTU) with an 8051 variant a few years back. It's a pretty simple protocol, but the way the RTU framing works I think I had to dedicate an on-chip timer to it to meet the specs completely without using (ugh) delay loops. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com ->> Inexpensive test equipment & parts http://search.ebay.com/_W0QQsassZspeff -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist