Searching \ for '[PIC]:Pic <--> Pic Comms' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Pic <--> Pic Comms'.

Exact match. Not showing close matches.
PICList Thread
'[pic]:Pic <--> Pic Comms'
2001\05\04@123253 by Russell Farnhill

flavicon
face
Sorry for the repost forgot the Tag :)



Hi all,

       I want to be able to control six F84's from a master
       F84. I think my options are I2C, SPI or some serial link.

       It would also be nice if the slaves could send data back
       to the master as well.

       Looking on the net I find lots of I2C routines, but they
       all seem to be for the master and not for the slave.

       Does anyone know where I could get a simple set or routines
       in 'C' for slave and master to get me going.

       SPI... Don't really know anything about this so I'll look
       at this if I can't get anywhere with I2C or Serial.

       lastly Serial...

       I think this is my best chance of success because I've already
       got one pic talking to another and probably just need to expand it.

       Would this serial set-up work ?

       Master pic Tx pin wired to all six slave Rx pins
       Master Pic Rx pin wired to all six slave Tx pins

       So now master should be able to send cmd's to any slave and
       any slave back to master. Also I thought of using six more pins
       on the master as Select lines going to each slave. So slave can
       grab attention of master and help on bus collisions.

       I'am a little unsure about all the slave Tx pins connected together
       on the master Rx pin, if all Tx's are low and one goes high to send
       data, will this cause a short and blow the pin ??, if so could I use
       some series resistor or something ?


       Any suggestions, help appreciated.

Thanks,

Russ.


-----EMAIL DISCLAIMER-------------------------------------------------
This email and any files transmitted with it are intended solely for
the addressee(s) and may be legally privileged and/or confidential. If
you have received this email in error please destroy it and notify the
sender. You must not use or disclose any part of this message if you
are not the intended recipient. Unauthorised use/disclosure may be
unlawful. Opinions expressed may be personal to the author and may not
necessarily reflect the opinions of Khaos Technologies or its
affiliates. We may monitor email communication passing through our
networks and we reserve the right to store all/part of any
communication. We take reasonable precautions to ensure our emails are
virus free, however, we cannot accept responsibility for any virus
transmitted and recommend that you implement your own virus checking
procedures.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\05\04@132536 by David W. Gulley

flavicon
face
One Wire Method:
  Assumptions:
     One PIC is master and others are slaves
     Each Slave PIC knows its "address"
       (either loaded in code or by input pins set appropriately)
     Speed of serial stream defined so that all slaves know how fast
       to sample the data from the host and how fast to send data
       back to host.
  Operation:
     At Reset all slaves  go to listen mode
     Master Sends out an ATTENTION code containing a target address
       and then sets I/O to input to listen for response
     All slaves see the ATTENTION, but only the one whose address
       matches responds to the master with an ACKNOWLEDGE and then
       goes back to listen mode
     If no ACKNOWLEDGE is received by the master within a defined
       period of time, it assumes the PIC at that address is dead
       or busy or otherwise indisposed.
     Note the ATTENTION can consist of command and/or data for the
     slave(s) and/or request for data from the addressed slave.
  Problems:
     No method for slaves to notify master that they need attention,
       so the master must regularly check on the slaves to see if
       they need to be serviced.
     Slow since the serial stream must be sampled multiple times to
       establish when bits are valid.

Two Wire Method:
    Many two wire methods are possible, but using an established
protocol
      may reduce time to develop
  Assumptions:
     Use I2C (or a derivation) allows multiple devices on a two
       wire bus. Either do a full up I2C or adapt it for your
       specific requirements.
  Advantages:
      Well defined, existing protocol.
      Uses a clock so the data transfer is not asynchronous

Three or More Wires:
  Advantages:
      Can add functionality (e.g. allow slaves to interrupt master),
  Disadvantages:
      Requires more pins


David W. Gulley
Destiny Designs

Russell Farnhill wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\05\04@164401 by David Cary

flavicon
face
Dear Russel Farnhill,

Russell Farnhill <spam_OUTr.farnhillTakeThisOuTspamSTOR-WAVE.CO.UK> on 2001-05-04 11:40:26 AM
>        Master pic Tx pin wired to all six slave Rx pins
>        Master Pic Rx pin wired to all six slave Tx pins
>
>        So now master should be able to send cmd's to any slave and
>        any slave back to master. Also I thought of using six more pins
>        on the master as Select lines going to each slave. So slave can
>        grab attention of master and help on bus collisions.
>
>        I'am a little unsure about all the slave Tx pins connected together
>        on the master Rx pin, if all Tx's are low and one goes high to send
>        data, will this cause a short and blow the pin ??, if so could I use
>        some series resistor or something ?

Yes. Since (most ?) PIC pins are rated to drive 25 mA without problems, a 5 V /
25 ma = 200 Ohm series resistor protects it from anything in the 0 to +5V range
(I think this is conservative). (You can use much smaller resistors or no
resistor at all if you are *sure* the other end of the resistor will never be
shorted to ground when you're trying to output a hi, or +5V when trying to
output a lo ...).

Now if all the slaves are hi (idle state) and 1 tries to communicate (pulling
lo), there's no damage done. But the master doesn't get the message. So we need
something else ...

{Quote hidden}

Your circuit works great with 2 PICs that need to communicate. What if 3 or more
PICs need to communicate ?
Using diodes and the pull-up is one method to keep the PICs from fighting over a
line. But there are other ways. Here's one I've been thinking about:

serial ring:

 .... ->[ Rx PIC4 Tx ]----->[ Rx PIC5 Tx ]----->[ Rx PIC6 Tx ]----->[ Rx PIC7
Tx ]--->....

with the output of the last PIC on the right (you can think of that one as the
master)
looped back around to the 1st PIC on the left.
(Perhaps put a 200 Ohm resistor in each communication link in case of a software
bug that
accidentally set RX to Output).

One transmission protocol idea: If a packet begins with destination ID = 0,
then accept the packet and do something with it. Otherwise, decrement the
destination ID number and forward the entire packet to the next PIC. (Don't
buffer the entire packet).

Advantages (compared to diode/pullup master/slave topology):
(a) Simpler hardware than any other network I've seen:
 no diodes or pull-up resistors needed, because each line is being driven by
one and only one source;
 only uses 2 or 3 pins on each PIC.
(b) The theoretical bandwidth is much higher, because
 the bit rate is no longer limited by the RC time constant on the Master's Rx
line
 (R = pull up resistor; C = parasitic capacitance of line).
(c) Scalable to any number of PICs, without having to set unique ID numbers.
(d) Easy to find out how many PICs are connected. (Think about what the master
PIC recieves after it transmits a message that no one claims).

Disadvantages (compared to diode/pullup master/slave topology):
(a) the software on each slave is more complicated, because each PIC needs
forward most messages to the next PIC. Token ring.
(b) Latency between the master sending the command and a slave recieving it, and
between the slave sending a response and a master recieving it, is worse.
(c) Master can't transmit a global ``Now !'' command to get all slaves to do
some (prearranged) activity simultaneously.

Same for both (diode/pullup master/slave)(serial ring):
+(a) Scalable to almost any number of PICs without adding more hardware at the
master
+(e) Both can be modified to use ``synchronous serial'' (the fastest serial
communication on a PIC).
 Synchronous serial uses 3 pins on each slave PIC:
 CLK and Rx input pins, Tx ouput pins. (Generate CLK on master PIC ?).
-(b) If a slave wants to say something, but it hears that another slave has
already started transmitting a message, the slave needs to hold off on its own
message, waiting for other slaves to finish talking, before it transmits its
message.
-(c) if it hears a message while it's transmitting, it needs to buffer that
message.
-(d) Every wire is essential to communication. (Fabric topologies can route
around a few broken wires).

Is there a better way ?

--
David Cary

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\05\08@062542 by Russell Farnhill

flavicon
face
Sorry REPOST NO TAG....



Hi,

       Thanks for all your suggestions, I've got some good ideas to try
now.
       I think I'll try the ASYNC serial solutions.

       Just one thing regarding I2C, When I mentioned I couldn't find
       any code for the SLAVE only the MASTER this was after looking at
       the HI-Tech example. Is this just for the MASTER or will it work
       for both and if so how do you set the slave address. It's just that
       I see that most of the functions take an address parameter but I
       don't see the address being set anywhere in the functions/code.


Thanks again,

Russ.



{Original Message removed}

2001\05\08@065436 by Michael Rigby-Jones

flavicon
face
The Hitech sample code is for a bit bashed MASTER only.  If you search
through the PIC archives (at http://www.piclist.com) you'll find that several
snippets of slave code have been posted in the past, as well as a wealth of
information on potential gotchas.

Regards

Mike

> {Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...