But the basic idea is that without such a circuit the charger is providing power to both the load and the battery, and may not be able to detect that the battery has been fully charged, and fire may result. The load sharing circuit lets USB power both functions independently so charging may continue to proper termination even though the load is still drawing current.
According to the datasheet, MCP73871 has a different "Y" topology: IN+VPCC, OUT, VBAT. I thought this would eliminate that problem? Then again, that appnote does explicitly name MCP73871, but uses a different circuit to MCP73871 datasheet.
There are four situations I wanted the circuit to handle:
- Powering via USB without a battery present at all
- Powering via USB with a fully-charged battery present
- Powering via USB and charging the battery at the same time
- Running on battery power
In the first two cases, VBAT is completely disconnected. In the third case, the current to the battery is monitored, as is battery voltage and the thermistor.
In the fourth case, the battery voltage is monitored for undervoltage lockout. I am pretty sure I could do this with lots of jellybean parts; the voltage references (precise 4.2V for the maximum and something slightly above 3.0V for the undervoltage lockout) would be the hard part.
Is there really no single-chip solution for this?
It really looks like I'm better off with just two parallel inputs (separated from each other, so one does not power the other, only the circuit), so that users can plug in another power pack when the other is going out, and charge using a proper charger out-of-circuit. That's not optimal, but if there really is no single-chip solutions, that works better for me than trying to work out the weirdnesses of charge controllers.
Your decision to use a switching regulator may not be the most efficient if the load current is small.
I am targeting 100mA to 600mA practical load range, with 800mA-1000mA peak or hard limit. A microcontroller with a display, basically. At this current range, the design report from TI Webench claims 90%-94% efficiency depending on the voltage.
I also want it to be able to be powered from USB directly. In that case, the power loss isn't a problem, but turning it to heat in the LDO is. A typical wall wart provides about 5.2V, so at 500mA the LDO is dropping almost two volts, becoming an one-watt heater. In a small, especially small plastic enclosure, that starts pushing things. The microcontrollers I use typically only consume 20mA-100mA (so third of a watt or so), and most of the rest is a display module -- but those display modules have the surface area to convect and radiate the heat away. The LDO, not so easy.
I do need to raise the question of your Q1 and Q2 mosfets. The only purpose I can see that they provide is reverse polarity protection. But that's not really a risk with microUSB, and certianly not coming out of the regulator. So I don't think you need them.
Q1 is there only if pads instead of an USB connector are used for powering. In particular, it is often easier/better for these hobby projects to cannibalize an USB cable, and solder the wires directly (although I tend to do that only when the device is tethered).
Q2 is there to protect this circuit from being backfed by whatever it is supposed to power.
Your points and criticisms are well appreciated, Peabody. I wonder if I am better off with a dual 5V USB power interface without charging circuitry, or if I should try to design a "triangle" circuit to do this properly:
Essentially, whenever there is 4.5V or higher potential at USB input, LiPo is disconnected from the load. LiPo is also disconnected from the load if the voltage across it drops below 3.3V. So these would basically be two MOSFETs there. The LiPo is either disconnected (from load, and no USB present), connected to the charger only, or connected to the load only.
If connected to the load, LiPo uses a LDO to 3.3V (okay to drop to 3V at the low end). When USB is connected, the LiPo is only connected to USB via a charger, and USB provides the power to the load via a buck converter. (Any buck regulator with better than 66% efficiency will generate less heat than a linear regulator, as the input is 5V and output 3.3V nominal here. Something around 90% efficiency at 100-500mA, with peak current capability around 800-1000mA, would be optimal. It's somewhat more about generating minimal waste heat -- so that this can be used in small plastic enclosures --, than about being as efficient as possible.)
To me, this seems a fairly straightforward problem, and one that would be very common with USB-powered gadgets.