Pic to Pic communication


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Yes, you can use SERIN and SEROUT (provided you are using a Resonator or Xtal), it's HSERIN and HSEROUT that require a USART.

  2. #2


    Did you find this post helpful? Yes | No

    Default PIC to PIC communications

    I have a system with 5 PICs all doing separate tasks in separate boxes. The PICs are in a peer to peer system with no master. All have equal priority and lose only a few microseconds checking bus activity every time through their main software loops. If a message is pending, all PICs need about 2 mSecs to work out if the message is for them.

    The hardware has a 10 way ribbon cable linking all PICs over about 2 metres and only using a few pins. 4 PICs are 18F4620 @ 20 MHz and one is a 16F88 @ 4 MHz. Each PIC has a different ID stored in location 0 of the EEPROM. All comms is at 9600 bps. Slow man is the 16F88 @ 4 MHz. With just the 18F4620 I can get a reliable 50 kilobits.

    I use 3 signal lines, plus power and ground. There is an ATTention line, and ACKnowledge line and a MeSsaGe line. ATT, ACK and MSG are tied to +5 volts with 10 K resistors and the PIC pins driving the communications bus are set as inputs. I have 220 ohm resistors on every PIC pin connecting to the comms bus to prevent damage if the software inadvertently sets rival pins to outputs. The 220 ohms also act as good line termination and suppress ringing.

    In normal operation, when each PIC is doing its own job and not communicating, the MSG, ATT and ACK lines are all floating high with those pins set as inputs. The software in each PIC checks for comms activity at least once per loop.

    When a PIC wants to send it checks that ATT and ACK are both high meaning the comms bus is free. If the bus is free it stakes a claim by setting the ATT pin to an output and pulling the ATT line low. That PIC immediately sends a continuous stream of address polls on the comms bus for as long as it takes for the target to finish it's own tasks and get around to checking the comms bus, or a timeout occurs.

    Whenever any PIC sees the ATT line go low it checks the message line for their address. If the address does not match their own ID that PIC goes back to its normal tasks. The PIC that does match the ID being polled pulls the ACK line low. The sender sees ACK go low so it knows the target PIC is ready to receive. The sender stops sending the Destination ID and now sends the message. The sender keeps sending until it sees the ACK line go high. This means the receiver has a clean copy of the message. All messages are error protected with simple CheckSums.

    The system works a treat. There are no interrupts needed.

    HTH
    BrianT

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. PIC 2 PIC communication
    By Mario in forum Forum Requests
    Replies: 16
    Last Post: - 28th April 2006, 01:56
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Pic to Pic communication?
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th April 2004, 19:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts