USB/Battery Switching Circuit - Page 1
Forum section: electronics / projects

author: optoisolated
author_rank: Unknown
timestamp: October 10, 2018, 09:32:05 am
content: Hi all,I'm working on a project which uses two power sources (a 9V battery, and 5V USB). My proto design just used two diodes to isolate the sources, but I want something more elegant, and to ensure the best possible life of the battery.I've whipped up a quick circuit and wanted to see if anyone had suggestions to make it simpler, more efficient, or point out if I've screwed something up.Note: VBUS is the USB Power Source, +BATT is the Battery.Cheers

author: mariush
author_rank: Super Contributor
timestamp: October 10, 2018, 10:42:31 am
content: Get a low quiescent current LDO or buck regulator (since you say you want long life) after the battery to get 5v and then you can use chips like TPS2115A :http://www.ti.com/lit/ds/symlink/tps2115a.pdfThere's also chips likeTPS22933which automatically selects the highest voltage from 3 inputs and has a built in LDO that does 3.6v at up to 75mABut it would probably make more sense to replace your 9v battery with 2 or 3 AAA batteries, 2 rechargeable batteries and a tiny boost regulator will most likely give more life to your product and rechargeable AAA batteries are cheap and easier to find compared to 9v batteries.AAA batteries are ~ 10.5mm x 44mm, 9v batteries are ~ 26mm x 48mm ... area used is similar.You can use boost regulators likeXC9142B50DMR-Gto boost to 5v with over 90% efficiency... only need a surface mount inductor and a couple ceramic capacitors so practically you can fit the whole circuit between the batteries or in the back of the area you have for battery contacts. And for this particular chip, the quiescent current is super low, something like < 25uA (not that you care much with rechargeable batteries)The 1-2$ you spend in extra components for the boost regulator, you save in a few months when you don't have to buy a new 9v battery...

author: Peabody
author_rank: Super Contributor
timestamp: October 10, 2018, 02:10:28 pm
content: I don't understand your circuit. First, it looks like you need a base resistor for the NPN. Second, it looks like power at VBUS would turn the battery on, not off. Well, as I said, I don't understand it.

author: Ian.M
author_rank: Super Contributor
timestamp: October 10, 2018, 03:58:34 pm
content: I understand it well enough.Quote from: optoisolated on October 10, 2018, 09:32:05 amAs Peabody notes, its totally screwed up. On when its meant to be off and visa versa, and that's if the BC547 survives having 500mA or more dumped into its base.Mariush has a good point about using a boost regulator and cheaper batteries. 2x AA are almost exactly the same mass and take up a similar volume as a single PP3, are a fraction of the price and will have about 50% more energy. A PP3 regulated down to 5V just isn't cost effective unless its either very rarely used or you only need a fraction of a mA for memory backup.

author: Peabody
author_rank: Super Contributor
timestamp: October 11, 2018, 02:45:54 am
content: The problem is that you're trying to turn off a P-channel mosfet when VBUS is connected, but you have no way to bring the gate voltage up to 9V, which is what you need to do to turn the mosfet off.I think the answer is to move all of this down to the negative rail, and switch to an N-channel mosfet. The attached circuit may work, but you would have to test it out. When VBUS is not connected, the NPN is off, which lets R2 bring the gate voltage up to turn on the mosfet, and conventional current flows from the system ground back into the negative battery terminal. But when VBUS is connected, the NPN turns on, which grounds the mosfet gate, which turns it off.I'm a bit queasy about the isolation of the mosfet source and negative battery terminal in the Off situation. The negative terminal may pretend to be -4V, which would turn on the mosfet. Maybe an expert can rule on whether this circuit will work.Edit: Indeed, I don't think my negative rail circuit will work at all. But see my next message below for a positive rail circuit I found online that looks like it would work.

author: optoisolated
author_rank: Unknown
timestamp: October 11, 2018, 04:08:05 am
content: Yeah I see where i've screwed up.I was trying to implement a NOT gate, triggered by the VBUS line being present, disconnecting the Battery via the P-Ch FET. I've been looking down the path of dual power source switching ICs now and will probably go down that path for my final design, as they are sub 70c for the parts in qty, and far more elegant. I am also definitely ditching the 9V battery now too in favour of a lithium primary or some other such cell.The draw of the design in idle mode (whcih it is in for ~95% of the time) is < 50uA and when active, its peak is 100mA with a duty cycle of approx 20%.. The 9v battery just doesnt have enough capacity for something that should stay functional ideally for about 6-9 months. I also need to write more optimisation into my MCU to reduce the load of the LED indicators.. they are currently configured to draw about 15mA and likely for the brightness needed, prolly would be comfortable on about 3-5mA.Much more to do, more breadboarding... but I will also play around with moving the circuit on to the negative rail just to see if I can get my head around implementing that original design, and make it work as I originally intended.

author: Peabody
author_rank: Super Contributor
timestamp: October 11, 2018, 05:14:43 am
content: I've concluded that my negative-rail circuit won't work. The problem is that the negative battery terminal isn't referenced to the rest of the circuit. Anyway, I found the circuit below online. It uses three mosfets, and there is some current drain from the battery via the resistors even when USB is plugged in. But it looks like it should work.And of course the resistors could be much higher values.I should also say that this is easier if the battery voltage is lower than USB, such as a single cell LIPO. and both are driving a downstream voltage regulator. Then all it takes is a Schotty diode, a p-channel mosfet, and a resistor.