# Op amp AND logic gate

Discussion in 'General Electronics Chat' started by Synopsis, Oct 29, 2009.

1. ### Synopsis Thread Starter New Member

Oct 20, 2009
3
0
Hi,

Can you make a AND logic gate using two op amps? (I have seen a circuit for an AND gate using one op amp however the main AND function was being performed by the two diodes on the input to the noninverting terminal).

2. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
You can do it with comparators because they are "open collector", and you can do logic by wiring their outputs together and sharing a pull-up. OpAmps have push-pull outputs, so you must use diodes for isolation, either on the inputs or outputs.

Another way. Tie two equal resistors from each logic input to the non-inverting input of a comparator. Feed the inverting input with a reference voltage which is 3/4 of the High Logic Level. The only time the comparator output will be high is if both logic inputs are High. If either is low, the non-inverting input will be at 1/2 Vh.

3. ### Wendy Moderator

Mar 24, 2008
20,772
2,540
Nice one Mike, I knew this, but did make the connection the OP.

I use diodes a lot for one or two gates, more than that I go with a logic family.

4. ### Synopsis Thread Starter New Member

Oct 20, 2009
3
0
Ok, stupid question maybe, but any op amp can be used as a comparator right? like the LM324 which I need to use, can you perhaps elaborate with a circuit diagram please? What I am basically wanting to achieve is to minimize the number of components being used and therefore replacing two transistors (to make a AND gate) and use the one or two op amps I have left on the LM324 package as I am only using two.

5. ### Wendy Moderator

Mar 24, 2008
20,772
2,540
Nope. A comparitor has a digital output, it can be a 1 or a 0. An op amp is a linear device. Under certain circumstances a op amp can be used as a comparitor (it will never be a good one), but a comparitor can never be a op amp with a linear output.

6. ### russ_hensel Distinguished Member

Jan 11, 2009
820
47
You can do it with one op amp. Set up as an adder. Set to high gain ( very high, sor of makes it a comparitor ) Bias to produce 0 output with either no or 1 input positive, and with V+ output for both inputs positive. There are several variations depending on which inputs you use, where you apply the bias, and there is the option of adding a bit of positive feedback. Calculation of values is left as an exercise. Output does not need to be open collector ( and use a rail to rail op amp with a single ended power supply )

7. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
But it requires 4 resistors. A simple AND gate can be made with 2 diodes and a resistor. Cheaper, in terms of component count. The only down side is you get a crappy logic "0" level. With the LM324 and 4 resistors, you get a crappy logic "1" level.

8. ### russ_hensel Distinguished Member

Jan 11, 2009
820
47
Your right it sucks, but I was just trying to answer the question as asked ( but I gues you could do it the other way and just add the op amps to do nothing )

9. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
It's a question of using the right tool for the job.

The LM324 isn't too awful as a low-power single-supply quad opamp goes.
But it really doesn't "cut the mustard" as a logic gate. Unless you like pounding in screws with a hammer.

MAYBE for very low-speed logic, it could be made to work in a very "iffy" way. You'd have better luck finding a '57 Chevy for under a grand.

10. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
If you can use surface mount (probably not), the cheapest component count is probably a Tinylogic NC7SZ08.