battery supply activation

hi,

i am using arduino connected to house supply. i need it to stay powered in case house supply fails. I'm thinking about using a battery, which is "activated" only when house supply fails.

is it possible? is there any solution?

thanks, athos

PS: sorry for my english. what's the correct expression for "house supply" (i mean the 220V) ?

The simplest way would be to diode-or the battery with your other DC source. If the DC source is at a higher voltage than the battery then it will deliver the current to the Arduino. When the power fails the battery voltage will be the higher voltage and will deliver the current.

(* jcl *)

if diode-or means this: http://cicloinf.dimi.uniud.it/didattica/B3/images/Image26.jpg

i guess that the reason why DC source voltage must be higher than the battery source voltage is to "switch" off the battery diode tand avoid current drain from battery. So DC voltage should be at least 0.7V higher than battery voltage, right? Example: 12v for DC and 9v for battery.

(instead in "canonical" OR use, "high" in-values are at the same voltage so current is drained from both sources. am i right?)

anyway, thanks a lot!

Correct.

You can get diodes with lower voltage drops than 0.7V (Schottky diodes are around 0.3 to 0.4V) but 0.7V is a safe number. The lower the drop the less power wasted.

12VDC and a 9V battery will work. Generating 5V from 9V wastes 4/9 of the power. If it is not run for a long time the convenience of a single battery may be worth the power waste.

(* jcl *)

Another simple solution is to get yourself a relay.

Your battery will feed the VREG but through the NC contacts of the relay.

When power is restored, it will remove the battery and use the wallwart.

On the +5 side, increase the capacitance to keep the 5V source during the delay in switching the power over. The actual value will depend on current draw, but 2200uF is good starting point.

Match the relay to whatever adapter voltage you have. (If you are using 12V wallwart, get a 12V relay.)

thanks to all!

i think i will try jluciani's solution. i will use arduino for the development and then build a board for my device.

I am trying to figure out what happens in the time domain when 12V supply is switched off. i guess that, the voltage at the output of the OR port suddenly ramps to 9V, without falling to 0V, so the voltage regulator will still output 5V and the atmega will not be aware of what happened, and this will be more true if i follow brutus advice about capacitance on the +5V side. am i right?

how can i make the micro understand that wall wart went out (so it can send a message saying that there was a trouble with wallwart supply)?

i'm thinking about another regulator connected between 12V and one of atmega's input pins, but this doesn't seem such an elegant solution...

The Arduino (or clone) will most likely have input and output capacitance for the on-board linear regulator. You shouldn't need any additional capacitance since the diodes will switch very quickly. The relay switches slower and would require a large capacitor.

Use a resistor and a zener diode to reduce the wall wart voltage to a level that is below the system voltage but above the level considered a "HI" by the uC. For 5V I would use a 3.3V or maybe a 4.7V zener. Connect the cathode of the zener to a digital input. You can then create an function that interrupts the uC on a falling edge. When the wall wart dies the interrupt is triggered and the uC can perform whatever actions are required.

(* jcl *)

yes, the interrupt function triggered by the in pin was the idea. thanks again for the quick and smart advice :)

athos