Maker Pro
Maker Pro

switch between wall and battery power

icydash

May 22, 2013
12
Joined
May 22, 2013
Messages
12
I'm trying to make a circuit that runs off wall power when it's plugged in (a 9v DC power adapter), otherwise it runs off the attached 9v battery. I'm not sure how to make the circuit detect if it's plugged into the wall or not, though. Is there some IC that is commonly used for this or something?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
If your 9V adapter has a slightly higher voltage than your battery, the simple solution is to place a diode in series with both your battery and your external power adapter.

Whichever one has the highest voltage will power the circuit.

Another approach is to have a relay energised by the external power to change over the power connections from the internal battery to external power.

The latter approach will cause larger glitches when power is plugged in and removed than the diode solution.
 

icydash

May 22, 2013
12
Joined
May 22, 2013
Messages
12
If your 9V adapter has a slightly higher voltage than your battery, the simple solution is to place a diode in series with both your battery and your external power adapter.

Whichever one has the highest voltage will power the circuit.

Another approach is to have a relay energised by the external power to change over the power connections from the internal battery to external power.

The latter approach will cause larger glitches when power is plugged in and removed than the diode solution.
Thanks for your reply. The diodes seems like a good solution. So when the wall power is plugged in, if it has a higher voltage than the battery, the wall will power the circuit. If the battery has a higher voltage (even when the wall power source is plugged in) the battery powers the circuit. If no wall power is connected, the battery powers the circuit. Is that correct?

What if the battery and wall power have the same voltage (i.e the wall adapter is plugged in and the battery starts off with a higher voltage than the wall power, but drains over time until they both have the same voltage in some instant)?

My concern is that people using this circuit will often install fresh 9v batteries, which may have equal (or greater) voltage than the 9v DC wall power supply.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Are two Diodes really necessary? Unless it's a regulated 9V wallwart, I doubt that it is, the battery can't back feed into it when the mains are lost. In fact it will just add some filter caps across the rails. I think it's only important to prevent the wallwart from feeding the battery. So one Diode in line with the battery should suffice. This gives the wallwart an extra (.7V) chance of being the dominant voltage.

CYA: All of the above may be ignored if I missed something! :D

Chris
 

icydash

May 22, 2013
12
Joined
May 22, 2013
Messages
12
Are two Diodes really necessary? Unless it's a regulated 9V wallwart, I doubt that it is, the battery can't back feed into it when the mains are lost. In fact it will just add some filter caps across the rails. I think it's only important to prevent the wallwart from feeding the battery. So one Diode in line with the battery should suffice. This gives the wallwart an extra (.7V) chance of being the dominant voltage.

CYA: All of the above may be ignored if I missed something! :D

Chris

What is the difference between a regulated 9V wall wart and an unregulated 9V wall wart? I'm not really sure what "regulated" means.

So you don't think the battery will some how feed back into the wall wart if the wall wart has a lower voltage than the battery supply?
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
What is the difference between a regulated 9V wall wart and an unregulated 9V wall wart? I'm not really sure what "regulated" means.

So you don't think the battery will some how feed back into the wall wart if the wall wart has a lower voltage than the battery supply?

If it's unregulated then battery current would have to find a path through the rectifier bridge. Normally this shouldn't happen. When a pack is regulated it usually states it. Current can back feed into the output side of a regulator and should be avoided. I'm not sure if I've seen a regulated 9V pack. I'm sure they make em but they're not common.

Chris
 

icydash

May 22, 2013
12
Joined
May 22, 2013
Messages
12
Ok so it sounds like I probably only need one diode. And then if the 9v battery and the 9v from the wall wart are too close in voltage, it sounds like the circuit will run off the battery until it drains enough such that there is a .7v difference between the wall wart voltage and the battery voltage, at which time it'll switch to using the wall wart. is that right?
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
I'm going to post a plot for you so you can see how the battery current never back feeds to the wallwart.
Also, you can reduce the Diode voltage drop considerably by using a more expensive Schottky Diode.

Chris
 

icydash

May 22, 2013
12
Joined
May 22, 2013
Messages
12
Oh sweet. That's great to know. It looks like the Schottky diodes only have a forward drop of around .3v, which is a big difference.
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Just a few notes about this schematic and plot. It assumes there is no bleeder resistor or voltage regulator integral to the wart. You can test for a back current path using an Ohmmeter with the (+ & -) probes connected to the wart's respective (+ & -) pins. This must be done with the wart unplugged from the mains and the cap discharged. A wart with no back current path will measure infinity after the cap charges from the Ohmmeter. Also, a modern DMM (Ohms Function) will not forward bias a diode junction so you will also want to also place the DMM in Diode Test mode to test again. This mode produces a voltage and current at the probes usually high enough to light a LED.

If you have any doubt and since you're going to use Schottky's you may want to use 2 diodes (the second in series with the wart) as Steve suggested. Your call.

Chris
 

Attachments

  • PwrSupDiodeIsolator.JPG
    PwrSupDiodeIsolator.JPG
    47.6 KB · Views: 458

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
I had an error in that last schematic. After checking the specs for a typical fresh 9V alkaline battery it should have been 9.48V as opposed to 9,6V. Not a huge difference but .... Anyway, I also greatly expanded the 'X' scale (Wallwart (V)) too.

Chris
 

Attachments

  • PwrSupDiodeIsolator.JPG
    PwrSupDiodeIsolator.JPG
    54.4 KB · Views: 3,544
Top