Help with comparator

Thread Starter

akb2

Joined May 21, 2017
9
Hello
I'm a new member to this great forums, and I hope I'll find some help to troubleshoot my circuit.
I want to make a light-activated circuit (it is dark-activated actually!), the comparator is connected as follows:
1- The inverting input: connected to a variable resistor to adjust the (criterion) I want to set for darkness.
2- The non-inverting input: connected to an LDR in series with a 10K resistor to detect the level of light.

The trouble is: the output of the comparator is always high, even if I adjust the variable resistor at its extremes (it has to be 12 volts) I measure the voltage at its pin in the comparator to be about 5v only and the voltage at the non-inverting input is higher than it !
I feel that the one input is affected by the other, so what's the problem ? Must I set a fixed reference voltage at the inverting input ? or should I replace the variable resistor ? or other thing should I do ?
comparator from Smart LED.JPG
 

AlbertHall

Joined Jun 4, 2014
12,346
Use a higher value for R1, perhaps 100k.
It would probably be better to supply the inverting input with two fixed, equal value resistors one to each supply rail to fix that input at 6v and make R1 the variable resistor. You will probably need a 220k or bigger pot for this. Many LDRs are very high resitance in the dark. The '741 inputs don't work near the supply rails and the suggested method keeps the working point in the middle of the supply and the '741 will be happy
 

Thread Starter

akb2

Joined May 21, 2017
9
to fix that input at 6v and make R1 the variable resistor
So, I move in the 0-6 V range?
another question, please: can the input of the op-amp be more than its supply (in this circuit, the input is ranging from 0-12v while the supply is 5v) is this suitable ?
 

AlbertHall

Joined Jun 4, 2014
12,346
Thanks for advice.
But excuse me, I didn't understand this point.
The '741 is now a very old design. It will not work if the inputs are within a couple of volts of either either supply rail and indeed the output won't go to very near either rail either. You have to design around these limitations.
 

AlbertHall

Joined Jun 4, 2014
12,346
So, I move in the 0-6 V range?
another question, please: can the input of the op-amp be more than its supply (in this circuit, the input is ranging from 0-12v while the supply is 5v) is this suitable ?
Definitely not. The inputs should never be outside the range of the op-amp supply. Why not supply the op-amp with the 12V?
 

AlbertHall

Joined Jun 4, 2014
12,346
Ok. The '741 output will probably not go low enough to count as a logic '0' anyway. Two possible solutions for that: use a transistor buffer between the '741 and the gate; or use a more modern op-amp or comparator which will take the output to ground and in this case you could use a comparator with open collector output (many do) with the pull-up resistor connected to +5V then the output will match the input of the gate.
 

GopherT

Joined Nov 23, 2012
8,009
The output of the op-amp is one input of the AND gate, so I want its output to be just 5V.
The "high" and "low" output of an old '741 op amp are about 2 volts from the chips supply voltage. Or, if supplying with 5 volts and ground, then the LOW output will be 2volts and high output will be 3 volts. Kind of useless.

A more modern op amp will have an output closer to the chip's power supply.

You may also want to add some hysteresis to the circuit to prevent oscillations close to the transition light intensity.
 

AlbertHall

Joined Jun 4, 2014
12,346
If the output is 3 volts, then it is considered high, isn't it ? (I knew that from this article: https://www.allaboutcircuits.com/textbook/digital/chpt-3/logic-signal-voltage-levels/ )
About connecting the output:
is it like this?
View attachment 127358
Yes, but you will also need a resistor between base and emitter of the transistor, 330Ω would be suitable, to ensure that the transistor turns off when the '741 output is as low as it gets (without that resistor, the transistor will turn on whenever the '741 output is above 0.7V, which is all the time!).
 

crutschow

Joined Mar 14, 2008
34,452
You are going to a lot of effort to use a device (the ancient 741) that was never designed to be used as a 5V comparator.
Can you not use a more appropriate device, such as an LM339/393 comparator?
With that you wouldn't need to add the transistor.
 

Thread Starter

akb2

Joined May 21, 2017
9
You are going to a lot of effort to use a device (the ancient 741) that was never designed to be used as a 5V comparator.
Can you not use a more appropriate device, such as an LM339/393 comparator?
With that you wouldn't need to add the transistor.
In fact, I had a lot of trouble, so I might use LM339 instead.
Thanks
 
Top