# Switching from wall power to battery and back again

I'm in the final phase of my BeerBot* project, and I'm looking for the best way to power it.

BeerBot will spend most of his life sitting in a docking station, keeping his battery charged and running off of wall power. When called upon, he needs to be able to disconnect from the docking station and switch to battery power without interrupting power to his brain. Upon returning to his docking station, he needs to switch back to wall power again.

I have a NiMH charge circuit, and I have a circuit for powering the robot from a wall outlet, I'm just not sure how to switch from one to the other without interrupting power. For my testing thus far, I've just been shutting the robot down and manually switching between wall power and battery power, and connecting the battery to an external charger as needed. This is obviously not a permanent solution, since BeerBot needs to be always at the ready - shutting him down to switch over to battery power every time I need a beer would defeat the whole purpose of BeerBot*.

So my question is, what is the best way to keep a robot powered from the wall, simultaneously charging the battery, and switching between wall power and battery power automatically when disconnected? I guess this is analogous to the way a laptop works - switching to battery when unplugged and and keeping the battery charged while plugged in.

I don't care if it's a ready-made solution or a circuit I can build, I'm just looking for a good way to do this without frying my robot or setting my house on fire. I'm mostly a software guy, so I know just enough about circuit design to be dangerous (and I've fried enough electronics to know that power supplies can be dangerous...). I've been looking at power management ICs, but I'm thinking that might be overkill since I already have a charging circuit and a wall-power circuit, I just need a way to switch between them. Can I just connect both and use a couple of diodes to keep current from flowing in directions it shouldn't, like this?

or do I need something more complex?

.

*If you're curious, BeerBot is a semi-autonomous beer-seeking robot. He sits quietly in the corner listening for commands. Currently his only command comes from a modified Easy Button on my desk, which sends a wireless signal to BeerBot. When he hears the signal, he wakes up, drives autonomously to the refrigerator, opens the door with his robotic arm, uses computer vision to detect a beer bottle (placed strategically on the bottom shelf where he can reach), grabs a cold one, closes the refrigerator door, brings the beer to my desk, and returns to his corner to await my next request. Phase 2 will incorporate a bottle opener.

Basically the simple Diode-OR circuit, you just have shown would be enoguh, if you (or your circuits) can get along with the voltage drop on the diodes. It is about 0.3 V - 0.5 V depending on the diodes you choose. But there is one thing you have to make sure, so the switching between the power supplies will happen correctly.

The voltage from the wall supply should be larger than the voltage from the battery, ensuring that when the wall adapter is connected D1 will conduct and D2 won't.

1. Wall adapter is disconnected: $$V_{out} = V_{battery}$$
2. When the robot connects to the adapter, where: $$V_{wall} > V_{battery}(=V_{out})$$ then D1 will conduct as the voltage on its anode (+) will be higher than on its cathode (-).
3. Now the output will be: $$V_{out} = V_{wall}$$ so the voltage on the cathode (-) of D2 will be higher than on its anode (+), disconencting the battery.

This won't work if the two voltage sources are equal, slightly equal.

There are also available autoswitching power multiplexer ICs on the market, such as this one.

Note that, this is just an example and it does not support 12 V input. You can find one with the correct voltage and current ratings though.