After hours of research, I was unable to find a suitable realtime, multi-master/peer-to-peer network protocol for RS485. So I made my own. Please evaluate it and comment on it. The protocol is designed to work over RS485, using an RS485 transceiver hooked up to a PIC's UART pins. 8 bit, no parity, 1 stop bit. Maximum length of data segment of packet is 0xFF bytes long, but since most midrange controllers don't have that much, I'll stick with 26 bytes. The protocol has a token bus type topology (or at least that's what I think it's called), so it's deterministic, collision free and real time. The packet looks like this: ... : 1 byte. Start of packet. 0xAA. , : 1 byte each. 0x01 - 0xFE. 0x00 represents the bus owner, configuration node or hub (unimplimented for now). 0xFF is broadcast, for all nodes. : 1 byte <0, 1, 2, 3, 4, 5, 6, 7> 0 - ACK - acknowledge 1 - NACK - no acknowledge (could not use the packet, for some reason) 2 - ACK_REQ - when sending, request an acknowledgement from target node 3 - ID_REQ - request identification information from the target node 4 - TYPE - is the data segment a special command type or a normal data type? 5 - TOKEN - this packet is a token and contains data of zero length; all other flag bits must be zero 6 - not used/application specific 7 - not used/application specific : the length (in bytes) of the data segment that follows : the data (or command) segment itself : the 8 bit polynomial checksum Notes: The lowest ID on the bus has voice (starts with token). If it has a message to send, it can send up to 4 packets. Then it MUST give up its voice and give the token to the next node. -> The 5th (or less if it has less or even no data to send) packet must be a token that it passes to the next node. If the node has no data to send, it will pass the token to the next node in the bus, which is it's own ID + 1. IDs are static on the bus and are assigned incrementally (I want to make them dynamic, though). When a byte is received, it is buffered in memory in the "interrupt on RX" function. After the last byte (checksum) has been received, the packet is checked, validated and used. It is discarded if the packet does not belong to the node. The packets shall be examined as CPU time permits. One question to you all though: since this type of network requires the constant examining of packets, I assume it takes a lot of CPU time. If I have other things to do, how do I create "tasks" so that the real tasks such as getting data from sensors, turning off the lights, and so on is done on a high priority basis? I know that an RTOS can do this, so do any of you know of any free RTOS that will run on PIC16Fs? I also googled and found some info on multitasking using PICs. Please comment and leave your opinions on this protocol. Thank you! -- [ solarwind ] -- http://solar-blogg.blogspot.com/ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist