Use Comparator As Logic AND Gate

Electrical Engineer, control systems, automation, small electronics, home automation, microcontro...

Intro: Use Comparator As Logic AND Gate

When you've got some comparators either already in your circuit or built into your MCU, there are some handy tricks you can use.  The following will show you how you can use a comparator to make a Logic AND Gate.

Resistors 3 and 4 are used to bias the non inverting input while resistors 1 and 2 are used to average the two inputs.  
Resistors 1 and 2 must be equal and resistor 4 must be selected to be twice the value of resistor 3. It is also recommended that resistors 3 and 4 are very large values as they will have a constant current draw through them and if a low resistance is chosen they can have a high power usage.

Both inputs will need to be Logic values (either High or Low) for this to work correctly.  If you are running analog ranging values through this circuit it will go HIGH at 2/3 V+ rather than at V+ (due to selecting resistor 4 to be 2 times the value of resistor 3).  You can obviously select resistors 3 and 4 to make this more accurate for analog signals, but it will never be perfect.

So now, if inputs 1 and 2 both go HIGH (V+), or higher than the input of the non-inverting pin, the output will go HIGH.  If either of the inputs are not HIGH the output will stay LOW.  You can also switch the pins of the comparator to create a NAND gate.

Share

    Recommendations

    • Audio Contest 2018

      Audio Contest 2018
    • Optics Contest

      Optics Contest
    • Plastics Contest

      Plastics Contest

    3 Discussions

    0
    None
    janzicek

    2 years ago

    The way this circuit is drawn it is a NAND gate, not an AND gate. Logic 0 (0V) on both inputs will satisfy comparator as TRUE.

    0
    None
    Rosemary42

    2 years ago

    What do you mean by "You can also switch the pins of the comparator to create a NAND gate?" Which pins are you referring to?

    1 reply
    0
    None
    BooRanRosemary42

    Reply 2 years ago

    By switching which resistor circuit goes into each of the + and - inputs of the comparator or by modifying the circuit to have R4 ties to VCC rather than ground you can create a NAND gate.