# How do I cause one switch to “lock out” other switches in parallel?

I have several momentary switches that are foot pedals (just two are shown below). simulate this circuit – Schematic created using CircuitLab

The goal is to supply the LED (or whatever) with different levels depending on the variable resistors.

The problem is that pressing two switches simultaneously combines the resistances.

When one switch closes, it should prevent the others from affecting the LED.

• I cannot use a mechanical selector switch like a rotary switch because the switches are foot pedal switches that are physically far apart.

• I could use a microcontroller but if there is a simpler option I'd prefer that.

• The other options I can think of are logic gates, a latch circuit or an IC.

Which of these is the easiest to implement conceptually?

Are there any other options?

I chose the NAND gate idea as the answer because it fits my question. But the relay idea was also good if you have those switches.

• Is implementing the logic in a microcontroller an option, or do you want discrete logic? – ThreePhaseEel Aug 17 '17 at 2:36
• Is "light an LED with a specific brightness depending on the switch" the actual thing you want to do, or just a placeholder? This will affect what the best choice is. (Please edit to specify.) – Kevin Reid Aug 17 '17 at 2:47
• @KevinReid - yes, that is what I want. – thatsagoal Aug 17 '17 at 2:59
• @ThreePhaseEel - I would prefer not to use a microcontroller if there is a simpler option. – thatsagoal Aug 17 '17 at 3:00
• Why not use a rotary switch? – Ignacio Vazquez-Abrams Aug 17 '17 at 3:05

When one switch closes, it should prevent the others from affecting the LED...

I could use a microcontroller but if there is a simpler option I'd prefer that. The other options I can think of are logic gates, a latch circuit or an IC.

Which of these is the easiest to implement conceptually?

Conceptually, a circuit using logic gates is the most obvious solution. When a switch is closed it must switch in its resistor unless any other switch is closed. Therefore each node has to somehow be able to tell that all the others are off before it turns on.

With two switches the circuit is the same as an SR latch, but operated 'inverted':- simulate this circuit – Schematic created using CircuitLab

A NAND gate's output goes low ('on') only when both inputs are high, otherwise the output is high ('off'). So in this circuit when both pedal switches are off both NAND outputs must be 'off'. Each NAND gate also monitors the output of the other gate on its second input. If the other gate is 'off' then it can turn 'on', but if the other gate is 'on' it can't.

When a gate is 'on' it pulls its associated variable resistor low. The diode isolates the resistor from the gate's output when high, so only low output affects LED brightness. The gate output could be used to drive a transistor if the logic gate cannot provide sufficient drive by itself.

With 3 pedal switches each gate has to monitor two other outputs, so 3 input NAND gates are required:- simulate this circuit

As more pedal switches are added the gates need more inputs and the wiring gets more complex. Standard TTL/CMOS logic gates are available with up to 8 inputs in a single IC. Beyond this you need to combine several gates to make each NAND, and a PLD (Programmable Logic Device) or MCU becomes attractive. Wiring complex circuits is tedious and error prone, so for any more than 4 switches (two 4 input NAND ICs required) I would probably use an MCU.

This scheme uses the difference in relay pick and hold voltages to do what you require. It has the small disadvantage that 2-pole foot switches are required.

DC relays typically pick at about 2/3 of their rated coil voltage and will remain on until the coil voltage drops below 1/3 supply. (These figures are very rough.) simulate this circuit – Schematic created using CircuitLab

Figure 1. Relay interlocking.

How it works:

• If SW1 is pressed the coil of RLY1 will be energised and the contacts will close. When the footswitch is released the coil will remain energised via R1, D1 and the hold-on contact.
• If SW2 is pressed RLY2 will pull in. At the same time the common hold-on supply will be shorted to ground and RLY1 will drop out.
• The spare contact of each relay can be used to control your "LED".
• R1 limits the current during short circuit.
• The diodes prevent back-feed onto the hold-on rail.

R1's value will need to be established by experiment. A value close to the coil resistance should give you 1/2 supply on the coil and this should be sufficient.

R1's power rating should be high enough to cope with a switch being held on indefinitely. e.g., On a 12 V supply, $P = \frac {V^2}{R} = \frac {12^2}{470} = 0.3 \; W$. simulate this circuit

Figure 2. By using changeover contacts only the highest priority switch will feed the "LED" load in the event that multiple switches are pressed.

If you just want switch priority then Figure 3 would suffice. simulate this circuit

Figure 3. Simple switch priority. simulate this circuit – Schematic created using CircuitLab

This fulfills the stated requirement of making SW2 have no effect if SW1 is already closed. And it produces the same LED currents as your original when either SW1 or SW2 is closed. I changed the V1 value because 1 V is not realistically enough voltage to turn an LED on.

How to extend it to more than 2 switches depends on the details of which switch you want to have priority.

You should also consider what you want to happen if SW1 is closed, and then SW2 is closed, and then SW1 is opened, leaving only SW2 closed.

• Thank you and this is a good solution. However ... R1 and R2 are going to be variable resistors (potentiometers). In that case there is no set order of priority. I should have mentioned that in my original post but I did not want to over-complicate the circuit. – thatsagoal Aug 17 '17 at 4:27
• @thatsagoal, we can only answer the question you actually ask. – The Photon Aug 17 '17 at 4:34
• Sorry I will think more about how to ask my question next time. – thatsagoal Aug 17 '17 at 5:16

## Basic Design

I never thought I'd be saying this, but it appears you may have found one of the few applications in which discrete diode logic could be useful... simulate this circuit – Schematic created using CircuitLab

The above circuit forms an OR gate using only diodes. When one turns on, roughly 8.3V is supplied to the resistor and LED. If another switch is pressed, the voltage across the LED and resistor stays about the same, and the current is split between the two (or more) of the diodes.

Design Process:

1. Choose the desired LED current

2. Determine the resistor needed to drive the LED at the desired current: $$R = \frac{9-V_D-V_{LED}}{I_{LED}}$$ where $V_D$ is the forward voltage drop across a diode, $V_{LED}$ is the voltage drop across the LED, and $I_{LED}$ is the desired operating current.

If the brightness of the LED varies significantly when different switch combinations are pressed, try adding a small resistor (less than 100 ohms) in series with each diode. These resistors will help equalize the current across each diode, but may also cause a larger change in current across the LED.

If all else fails, consider driving the LED with a current mirror. The current mirror prevents variations in diode voltages from changing the LED drive current. simulate this circuit

$$I_{LED} = \frac{9-V_{BE}}{R_1 + R_2}$$

A few caveats:

• This circuit has a significant quiescent current (20mA in the example), even when all of the switches are off.
• Depending on drive current, the 2N3904 may not be up to the task. The PN2222A would likely be a better choice.
• Even with 47 ohm ballast resistors (R2 and R3), poor transistor matching means that the drive current could end up being several milliamps above or below the desired value. This probably doesn't matter in your case.
• I'm afraid I'm not familiar with diode logic. You say "When one turns on, roughly 8.3V is supplied to the resistor and LED. If another switch is pressed, the voltage stays about the same, and the current is split between the two diodes." but surely this would happen also without the diodes? – thatsagoal Aug 17 '17 at 10:03
• Notice that OP actually wants the LED brightness to vary depending on which switch is closed (and wants to be able to control the brightness on a switch-by-switch basis, I think). – The Photon Aug 17 '17 at 15:55
• @thatsagoal Diodes have a fairly constant voltage drop (about 0.7V for silicon) across a wide range of currents. This is very different from a parallel combination of resistors. – Caleb Reister Aug 17 '17 at 21:31
• @Photon I'm not sure if that can be done reliably without resorting to some sort of PWM configuration, since the luminous intensity of an LED is highly nonlinear. – Caleb Reister Aug 17 '17 at 21:34
• It's not clear if s/he wants the brightness differences to be proportional to anything in particular, and in any case the response is quite linear with respect to current, so once you have enough series resistance to make the source look like a current source instead of a voltage source the nonlinearity shouldn't be much of an issue. – The Photon Aug 18 '17 at 0:49