User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Providing power for intermittent power loss

Mon May 06, 2013 11:31 pm

So I'm planning an application for the R-pi Model A where power loss is to be expected for half a second randomly, and by randomly, I mean *randomly*. It could be days or weeks between power loss, or it could happen 3-6 times withing 5 seconds.

In fact, lets just say the basic setup condition for this scenario is that I loose power for 5 seconds.

I want to keep the model A running through this situation. It's a headless application, using a wifi adapter, so we're talking less than 500 mA power consumption, but for argument's sake less call it an even 500 mA.

Would I be better off using a capacitor (or a couple of capacitors in series?) to keep the pi going for this power outage, or should I look into a battery backup situation? My only initial reluctance towards a battery backup is that greatly increases the cost of the project. All things considered, I think I would come out ahead having to purchase $10 in capacitors rather than getting a true battery backup.

Thoughts?
Dear forum: Play nice ;-)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12416
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Providing power for intermittent power loos

Tue May 07, 2013 12:03 am

The bigger "supercaps" (because that is what you are talking about, capacitors of several farads, are all max 2.7 Volt. There are some "5.5V supercaps", but these simply contain two closely paired 2.7V supercaps. I say closely paired because if you put two capacitors in series the voltage across each is inversely to their capacitance distribution, that is the capactor with the largest capacitance will get the least voltage across it, and the other one the largest.
So if you try to put 5V across two supercaps the voltage probably won't distribute evenly across them, as their capacitances wont be identical. With two capacitors that can resist a voltage of really specifically no more than 2.7 Volt, the danger is big that one will develop a voltage larger than the 2.7V it can have, and the capacitor will be destroyed! So you will need some kind of charge balancing circuit! And must also make sure the voltage across the two supercaps never exceeds 2 x 2.7 = 5.4V or its magic smoke time!

Then about the capacity for the supercaps to hold up a certain voltage. In fact they don't, that the thing, if you (manage to) draw a constant current from a capacitor its voltage will decrease linearly!
Just like it will rise linearly if you manage to fill it up with a constant current,

That is unlike a battery, that keeps a more or less constant output voltage for most of the time you draw current from it. A (super) capacitor doesn't do that, so it means that if you fill the cap to the max with 5.25V it will linearly drop until it reaches 4.75V, and so it will only be good for "half a volt", while 4,5V of charge is still unused inside it! Thats a bit of a waste, compared to batteries.
The situation would be a bit better if you could somehow use all the energy stored in the cap, and you can, but it would take a buck boost regulator to do it!

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Providing power for intermittent power loos

Tue May 07, 2013 12:09 am

I did not know that about super caps, thanks!

So a battery is the best way to go, no big deal I suppose. Well my number two choice is to use an in-line charger. I've seen such things like that for Li-ion (like this over at adafruit http://www.adafruit.com/products/259 ) but is there a nimh option? I mean for the level of power and duration I need, I could even step up a single 1v2 AA and still have power to spare between charges.

(option three is to do a trickle charge circuit using 5v to charge it, but I haven't researched that so if anyone knows a good resource I'd be thankful ;-) )
Dear forum: Play nice ;-)

User avatar
cyrano
Posts: 714
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: Providing power for intermittent power loos

Tue May 07, 2013 9:42 am

If you only need the power in 1 AA cell, you could very well use a couple of 2,7V supercap's in parallel. Just keep adding caps until you reach the time you need.

It'll be bigger and probably more expensive to build, IMHO.

Personally, I'd buy a good multi-purpose charger and a couple of cheap cells to experiment with. And an ebay stepper-upper, of course. A charger with a good reputation in the RC and robot blogo sphere, is the one from Hobbyking:

http://hobbyking.com/hobbyking/store/__ ... ancer.html

This is a 50W charger, so you might want to choose a smaller one.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Providing power for intermittent power loos

Tue May 07, 2013 12:56 pm

:lol: yeah I think I'd need a smaller one, especially since I don't want to remove the battery to charge it. I did some very brief and light research and saw that while it did not discuss voltage, it did say to appropriately trickle charge a battery you supply it with 10% of it's rated capacity (so a 2400 mA would need a charge less than or equal to 240 mA), that's the direction I'm leading right now as the circuit would require three diodes and a resistor (two diodes to control which power source is being used, the third to provide a charge from the main power source to the battery, and a resistor to limit the current to the 10% mark)
Dear forum: Play nice ;-)

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Providing power for intermittent power loos

Tue May 07, 2013 1:55 pm

I don't know how much supercaps cost, but I found the LT4425 chip which fixes the load-balancing problem of two 2.7V supercaps mentioned above.

http://www.linear.com/product/LTC4425#overview

If you download the datasheet you will see a circuit at the bottom of page 16. It's a 12V input (from somewhere, maybe a 12V mains transformer) to 5V output, provided by two supercaps.

The LT4425 keeps the caps charged, and when the input power goes, the caps will power the load. In that circuit you could probably ignore the LT3663 and just use a USB PSU as an input to the LT4425. The length of time you can power the Pi will depend on the size of the supercaps, and the time and duration of the power outages (you need some time for the supercaps to recharge).

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Providing power for intermittent power loos

Tue May 07, 2013 3:31 pm

I'm getting a lot of conflicting information on trickle charging. Some places say it's fine, some say it reduces the life of the battery. I'm thinking I'd be better off doing something like:

1) Discern approximately how much battery power is used per second.
2) Have GPIO set up to sense when power is lost (opto-isolator with 5v from PSU on one side and 3v3 pin to GPIO input on the other)
3) Enable the trickle charge of the battery for an amount of time equivalent to the power lost (say with GPIO output going to a transistor)
4) One every couple of days or once a week or once a month, keep the trickle charge on for a full day or two to ensure battery is topped off
5) Alternatively, run an LED off the battery every so often to make sure it's discharging more than just a percent during random power loss

Otherwise,

I'm looking into this option I found on ebay

http://www.ebay.com/itm/PCB-Charger-mod ... 3cba39cefa

It seems like it is specifically designed to be used with the 18650 Li-ion battery which supplies 3v7, but it claims to be compatible with NiMH which means in theory I can take two NiMH, wire them in series and get enough voltage to fall within the parameters of this board... of course then I have to worry about them charging evenly. I might just come out ahead getting the board and a single 18650 battery

Thanks for the input thus far, it's helped!
Dear forum: Play nice ;-)

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Providing power for intermittent power loos

Tue May 07, 2013 4:11 pm

There shouldn't be any problem with charge balancing NiMH in series. If you give 0.1C to one, then you give 0.1C to the other. And you can give them that forever without causing damage, so if one needs the full 15 hours and another doesn't, you're not going to break anything. I've done that myself with a 12V stack of C cells.

It might be worth cutting the charge current down to 0.04C. That avoids harming the life expectancy. Then maybe add a switch to override it to 0.1C for the initial charge or when it has been running off battery for more than 1/25th of the time it's been on mains power. (http://www.powerstream.com/NiMH.htm)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12416
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Providing power for intermittent power loos

Tue May 07, 2013 4:53 pm

ame wrote:I don't know how much supercaps cost.
Depends very much on the capacitance, 2,7V capacitors range from € 1,50 for 1 Farad to more than € 500,- for 3000 Farad, but to give you a pointer, a 100 Farad 2,7V capacitor is about ten euro.

BudBennett
Posts: 89
Joined: Fri May 17, 2013 2:45 pm
Location: Westcliffe, Colorado, USA

Re: Providing power for intermittent power loss

Thu May 23, 2013 6:45 pm

My Pi is controlling the heating system in my house. I need a circuit that will ride through short power glitches 1-2 secs, but also hold up the 5V input until the Pi is shutdown properly. It then needs to re-enable power (or perform a restart) once the power supply is back up. Here's the first pass of the circuit I think will probably work. It uses a LTC4425 and a LTC4411 combined with two 350F super caps. I'm trying to keep the part count as low as possible and cost is not a real concern (obviously... the 350F cap is $11 at Digikey). The 4425 will manage the supercaps and prevent damage while charging. The 4411 has an internal 150mOhm switch which will cause an immediate 100mV drop when activated, so I figure I have about 0.3V before the Pi gets into a grey area below 4.6V where it will become unstable. This circuit should hold up the supply for about 1 minute, which should get everything shutdown properly.

The 1-2 sec deglitch can be handled by software. I still haven't solved the problem of the input voltage coming back up while the Pi is in the process of shutting down. I'll probably have to toggle the reset input in that case.
Attachments
HoldUp.jpg
Hold up circuit
HoldUp.jpg (44.17 KiB) Viewed 8088 times

BudBennett
Posts: 89
Joined: Fri May 17, 2013 2:45 pm
Location: Westcliffe, Colorado, USA

Re: Providing power for intermittent power loss

Sun May 26, 2013 1:24 am

Here's the second draft of the circuit, after a lot of thought and cuddling with the data sheets for the LTC4425, LTC4411 and LTC4415. My first draft wouldn't work at all. I'm about ready to order parts from Digikey unless somebody spots a serious flaw in the design.

What this circuit does:

The RPi is powered by the 5VIN input. If 5VIN dips below 5V the 5VOUT lines is held up by the two super caps and the PowerFail signal is asserted. If 5VIN returns to 5.1V within 2 seconds then 5VOUT is again powered by 5VIN and the PowerFail signal is low. If the dropout continues for more than 2 seconds then the condition is latched and the super caps continue to power the RPi as it shuts down. When the voltage at the top of the super cap stack falls below 4.63V the 5VOUT line is disconnected and the RPi is powered down for 10 seconds. It stays in this state until power is available to 5VIN. After 5VIN is above the voltage on the super cap stack for 10 seconds the 5VOUT line is reconnected to 5VIN and the RPi boots. If power returns to 5VIN during the shutdown period then the 5VOUT line is still disconnected but is reconnected 10 seconds later and (hopefully) the RPi begins to boot.

The circuit draws about 37uA from the super caps while in shutdown. This will drain 1V from the super cap stack in about two months.

How it works:

The first time that you apply power the 4425 begins to charge the super cap stack with about 1.3A, keeping two super caps balanced. The PFOB, power fail (active low), signal is low so the 4415 diode2 is disabled while the stack charges. The 4415 STAT2_B goes high-Z, and after 10 seconds enables the 4415 diode1, which powers 5VOUT to 35mV below 5VIN. In order to supply power to both the super cap charger and the RPi you will need at least a 2A source at 5VIN. The super caps could take 15-30 minutes to charge to their 5V "float" voltage. After the super caps are charged the PFOB signal goes high, enabling the 4415 diode2. Diode2 is active but won't conduct until the voltage at 5VOUT falls below the stack voltage.

If 5VIN drops 15mv below the stack voltage diode2 automagically conducts and holds up 5VOUT. Since diode1 is not conducting the STAT1_B pin goes high and asserts the POWERFAIL signal to the RPi. The STAT2_B pin goes low to indicate that diode2 is conducting - R8/C5 provide the 2 second delay to EN1, which will disable diode1. If the voltage at 5VIN returns before diode1 is disabled then the circuit returns to normal operation, but once diode1 is disabled the power down condition is latched since there diode2 is the only source of power and STAT2_B remains low.

The super cap stack can provide power for long enough to allow the RPi to shutdown. It will keep draining the stack until the voltage reaches 92.5% of the float voltage and then PFOB goes low to indicate a power fail condition. I can't predict how long this phase might take. In my situation it doesn't matter as long as it is at least 45-60 seconds but not longer than about 10-15 minutes. This forces EN2_B high which disables diode2 and disconnects power to the RPi. This causes STAT2_B to go high-Z which re-enables diode1 after about 10 seconds.

If 5VIN is restored then diode1 conducts and pulls up the 5VOUT line, setting PowerFail low, and we're back where we started.

Why I chose this concept:

I really like the ideal diode concept. Using switches driven by comparators almost always results in oscillation with some set of conditions.

The are very few components. Fewer components generally means higher reliability. The power dissipation is trivial after the super caps have attained their float voltage. The power loss through diode1 is only 25mW! Super caps can be charged to any voltage below their rated voltage and don't have any special trickle charging, memory problems, outgassing, etc. They should last 10 years at room temp according to the manufacturers. It's a set it and forget it circuit.

Problems I expect:

The 4425 and 4415 both have an exposed pad that must be soldered to GND. I will have to experiment with methods to perform this task as I have no experience with that aspect of assembly. I might also have misinterpreted the data sheet explanation of the power fail feature or some other aspect. Breadboarding it will prove the concept. Notice that the 5VIN voltage must be above 5.1V, but below the RPi upper limit of 5.25V. I am only making one of these so either I find a charger that runs on the high side or tear one apart and alter the resistor divider that sets the output voltage to get the desired result. Alternatively, I could set the stack float voltage to 4.9V and just use the unit I have (which outputs 5.01V) but I don't know how long the stack will hold the 5VIN line above the voltage where the RPi becomes unstable in its operation.
Attachments
HoldUp2.jpg
Second draft schematic.
HoldUp2.jpg (60.22 KiB) Viewed 8055 times

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: Providing power for intermittent power loss

Thu May 30, 2013 2:25 am

May I suggest this simpler solution: Three 47.000uF 25V electrolytics, charged to 24V by some small power supply. A series regulator will provide 500mA from those caps for about 5 seconds. Total cost about $20, if you don't find the components in your garage.
Attachments
holdup5s.jpg
holdup5s.jpg (22.95 KiB) Viewed 7989 times

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Providing power for intermittent power loss

Thu Jul 18, 2013 1:57 pm

Interesting concepts. I would like to work my way back from the time the Pi needs to shutdown, and then workout the parts needed.
I'm far away from a Pi at the moment, has anybody figured out how many seconds are needed?

DaveTheWalker
Posts: 36
Joined: Wed Jul 04, 2012 9:06 pm

Re: Providing power for intermittent power loss

Thu Jul 18, 2013 3:48 pm

Just thought I'd throw in my tuppence-worth.

Trickle charging NiMHs is OK, but not really "supported" by the manufacturers. Having discussed it at length with some of the manufacturers, I can report that a charge current of C/30 will do no damage at all under most conditions.

Therefore, if you have a 2400mAh cell, you can charge it at 80mA continually.

2400mAh x 1.2V = 2.88 WattHours, which is LOADS for your application.

For a Pi running at 1 Amp (which is well above most applications) on 5V, this would last over half an hour....assuming you could boost the voltage up efficiently.

Find a step-up regulator to get from ~1.2V to 5V. Efficiencies of ~80% aren't unachievable at all.

Alternatively, simply stack 5 cells in series (they're cheap), trickle charge at 80mA and use a linear 5V regulator to drive the Pi... pretty shonky engineering but would get the job done simply! (Just a thought....in reality, I think the single-cell and boost regulator is a better option).

EDIT:- Just noticed the age of this thread. I assume it's all been designed, built, tested and commissioned by now?...

UPDATE:- I just did a "sudo shutdown now" and it took about 5 seconds to "die"...

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Providing power for intermittent power loss

Fri Jul 19, 2013 7:21 pm

I am not familiar with step-up convertors, but found two that seem to be suitable I think.

The LT1302 works with 2V in and produces 5V up to 2A max, 600mA cont. It needs 2 AA (rechargeable=2x1.2V) cells to work from.
http://cds.linear.com/docs/en/datasheet/lt1302.pdf

The LT1073 can work with 1 AA cell, and it produces 5V with 1.5 A max, 400mA cont.
http://cds.linear.com/docs/en/datasheet/1073fa.pdf

They both come in 8 pin DIL packages, easy to work with.
Is there somebody with experience on these or are there other suitable ones?

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Providing power for intermittent power loss

Sat Jul 20, 2013 8:57 pm

I've started a new post, dedicated to a controlled shutdown when power is lost.

http://www.raspberrypi.org/phpBB3/viewt ... 56#p391056

Return to “Other projects”