I have a simple comparator circuit I was planning to use for a 2-cell Li battery. I'd like to cut the voltage off at around 2·2.8 V = 5.6 V.

To accomplish this I have the circuit below, but just a little bit of noise in the battery voltage and it will cause my comparator (which drives a P-MOSFET) to oscillate between high and low output.

So I'd like to add some hysteresis. I found a good article about this. During good battery voltages I want the output of the comparator to be GND. I believe I have the correct configuration for this.

I would like to add approximately 0.5 V of hysteresis such that once I transition into bad battery voltage at 5.6 V I need to make it to 6.1 V again before I can close the load circuit again.

For hysteresis calculations I will assume the Voh (output high) is 7.4 V and Vol is 0 V. But I need to select a value for either R1 to solve for R2 or vice versa. How can I go about selecting a resistor value?


Datasheets: TLV3401IDR



3 Answers 3


1º point: Looking at the Analog Devices post I think that the circuit that works for you is not the one in figure 3 but the one in figure 5 the single supply inverting hysteresis understanding that you want to power the comparator only with the battery.

2º point: I find the math functions of the AD post complicated, but in this Texas Instrument file they present the functions in a simpler way for that circuit in section 2.1 (page 7) and I ended up with this circuit, the only thing I change is the reference voltage from 2.5 to 3.3V and the circuit use E12 standard resistors values.

Vl = 5.6V / 2 = 2,8V ||| Vh = 6.1V / 2 = 3.05 ||| Vref = 3.3V

enter image description here

*The resistor values of 1.12M are not stadard, I take 1,2M from E12 standard series values.


simulate this circuit – Schematic created using CircuitLab

The behavior of the circuit should be similar to this: enter image description here

  • 1
    \$\begingroup\$ This is excellent. But there are two sources of confusion to me. The first is, does it matter that the pull-up resistor was not taken into account for the output? The second is what is the purpose of R4? Is it to drop the 3.3V reference slightly with a voltage divider to achieve standard resistor values? I believe you were correct that fig5 (second image) of AD source is a better fit for my application. \$\endgroup\$
    – Feynman137
    Sep 23, 2022 at 14:32
  • \$\begingroup\$ The R4 is not part of a voltage divider, is part of the hysteresis op amp topology. For the pull up resistor, in the article on AD, in the 2nd paragraph, it says that this resistor is a good way to add flexibility to the circuit, for example you can put a low resistor to increase the current throw a mosfet gate to increase the frequency of switching, in this case I presume high frequency isn't necessary, I probably put a standard mosfet resistor connecting the gate and source of 1k. \$\endgroup\$ Sep 23, 2022 at 16:55

Note that the total voltage of a multi-cell battery is not a reliable indicator of the remaining charge. At 7V you could have both cells charged to 3.5V (meaning you still have some charge left), or you can have one cell at 4V and another one at 3V (meaning you have very little charge left). The only way to reliably monitor the battery is to measure each cell individually. This complexity is one of the reasons why many devices use single-cell batteries, while they could benefit from a 2S battery offering a higher voltage.

Discharging a Li-ion cell to 2.8V is not a good idea anyway: if memory serves, there's only about 5% of charge remaining once the cell goes below 3V, and the risk to permanently damage the cell becomes significant. A 2S battery discharged to 5.6V will likely never recharge to full capacity again, because the weaker one of the two cells will be at 2.5V or less at that point. It may even blow up when you try to charge it.

  • \$\begingroup\$ I think the point regarding excessive discharge is valid maybe I will consider a higher voltage like 3V per cell. I have a balanced charger so I don't think the blowing up is an issue along with overcharge protection. Is it really a practical concern that the batteries will drain unevenly? \$\endgroup\$
    – Feynman137
    Sep 23, 2022 at 15:59
  • \$\begingroup\$ @Feynman137 Yes, if you have one cell with a 20% higher capacity, the balancing charger will correctly charge both cells to 4.2V. However, during discharge the weaker cell will be near 0% charge at 2.3V while the second cell will still have 20% left, with about 3.3V across it. If you get matched cells (with capacity within 5%) it will not be a problem, but it will become one as the cells age. \$\endgroup\$ Sep 23, 2022 at 16:07
  • 4
    \$\begingroup\$ I have tested a whole bunch of failed laptop batteries, and it's always the same outcome with cheap batteries: one cell below 2V, the other two charged to 4V or so. The whole battery delivers some voltage (and the laptop displays around 50% charge), but it drops radically once any current is drawn from it, resulting in the laptop switching off the moment you disconnect the charger. \$\endgroup\$ Sep 23, 2022 at 16:10
  • 1
    \$\begingroup\$ I see I will consider having one of these circuits per cell then. \$\endgroup\$
    – Feynman137
    Sep 23, 2022 at 16:33
  • \$\begingroup\$ @Feynman137 Note that those cheap laptop batteries are not "design failures", they are build in a way which helps to reduce the complexity (and price) at the expense of failing earlier. I make flying drones for a hobby, and I try to make everything as simple as possible to reduce weight. I only monitor a total battery voltage in my drones, however, I set the low threshold to about 3.5V/cell (about 30% of charge left). Even if I have poorly balanced cells (e.g. one at 20% and one at 40% when the threshold is reached), I still have at least 20% of charge left for a safe landing. \$\endgroup\$ Sep 24, 2022 at 9:34

Assume your reference output is 2.5 V. If the output of the comparator is 7.4 V, then there is a voltage drop across R1 and R2 of 4.9 V. This voltage drives a current. You will need to decide how much current you can tolerate, as it will drain the battery.

If we assume 100 uA static current draw through R1 and R2 (still less than what the reference itself consumes), we see that R1 + R2 > 40 kΩ.

Same thoughts apply while the comparator output is low. Also consider the R118 and R119 divider's power consumption.

In general you'd also want to verify that the current sunk at the comparator's non-inverting input pin is insignifcant compared to this. Here it is ~pA, so not relevant.

Don't make the resistors too large either. Otherwise you'll face issues with parasitic capcaitances 'shorting' the resistors at frequencies you care about. Here, speed is not a concern, AFAICT. I'd choose R1 and R2 to be ~100 kΩ.


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.