How to measure 2 inputs (0V-5V) and output the highest voltage

Discussion in 'The Projects Forum' started by skyrat, Aug 3, 2006.

  1. skyrat

    Thread Starter New Member

    Aug 3, 2006
    I need to design a circuit that will take two inputs (from pots), both of which have a range from 0V to +5V.

    From these two inputs, I then need to output the one which has the highest value.


    Input 1 = +2V
    Input 2 = +4V

    Therefore output = +4V

    Does anyone know of a circuit that can do this ?

    I thought of using 2 diodes (as an analogue OR gate) but then I would get a voltage drop accross the diodes.

    There must be some way of doing it using op-amps and resistors etc ?
  2. beenthere

    Retired Moderator

    Apr 20, 2004

    You might set up two comparators with the test voltages as inputs. Generate a voltage ramp as the other input to both comparators. Whichever comparator changes state last had the higher voltage.
  3. Papabravo


    Feb 24, 2006
    The comparators have a logic output, not an analog one. Reread the original post. What you need is a comparator whose output goes to an analog switch with one normally open and one normally closed device. You problems are not over yet since you need to do something rational if both inputs are very close to each other. The comparator output may beat up and down at a fairly highr rate.
  4. beenthere

    Retired Moderator

    Apr 20, 2004

    Papabravo is right. I tend to focus on the most interesting aspect of the problem, and lose track of the rest. Using a fast-rising ramp will help with the uncertainty if the two voltages are close together.
  5. Ron H

    AAC Fanatic!

    Apr 14, 2005
    Your simplest solution is two operational rectifiers ("ideal diodes").
    Is this a homework problem?
  6. hgmjr

    Retired Moderator

    Jan 28, 2005

    This may be a good place to apply a bit of hysteresis to each of the comparators as a way of addressing the problem that arises from having the two input voltages that are close together in value.

    ronh's "ideal" diode using an opamp represents a good alternative.

  7. pebe

    AAC Fanatic!

    Oct 11, 2004
    Here is a possible alternative circuit.
    IC1 is an opamp like a 3140 that will allow an input down to the -ve rail. S1 to S3 are 3 switches in a 4066 analogue switching IC.
    If A>B then S1 switches on (S3 switches on turning off S2).
    If B>A then S2 will be switched on,
    So whichever input is the higher will be switched to the output.

    Edit: Once again I can't seem to upload a circuit. I'll have another try later.
  8. pebe

    AAC Fanatic!

    Oct 11, 2004
    Here it is ( file was too large)