Mains power, battery and charger to feed an Arduino

EDIT: You may scroll down, this first post is just about the main idea. A working schematic is drawn in a post further below.

Hello there,

Before I start, I ask you to please bear with me, since my knowledge of electronics is way too minimal.

For a while now, I've been trying to find a way of providing an UPS (Uninterrupted Power Supply) to an Arduino project.
Since I couldn't find any ideas already in place, I thought of this (please imagine that instead of the LM7812 regulator there's a lead acid battery + charger):

Because the 15V output from the LM7815 would be always higher than the battery + charger output, the battery will only be drained when the converter fails. Is this correct?

And then some additional questions arise:

  • Is 14.3V an acceptable input voltage to an LM7805? (5VDC regulator)
  • Are diodes the best way to approach this design? The intent is preventing current from flowing in the wrong direction.

Thanks in advance for reading.

please imagine that instead of the LM7812 regulator there's a lead acid battery + charger):

That is hard, basically because the battery charger has two wires and a regulator has three.

The idea of getting diodes to control the flow is good, but you don't need those diodes in the ground. If you look at D6 it is just shorted out and the diodes on the other regulator don't make sense. All grounds must be common, do not put in diodes.
So have a draw again closer to what you need. By the way looking at your image on that web site caused my Mac to come to a crawling stop, I had to quit everything and reboot, so maybe it is not the best site to use.

Is 14.3V an acceptable input voltage to an LM7805? (5VDC regulator)

Yes, I think the data sheet says 30V is the maximum.

Are diodes the best way to approach this design?

Yes

I've sketched a rough idea for a simple Arduino UPS at....

... and will be updating it with comments posted here, if anyone feels willing to make suggestions for solving the problems I've sketched.

This UPS question is an old chestnut, a wheel not yet invented, as far as I am aware, and it is about time we DID get something in place! <^_^>

My "answer" is a very, very simple one. Perhaps too simple.... but I'd like at least to find out why what I propose "can't" be done. I just take 15v, run it through a current limiter followed by a diode to a rechargeable "12v" battery, and take the Vunreg for an Arduino from the "top" of the battery.

Maybe that "current limiter" is too hard to design?

I also spent some years in the security alarm business. When we need to add a power supply, it has to have a backup battery source. Something like this is a real fast solution:

http://www.altronix.com/p_pdf/AL624.pdf

Hi all,

I'm glad to see that I'm not "alone" in this pursuit.

Grumpy_Mike,
The reason I said "imagine" is because the software I'm using doesn't have the components that I'd like to place in the circuit :slight_smile:

Rokkit,
Your suggestion although really appropriate for the task at hand, is quite expensive, considering that we'd also need a transformer up to 30V AC, and compared to what I'm planning (assuming it will work). But yes, it is a real, tested and proven solution.

tkbyd (and everyone else),
Very good initiative. Thank you for that.
In the circuit I posted above, I'm removing the diodes from the ground line as suggested by Grumpy_Mike.
Where I say "instead of an LM7812, imagine a battery + charger", what I mean is using an L200C + battery.
Here's a good example I found after some "Googling": Sealed Lead-Acid Battery Charger Circuit

L200C: 2,50 EUR
3 resistors + 2 small capacitors: 1 EUR
I wouldn't know how much these cost in the U.S. Oh wait, but I do: i.e. mouser 3,40 USD

The reason why I was planning on using a 12V battery instead of 6V, was that it would not be a good idea to regulate from 6V to 5V (too little difference for the regulator to handle).
Sure I could apply a voltage divider, but I'm not that confident on supplying fluctuating voltage to the circuit.

Is someone able to confirm/deny my first assumption of all? Will the greater voltage supply "win" over the battery while there's Mains power? In practice not draining from the battery at all?

Either way, how would I block current flow entirely, once the voltage drops below a certain limit?
Because I don't want my circuit to fry or malfunction when that happens. And I certainly don't want to drain the battery dry because, as I'm sure you know, draining the battery below a certain level will ruin it for good.

These are my thoughts for the moment.
Sorry for not having posted a revised circuit by now; I'm lacking the knowledge and/or software for that.

Oh, just one other thing,

The real downside about the 12V battery is this:
You need +2V to power the battery charger. That is, at least a 14V DC supply.
The closest thing on the market is 15V, BUT... They're not THAT easy to find, nor as cheap as the 12V (although that was pretty obvious).

Ok, done for today :slight_smile:
Thanks again for your participation!

footswitch:
it would not be a good idea to regulate from 6V to 5V (too little difference for the regulator to handle).

Have you considered a low drop-out regulator. Just doing a quick search the 1st result is the National LP2954

The LP2954 is a 5V micropower voltage regulator with very low quiescent current (90 µA typical at 1 mA load) and very low dropout voltage (typically 60 mV at light loads and 470 mV at 250 mA load current).

Not saying that's appropriate specifically for your usage, but it's an example of the type. A Micrel MIC2940A-5.0BT is another.

The reason I said "imagine" is because the software I'm using doesn't have the components that I'd like to place in the circuit

Draw it with pencil and paper, and take a photograph.

Will the greater voltage supply "win" over the battery while there's Mains power?

Yes

Sure I could apply a voltage divider

Not for a power supply you can't.

Either way, how would I block current flow entirely, once the voltage drops below a certain limit?

There is no simple way to do this. Perhaps the simplest would be a relay being held on by the arduino supplying the power to the arduino. You have to be creative with the normally open and normally closed contacts.

Either way, how would I block current flow entirely, once the voltage drops below a certain limit?

Again, from the alarm years:

http://www.smarthome.com/72827/ELK-ELK-965-Low-Battery-Cut-off-Module/p.aspx

Rokkit is a resourceful guy!
We now have two thoughts on "Low Battery Cutoff/Handling", let's save them for later (of course I want to build that from scratch as well!).

OKAY.
Brace yourselves, for we are entering the "BLOWING STUFF UP" phase!

This goes without saying. It's late, I'm human. If you want to build this, please take the time to analyze the circuit, and make the necessary measurements before plugging it in. Thank you for being responsible.

What do you think?
Let me tell you that I'm leaving it on during the night, charging a 12V 1.3Ah battery.

So... now that 24h have passed, my results:

  • Always remember to put a heatsink or other form of heat dissipation in the L200C :blush:
  • Unless the battery is dead, the charging voltage is fairly steady at 13.5 to 14V, until the battery is almost full. Then it slowly drops until it reaches the "fully charged" voltage (in my case, around 12,6V). Either way, the L200C approach seems to be "don't push the battery straight to 14V unless it's already almost charged".
  • When the battery is fully charged, the L200C seems to output a steady current flow of around 20uA.

Something else I forgot to mention before, from the specification sheet: the maximum charging current that the L200C can provide is 2A.

And the only thing left right now is connecting the whole circuit and see if it works as expected, or distorts the space-time continuum :grin:

After some testing, I had to add a diode from the charger output to the battery.
This prevents the battery from feeding the charger once the mains power is lost.
I also increased Vcharge in about 0.5V (in practice, increased the R2 value) to compensate for the diode's voltage dropout.

Before placing the diode, current flow from the battery to the charger: around 20mA
After placing the diode: 1uA

:slight_smile:

Now I'm just wondering, since power outage will produce a sudden drop of voltage (from 14.5V to 12.1V), how big of a capacitor before the regulator will I need? The circuit takes normally well under 400mA, but has an "unpredictable" peak current flow of 2.5A@5V (after the regulator) (it depends on sensor readings and consequent actions).

Also, if I use a big capacitor (>100uF?) I need to limit the current passing through the capacitor, right?
I don't know the calculations involved and how big of a resistor should I use...

P.S.: do you have any comments at all on the circuit? This is something I've been looking for for 2 months. I also think it would be quite an evolutionary step for the Arduino community if we started building a Wiki entry with different ways of powering an Arduino. (mains, battery, solar, all three combined...) What do you think?

Put a 100 uF capacitor after the regulator, and you probably won't need a resistor at all. You may also get away without a resistor on the input side, too -- the regulator itself has some resistance.
Just make sure you heat sink the regulator properly, too, for the load :slight_smile:

Hey guys, regarding this subject, I'm just passing by to report that this circuit has been working for 6 months now.

Yes. It's ugly; uses 15VDC supply, which is not very common; it's rather big and heavy, so not exactly portable; it's a bit inneficient and doesn't take some things into consideration like low voltage cutoff, but hey, it gets the job done.

There are 100uF capacitors before and after the final regulator; they're just there for stability, as discussed.

In the mean time, if someone has discovered or knows about ANYTHING out there like this, but pre-manufactured, for lithium batteries and with low voltage cutoff, please leave a comment. It would really mean a lot.

By the way, it looks like the Pinguino 32 has something like that already built in.
I wonder what it would take to duplicate the circuit.
The power supply looks pretty complicated:
http://www.pinguino.cc/download/schematics/PIC32-PINGUINO/PIC32-PINGUINO-schematic.pdf
Sweet baby Jesus.

Ok, thanks for reading. And stay hungry.
I mean, if you're hungry, please do eat something.

The Seeedstudio LiPo Rider Pro probably comes close:
http://www.seeedstudio.com/depot/lipo-rider-pro-p-992.html?cPath=155

I built a circuit on my own based on an MC34063 switching boost converter and a top-end power FET. It worked something like:

Input -> linear regulator -> power FET -> 3.7V LiPo cell (18650 size, 2600 mAh) -> MC34063 switching boost converter -> AVR microcontroller.

The AVR would control the power FET for charging/not based on voltage measured into an analog-in pin, with some hysteresis. Turn off at 4.1V, turn on again when back to 4.0V. I also had a bypass where the linear regulator also fed directly into the AVR when connected to power.
A bit more complex, but actually worked (once I heat sinked the regulator and power FET to deal with the 1.5A charge current :slight_smile:
The LiPo additionally has built-in overcharge protection at 4.2V, but I didn't want to push it that far for longevity reasons.

However, I've now tried some LiFePO4 cells, and they are a lot kinder/gentler than the LiPo cells. Yes, you can ruin them through overcharging, but the "it will explode and burn your house down" factor is significantly diminished!

It does come close, thanks for posting this.

If it weren't for the 2 amps I need (peak current), I believe it would be just perfect for my needs.
I'm ordering a couple of these right now. I mean, for 15 bucks, I'm sure it won't be a bad investment ]:slight_smile:

Thanks again!
footswitch

Sorry but will the schema will works ?

The main goal, is :

Using an external battery power from a broadcast video camera, and then allowing to charge the lipo battery.

When the battery of the camera is unpluged (or if it dosn't get an special connector to provide 12v), then the lipo will works to do the job for the lilipad.

The dual switch is to avoid a discharging of the lipo when it's not used (2 or 3 weeks along). the lipo is in enclosure that will open only a few days a years (to change some parameters of the lilypad).

Can you tell me if it works.

The sparkfun lipo charger I've ordered is this one :

and this is a picture of my schema.

Thanks a lot for your help.

Well, from your schema it certainly looks like there's a situation where you're plugging the 12v camera battery directly to your 3.7v LiPo. Fireworks :stuck_out_tongue:
And it's unclear to me if SYS OUT will feed from the battery when the circuit isn't plugged in to a charging source. Also, we're talking about an IC designed for LiPo charging. Don't really know what can happen when it's charging a cell PLUS powering a circuit. I really have no idea, but we COULD be talking about fluctuating voltages and currents, and the circuit may not hold.
But if you ordered one I guess you'll find out soon enough and then share your findings with us :slight_smile:

In this schema, the 12V from camera bettery is just going to the 7805 regulator and never goes directly to the lipo !

Then this is the regulator that will power the sparkfun lipocharger.

The switch is an dual circuit (bipolar ?).

Another question : my lipo is an 3.7V 500ma.

What kind of charging parameter must I use ? 100 or 500 ? (considering the sparkfun lipo charger)

The switch is an dual circuit (bipolar ?).

The proper name for the switch is a double pole, or ganged switch. The full name would be a DPDT, for double pole double throw. The last bit saying you want a contact somewhere no matter what the switch position is.

The circuit looks fine to me. Sorry I don't know about the charging.