# Simplest way to compare two voltages and output the one that last changed (by a small %)

I am working on an installation in a living space where there will be two wall mounted volume controls. Whichever volume control is last operated, should be the one that sets the volume of the audio.

The amplifier we’re using accepts a single 0-10v input, to control the volume from distance. The plan is to use standard 0-10v type wall mounted dimmer controls, that are simply analog pots underneath.

How can we use two (and optionally 3…) such wall mounted dimmer controls, so that the last one operated controls the volume of the amp?

A more precise request might be…

Compare two voltages A and B, which are between 0 and 10v. When either A or B changes by 5% (adjustable), switch the output to be the voltage of whichever one just changed.

I have researched other answers, including the excellent 'Most simple way to detect small voltage changes (~150mV)' which I was able to recreate successfully in iCircuit, but this and other answers don't allow for two 'variable' inputs as described.

As my experience is more on the AV side rather than circuit design, a suggested circuit like the one in the linked answer, would be awesome. Ideally I'm looking to use simple analog components that I can fashion a small circuit board out of.

• Don't use potentiometers. Use rotary encoders. It will ultimately make your life easier. Nov 6, 2022 at 23:11
• So, pot A is set very low -- maybe someone listened to Inna Gadda da Vida, or jumped up when the organ went to Extreme Fortissimo in the second movement of Saint-Saens' Symphony #3 and frantically turned it down. Pot B, on the other hand, is set at 11, because your metal-head roommate was listening to Nordic Death Metal at an appropriate volume for the genre. The system is running off of pot A. You think "hmm, I'll nudge that down a bit" and grab hold of pot B... Nov 6, 2022 at 23:29
• If pot A has been adjusted, and is thus the last one used, how is pot B going to gain control? Nov 6, 2022 at 23:54
• Interesting, would you prefer an Arduino like solution or an old school analog circuit?
– Jens
Nov 7, 2022 at 1:48
• In answer to questions... Barry, as soon as pot B changes, it would have control. Jens, I'd prefer an old school analog circuit. Many thanks. Nov 7, 2022 at 2:27

Well, you wanted an analog mass grave, there it is:

simulate this circuit – Schematic created using CircuitLab

There are two window comparators made of two comparators each. If you use LM339, the diodes in the output paths are not needed. The 4 resistors R1-R4 define the voltage window, the minimum input change for reaction.
The smaller R2 and R3 are, the smaller is the needed minimum input change.
The output of the upper comparator goes low for rising input changes, the lower one goes low for falling changes. Without a change, both outputs are high.
Comparator OA5 is a simple R/S flipflop. You can use two NAND gates from a CD4011 as well, but I wanted to stay in the analog style.
This simulator does not contain analog switches like CD4053, so I used an ugly relay with driver transistor here. In a real application I would prefer the analog switch.
At startup a random input wins, or at least I'm too lazy to think this through.
Probably you need R/C lowpass filters at the inputs to avoid reactions on EMI interferences.
If you need more than two inputs, you cannot use a simple flipflop. This would need a clock generation derived from all comparator outputs collected in a multi input NAND, a D-Register and a priority encoder. This would be the time, you switch over to a software solution with a MCU.

• This looks fab - will look at in detail this evening. Thanks very much Jens. Nov 7, 2022 at 19:12
• Hi Jens. Firstly I really appreciate your work. I replicated it in iCircuit which I'm more familiar with and it's 'sometimes' working. My skills are insufficient to understand what is going on, what I can tell you is that a change of either input does indeed cause the relay to flip, however, in almost all tests (but not all!), the relay flips back to the upper comparator after about 3 seconds, and occasionally to the bottom one. It's random. When it happens the two inputs to the final comparator OA5 are both exactly 5v. Nov 7, 2022 at 23:27
• @Smashing It should be impossible that In+ of OA5 sees 5 V, because the positive feedback via R13 must pull this either to 4 V or to 6 V to maintain the flipflop status. If you use LM339 there, you indeed need a resistor of, say, <3.3 kohm to +10 V at the output, because this comparator type can only sink current, not source. If you have problems there, I can solder this circuit to verify the function.
– Jens
Nov 8, 2022 at 18:13
• I checked my circuit again and I don't see any obvious errors. That said, it's still possible I made an error, or perhaps it's some kind of vagary of iCircuit vs. CircuitLab. That's an exceedingly generous offer about soldering the circuit. Am not quite sure what to say! Nov 9, 2022 at 13:59
• I forgot to tag you (I tried to edit and add the tag but I guess that's verboten) Nov 9, 2022 at 14:02

This looks quite complicated.

I'd use a bunch of SPDT momentary wall switches which seem to be available. These have a conveniently labeled "+" and "-" switches, which you can wire in parallel.

Then any microcontroller (or if you insist, up-down counter and dac) with an opamp as output amplifier can register presses on +/- buttons and generate a 0-10V output to drive the amp.

If you do not wish to design circuits, here's another solution:

Several of these round LED dimmer remote controls, paired with a compatible LED dimmer, will make it output PWM according to the chosen brightness. Simply convert the PWM into 0-10V and you're good to go. Plus these are battery operated so they don't have to be on a wall, you can put them on the coffee table too. The protocol is very simple and can also be received with some RF microcontrollers (I believe nRF24L01 will do the deed) if you want a nice looking remote with a custom receiver.

Agreeing with other commentors, a cleaner solution (than multiple potentiometers) would be to have each wall mounted control consist of two buttons: increase and decrease (volume). This avoids the pitfall of sudden volume changes due to potentiometers being in different positions. It also simplifies wiring as all the control boxes (as many as you’d like) can be daisy-chained with a 3-wire interconnect. If you’re OK with 16 volume levels, I think it can be done with a CD4029 up/down counter, a CD4001 quad NOR gate, and a 555 timer.

The CD4029 is a 4-bit up/down counter that can run at 10V so with a simple R-2R ladder on its four outputs can generate 16 voltage levels from 0 to 10V.

Pressing any UP button brings the INC_N input low, and pressing any DOWN button brings the DEC_N input low. Either of these going low causes the counter to count (because the clock enable pin gets asserted). It will count down if any of the DOWN buttons is pressed otherwise it will count up.

Setting the clock rate to about 5Hz will allow counter to step through all 16 states in about 3 seconds but hopefully not so fast you can’t get a single inc/dec with a quick tap. The clock is an astable multivibrator circuit built around the ubiquitous 555, an exercise left to the reader.

When the counter counts up and reaches its max (1111) it will wrap back to 0000 (min) if precautions aren’t taken. Worse, when counting down and min 0000 is reached, the counter will wrap to 1111 (max) which would make for unhappy listeners.

The CARRY_OUT_N pin provides us protection from wraparound. When counting UP it will assert (low) upon reaching terminal count 1111. When counting DOWN it will assert upon reaching 0000.

Normally CARRY_OUT_N is high and the inverter on it (1/4 CD4001 quad NOR gate) provides a low enable to the two NOR gates (drawn as equivalent AND gates with inverted inputs). In this state any UP or DOWN key press enables the counter.

When UP is still pressed when max 1111 is reached, CARRY_OUT_N goes low, the inverter goes high and the INC_N is inhibited from enabling the counter. If DEC_N is then pressed the CARRY_OUT_N line goes back high because 1111 isn’t the terminal count when counting DOWN.

Similarly, when DOWN is still pressed when min 0000 is reached, CARRY_OUT_N goes low, the inverter goes high and the DEC_N is inhibited from enabling the counter.

• Thanks for taking the time to suggest this in detail. I agree that it solves the problem you describe. Unfortunately, the dimmer has to be a rotary dimmer. It's a pretty spectacular one tbh, with superb movement, large diameter, looks to die for, and has those delightful clicks as you turn it. It will match other controls (lighting etc) that are already decided. Nov 7, 2022 at 19:49
• Thanks. It looks like your fancy encoder (I hope you can get to the potentiometer pins - it looks like it's built like a tank!) also includes a push button. Perhaps that could be used to directly control a relay: you would first move the knob to where you want it and then press the button to select that knob. Nov 7, 2022 at 20:10
• Nice idea. Actually the push button will be used to send a GPIO trigger back to the central music server to change genre. Nov 8, 2022 at 14:03