I'm working on an automatic battery charging source switching between solar power and a 24Vdc wall adapter.I'm using a LM741 as voltage comparator and a relay for power switching. Basically, if solar power is not available or solar voltage is below a threshold value then battery charging source should be automatically switched to the DC wall adapter supply. So, for detecting solar voltage threshold, I'm using a LM741 as voltage comparator.

I'm facing issues with the LM741.

Whenever solar power is available whether it is as low as 3.1V or as high as 12V, the relay remains switched to solar power source.

To set the threshold value I'm using a 10K potentiometer.

The relay switches to the DC wall adapter when solar voltage goes below 3.0V.

I have tried changing the potentiometer position, but at every position the threshold value remains 3.0V, and the relay switches back to solar power when the solar voltage gets above 7.7V. I have tried changing the potentiometer position, but at every position this value remains 7.7V.

I have attached my schematic diagram. Can someone please tell me why I'm not able to change the threshold voltage using the potentiometer?

enter image description here

  • 1
    \$\begingroup\$ The - input of your 741 is grounded while you're not using a negative supply rail. The 741 doesn't like this and will not work. The 741 has more issues see: electronics.stackexchange.com/questions/304521/… so also use a "better" opamp instead of the 741. \$\endgroup\$ Commented May 27, 2019 at 8:21
  • \$\begingroup\$ What is the purpose of R1? it is parallel to your pot so it lowers the effect of your pot. Also you defined the threshold at positive terminal of opamp so you should apply your solar power to negative terminal to operate as comparator but you applied GND to the negative terminal. Can you explain the reasons for them ? It looks like you have hysterisis between 7 and 3V, you can look for hysterisis design for opamps and i suggest you to apply proper supply voltage(>5) to your opamp, not 3V \$\endgroup\$
    – CanSevgi
    Commented May 27, 2019 at 8:52
  • \$\begingroup\$ 1) Use a dedicated comparator chip instead of using a common op-amp. 741 input voltage range is limited and so on as Bimpelrekkie mentioned. You can use LM339 or better. 2) You don't have stable reference voltage using potentiometer since you're saying that SOLAR_P voltage is dynamic (3.1V - 12V). 3) Why did you ground the negative input? R1 will be wasting power and useless. 4) What is the purpose of R1 in the first place? \$\endgroup\$
    – Unknown123
    Commented May 27, 2019 at 9:56
  • \$\begingroup\$ @user287001 and also connected to ground? \$\endgroup\$
    – CanSevgi
    Commented May 27, 2019 at 11:01
  • \$\begingroup\$ +1 for the well-asked question \$\endgroup\$ Commented May 27, 2019 at 13:53

2 Answers 2


I'm afraid you've set yourself up for a Learning Experience. I'm not trying to be disagreeable, but you've done pretty much everything wrong you could.

1) 741s are only specified down to about +/- 5 volts. Trying to use one at 3 volts single-ended is never going to end well.

2) 741s have limited input common-mode range, typically within about 2-3 volts below V+ and above V-. That is, you cannot tie an input to the V- pin and expect the chip to work. Maybe it will, and maybe it won't, but if it doesn't you have nobody to blame but yourself.

3) 741s have limited output swing, typically within about 2-3 volts below V+ and 2-3 volts above V-. So, if the output works at all in your circuit, you'd expect several volts on the output regardless of the inputs. This, in fact, seems to be what's happening - your relay is always on. However, it would not be at all surprising if some 741s operating in this circuit would always have a zero output - and there is no way to tell in advance.

So, the short version is that 741s are intended to be used with both + and - power lines in the range of 5 to 15 volts, centered on ground. Input signals should be within the range of 2-3 volts less than the power supplies, and also centered on ground. You should not expect output voltages outside the allowed input range, and maybe even less if you're trying to provide a lot of current.

It's perfectly possible to use a 741 in single-supply operation, but it takes more knowledge than you have right now, so don't try it until you get more experience.

For your circuit, you should get a real comparator which is specified for 3 to 12 volts power supply voltage.

Finally, even if you do get a proper IC, your circuit will ALWAYS behave as it does now. Since pin 2 is tied to ground, pin 3 will ALWAYS be greater than pin 2, and the relay will always be activated.

With a 10k base resistor to T2, you will not be guaranteed enough output current to turn on the relay. Using a 12-volt relay at 3 volts should never work at all. That fact that it seems to do so says that something very wrong is going on in your circuit.

As has been mentioned, you also need to add hysteresis. As it stands, even if everything works (and you've changed the pin 2 issue), the circuit will chatter uncontrollably when the solar voltage is near the trip point. When the voltage gets high enough the relay will activate and the solar cell will try to supply current to the charger. The combination of relay current and charger current will load the solar voltage, which will drop. The comparator will detect the low voltage, turn off the relay, so the voltage will rise, and the whole cycle will repeat.

  • \$\begingroup\$ I will consider your suggestions!! How can I add hysteresis? \$\endgroup\$ Commented May 31, 2019 at 11:00
  • \$\begingroup\$ In this case, a high-value (100k to 1M) resistor between pins 6 and 3. Also called "positive feedback". Do some research. Also, if you have not done so already, you desperately need to spend 20 bucks and get a cheap DMM. Without one you have no hope of figuring out what's going on in your circuit. \$\endgroup\$ Commented May 31, 2019 at 18:20

You should have a zener diode about 2 volts in the place of the wire between pin 2 and GND to have any sensing. Still the circuit would be bad, because

1) nobody quarantees that 741 works properly at 3V. You should use a proper comparator which is designed for single supply operation, can sense near GND (741 cannot in single supply applications) and works at 3V.

2) you need hysteresis to prevent fast ON-OFF oscillation near the treshold due noise and other slight variations

3) there should be a big capacitor between the supply voltage pins of the comparator to prevent oscillations caused by supply voltage wire resistance and inductance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.