Button/Switch Combinations

Hello all,

Looking for some pointers on the best way to combine button/switch events(or alternative options all together). I apologize now for the long-winded post...

Right now I have a SP switch set up in a loop and monitored for changes via the simple command (switchState != lastswitchState).

Works great. If the switch is flipped "on", the pin goes High and action A is performed. Flip it "off" and the pin goes Low and action A is stopped. Basic stuff.

I ran into a problem where this simple setup spontaneously failed out of the blue after working flawlessly for years. The switch was in the on (High) position and action A was running. Out of nowhere action A was terminated despite the switch being in the on position. Long story short - bad things happened and many hobbits were lost.

My investigation showed that the hardware link between the pin and the controller itself had failed. (ended up being a solder issue with the SM controller which was fixed with a re-flow). So I'm looking for insurance to prevent this issue, the outcome anyway from happening again.

With a DP switch I would like to monitor two pins. When pin X is High and pin Y is Low, that is "off". The inverse would be "on".

Is there a "best practice" method for what I'm trying to achieve? Any pointers would be great appreciated.

-CC

No idea if there is a best practice. A voltage measurement using an analog pin might be an alternative.

Resistor divider 5V → R1 → R2 → GND; Arduino pin connected between R1 and R2
Switch center connected to pin, one pole to 5V and one pole to GND

If the wire breaks or comes loose, the voltage will no longer be 5V or 0V (e.g. 2.5V if R1 and R2 are equal). If the wire is OK, you will either have 5V or 0V.

Mission critical wiring is often installed as N/C circuits - so that if the wiring loop is broken or damaged - it goes to the 'ON' state - raising the alert condition. This is of course is dependent on your solution, but often used in high-availability systems to determine when a mid-stream, or downstream device has failed or become disconnected.

Proper soldering is step one.

Switch monitoring with a supervision resistor is best IMO.

.

sterretje: No idea if there is a best practice. A voltage measurement using an analog pin might be an alternative.

Resistor divider 5V -> R1 -> R2 -> GND; Arduino pin connected between R1 and R2 Switch center connected to pin, one pole to 5V and one pole to GND

If the wire breaks or comes loose, the voltage will no longer be 5V or 0V (e.g. 2.5V if R1 and R2 are equal). If the wire is OK, you will either have 5V or 0V.

Interesting thought...

I'll have to give that a try.

Do you think this would be better than trying to get a "'if pin 1 is high and pin 2 is low start x '/ 'if pin 1 is low and pin 2 is high stop x'"(which I'm not sure how to properly implement) working?

lastchancename: Mission critical wiring is often installed as N/C circuits - so that if the wiring loop is broken or damaged - it goes to the 'ON' state - raising the alert condition. This is of course is dependent on your solution, but often used in high-availability systems to determine when a mid-stream, or downstream device has failed or become disconnected.

You're right, unfortunately in this case setting things up as NC means a failure turns thing on which is also not desirable if I'm not around.

larryd: Proper soldering is step one.

Switch monitoring with a supervision resistor is best IMO.

Agreed on the proper soldering. But other than calling up the board manufacture and telling them to turn up the heat on their SMT placement machine, I'm not sure anything can be done. So far the re-flow is working and long term plan is to replace the board completely - just because.

Regarding the supervisor resistor, I'm sorry I don't know what you mean?

Thanks for the help everybody. -CC

In avionics, nearly every device is triple redundant - 3 flight computers, 3 pitot tubes, 3 GPS units, etc... That way if one of them fails, there is a voting circuit ignores the lone faulty signal and the plane continues to fly as normal.

If you can find a triple throw switch, you can have the Arduino do the voting in software. If you only have a double throw, how do you know which signal is correct (high or low)? You need a third signal to vote the bad signal off the island (so to speak).

CircuitChasser:
Interesting thought…

I’ll have to give that a try.

Do you think this would be better than trying to get a “'if pin 1 is high and pin 2 is low start x '/ ‘if pin 1 is low and pin 2 is high stop x’”(which I’m not sure how to properly implement) working?

You’re right, unfortunately in this case setting things up as NC means a failure turns thing on which is also not desirable if I’m not around.

Agreed on the proper soldering. But other than calling up the board manufacture and telling them to turn up the heat on their SMT placement machine, I’m not sure anything can be done. So far the re-flow is working and long term plan is to replace the board completely - just because.

Regarding the supervisor resistor, I’m sorry I don’t know what you mean?

Thanks for the help everybody.
-CC

2017-07-24_21-24-25.jpg

larryd:
2017-07-24_21-24-25.jpg

Yeah, but how do you know if the switch is really closed or not? You need an odd number of inputs.

Power_Broker: Yeah, but how do you know if the switch is really closed or not? You need an odd number of inputs.

Well, this isn't the space shuttle. I guess that has been retired.

Might have to accept "bad things happened and many hobbits were lost".

If you can find a triple throw switch, you can have the Arduino do the voting in software.

But how do you know if it is open when it's open. But . . . But . . . But . . .

Good stuff though.

larryd: But how do you know if it is open when it's open. But . . . But . . . But . . .

Oops, forgot to mention the pullup resistors on all the inputs.