TP4056 and disconnecting battery when USB unplugged - Page 1
Forum section: electronics / projects

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 06:07:51 pm
content: My project is powered by either USB or battery. When USB is plugged in, the battery should charge.A 6 way rotary switch functions as an ON/OFF switch (MCU etc) and also a mode switch. It should charge in any position if USB is connected.When USB is disconnected, and rotary switch is in any of the "on" states, system should run on battery.I want to automatically disconnect the battery from the charger (TP4056) when USB is not present, so it doesn't draw from the battery.It also has some safety "features". Over-charge/-discharge and reverse polarity cut-off.Since it's handling several scenarios of disconnecting BAT+ and BAT-, I'm sure it will stumble and mess up in some cases.For example, over-discharge will never work (break battery ground), since this is handled by DW01A, but this is only activated when USB is present.And reverse polarity protection won't work if USB is present (since DW01 connects battery ground anyway).There are probably speciality chips that deals with most of these questions I have in one package, but that not what I want.Can I restructure/combine anything, to make it work?[ Attachment Invalid Or Does Not Exist ]

author: ajb
author_rank: Super Contributor
timestamp: January 02, 2025, 06:22:08 pm
content: Why do you want to disconnect the charging IC? It shouldn't consume any current from the battery when the USB supply isn't present, that would make it pretty bad at its intended purpose!

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 08:40:20 pm
content: Quote from: ajb on January 02, 2025, 06:22:08 pmI have sometimes seen that battery chargers actually drain then battery (very slowly), after the charge cycle ends. If I leave the batteries in my Technoline BC700, it ends at 1.45-1.50V, but if I leave them overnight, they are often down to 1.30-1.35. But if I pull them out, and measure them the next day, they have not dropped.So I figured the charger output has quite high internal resistance.

author: ataradov
author_rank: Super Contributor
timestamp: January 02, 2025, 08:46:27 pm
content: TP4056 is specifically designed to be permanently attached. It won't drain the battery. I have a number of boards with it and they sit for months without being recharged and don't drop in any significant way.

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 08:49:05 pm
content: Quote from: ataradov on January 02, 2025, 08:46:27 pmExcellent.So I run the battery ground through two circuits, like in the updated schematics? First the reverse polarity circuit, then the DW01A...Is it possible to simplify/reduce it?

author: ataradov
author_rank: Super Contributor
timestamp: January 02, 2025, 09:13:46 pm
content: Remove DW01A, it is not going to do anything. It is designed as a last measure protection for battery packs, not for regular use.Why do you need the battery switch? Just power everything always though BAT+. When USB is on, TP4056 will pass though the voltage while charging the battery if needed.

author: ajb
author_rank: Super Contributor
timestamp: January 02, 2025, 09:27:57 pm
content: I'm not sure how you're expecting the whole 'power path' section of the schematic to work, but I don't think it's going to do what you want. Or if it does, there are probably better ways to do it. In particular the 2.5V regulator means that Q5 may or may not turn off depending on battery voltage, and IC2 will always be consuming (some small amount of) current from the battery.As ataradov says, you can just run the device from Bat+ at all times in most cases. The current consumed by your other circuitry will effective be subtracted from the charge current into the battery, so it will charge more slowly if charged while operating. If that's a problem, you can still switch the main circuitry over to be powered directly from USB, but that can be done in more straightforward ways, depending on what exactly you're doing with the selector/power switch. There are dedicated power switch ICs designed for this exact purpose, but it can also be done with a couple of transistors if you want a jelly bean solution.

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 09:47:46 pm
content: Quote from: ajb on January 02, 2025, 09:27:57 pmI've used the power path section in many of my projects, and I didn't experience any trouble before. It passes USB 5V directly through to the 3.3V to power the rest of the system, instead of everything going through the battery. But I'm open to better solutionsI use a 2.5V regulator to have a "fixed" reference for a resistor ladder, to use only one ADC pin for six switch positions. Previously I used BAT+ as the common switch pin, but with high and low battery levels, there was overlaps between ADC values. I could have used the battery voltage as a ADC reference, but a 2.5V regulator is almost "free". Also here I'm open to suggestionsI would prefer a jelly bean solution

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 09:50:11 pm
content: Quote from: ataradov on January 02, 2025, 09:13:46 pmIn so many forums, people advice against running your system directly from battery while charging, as small mA draws will force the charger to continually charge the battery "forever".

author: ataradov
author_rank: Super Contributor
timestamp: January 02, 2025, 09:53:36 pm
content: It will "charge" it. but the charging current will be minuscule. You are really overthinking it, but if your design is plugged in most of the time, then it may be a concern.

author: mtwieg
author_rank: Frequent Contributor
timestamp: January 02, 2025, 09:57:08 pm
content: Quote from: ajb on January 02, 2025, 09:27:57 pmAgreed, this part of the circuit makes no sense...QuoteI've read elsewhere that this is a bad idea with this chip, as it can result in the battery being held at its float voltage indefinitely, degrading the battery in over time.

author: okw
author_rank: Frequent Contributor
timestamp: January 02, 2025, 09:58:35 pm
content: Quote from: ataradov on January 02, 2025, 09:53:36 pmHehe, maybeI just don't want to have accidents damaging batteries which can catch fire. I'll use one 18650 cell.When system is in use, it won't be connected to USB.And if it's charged properly, it should be turned off (position 0).

author: ataradov
author_rank: Super Contributor
timestamp: January 02, 2025, 10:02:15 pm
content: If it will be connected to USB mostly during active charging, then what is the issue with using VBAT directly? You either have charging voltage because you need charging or you don't have it because device is in use. So, most of the time the battery will be charged only when it needs to be charged.

author: kmm
author_rank: Regular Contributor
timestamp: January 02, 2025, 11:27:27 pm
content: Came here to ask a pretty similar question so I'll just tag it on to this thread:Does anyone have a favorite design guide/app note/project that covers the whole power/battery management section of a "low power gadget" class of device that uses one of these cheap jellybean management chips like the TP4056?I'm also interested in what your favorite jellybean power management chips are, I think I discovered the TP4056 via either tearing down some piece or Chinesium myself or watching Big Clive do the same. There's a ton of cool little chips from the Asia market but they're really hard to discover if you don't know Chinese or just happen to come across them.I've done a couple designs based on the 4056 and they work fine but I was never really sure if I was doing the power management section optimally in terms of safety and preserving the battery longevity, the datasheets for these parts are usually pretty light on examples and details. Getting ready to redesign one of my boards and I'd like a known-good power section and some notes to crib from, and possibly explore other options for charge/protection ICs.

author: Peabody
author_rank: Super Contributor
timestamp: January 02, 2025, 11:57:34 pm
content: I think you're absolutely right about having a power path circuit, and what you have in the drawing looks correct. If you don't have that, load current will pass through the charger, and may be greater than the termination current of the TP4056, which is 10% of the full charging current. If that happens, charging will never terminate, and that's not good for the battery.In addition, if load current has to pass through the charger, then when the battery is fully charged, the TP4056 will shut down. Then the battery will be powering the load even though USB is still connected. That will cause the battery to cycle between 4.2V and 4.1V when that's completely unnecessary.The power path circuit allows USB to power the load 100% when it's connected, and independently charge the battery to correct termination if needed. So it's definitely something you want to have.I agree that you shouldn't disconnect the charger or the protection circuit. They will draw at most a couple microamps. Most lithium polymer batteries have a DW01 protection circuit built into the battery. 18650s usually don't, but there are exceptions. I offer as support for my power path views this app note, which calls it "load sharing":http://ww1.microchip.com/downloads/en/AppNotes/01149c.pdfI can't speak to your reverse polarity circuit. This is a tough situation because current flows one way when you're charging the battery, but flows the other way when the battery is powering the load.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 03, 2025, 02:27:16 am
content: Quote from: ataradov on January 02, 2025, 09:53:36 pmI prefer implementing some kind of power path to avoid this situation - usually: if the external power source is connected, power the charger IC with it, and the rest of your device. Use a transistor to disconnect the battery itself from the rest of your power supplies when it's charging (so basically when there is an external supply). Some charging ICs have such a feature embedded. Otherwise, it's just a few additional parts.The downsides of directly powering your circuit from the battery when it's charging are multiple:- It requires designing your circuit so that it works down to the cutoff voltage of the battery. Otherwise, you find yourself in a situation where your device won't be immediately operational when the battery is depleted and your plug in an external power source. It was something not unusual on old devices. VERY annoying.- The charger will current-limit at the charging current (while the battery is charging in the CC phase). It may or may not be satisfactory depending on your device.- One corollary is, as you said, even if the set charging current is enough for your circuit, it may not leave enough for the battery to charge at all, or in any reasonable amount of time.- If you set the charging current much higher than needed for the battery, to accomodate for that, but you can't guarantee that your circuit itself draws a relatively constant current, there may be situations where the battery will be subjected to an excessive charging current. That's pretty awful in terms of design.- It is likely to make the charger IC go berserk at some point after it switches to CV mode and the drawn current doesn't significantly decreases as expected. At best, it will eventually time-out and cut the charge. It may detect is as a fault and if you handle this fault indication, you may indicate to the user that there's a problem with the battery when there isn't.The only cases where it can be acceptable IMO is when your circuit draws negligible current compared to the charging current. But that's not so common in practice.