# Compare two voltages and output the lower of the two

I am working on a circuit that is connected to a 10V supply (can supply about 1-2mA).

We have two signals, let's call them S1 and S2. We also have an input to the circuit called IN1.

My goal here is to compare the two signals, S1 and S2 (They may range from 0 to 10V) and output the LOWER of the two into the circuit's IN1 pin.

What makes this challenging is the fact that the LOWER voltage needs to be output.

I can easily make a microcontroller compare two voltages on the A/D pins and output the lower on the D/A pin, but i'm afraid 2mA of power will not be enough to run the microcontroller properly - plus i'm sure there must be a much easier way.

EDIT: According to the simulation, accepted solution works like a charm! OpAmp source current is important in order to make sure it doesn't go past the current limit. Proper selection of OpAmp also allows OUT to be very close to V- (0V in this case).

I simulated this in LTSpice with a LT1490A OpAmp and a 22K resistor instead of a 1K.

To simulate i simply chose IN1 as 5V and varied IN2 from 0 to 10V. The results should be quite clear and self-explanatory. V1 (not shown below) and V2 are my V+ and V-. These are 10V and 0V.

• How fast are the signals changing? What AC content is on the two voltages? What impedance do the two signals have? Are they both referenced to 0V or are they independent? Dec 20, 2013 at 11:55
• Signals are very slow - they are activated by heat changes (can take minutes for them to slightly increase/decrease) or human interaction (potentiometer). AC is negligible. I believe they have the same reference. Dec 21, 2013 at 4:46

I think you can just use standard "precision rectifier" circuits. You need a dual opamp and diodes. To get the output down to zero volts, a negative supply is required.

• Nice! One thought though, the op-amp of the higher voltage will go into saturation; can that have side effects (recovery time / power consumption / component life). Would it be worth it to and an extra resistor and diode to the feedback loop? (shall I ask it in a separate question complete with a diagram that I have in mind?) Dec 20, 2013 at 8:25
• @Michael, that's why the two-diode precision rectifier was invented. But this circuit will work fine at DC and with general-purpose op-amps. The bandwidth was not specified, so I went for the simple solution. Dec 20, 2013 at 15:28
• Actually 1V is more than enough as the low goes. Circuit doesn't really do much if i feed it 0-1V - I'll try this out and reply once i get it working :) Thanks!! Dec 21, 2013 at 4:51
• Shouldn't the diodes be the other way around? Dec 22, 2013 at 9:49
• @m.Alin, the spec is to select the lower of the two voltages. That's why the diodes are that way. Dec 23, 2013 at 5:33

A simple circuit would be to tie each input to IN1 through a MOSFET, one a p-channel and the other n-channel. Then put the S1 and S2 inputs into a comparator and connect the output of the comparator to the gates of the MOSFETs. Of course the inputs need to be fed into the comparator such that when the comparator turns on a MOSFET it is turning on the one connected to the low input signal.

The comparator outputs tells the MOSFETS which side is higher (or lower) and since the MOSFETS are complimentary one turns on and the other turns off.

EDIT:

Adding screen shots from i Circuit showing 5V on one side with the other side at values below and above 5V.

• @Phil Frost - thanks for the encouragement to improve my answer. Dec 21, 2013 at 7:09
• Should the source and drain on the PFET be reversed? As drawn I would expect it would conduct through the parasitic diode whenever S2 exceeds S1 by a diode drop or more. Dec 21, 2013 at 8:08
• FETs are completely symmetric structures. Source and Drain ends are only drawn for clarification purposes in general. Most of the time, this information is handy in determining which side has a higher DC voltage in amplifier circuits, but again, is not functionally relevant.
– Cem
Dec 21, 2013 at 12:54
• Furthermore, FET's have no junctions between their gates and drain/sources. There is an oxide in between(hence a Metal-Oxide-Semiconductor) through which only a minute current(in the order of pAs) can flow. The parasitic diodes in the FET structure are located in the interface of bulk-source and bulk-drain, and the related effect is known as Body Effect.
– Cem
Dec 21, 2013 at 12:56
• However it should be noted that, while comparing two very low voltages(i.e. the voltages close to negative supply of the op-amp), S2 will not be properly transferred to the output, as is the case while comparing two high voltages(voltages close to the positive supply of the op-amp) with S1. In order to prevent this, a modified version of this circuit can be used with CMOS Transmission gates instead of single transistors on either sides.
– Cem
Dec 21, 2013 at 13:02