LM358 With LED

LM358 With NPN Mosfet


enter image description here

enter image description here

enter image description here

The circuit above is a constant current load based on an LM358 comparator.

It is very useful to measure the capacity of lithium-ion batteries.

The original circuit I found online had a 5V supply but that didn't work for me so I replaced it with 9V and everything looks good.

The LM358 is a dual comparator, only one is used in the circuit. The one on the left.

How can I use the other empty non-used comparator to cut off the entire circuit when the voltage of the lithium battery reach desired voltage - let's say 2.5V or 3V?

It's easy to connect an LED to the non-used comparator as an indicator, but connecting a MOSFET is really hard because of something called "hysteresis."

The moment you cutoff the load on a battery the voltage starts to climb up again, and the comparator will reconnect the load again and this process will be on and off rapidly.

The solution of hysteresis is simple by adding a fly-back resistor like R3 on my 2nd image.

Calculating its value is beyond my ability.

Is there any simple way to cutoff the circuit at a certain voltage eg:2.5V-3V with or without the non-used comparator?

Is there any smart other way you can thing off to turn off the entire circuit when the lithium battery is 2.5-3V?

Update> Image #4:

  • Removed R3 from Image #3
  • GND connection to the bottom of R1.
  • I removed Q2 in Image #3 (IRFZ46n) because why wasting such a powerful MOSFET for a small job. I think I can replace it with any NPN transistor. I have a lot of NPN transistors laying around: 13003-D882-8050-9014. Please help pick the right one with a prober resistor.
  • I added a Buzzer (PZ1) the same you can find in PC case.
  • Added Q2. An NPN transistor to give the proper V/A for the Buzzer, but I'm unable to calculate Neither R1 nor R2.

Update> Image #5: I've updated the circuit as suggested.

  • Q2 and Q3 are set to be S8050 NPN transistor:

The type of transistor is NPN (BJT)... Collector Current Max (IC) is 700mA/0.7A... Voltage from collector to the emitter (VCE) max is 20V... Voltage from collector to base (VCB) Max is 30V

  • Add SW1 and SW2 (only one well be used) in NC condition to break the circuit.
  • Add D1 LED with 1K resistor as indicator.
  • I still can't figure out the values of R1 and R2. A 1K value were set randomly.

The white circuit is taken from YT video here:


  • \$\begingroup\$ The LM358 in your schematic is labeled as "#1 Comparator", but the LM358 is an op-amp, not a comparator. What model are you actually using? \$\endgroup\$
    – marcelm
    Jan 22, 2022 at 19:10
  • \$\begingroup\$ Image #4 has a problem. See my answer update. \$\endgroup\$
    – AnalogKid
    Jan 23, 2022 at 14:26

2 Answers 2


You can do something like this. R1 and R2 and D1 set the hysteresis so it will switch at exactly (very close to) 2.5V going down and about 5.2V going up. Since 5.2V is above the normal voltage of the battery, a N.C. switch is included to reset the latch. If you don't have a N.C. switch you can connect a N.O. switch from the junction of D1 and R2 to +9V instead.


simulate this circuit – Schematic created using CircuitLab

Rather than shorting out the 9V supply with a MOSFET as your schematic suggests, a better possibility may be to switch the pot voltage going into the constant-current sink using a CD4053. Connect one analog input to the pot, the other to ground, analog switch output to the op-amp input, and control the switch with OA2 output.

enter image description here


To be clear, the battery voltage is decreasing, and when it drops below a trip point you want the discharge action to end. The battery voltage will then recover a bit, but the discharger is to stay off until reset. Yes / No ?

If yes, then in image 2:

  1. Delete R3.

  2. Swap the inverting and non-inverting inputs to the 2nd opamp.

  3. Connect the Q2 drain to the VR1 wiper.

When the battery voltage drops below the trip point, the #2 output will go high, turning on the FET, and effectively "shorting out" the input to #1. With the #1 input very near to GND, it will work to produce 0 V across R2, which equates to zero battery current.

To reset the circuit break the connection between Q2 and VR1. This can be done with a NC (Normally Closed) SPST switch, or the NC contacts of a SPDT switch.

Also, you can delete/bypass R1.

Update for Image #4:

You have added things between the Q3 emitter and GND, so that transistor now is not pulling the VR1 wiper to GND, it is pulling to a voltage above GND, through R1, Q2, and PC1. This will not reduce the battery current.

To fix this, separate the beeper current from the VR1 wiper current:

  1. Disconnect R2 from the Q3 emitter, and reconnect the Q3 emitter to GND.

  2. Connect R1 directly to the IC1a output (along with R1). The opamp will have no problem driving both transistor bases in parallel because they have individual base current limiting resistors.

  3. Connect PZ1 between the Q2 collector and Vcc.

  4. Connect the Q2 emitter to GND.

  • \$\begingroup\$ Do you mean like Image #3? \$\endgroup\$
    – Alaaj99
    Jan 22, 2022 at 20:39
  • \$\begingroup\$ That's the idea. Also, all three images are missing a GND connection to the bottom of R1 (the battery -). \$\endgroup\$
    – AnalogKid
    Jan 22, 2022 at 22:00
  • \$\begingroup\$ Your ideas is very simple and clever. Thank you very much for your help so far. I've added an Image (#4) with few updates as you suggested. There are some finale things I hope you can help me with. I added them as an answer. \$\endgroup\$
    – Alaaj99
    Jan 23, 2022 at 13:23
  • \$\begingroup\$ Updated the circuit as you suggested Image #5. I think it should now work properly. Thank you again very much for you effort and time. Any notes? or mistakes? \$\endgroup\$
    – Alaaj99
    Jan 23, 2022 at 19:45
  • \$\begingroup\$ I just noticed that we're not quite there yet. U1a latches off U1b, but it does not latch off itself. When the battery is unloaded, its voltage can rise above the trip point (2.5 V) again, re-enabling the entire circuit. oops. To fix this requires a positive feedback path from the U1a output (or the Q2 collector) to its own non-inverting input. Maybe one diode and one resistor. Hmmm ... More later. \$\endgroup\$
    – AnalogKid
    Jan 23, 2022 at 20:21

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.