# Power LED light from battery when mains fails

I'm attempting to design a circuit for some LED lighting that will be powered from a mains connected 24V DC transformer but if the power fails then the a battery should take over as the power source and automatically switch the LED lights on.

In the circuit below the idea is the LED light D1 is normally powered by V1. When V1 has power relay SW3 would switch from the position shown in the diagram and thus break the B1 circuit meaning D1 LED would be controlled by V1 and SW1. When V1 loses power SW3 would be in the position shown and the LED light would be powered by BAT1 and always on.

Is my analysis on the right track or is there a much simpler way to accomplish my goal? If I am on the right track what sort of relay should I be looking at for SW3?

Update:

Below is my revised attempt. The polarity on the SW1 terminals needs to be reversed. I don't think there's any need for a diode between the + terminals of BAT1 and V1 since they will only ever be connected if V1, the mains supply has failed in which case it will act as an open circuit. I think there is a problem with this new circuit in that the SW1 relay will always be off while SW2 is open and hence the LED will be lit by the battery. I need SW1 on even if SW2 is off.

• What if you tell us the ultimate purpose of what you want to do? // V1 will NOT act as an open circuit when the mains fails. // You need much more than 100 ohm, with that LED, as we told you. Commented May 23, 2012 at 13:46
• Telaclavo said 1.1k$\Omega$, and I said 1k$\Omega$, and told you it's a 20mA LED. Why aren't you listening? Learn to read datasheets if you want to get your circuits working. Commented May 23, 2012 at 13:55
• TBH I didn't even think about the resistor's value, 100 Ohms is the default value the circuit diagram tool put in. I'm focused on the general circuit design at this point rather than the component details. Commented May 23, 2012 at 20:50

Your circuit is not quite correct. If V1 is present and you close the switch V1 and the battery will be shorted together, and you don't want that. Their voltages will never be exactly the same, and that will cause a large short-circuit current. More about this in a minute.
When V1 is present the LED will be on through the battery, regardless of the position of SW1.
If V1 is gone the relay will be off, and so will the LED.

How to solve these issues? Use a switch-over relay to switch between V1 and battery and place it at the node next to the LED's anode.

A minor thing, though it will not change the circuit's functionality: you're interrupting the ground with your relay. Don't. Swap the relay contacts and the LED, so that you interrupt the positive voltage instead. Just a good habit. Has been fixed anyway in the previous paragraph.

And don't forget to place a series resistor with the LED. For a 20mA indicator LED a 1k$\Omega$/1W will do.

And clean it up a bit. The ground line at the bottom, going to the contact of SW3 is superfluous, and draw a single ground line for both power sources, so that it's obvious that they're connected.

We're almost there. The switch is in series with the relay coil, so closing it will create a path from coil through R1 and LED to ground. The - of the coil should go directly to ground, and the switch should go between V1 and the unused relay contact.
But schematic-wise it looks already much better, don't you think? It may even pass the olin test ;-).

• (24-0.4-2)^2/1e3 = 0.47 W. A 0.5 W resistor would be too tight. Commented May 23, 2012 at 12:39
• this resistor doesn't need derating below 70°C ambient. Besides, I use a 3V white LED :-), so that's 0.44W. Commented May 23, 2012 at 13:10

(In fact, I still don't get the ultimate purpose of what you want to do. Do you want to have light only when the mains fails? If so, what's SW1 for? The only purpose for SW1 would be "to force draining the battery while there is mains", which does not make much sense to me. Do you want to have light always? My answer below was for "always".)

Don't do that. You need relays, detect voltages, and you may end up connecting in parallel both voltage sources, which is not good.

Do this:

If the two sources give indeed the same voltage, use two schottky diodes in series with the battery, as shown. If you can slightly modify the output voltage of your 24 V dc power supply, make it slightly larger than the voltage of the battery, and use one schottky diode, instead of the two in series, shown. In any case, you must have a minimum of two schottky diodes, in total. Doing this, the battery will not be drained if the power supply is on.

R= 1.1 kohm, 1 W, for the LED you mention.

• What happened to the switch? Commented May 23, 2012 at 12:36
• @stevenvh It took some days off. It was starting to feel the stress of just going back and forth. Commented May 23, 2012 at 13:17
• It didn't suffer from burnout, did it? :-) Commented May 23, 2012 at 13:37
• Why Schottkys? The priority detection will work better with the larger voltage drop of a 1N4001. There's no point in keeping the voltage drop low; it will be consumed by the resistor anyway. Commented May 23, 2012 at 14:42
• @stevenvh The priority mechanism works equally well with 0.4 V and 0.7 V voltage drops. I bet there are more circuits in the world that use schottky diodes in that configuration, than circuits that use PN diodes (in that conf). // The low voltage drop is (of course) to waste less power, when he connects the main 24 V load (and when he tells us which one it is). I hope he doesn't want to build all that (and with 24 V) just to drive a 20 mA LED. I'm actually waiting for him to resolve this mystery. Commented May 23, 2012 at 15:01