Introduction: Use Comparator As Logic AND Gate

Picture of 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.

Comments

janzicek (author)2016-10-01

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.

Rosemary42 (author)2016-01-29

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?

BooRan (author)Rosemary422016-01-31

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.

About This Instructable

5,173views

5favorites

License:

Bio: Electrical Engineer, control systems, automation, small electronics, home automation, microcontrollers etc.
More by BooRan:Automatic Irrigation SystemStand Alone Science Mission DirectorateDSO Nano V2 Guide
Add instructable to: