Connecting multiple Arduino digital outputs to a single digital input

My project uses seven Arduinos: six slaves and a master. I want to dedicate a digital output pin on each slave that can be set low (preferably) to signal the master that a fatal error has occurred. So one wire coming out of a digital output of each slave, normally high, and those six wires going into a single digital input on the master. I also want to add some "emergency stop" buttons that will ground the wires in a similar manner -- so that will be another few wires from the stop buttons, all joining at the master's digital "emergency stop" input pin.

All of my grounds are connected together, but the Arduinos have their own +5v supplies from wall warts.

This was easy with just the emergency stop buttons -- because every one would just have an open wire that would be connected to ground when the button was pressed. Simple!

It's more confusing (to me!) with the Arduino outputs -- if I set all six to normally high (+5v) then I guess that's not a problem...and the master sees +5v at it's input pin. But if one of the slaves pulls its output pin low, to signal emergency stop, then I have a short circuit between it and the other five slaves, and no telling what the master would see on the wire.

So I installed diodes on each of the six slave output pins, with the stripe towards the digital pin. I was thinking this would block the +5v from getting out, but would allow a ground to pass through it, so any slave that pulled its line low would thus pull the master's line low. Of course it didn't work as planned.

What I need is an "open circuit" output from the pins, like my emergency stop pushbuttons, rather than either +5v or ground...so they would behave like the pushbuttons. Could I do this by setting all of the slave "output" pins to input mode, and then changing just one (whichever wanted to signal the emergency stop) to output mode, low? That would eliminate the short circuit problem, but I'm not sure how the master would see all those six incoming wires that were set to input mode at their source??? I'm guessing this is an undefined state and would not be a reliable solution.

If necessary, I could change the setup so that the emergency stop was triggered by a high on the master's input pin -- but I don't see how that would eliminate the short-circuit problem. I know just enough electronics to be dangerous -- but I'm trying to learn so don't hate me!

Can someone please point me in the right direction? Thank you!

When you had all the diodes hooked up did you include a pullup resistor to +5 from the anodes? That forms your basic AND gate. I would think a 4.7K resistor should be plenty.
If you were relying on the weak pullup on the Arduino I think the internal pullup is too weak for all that you are putting on it.

You have not made it clear which end the cathode of the diode is facing. Did you mean facing toward the output or the input ?

If they're outputs and yiu have diodes, then they should be configured as outputs but personally I am not a big fan if software interlocks. I'm "old school" and prefer hardware interlocks in case the uC "wigs out".

The cathodes (the end with the stripe) are connected to each slave's digital out pin.

I've drawn a simplified schematic and included the 4.7K pullup resistor recommended by Due_unto.

I hope I'm understanding you correctly.

If I set all slaves to output HIGH, then master should see high and we shouldn't have any problems even though the +5v on each Arduino is coming from a separate wall wart (all grounds are connected together.)

If I set a single slave to output LOW...then what happens?

Thanks for looking at this. It's just slightly out of my wheelhouse, but I'm trying to learn it!

IMG_2114.JPG

That looks good.

(It's a logic "or", which is exactly what you want. An "and" would require all of the signals to be active.)

Thanks for taking the time to help me with this.

Can/should I set the slaves to INPUT mode until an emergency...letting the 5v pullup resistor deliver HIGH to the master's digital input? Then change a single slave's pin to OUTPUT and set it to LOW... Would that override the +5v pullup and show up at the master's input pin as ground???

And since everyone, even the slaves, would be in INPUT mode, they would all see HIGH. When a single slave changed to OUTPUT mode and set it LOW, then everyone including the other slaves would see that go LOW (because the triggering slave's output low would override the +5v pullup voltage, right?) and thus everyone including the master would know there was an emergency stop.

If that would work, it would be ideal!

I think you are overlooking the basic fact that if all the Gnds are common and the master is pulled high with a resistor and the slave outputs are high , then there is NO difference of potential between the slaves and the master ( ie: 5V-5V = 0 V)
Do you understand ? It makes no difference that they are separate wall warts if there is no difference of potential between the slaves and the Master. (of course UNTIL a slave goes LOW)

This reply is for Randy, not Raschemmel. Takes time to compose and write...
Not quite. An AND gate only becomes "active" when one or more of the inputs go low. When all the inputs are high everything involved is high, so the output will be high. When one of the inputs goes low the gate output will go low. The other diodes will prevent the logic low from feeding back from the gate.
The reason this circuit is call an AND gate is that, for instance, a 3 input gate, input 1 AND input 2 And input 3 must be high for the output to be high. Any input going low will force the gate output low.
When an input goes low, the output goes low, placing 0 volts on all the other diode anodes, and those diodes will have +5 on their cathodes. This shuts the diode off, like a cut wire.

My personal rule of thumb for AND gates is LOGIC 0 rules. For an OR gate LOGIC 1 rules.

raschemmel:
I think you are overlooking the basic fact that if all the Gnds are common and the master is pulled high with a resistor and the slave outputs are high , then there is NO difference of potential between the slaves and the master ( ie: 5V-5V = 0 V)
Do you understand ? It makes no difference that they are separate wall warts if there is no difference of potential between the slaves and the Master. (of course UNTIL a slave goes LOW)

Raschemell: Isn't that what I want? I want the master to see a high until such time as one of the slaves' digital output goes low.

Due-unto, sorry I wasn't clear if you were replying to me or someone else???

SUMMARY: If I set all slaves and the master to INPUT, using the circuit in the photo attached earlier (with the pull-up resistor on the common wire)...then all Arduinos see logic high on their inputs, via the pullup. When any slave wants to trigger an emergency stop, it changes its pin from input to output, and sets it LOW. At that point, all of the other slaves and the master will see their inputs transition from high to low...and thus they will all know that someone has triggered an emergency stop. Correct?

In that scenario, I may as well put a diode on the master so it's wired exactly like all of the slaves...then anyone can trigger an emergency top including the master, and everyone else will know about it by seeing their input pin transition from high to low. Right?

In fact, I'm not even sure why I would need any diodes with that setup...???? Maybe it would only work without diodes! I need to see HIGH coming in, and be able to send LOW.

randydpeck:
Raschemell: Isn't that what I want? I want the master to see a high until such time as one of the slaves' digital output goes low.

Due-unto, sorry I wasn't clear if you were replying to me or someone else???

Yes, it was you.

SUMMARY: If I set all slaves and the master to INPUT, using the circuit in the photo attached earlier (with the pull-up resistor on the common wire)...then all Arduinos see logic high on their inputs, via the pullup. When any slave wants to trigger an emergency stop, it changes its pin from input to output, and sets it LOW. At that point, all of the other slaves and the master will see their inputs transition from high to low...and thus they will all know that someone has triggered an emergency stop. Correct?

No, the diodes from the slaves that are putting out a 1 will prevent the gate output (the connection to the master) from feeding the low signal back.

In that scenario, I may as well put a diode on the master so it's wired exactly like all of the slaves...then anyone can trigger an emergency top including the master, and everyone else will know about it by seeing their input pin transition from high to low. Right?

No, diodes only conduct in one direction. Putting a diode on the master will prevent it from seeing the gate output. Please reread post #7.

In fact, I'm not even sure why I would need any diodes with that setup...???? Maybe it would only work without diodes! I need to see HIGH coming in, and be able to send LOW.

You really need the diodes in order for the AND function to work properly. The drawing you provided in post #3 is fine.

@ randypeck,
You are still not "getting it".
There is NO reason to use you're idea of setting the slaves as inputs if there us no difference of potential when they are outputs. It is entirely unnecessary and is not as reliable as leaving the slaves as outputs.
You are trying to design with no design experience.
If you understand electronics then you should understand that there is no need to make the slaves "inputs".
Also, Due-unto is right about the diodes preventing the Master from "seeing" the slave highs.
Only the Master needs a pullup anyway.
As Due-unto stated: it is an OR- gate.
If the EMO is wired to the Master input ( with a pullup), and each slave is connected with a diode with the cathode at the slave end, any slave LOW will pull the EMO low but the Master is an input not an output so the Master could not pull it low without being changed to an output.

raschemmel:
Ykou ard trying to design with no dezign experience.

Yes, well, that's what I'm trying to do here is get experience. Try and fail and try again. I'm retired and is a large model railroading hobby project that I've been working on for a few years. I have read a lot of books and watched a lot of tutorials, fried a few components -- but trial and error is a great teacher and I'm getting better all the time.

Thanks for everyone for your input. I'll go with the version in the schematic I posted.

I have read a lot of books

Have you read this one ?
TTL COOKBOOK by Don Lancaster

TTL Cookbook. Ha ha, yes! Back in the late 70s, when I bought an original Apple II and wanted to learn more about it. At about the same time I read a bunch of Forrest M. Mims' books. I went into software but never lost my interest in electronics. Now my model railroading project is a perfect opportunity to use and improve both skills.

I do understand Boolean logic, and see that we're dealing with an AND gate...but the electronics in my example had me scratching my head. I could do it with an AND chip, but the discrete diodes and flow of current threw me, as simple as it appears to be.

Thanks.

Fantastic! It's always a pleasant feeling when the light bulb comes on.
Back in the mid 60's, coming off active duty I landed a job with a company called Friden where I cut my electronics teeth on the deep inner workings of an electronic calculator ( EC-130 ) which was totally discrete. No chips, just resistors, capacitors, diodes and transistors. The thing ran on diode/resistor AND & OR gates, hundreds of them. Transistors were used for inverters and flip-flops.

Good luck with your project.

For the record, it worked! Thanks again for all the advice, guys.

For the record, your application is an OR function (NOT AND)

Y= A+B+C+D+E+F ( the Y is Y-BAR) and the letters each have bars on top to indicate that the logic active- LOW function is active if any active low input is active.)

(Y=0 if any input is 0)

If it were the AND function ALL of the arduinos would have to be LOW which would be implemented with three 2-input NOR gates and one 3-input NAND gate. (three 7402s and one 7410)

Thanks for the clarification. I'm going to have to think about this but I'll take your word for it. An OR is what my original intention was, without thinking about voltages. If any slave signals the master, then the master reacts. OR.

But if you look at the circuit as a black box it feels like AND to me: if all inputs from slaves are high then the output to the master is high. If one or more input goes low then the output is low. That's why I thought it was an AND.

I guess that's true.

Depends on how you look at it.

Most physical digital chips will have their logic based on 1 (high voltage) and 0 (low voltage) levels. The AND gate requires all inputs to be 1 for the output to be 1; OR requires all voltages to be 0 for the output to be 0. In this formulation, your implementation is an AND gate.

Rashemmel is thinking in terms of having the ASSERTED level be 1, and the NONASSERTED level be 0. In this formulation, it is an OR expression. The OUTPUT is ASSERTED if any of the inputs are ASSERTED. The output is only NONASSERTED if all inputs are NONASSERTED.

The fact that you are using LOW as the assertion level is what's causing the seeming reversal of these two ways of looking at it.

Neither one is wrong, per say, but yours is closer to how actual logic chips are named.

You do not need diodes to do this. What you need is to use the Arduino pins to simulate an open drain output. You flirted with this idea earlier in the thread, but I didn't see that it was finished.

Open drain refers to an output that is high impedance when unasserted, and low impedance to ground when asserted. It is exactly the kind of output you need for this. The name comes from the drain segment of a MOSFET that can be used to implement this kind of output. If done with a BJT, it would be called open collector; the difference is only in name.

How you do it is to connect an external pullup resistor on the master board, something between 1k and 10k. The exact value isn't important, but you'll want it a bit stronger (lower resistance) than the builtin pullup. Wire all the slaves to this pin; they don't need another pullup.

pinMode that pin to INPUT on all the devices, master and slaves. With all of the high-Z, the pullup sets the voltage to Vcc, and they all read HIGH. When you want to assert the line, pinMode to OUTPUT. You don't need to digitalWrite to LOW, it will already be at LOW. When you need to deassert the line again, pinMode to INPUT.