Haw to connect two pic?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Cool Haw to connect two pic?

    Good day.

    I need a suggestion about haw to connect a pic18f2520 (master) with 2 or 3 pic16f876 (slave).
    The serial out/in of master are use to connect it to PC.
    I was thinking to simulate a I2c connection.

    Can any one help me?

    Thanks (form Italy)

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251

    Default

    I2C in PBP cannot do master slave.
    Just connect them as a serieel port without RS232 ic's.
    The master serialout to both slave's serial in and the slave serial out's to the master serial in.
    Don't forget to put the slave serial out's in the input mode when doing nothing. Set the slave serial out only to serial out if you have been asked to tell something.

  3. #3
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Question

    Thanks, I will try this.

    I will try to do a better description about what I wont realize, maybe It is an other way.

    I have already a pic18f2550 connected with almost all pins, and a internal software with several function.
    I need to read 2 or 3 more value, which one are coming from a pic16f876. This value are byte type.
    I was thinking to connect all pic's in this way.
    When I need the last value I will activate a pin from pic18f2550 like issue, and pic16f876 will respond with his value.

    edysan

  4. #4
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Unhappy

    I have try the Mat Janssen suggestion, but think is a little bit complicated.

    Have anyone some other idea?

    Thanks.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Try SERIN2/SEROUT2. Use two pins on each PIC. One pin to SEROUT2 and one to SERIN2. I suggest SERIN2/SEROUT2 because of the time out option.

    When PIC #1 is ready for data it will send a signal to PIC #2 from PIN_X.
    PIC #2 receives the signal for data on PIN_X.
    PIC#2 will then send data one PIN_Y.
    PIC#1 receives data on PIN_Y.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352

    Default

    Hi Edysan,

    It's not hard to do. What Matt and Dave are telling you is the way to go. I have a display board that is connected to 20 other boards in a card cage. ONE wire is the Serial I/O line. Another wire is the busy line. ALL boards including the display board are programmed as inputs. There is one pull up resistor for this line. The BUSY line is the key to the whole process. If a board wants to send a "byte" sized message to the display board, he first checks the status of the busy line. If it is low then the board stays in a loop checking for the low to go back to high. Once the busy line is free, he makes the busy line low and sends his signal and clears the busy line when finished. Just remember, you make each board an input. The SEROUT2 command makes the pin an output. When done "talking" you make the pin an input again. (TRISB.7 = 1 for example makes B7 an input)

    I hope this makes sense. The display board simply stays in a loop looking for the busy line to go low. Once it does it gets the "message", it then makes the busy line low until it's done sending a time stamped message to a printer. Once that's done, then it releases the busy line waiting for the next message.

    A gentleman by the name of Steve Collins has a program called "SixPICs" available on the melabs website. MisterE also has posted a similar type of program here on this forum. Steve's (MisterE) program uses a code to address each board. The slaves just sit and wait for their code to be sent out, then they respond. These systems can be made to "talk" to each board in a polling type fashion. The Master sends out the code for a specific board. When that board hears its name, it answers, and waits for the message. When done the Master calls for then next board. It will take you a while to get this going. Start with one to one communications then add another board. It was very frustrating for me but Steve Collins called me and explained how to do it and I was off and running after that.

    The two examples I've mentioned should help get you going.

    HTH,

    BobK

    PS Make sure there is a 1K resistor in series with each Serial I/O pin to prevent accidents.
    Last edited by BobK; - 23rd August 2007 at 02:54.

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352

    Smile

    Sorry for the double posting.

  8. #8
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    17

    Thumbs up

    Thanks.

    Is exactly what I need.

Similar Threads

  1. How to connect Buzzer to PIC?
    By koossa in forum Schematics
    Replies: 32
    Last Post: - 21st April 2010, 04:17
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. how to connect ac sensor to PIC ?
    By iugmoh in forum Schematics
    Replies: 3
    Last Post: - 1st June 2008, 18:35
  4. connect microphone to pic?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th January 2008, 08:33
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

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