Maker Pro
Maker Pro

Automatic Battery/External Power supply switch circuit

Finndersen

Feb 23, 2015
13
Joined
Feb 23, 2015
Messages
13
Hi,
I'm making a portable Rpi 3 project that will be battery operated but switch over to external supply and charge battery when connected.

I'm planning on using a USB power bank thing which has a 5V charging input and 5V USB power output, with in-built battery charging circuit etc.

I just need a circuit which effectively switches Rpi and external power source from battery output to charge input when external plug is connected.

I've got this P-channel MOSFET/diode circuit which would work great, except for the diode voltage drop, since USB power/battery output is 5V and Rpi needs 5V (sorry for horrific sketches):
JkcGYij.jpg


I can also use a DC jack which has a switch to disconnect battery output when plug connected, however the battery ends up being connected to itself normally and would just drain to death...
fJZwfC1.jpg


I would like to avoid multiple input power ports/manual switches etc. It would also need to supply at least 2A. Surely there's a way to make this work without diode voltage drops?

Thanks for any help
 

AnalogKid

Jun 10, 2015
2,875
Joined
Jun 10, 2015
Messages
2,875
The switching jack is the most simple approach, but your wiring is incorrect. If the AC adapter center pin is GND, or - as indicated on your drawing, the the center pin, battery negative terminal, and Rpi GND input all are tied together. None of those connections is switched. The battery + terminal goes to the switched contact, and the Rpi +V input goes to the barrel contact (the bottom one in your drawing. when the AC supply is plugged in, the switched contact is floating and the battery is disconnected from the circuit.

ak
 

Finndersen

Feb 23, 2015
13
Joined
Feb 23, 2015
Messages
13
The switching jack is the most simple approach, but your wiring is incorrect. If the AC adapter center pin is GND, or - as indicated on your drawing, the the center pin, battery negative terminal, and Rpi GND input all are tied together. None of those connections is switched. The battery + terminal goes to the switched contact, and the Rpi +V input goes to the barrel contact (the bottom one in your drawing. when the AC supply is plugged in, the switched contact is floating and the battery is disconnected from the circuit.

ak
Isn't that what my circuit already shows? The battery output becomes disconnected when plug is in, but the problem is, when there's no plug the battery output becomes connected to it's charging input so it will continually discharge itself
 

AnalogKid

Jun 10, 2015
2,875
Joined
Jun 10, 2015
Messages
2,875
Isn't that what my circuit already shows?
No. Among other things, your drawing has no connection to the DC connector center pin, and no GND connection to the Rpi.
The battery output becomes disconnected when plug is in, but the problem is, when there's no plug the battery output becomes connected to it's charging input so it will continually discharge itself

That is what you drawing shows, which is why it is not correct. To start with, a battery does not have an "in" and an "out" terminal, or a "charging input". It has a positive and a negative terminal. Either one can be an input or an output, depending on what the battery is doing. Re-do your drawing by first connecting all of the negative net items together as described, then the positive net items. It should be different from your first drawing.

ak
 

Finndersen

Feb 23, 2015
13
Joined
Feb 23, 2015
Messages
13
No. Among other things, your drawing has no connection to the DC connector center pin, and no GND connection to the Rpi.


That is what you drawing shows, which is why it is not correct. To start with, a battery does not have an "in" and an "out" terminal, or a "charging input". It has a positive and a negative terminal. Either one can be an input or an output, depending on what the battery is doing. Re-do your drawing by first connecting all of the negative net items together as described, then the positive net items. It should be different from your first drawing.

ak

In the circuit I'm assuming all grounds are common (tied together)

I'm not using a plain battery, but a mobile USB power pack which has inbuilt charge circuitry, with 5V charge input and 5V power output
 

AnalogKid

Jun 10, 2015
2,875
Joined
Jun 10, 2015
Messages
2,875
Then it is even more important that the drawing capture the return connection(s). Does it have 3 or 4 contacts/wires?

ak
 

Finndersen

Feb 23, 2015
13
Joined
Feb 23, 2015
Messages
13
The battery pack is like this, with a usb port input and usb port output.
xuma_bub_a26b_2600mah_portable_battery_pack_1062792.jpg

Therefore I guess it would effectively have 3 wires, if input and output ground are tied together (not sure)
 

AnalogKid

Jun 10, 2015
2,875
Joined
Jun 10, 2015
Messages
2,875
That clears up several things. The most simple way to automatically switch from battery to external DC power is not to switch at all. Connect the load to the XUMA output only, and connect the external DC to the XUMA input only. This works if the load on the battery is not pushing its limits. For example, if the Rpi draws 100 mA - 200 mA, and the battery is not completely dead, the 1 A external power input should be able to run the device and recharge the battery at the same time.

BUT - if the XUMA device cannot do both things at once, such that its power switch prevents simultaneous charging and load power, then this will take a switching device or a small relay.

ak
 

Finndersen

Feb 23, 2015
13
Joined
Feb 23, 2015
Messages
13
Yeah I was thinking of that, it depends how it's wired though. If it can route directly from input to output that would be ideal, but I don't want it going through the battery and simultaneously charging and draining. I might just have to test, thanks
 
Top