You do not state any distance or speed restrictions so I assume you have your devices within a metre or so. That means you can work up to at least 100,000 bps with the DEBUG and DEBUGIN commands - assuming 20 MHz crystals.
I have several applications with three or more PICs chattering amongst themselves. In one case I use a bidirectional data lne with the SERIN/SEROUT commands at 9600 bps. In another I use separated data in and data out lines with the DEBUG/DEBUGIN commands. The DEBUG approach should also be able to use a single shared TX/Rx line. The Master Controller (MC) is a PIC 16F877A as is one of the slaves. The second slave is a PIC 16F88. The slave 'F877A mixes gases while the 'F88 runs a Peltier heater/cooler plus a DS1620 and controls temperature. The MC drives some analyser equipment.
Usually, each processor has a single bidirectional data line to the other processors. In addition, each processor has two strobe lines between them.
Whenever the MC needs to send a command temperature to the 'F88 or a desired gas mix to the slave 'F877, it raises the relevant Strobe 1 line. Each slave checks once per loop to see if there is a new command waiting. As soon as the slave sees that Strobe 1 is high it then knows the MC has new data for the slave. The slave raises Strobe 2 and uses a DEBUGIN command with a timeout to load the new command which arrives in a checksum protected packet at 100,000 bps from the MC.
Likewise, if a slave needs to talk to the MC, it raises Strobe 1 and waits for the other processor to reply by raising Strobe 2. The slave then sends a short checksum protected packet to the MC via the DEBUG command. Except when a command exchange is needed, all PIC to PIC lines are configured as inputs and for safety there is a 330 ohm resistor on all PIC to PIC lines.
In my case the packets are only a few characters long and data rate is 100,000 bps so the data exchange takes place in a few milliseconds.
HTH
Brian
Bookmarks