# Switch between battery and USB power

Following on an earlier question I am looking for a circuit where it powers from USB when it is available and uses the battery when USB is not plugged in.

I want voltage drop to be minimal, zero if possible. So using oring diodes is not possible. The mosfet power oring ICs mentioned in the answer are extremely expensive (4\$ for 1K) although they have low voltage drop.

I am looking for a discrete solution where I can build with simple switches or even a cheap LDO. I didn't try to build it but I thought I could use the existence of the Vbus to do a simple switch to control LDO's one from VBus, the other from VBat.

UPDATE

• Ideally zero drop is wanted however up to 100mV can be tolerated.

• My system has 4 AA batteries, so there could be cases where the battery voltage is larger than 5V, that is why I focus on the existence of VBus. The small drop comes from the Operation voltage of one of the ICs, it needs to be 3.5V (min) and the larger voltage drop eats into the battery life. (i.e. 4 battery, 0.9 each, 3.6V, 100mV drop, I can squeeze the batteries). If there is a 0.7V drop, I can not use the full battery power. (I have to shut down the system at some point of time to ensure proper operation but batteries has still a lot of juice left)

• eg if Vout is 4.5V - 5V and battery is 4 x AA Alklaine then Battery need a regulator while above 5V and works down to 4.5V + any LDO drop. When Battery ~= 5V when USb is present a simple comparison does not all USB to take over as VUSB < Vbattery.ie system MAY be complex to define. Answer can be simple to implement but not trivial in concept. Commented Oct 31, 2011 at 4:40
• The requirement is easy to meet if you know what it is. ie the question is good but not complete. You say you cannot tolerate a Schottly drop but then talk about LDO's, implying at least some drop. What is the (1) required and (2) (tolerable) output voltage to system eg 5V, 4-5V, 3.3V, 3.3-6V. | What battery is used. Chemistry. number of cells? Will Vbattery be below VUSB when USB is live? Is the battery rechargeable? May or should the USB recharge the battery? Must changeover be continuous or may system "glitch on changeover"? | All those questions affect selecting the best solution. Commented Oct 31, 2011 at 4:43
• @RussellMcMahon you may be looking at this the wrong way. My thinking is, if USB present, cut down the battery LDO and feed USB. We can see if USB present via VBus, no voltage comparison needed. Simple on/off. However I am not good enough to draw that circuit, hence the question Commented Oct 31, 2011 at 5:24
• You MAY be right. I MAY be looking at it the wrong way. But, am I? If you don't know and if you can answer my questions then why no do so. eg What if someone uses a USB supply that has power on the +/- power rails and nothing else (which can happen, regardless of specifications). If you don't care if your device fails when this happens then no problem. If you want it to work as well as possible then knowing as much as possible helps. Commented Oct 31, 2011 at 7:38
• I looked again at my questions. Starting at "What is the (1) ..." to " ... changeover" still seem relevant and I'd have thought you could answer out of your head. Your answers may be "don't know" or "don't care" but if you want your need met then we need to know what it is. I can provide a circuit that will do almost anything - as long as I know the specs of "almost anything". Commented Oct 31, 2011 at 7:39

## 2 Answers

A circuit that will do what is wanted, or as much as what is wanted as has been revealed, is shown below.

This circuit is much simpler than it sounded like it was going to need to be, due to the revelation that the USB power feed could easily accomodate a Schottky "blocking dioe" and still meet the Vout requirement. If this diode had had too high a voltage drop to be acceptable then a circuit withtime delays and current flow direction detection would hav ebeen needed. It can be surprising how much difference a little more information can make to the solution of a problem.

Battery feed at top. USB power feed at bottom.
USB power is fed to load via Schottky diode D1. Power may be fed via Ja and the LDO regulator or via JB as desired.

If feed via JB is used the LDO must survive with external voltage on its output when it has no input. If necessary (depends on LDO) adding another Schottky diode across Ja "pointing upwards" would apply the same voltage across either side of the LDO and minimise quiescent current (in most cases) when USB power is in use.If absolutely necessary another FET could be used to block USB feed from LDO but should not be needed. LDO could be put above Q3 BUT then battery supplies LDO quiescent current at all times = poor.

When USB voltage is absent Q3 = P Channel MOSFET is turned on by R4, feeding battery voltage to LDO and thence to Vout.

When USB voltage is present Q1 is trurned on by R2/R3 and this turns on Q2 (usually held off by R1) which clamps Q3 gate high turning it off, thus disabling battery feed. USB power feeds via D1 either via Ja and LDo or Jb as above.

Battery current when USB connected:

Changed R1, R4, R5 to nominal 1 megohm each to reduce battery load when USB in use. A small MOSFET for Q2 and/or some more thinking will reduce required standby current.

USB on, Q1 on, About 5 uA via R5 to turn Q2 on. About 5 uA via R4 to turn Q3 off. R4 can probably be 10M if slow response OK. ( At R4 = 10 megohm if gate capcitance on Q3 is say 10 nF then time constant for turn on = RC = 1E7 x 10E-9 =~ 0.1 second. Depending on =FET gate threshold it MAY take a few 10ths of a secind for battery to turn on when USB is unplugged. This could dropout powered cct unless a large enough output cap was provided. At R4 = 1m the time constant is about 10 milliseconds and a "usual" sort of cap on output rail would suffice.

Can be "tuned". Q1 on removes voltage from R1. 10 uA quiescent when USB is on =~ 90 mAh/year. This is about 3% of battery pack capacity. Small but annoying.

Q1, Q2 = almost any jellybean bipolar. Q3 = P Channel MOSFET. Vthreshold << Vbattery. D1 = Schottky eg 1N5817. LDO to suit.

Roll your own LDO with MOSFET and eg TLV431 can have about 100 uA quiescent when running and essentially zero dropout voltage. Can be much lower with lower Iq ref diode.

BUT

When you can get eg Microchip's VERY nice TC2104 LDO for under 50 cents in 1's, making your own makes less sense.
ASdded Oct-2001: The TC2104 seems to have vanished. The LM293x series is widely avail;able - see eg Digikeys listings here

Or, here are LDOs with 0.1V or less dropout voltage - Digikey listings quantity 1.

Added 9/2015 Kar asked

... why are the BJTs needed?
Why not just have a MOSFET and a diode, and that's it?

@Kar Good question.
The MOSFET solution is a good one but it is slightly more design-demanding than may be apparent, whereas the bipolar solution uses a few more components but is easier to ensure operation ioj all conditions.

Tpo use the MOSFET as shown the FET's Vgsth must be chosen to suit.
Battery max voltage (assuming his AA cells are Alkaline) is 1.65V (new cells) x 4 = 6.6V.
In a few cases even maybe 1.655V so say 6.8V for 4.
USB is say 5.3V max when on and 0V when off after any capacitors discharge.
But critical here is not USB Vmax but USB_on_min
USB_on_min = say 4.8V.
Under that condition FET must be off, so
FET Vgs = (6.8-4.8) =~~~~ 2V worst case.
The FET MUST NOT turn on at Vgs = 2V.
Battery min is say 4V and USB low falls to 0V "after a while" so FET must turn on at Vgs = 4V. That puts the FET Vgs_off_max and Vgs_on_min in a fairly narrow 2 to 4V range.
That's certainly doable by correct choice of FET - but datasheet must be chacked to ensure that worst case spread lies in the desired range.
The designer needs to be aware that design is needed!

In the bipolar case the USB Von_min is very easily accommodated by Q1 and if desired full turnoff can occur when V_USB is say 2V so changeover to battery is better defined.
So overall, the bipolar addition adds 2 x Q and 4 x R (small but non trivial) for the sake of better flexibility and designability.
BUT the MOSFET only solution is a good one as long as the complexity that goes along with the simplicity is properly understood.

• Does USB power feed really accommodate a Schottky blocking diode? If we take 1n5817 as example, it has a voltage drop of 0.45A. Could a high-power device, like a phone, be operated at 4.55V? According to this paper, high-power devices need at least 4.75V. Commented Aug 28, 2015 at 5:17
• Great answer, Russell. However, why are the BJTs needed? Why not just have a MOSFET and a diode, and that's it? Something like this (fixed!)
– Kar
Commented Sep 4, 2015 at 14:35
• @Kar Good question. The MOSFET solution is a good one as long as the FTE Vgsth is chosen to suit. Battery max voltage (assuming his AA cells are Alkaline) is 1.65V (new cells) x 4 = 6.6V. In a few cases even maybe 1.655V so say 6.8V. USB is say 5.3V max when on and 0V when off after any capacitors discharge. Critical here is USB_on_low = say 4.8V. Under that condition FET must be off so FET Vgs = (6.8-4.8) =~~~~ 2V worst case. The FET MUST NOT turn on at 2V. Battery min is say 4V and USB low falls to 0V "after a while" so FET must turn on at Vgs = 4V. .... Commented Sep 4, 2015 at 14:58
• .... That puts the FET Vgs_off_max and Vgs_on_min in a fairly narrow 2 to 4V range. That's certainly doable but the designer needs to be aware that design is needed. || In the bipolar case the USB Von_min is very easily accommodated by Q1 and if desired full turnoff can occur when V_USB is say 2V so changeover to battery is better defined. So overall, the bipolar addition adds 2 x Q and 4 x R (non trivial) for the sake of better flexibility and designability. BUT your MOSFET only solution is a good one as long as the complexity that goes along with the simplicity is properly understood. Commented Sep 4, 2015 at 14:58
• @Kar answer added to to reflect your (good) question. Commented Sep 4, 2015 at 15:13

We had a similar problem in a small portable device a while back. We used a battery (CR2032) guaranteed to have a lower voltage than any valid USB power, then used the lowest voltage drop Schottky diode we could find in series with the battery. That was good enough for that case.

In your case it sounds like you can't rely on the battery being lower voltage than the USB power. In the general case, you want to 0-drop diodes, one in series with each power conected. One way to get close to this is to start with two Schottky diodes but put a FET accross each. The diodes will make sure the circuit is powered up as long as one of the voltage sources is on. The circuit can then contain detection of which power is being used and turn on the appropriate FET to short accross that diode. You have to keep monitoring the two input voltages and turn off the FET when things change.

In switching power supplies, this is called synchronous rectification.

• I've sketched out a cct but it's an interesting challenge. The Vbattery > to < range adds fun. It actually needs some state memory and time delay and detection of USB depowering if you want to do it well. Commented Oct 31, 2011 at 15:26
• @Russell: Yeah, it's not trivial. I would try to make due with low forward drop Schottky diodes, but the OP really seems to want very little drop. Commented Oct 31, 2011 at 15:42