Connect more Arduinos through Serial

Hello,

My setup is like this:

I have one master arduino, that will transmit broadcast message to all the slave arduinos. This part i have managed to do as i connected my master TX to the slaves RX. But how can i send info collected from the slaves to the master?

The problem it seems to be that when I transmit from one slave TX my message will not arrive to the master's RX pin.

How can i resolve this problem?

I don't want to use I2C connection, because all the slaves will have I2C devices attached and i dont think they can be slave for one device and master for other.

I can only speculate on the operation of the TTL tx/rx pins, but it might be possible to put a diode in the slave tx lines such that they will not supply voltage into the common master rx connection.

What kind of diode?

I am kind of new to electronics.

Providing each slave has its own address and responds only when it get a command this should (logical) work. So post your code. Each slave will need its own address and thus its own code.

Mark

chip69: What kind of diode? I am kind of new to electronics.

I'd try a common small signal diode aligned such that current can flow from the common master rx connection to the slave tx.

chip69: The problem it seems to be that when I transmit from one slave TX my message will not arrive to the master's RX pin.

How can i resolve this problem?

Yes, that would be the problem - the different slaves' Tx pins are all shorted together and fighting against each other. It's even possible that you are overloading and damaging the pins by effectively shorting a transmitting agent's Tx pin via the other non-transmitting agents.

I can see a couple of ways for this to work. You can either use a multidrop signalling standard such as RS485 on each serial interface, or arrange to tri-state the Tx pin on each slave to that it is configured as an input except when it is actively transmitting. You would have to design your own messaging protocol to ensurfe that only one slave tries to transmit at a time, and the simplest way to do that is to have the master control which slave transmits and when. Note that if your messaging protocol goes wrong and you end up with multiple slaves transmitting at the same time, you are back to the current situation and the risk of hardware damage.

First off, if the slaves are sharing a single line from their TX pins to the master’s RX pin, you will definitely need a protocol to tell each slave when to send while the other are quite (as suggested). The easiest protocol involves the master sending a query to a given slave, then watching it’s RX for some time period for an answer; only the addressed slave would send, within that time period.

Two ways have been suggested: using a diode per slave, or tristating the un-addressed slave TX pins.

Yes, you might be able to get by with diodes (look up diode OR gate). I did that with RS-232 years ago, it could probably work with 5v CMOS/TTL as well. You may need a resistor pull up at the master RX.

If you choose to tri-state the slave TX pins, be sure to have a pull-up resistor on the master’s RX line (internal or external), so that it won’t pick up too much noise when no slave is transmitting (all slaves are tri-stating their TX pins).

How far apart are the master and slaves?

Try this:
May have trouble if the cables are too long.

7-5-2013 5-00-59 PM.jpg

Try this: May have trouble if the cables are too long.

I think your diodes may be reversed.

Direction of diodes depends on level of "marking" (quiet) slave TX. That's easy to check with voltmeter. If near zero, diodes shown are correct, else reversed.

At idle, the o/p of the TX is -12V (about -3 to -25) it goes +12V at the start bit etc. so the diodes are OK.

EDIT: http://en.wikipedia.org/wiki/File:Rs232_oscilloscope_trace.svg

polypagan: Direction of diodes depends on level of "marking" (quiet) slave TX. That's easy to check with voltmeter. If near zero, diodes shown are correct, else reversed.

I think I measured the tx at ~5v with no communication activity in progress. I suspect the master rx pin is also "lightly" held high to suppress noise and floating issues. As I understand the serial TTL communication setup, the tx pin is in control. The initial communication start marker is the tx pin going from high to low (probably to ground), pulling the rx pin low along with it. If this is true, the diodes need to be aligned to allow current to flow from the master rx pin to the slave tx pin (aka, they appear to me to be reversed in the drawing). The other diodes keep the other high tx pins from feeding voltage the common rx connection. The resistors in the drawing also need to be removed as the may negatively impact the communication. Just non tested speculation.

LarryD: At idle, the o/p of the TX is -12V (about -3 to -25) it goes +12V at the start bit etc. so the diodes are OK.

EDIT: http://en.wikipedia.org/wiki/File:Rs232_oscilloscope_trace.svg

I'm talking arduino rx/tx pin TTL, and you appear to be talking RS232.

Yes. If TTL, reverse the diodes. If RS232, use the diodes as is.

EDIT: You may have to drop the resistor values.

Thank you all for responses.

Yes i will have differrent code for each slave.

For now all i have done is sending a message through Serial from TX. If the message ends in 1 a led on the first Atmega will blink (and theoreticly the pin 13 led on the master will blink once as a response to what the slave is sending), if the message ends in 2 the second Atmega and so on.

My purpose is to connect up to 100 (i want to see the limit of this) Atmega, but very close to the master.

Logicly i think the diodes should be connected to the slave TX pin, letting the current from the slave to the master and not letting the current from other slave TX pin. I would buy today some diodes and put them to test.

If the diodes don’t work, i will try to change the TX pins to Input when not transmitting and see where this is getting me.

It had worked with the 1N4148 diodes. I created the communication in both directions. Now to test the limits of this setup. Let's hope i can get it to 100 slaves at one master.

Let's hope i can get it to 100 slaves at one master.

What are you doing?

What do you mean, what am i doing?:)

If it is regardes my project, I would like to make a presentation office for different products (i dont how many). For each slave i might have 3-4 sensors (weight, color, distance) to detect different kind of objects.

I want to connect as many as i can, so i can see the limitations of such setup. I dont believe i will go to 100, but even 50 is ok.

I was just commenting about the large number of slaves, this is quite big project.

I hope it is and my client would like the idea:)