This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

One Master with many Slaves

When I have a Master which to need to communicate with many slaves through the RXD,TXD pins, is it possible for the slaves to communicate with master independently. That is whenever the slave wants to do so. The reason why I asked is if there is an attempt by more than one slave to communicate with the Master at the same time, won't it cause a conflict? If so, how such situations to be handled?

Parents
  • Is it not possible that when any slave communicate with master, it starts with a start byte and end with a stop byte which all slaves connected to the line will also receive.This information can be used by slaves to know whether the line is busy.

    I think you may be missing the point. No slave should ever talk unless it has been told to do so by the master. It doesn't matter if slaves see each others transmissions as the slaves should only recognise and respond to a transmission from the master.

    There needs to be sufficient information in your protocol so that each 'node' on the bus can clearly and unambiguously identify when a message is addressed to it. A typical approach is to allocate an 'address' to each node - this need be nothing more than some arbitrary number.

    The slaves do not need to detect whether the line is busy because they only transmit when addressed by the master, at which time the line will automatically not be busy. If for any reason a slave may not be in a position to respond then you will need to use a timeout at the master end and require slaves to respond within that timeout period.

Reply
  • Is it not possible that when any slave communicate with master, it starts with a start byte and end with a stop byte which all slaves connected to the line will also receive.This information can be used by slaves to know whether the line is busy.

    I think you may be missing the point. No slave should ever talk unless it has been told to do so by the master. It doesn't matter if slaves see each others transmissions as the slaves should only recognise and respond to a transmission from the master.

    There needs to be sufficient information in your protocol so that each 'node' on the bus can clearly and unambiguously identify when a message is addressed to it. A typical approach is to allocate an 'address' to each node - this need be nothing more than some arbitrary number.

    The slaves do not need to detect whether the line is busy because they only transmit when addressed by the master, at which time the line will automatically not be busy. If for any reason a slave may not be in a position to respond then you will need to use a timeout at the master end and require slaves to respond within that timeout period.

Children
  • You seem to be trying to upgrade a master/slave system into actually operating as a multi-master system.

    But whenever you have multiple masters, you must have a method to synchronize.

    CAN or Ethernet for example have a system where a transmitter can listen to the line while sending, and on a bit-by-bit basis notice a collision and instantly stop the transmission at a later time. The master that sent the dominant bit combination didn't notice the collision and could continue with the transfer.

    A normal UART doesn't have that hardware collision-detect feature so you must implement solutions either by byte-wise protocol or by adding extra signal lines or by polling.

    The complexity can quickly increase dramatically so think twice. The easiest solution is to either have one master poll all slaves.

    The second easiest solution is to have a token-ring system where each device is enumerated, and where they talk in sequence - potentially just saying "i'm done - next". But a token-ring system must handle enumeration (unless you hard-code the addresses) and it must handle the loss of the token (transfer error or one of the units rebooted).

    Somewhere down the line comes collision-detectin solutions. They tend to be very messy. And it is possible to produce something that seems to work, but still fails randomly at bad times.

    Don't go for multi-master solutions unless you really, really have to. It is easier to go for a solution with higher baudrate if you need to speed up the response times in a polling or token-passing solution. Or have each slave add a separate signal line - either directly connected to the master or through a priority encoder - so that slave 5 can draw attention when it needs servicing.

  • there is, basically, two methods for multiple nodes
    a) master-slave which has collision avoidance because no slave speaks till granted permission. This is fairly simple.
    b) multi-master which must have collision detection because there is no way to avoid two nodes starting at the same time by 'listening'. This type must have retransmit capability and random start in case of collision.
    I have done both, but my absolute preference is collision avoidance whenever possible.

    Erik