Your Pick can be one of many. Pick SOME NAMED STANDARD and stick to it (sorry for the shout). Modbus, STD-12, et., al. IMHO. if you let someone bastardize some Standard , I think you are doomed for life. Regards Keith -----Original Message----- From: Ray Gardiner [SMTP:ray@DSP.COM.AU] Sent: Friday, August 25, 2000 12:00 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: Protocols for Serial Communications Hi Philip, Someone once said, the nice thing about standards, is that there are so many to choose from. Since what you want is a point to point link between the PC and a PIC based controller, I recommend that you consider the following approach. Use modbus framing. This is simple and well documented. see www.modbus.org Implement only two transaction types. ReadHoldingRegister and WriteHoldingRegister. This allow you to simply read and write any memory that you choose on the target (PIC) Additionally you can extend the networking to multiple PIC's by going to RS485 HDX. see:-- http://www.modicon.com/techpubs/toc7.html for more detail on how to do other functions, crc calculation etc. The basic modbus frame for reading is 8 bytes as follows. == 0x01 // ok, you don't really need it but // it makes for a convenient sync flag // anyway == 0x03 // 0x03 == read holding register == 0x?? // address in PIC data space == 0x?? == 0x?? // number of registers to read == 0x?? // <16bitCRClobyte> == 0x?? <16bitCRChibyte> == 0x?? The response will be something like... == 0x01 == 0x03 == 0x?? == 0x?? == 0x?? == 0x?? .... for DataCount Bytes ... <16bitCRClobyte> == 0x?? <16bitCRChibyte> == 0x?? The 16 bit CRC is sufficient for most applications. But... IF you are transmitting over a noisy link (eg radio), you could consider implementing some kind of FEC (forward error correction) using hamming codes or reed-solomon. This means assembling the packet and then encoding with the appropriate FEC. Then decoding and correcting errors before passing up to the modbus receive routine. If you have low error rates then you don't really need it. >> I have been working towards a stable serial link with a PC. I am not >sending >> a lot of data, things like date,time stamps plus the odd 6 or 8 byte >codes. >> However it has become pretty clear that good serial coms has a lot more to >> it than banning bits in and out of a PIC, bits DO go missing or get >> corrupted. It also seems that the pins for hardware handshaking are never >> used so there must be protocols involved, so here are my questions. >> >> Is there a standard protocol or at least a guideline that one could work >> from? >> >> Do I need to use CRC or is a xor check sum ok? >> >> Thanking you in advance. >> Philip -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu