I'm trying to detect if the battery in this circuit is charging or not by comparing the voltages across the diode. The battery is not charging if it's at a voltage higher than the charging input. For example when the battery is at 10V and the charger is at 9V, the battery is not charging. The battery is charging when the current is flowing across the diode and produces a voltage drop. To detect if a battery is charging, the battery voltage must be less than or equal to the charging input.

enter image description here

I've come up with this naive circuit that powers a comparator with the battery voltage since it's typically higher than the charger's. The inverting input comes from the battery, and the non-inverting input comes from the charger. When the battery is lower than the charger, the circuit properly turns on the output in simulation. From my research and experimentation (with an LM339N), it appears that real comparators need a power voltage higher than the two inputs to properly compare them.

enter image description here

I don't want to add a voltage booster to my circuit, and I don't want to use two ADCs

Is there a chip or circuit that can determine if the diode in my charging circuit is forward biased?

  • 1
    \$\begingroup\$ Look for the term "rail-to-rail". \$\endgroup\$ – Oldfart Jul 14 at 19:03
  • 2
    \$\begingroup\$ @benjinne what you are describing is FUNDAMENTALLY UNSAFE AND UNWORKABLE - YOU MUST CEASE USING IT AT ONCE. Lithium battery chargers need a direct connection to monitor the voltage of the actual cell and adjust the charge appropriately, they cannot work with a diode in the way. You should use a distinct charger for each pack. \$\endgroup\$ – Chris Stratton Jul 14 at 19:51
  • 1
    \$\begingroup\$ No, what you are not understanding is that your design is not an acceptable way to charge lithium batteries, especially multi-cell packs. \$\endgroup\$ – Chris Stratton Jul 14 at 20:07
  • 1
    \$\begingroup\$ @Benjinne Unless you both understand LiIon far better than appears to be the case (possible but unlikely) and have some practical experience therewith it is very very very strongly recommended that you take note of advice offered by people here. || If Icc was at Imax allowed you would not need to increase it - just add another bank when the currently charging one reached cuttoff. || Adding a bank reduces V_Icc to Vbat + Vdiode. Voltage rises to Vmax. When Vmax is reached add another bank. \$\endgroup\$ – Russell McMahon Jul 14 at 20:12
  • 1
    \$\begingroup\$ @ChrisStratton is right, your scheme sounds incredibly dangerous. Just don't do it. \$\endgroup\$ – Elliot Alderson Jul 14 at 20:41

If you power the comparator from the 3S battery and divide the two voltages to be compared with a resistive divider of say 2:1 ratio it will do what you want.
Note that the LM339 has an open collector output and the output must be "pulled up to operate correctly.


As Chris says, you need to charge Lithium Ion batteries "correctly" or you will destroy them.
Vmax is usually 4.2V/cell BUT you must not leave this voltage connected once charged or they will be damaged or destroyed "quite rapidly".
In your case, with a 3S pack if the cells are balanced then applying 12V or less to the 3S pack will not overcharge them.

The diode will drop about 0.6V if silicon and about 0.3V if Schottky when charging but may drop close to zero voltas as the current tails off at the end of charging.
As long as battery voltage never exceeds 12V AND the cells are balanced a Vmax of about 12V is "safe".

Charging from 9V will only charge batteries that are almost fully flat, and then only by a small amount.
Use of a purpose designed LiIon charger circuit is very very very very strongly recommended.


Your idea is good, but it won't work with a diode. Lipo batteries have specific charging requirements that are critical for safety, and the charger won't work properly if it doesn't see the expected battery voltage. A diode will add at least 0.3V to the battery voltage when charging, which will prevent the the battery from getting a full charge. Also the charger will not see any voltage coming from the battery when not charging, so it may think the battery is disconnected or dead and not even start charging it.

You need to monitor the charging current without significantly affecting the voltage. This can be done with a very low value resistor, and an op amp or comparator to detect the small voltage across it. The only problem is the op amp must have low drift and offset to reliably detect the small voltage.

Some op amps are able to work at input voltages up to and slightly above the positive supply rail. Then you can use a circuit like this:-


simulate this circuit – Schematic created using CircuitLab

Most Lipo chargers stop charging when charge current drops to ~10% of the programmed value. For a 1A charge rate this would be 100mA, which would drop 10mV across a 0.1Ω resistor. At normal charge current the voltage drop across the sense resistor is 100mV, which should be low enough to not significantly affect charger operation.

The TL082 is a JFET input op amp which accepts voltages up to and slightly above the positive supply rail. It has a maximum offset voltage of +-20mV, so R5 (in conjunction with R4) pulls the sense voltage down by ~27mV to ensure that the non-inverting input has a lower voltage than the inverting input when not charging. R2 adjusts the reference voltage (relative to battery positive) on the inverting input to set the turn-on point. R4 and C1 filter out high frequency noise that may be present if the charger uses switch-mode voltage regulation.

  • \$\begingroup\$ To expound on the problem created by the in-line diode idea, if the charger even recognizes the battery pack at all, the balancing portion of the charger will want to discharge the top cell with respect to the lower two cells. If it manages to accomplish this with a diode there, the upper cell will be overdischarged next time you use the pack and your pack will be destroyed... or on fire. \$\endgroup\$ – Kent Altobelli Jul 14 at 22:02
  • \$\begingroup\$ Yes, if a balancing charger is used this could be yet another hazard, depending on how it balances the cells. If the battery has separate connections for charging and balancing it should be OK, since the balancer is monitoring cell voltages after the sense diode/resistor. Some chargers also stop charging while measuring cell voltages, to eliminate errors due to resistance in the charging path (this technique would cause the charge LED to go out periodically). \$\endgroup\$ – Bruce Abbott Jul 14 at 22:15
  • \$\begingroup\$ If it were just about monitoring a proper charger properly connected to a single pack as designed, yes a shunt (easier upstream of the charger itself) would work (I'll sometimes even plug phone chargers in through a simple consumer AC wattmeter that goes on the mains outlet and has a plug for a load - you can readily tell fast from slow from no charging). But that's not what the question is really about - the whole detection is part of a dangerously ill-advised scheme to make an ill-conceived charger adjust to the overall number & state of connected packs, rather than each having a charger IC. \$\endgroup\$ – Chris Stratton Jul 14 at 22:37
  • \$\begingroup\$ "But that's not what the question is really about..." - there is no hint of this in the question, so my answer stands. \$\endgroup\$ – Bruce Abbott Jul 15 at 0:22
  • \$\begingroup\$ On the contrary, it isn't just a hint, the asker's comments are quite explicit - to quote: "Then, by determining when a new battery starts charging, the charging circuit can increase its constant current rate." - which is an utterly broken idea. \$\endgroup\$ – Chris Stratton Jul 15 at 2:47

Since a non-intrusive solution hasn't been proposed yet, I'll recommend one. Basically: don't build a charger from scratch unless you actually know what you're doing and understand how lithium cells/packs are charged, balanced and protected like they are in commercial products

As far as intrusive solutions go, adding a diode is probably the worst possible idea since it greatly changes the circuit behavior and has a voltage drop that may change with current. Using the smallest shunt resistor you can possibly stand to measure current seems like the preferable option but still intrusive and will slightly affect the voltage measurement your charger depends upon to not blow up your batteries.

For a non-intrusive solution, I'm going to recommend a hall effect sensor clamped directly onto to the high or low side wire between the battery pack and the charger. If you use a gapped toroid, or the cheaper looking alternative in Figure 6C of this Allegro MicroSystems article from 1998, you could probably get a good enough reading to determine if the battery is charging.

Allegro MicroSystem Current Sensor

But why build your own that could potentially light your house on fire when you could just get several charging ICs like this?

  • \$\begingroup\$ The problem is that the charger itself is an ill-advised custom disaster; the whole reason they want to detect what is happening with a particular pack is to adjust the overall charge in a dangerously ill-advised way based on that knowledge. \$\endgroup\$ – Chris Stratton Jul 14 at 22:35
  • \$\begingroup\$ Ah I see his intended application in the comments now. To be fair though, as long as OPs custom charger limits the overall current to what the least capable battery can handle and carefully monitors the voltage to never exceed the max voltage for the battery chemistry (assuming properly balanced), it would be no different than cheap commercial chargers. From a usage perspective, it would be annoying to use because lowest battery will be charged first, First In Last Out, and all batteries would have to share that small amount of charge current. \$\endgroup\$ – Kent Altobelli Jul 15 at 0:04
  • \$\begingroup\$ "as long as OPs custom charger limits the overall current to what the least capable battery can handle" is not something that can be determined from the proposed single connection to each series string. Nor will the charge termination condition be correct. \$\endgroup\$ – Chris Stratton Jul 15 at 0:19
  • \$\begingroup\$ When OP says "The circuit has a custom charger" that makes me think OP is building a charger from scratch and understands the impact of his/her actions. If the positive terminal from the single charger has a current sensor, that could be used to limit the total current to what the weakest battery can take. Then if it's split to multiple batteries downstream of that, there's no way a battery could be harmed as long as charging is terminated properly, in this case OP should shoot for 4.1V per cell to give room for error, so (4.1V * #cells) + diode_drop termination voltage would be wise. \$\endgroup\$ – Kent Altobelli Jul 15 at 0:48
  • \$\begingroup\$ Yes, they are building a custom charger. No, they don't know what they are doing. Acceptable current depends on individual cell voltage, they have no ability to measure that. \$\endgroup\$ – Chris Stratton Jul 15 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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