Two arduinos controlling one digital output

I'm interested in using two physically separate arduinos to control a single output. I'm using two as a redundant system - if one fails the other should still work.

I'm guessing that just hooking up a digital output on both arduinos to the item (in this case a power transistor) is not a good idea - MOST of the time both digitalOuts will be LOW, but at some time, one will go HIGH, and probably not at the same time as the other. I'm guessing this wouldn't be healthy for either, and in fact might damage the outputs, or prevent the transistor from correctly reading a HIGH.

I was thinking of making both pins INPUT, then when I was to turn on the transistor, change the respective pin to OUTPUT and set it to HIGH. There would still be the potential though for both to be OUTPUT at the same time.

Any ideas on how to deal with the situation?

Thanks

Alex

if one fails the other should still work

If you've only got two, how do you decide which one is "correct" and which has "failed"?

The only way to connect outputs together is with the so called "wired OR" configuration. That is where the outputs are open collector, that is they sink current and do not source it. There is a common pull up resistor. So if any one of the outputs is low (or indeed both) then the output is low.

This is used on buses like the I2C bus where any one of a number of devices can pull the bus low.

Indeed there are more solutions. It is not generally forbidden to wire output pins in parallel. In fact this is standard technique for enhancing the current in drivers.

As trialex already noticed, this is no good if they will not work strictly synchronized. In purely electronic solutions the jitter is sub ns and generally negligeable,but not when you switch with software, and are additionally handy-capped by the Arduino "only one pin at a time" limitation.

A solution can be to put diodes at the outputs. This will reduce the voltage for 0.3 volts only when you use a Schottky type.

The original idea is fine I think (presuming no software bugs ;-) ), but is flawed by the Arduino design. You cannot switch from HIGH to INPUT, as the internal pull-up will then be switched. This is often forgotten... See the modified Blink below for a direct experience.

A network of resistors can also be a "best case" solution: When you have to limit the base current to the transistor anyhow than connect the base to each pin with an own resistor (>1k). I said "best case" solution, as the failure might also consist of a LOW at the fault pin. In that case the voltage to the base would be cut in half, which however will be an issue only if the "base" in fact is a "gate" :-)

So my recommendation is: use (Schottky) diodes.

To become more philosophical again: This is DTL (in contrast to Mike's RTL)

void setup()   {                
  // modified to show working of internal pull-up

  digitalWrite(ledPin, HIGH);   // set the LED on  
    pinMode(ledPin, OUTPUT);
}

void loop()                     
{
    pinMode(ledPin, OUTPUT);
  delay(1000);                  // wait for a second
    pinMode(ledPin, INPUT);
  delay(1000);                  // wait for a second
}

So my recommendation is: use (Schottky) diodes.

Problem with diode oring is that you can only achieve a logic one output, you can’t achieve a logic zero because the diode prevents them from sinking current. Of course this might not matter in your application. It also might not matter if you loose 0.3v or the conventional 0.7v that you get with a normal diode. By the way all power Schottky diodes I have seen drop 0.5v not 0.3v.

The original idea is fine I think (presuming no software bugs Wink ), but is flawed by the Arduino design.

Even if you had two raw independent processors running off the same clock (take arduino out of it) then it is still a rubbish idea as you will never be able to synchronise the switching of two output pins to occur simultaneously. You could do this with a single processor only providing the two outputs were on the same output port. Any delay in switching of an output that can both source and sink current would lead to a condition known as “shoot through” which results in high currents flowing as one output sources and the other output sinks.

It all depends on what you want these outputs to do, a simple compromise might be to have a series resistor on each one of greater than 100R. In that way any shoot through current will be limited to below the absolute maximum of the arduino’s current limits.

Just to clarify. There were a lot of things discussed and it is understandable that misunderstandings can occur.

When I spoke of a “flaw”, I was addressing the transition from HIGH to INPUT and this is not possible without interflicting the internal pull-up for a (very) short time. This happens inside one processor.

I did not address the issue of synchronizing two independant processors, as this is already difficult enough for two pin on an Arduino.

I think I had been very clear with my proposal of serial resistors.

0.3 V drop from low power Schottkies came from my memory, I am sure I have measured that sometimes…

0.3 V drop from low power Schottkies came from my memory

yes that is the figure that I always remembered but recently I had to use two of them to connect two PSUs and couldn't find anything under 0.5v. I was surprised. Maybe it is only an issue for power diodes.

Richard, I quite agree a redundant system is difficult to implement and requires much more than commoning up signal lines. There are lots of other things to consider like the identification of single point failures and even the possible failure modes themselves.

My first thought is: how will you avoid split brain issues http://en.wikipedia.org/wiki/High-availability_cluster ?

Udo

This mainly depends on the failure modes to be identified... For advanced safety requirements a triple redundant system with hardware voters is still common; this it not so expensive as you might think and gives you a lot of head room..

Firstly thanks all for the responses. As expected, I was hoping you'd all be able to bring up the issues that I knew would be out there, but didn't know what - the "unknown unknowns".

To clarify the "redundant" issues - I was using this term as a basic descriptor, and not necessarily as an exact statement.

To explain it fully, I have a cut down system that is turned on by a power transistor. At the moment it is hooked up to an arduino which is reading GPS strings. If the GPS string places it outside a certain radius, the pin goes high, the transistor allows current to flow through a nichrome wire which heats up, and the line is cut.

Now I want to also be able to control the cutdown on a second arduino. This one will read serial strings from a radio, so if i send a "oh crap lookout!" sentence, the pin goes high, the line is cut. I want to do this on a second arduino because [1] if the first arduino fails (battery goes flat etc) there is a backup, and [2] it means I don't have to deal with software serial or multiplexing the serial port. I know this is not the technical definition of redundant.

Doing research now on diode OR-ing. Might have to switch from an NPN to PNP transistor.

Thanks again for your help, any more info or ideas on how to do this more than welcome.

Alex

Doing research now on diode OR-ing. Might have to switch from an NPN to PNP transistor.

Thanks again for your help, any more info or ideas on how to do this more than welcome.

I think you have described the application well enough. Simple two diode ORing should work OK, with anodes wired to the output pins and the common cathode wired to a series resistor to the base of a NPN with grounded emitter. Be sure to remember to have a common ground wired between the two Arduinos and the transistors ground emitter connection.

This is of course no way a redundant circuit, just two independent ways to trigger a single cut circuit. The redundacy is in the fact of two different sources that detect the need to cut.

Lefty

For such an application I would use two nichrome cutters to cut the same line. Just in case one of the cutters or their driver transistor would fail. This also gets rid of the logic coupling issues completely.

Udo

I would use two nichrome cutters to cut the same line

Yeah I was thinking the same thing, but, how do you cut a single line at two places, and ensure the other one releases? The nichrome has to be reasonably tight around the line.

Very simple, use two lines instead of one line. Here is a crude ascii picture.

F----/-----O-----/----F
           |
           |
           L
  • = standing line / = nichrome heater F = place where standing line is fastened O = some loop in the load bearing line that can slide freely on the standing line | = load bearing line L = load

I hope the picture makes it somewhat clear. The approach can be generalized to any number of heaters. But I think more than 4 would be somewhat impractical.

Udo

Very interesting!

You have thrown a spanner in the works my friend. Now for some thinking...

Just one more thing. Of course the real thing would look more like a Y instead of a T shape as in my picture.

Tell us of your results :slight_smile:

Udo