Energy requirement for shutdown

Hi,
I've been asked to create a "graceful powerdown" circuit for a Raspberry
Pi 3.
The idea is to detect input power failures, then request that the Pi
shutdown by (e.g.) changing the state of a GPIO, then supplying power
from (e.g.) a capacitor and a DC/DC converter until the Pi has completed
its shutdown.
That doesn't sound too hard, but I don't know how long it takes a Pi to
shutdown, and what sort of power it's using during that time.
I'm guessing a few seconds at a watt or two, for a total energy of a few
J.
Any improvement on that?
BTW, I'd measure it, but I don't actually have a Pi. I have one coming
on overnight delivery but it's been a week so far. :(
Thanks,
Allan
Reply to
Allan Herriman
Loading thread data ...
Seconds to a minute depending on what it's doing. If you're not using it, you can monitor the serial Tx pin and when it goes low, the Pi has halted.
Gordon
Reply to
Gordon Henderson
In case you don't know about them, there are a couple of people selling UPS systems specially designed for the RaspberryPi. I haven't used them, but it may pay to check them out:
formatting link
formatting link

Both are RPi expansion boards that can recharge the standby battery and/ or run off a fairly wide variety of voltages and battery chemistries.
--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie
How long is a piece of string? Your question has no set answer because it will depend on many variables. Shut down time will depend on the running software and the power consumption during that till will likewise depend on the running software.
--

Rick
Reply to
rickman
By asking the question the way I did, I found out that the shutdown time may be as long as 1 minute under certain circumstances. Thanks to Gordon Henderson for that.
This then tells me that (under certain circumstances) it might need some tens of joules rather than a few joules, which puts it outside the realm of cheap capacitor banks. Instead, I might need to use something like a NiMH cell, and the products that Martin Gregorie linked would seem to work well enough, and would (in the quantity that I want) be more cost effective than developing my own.
That said, I received my Pi 3 this afternoon, and it does seem to shut down in about two seconds (when idle). I haven't measured the current yet, but there's a chance the energy requirement is small enough to put a capacitor bank back on the cards.
Allan
Reply to
Allan Herriman
It really depends on what it is running and what that software is doing. When it is in the middle of a kernel update or has just finished one, it may have a lot of to-be-written blocks in RAM and need a minute to write them all out. Or sometimes shutdown scripts are lazily coded to do a "ask process to shutdown, wait 20 seconds" and that also lengthens the shutdown.
Ask the people who do the application. And ask them to code the shutdown in an event-driven way, not using sleep.
Reply to
Rob
A key factor in the time it takes to shut down cleanly is the amount of data still to be written to files. If you can minimise that (e.g. by frequently flushing cache or disabling write cache completely) then you may be able to reduce the time to shut down cleanly, or minimise the damage caused by power loss.
Reply to
Rob Morley
Don't have a Pi 3 specifically here either, but I suspect a capacitor driven approach is going to be unweildy even with supercaps. Using back-of-the-envelope figures of 300mA draw and 500mV permissible drop gives a capacitance of more than 0.5F per second of operation - you'll need tens of farads to make a practical circuit.
As for how long you need power for, as others have noted that varies depending on the circumstances. The only thing I have to add is that sod's law applies strongly there and shutdown may take much longer under the critical condition than it does normally: things like gracefully closing network sockets tends to be quite fast. Waiting for them to time out because the other end (or an intermediary device such as a switch) has been affected by the same power failure takes a lot longer.
The usual approach to something like this would be to use a gel cell kept on float charge and power the Pi from that via a suitable regulator. However, I'd have to look up a suitable regulator here - a 6V cell would be the natural choice and the only LDOs I have to hand here that are "low" enough are only good for 100mA or so: vanilla regulators such as 7805s need more headroom than you have.
There is a potential alternative for standby applications where you don't expect to ever actually need the power though, and that is primary batteries - commodity alkalines are available with 8 or even 10 year shelf lives. That has a couple of advantages, firstly of course you need no charging circuit, and secondly organised correctly you can get the batteries "for free" - replace them after five years and put the still-fairly-fresh old ones into general service. The initial cost of a suitable gel cell may be broadly comparable but at the end of the five years the cell is good only for recycling.
I use that approach myself at home to power a couple of small switches in locations away from where they can be powered from a "proper" UPS. It works well, but of course if you do have more than a brief power cut you need to go around afterwards replacing the batteries.
--
Andrew Smallshaw 
andrews@sdf.org
Reply to
Andrew Smallshaw
If you use a boost switching regulator and an under-voltage pack (eg 4.5v) you don't need to worry about the voltage level dropping; it'll happily squeeze so much juice out of them that the batteries run until completely flat. You do however need to handle the switchover from mains to battery - you don't want the switching regulator running when the device is mains powered.
You could also have a similar approach with NiMHs; a trickle-charge circuit isn't complicated, and you don't have to replace them after a power cut. You would have to have a low voltage cutoff on the switcher - it could easily kill them by deep discharging.
Theo
Reply to
Theo Markettos
Allan, you could use something from this range:
formatting link

The 10400 mAh version keeps a Pi going for a while.
--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor
I use one of those on my pi-driven central heating controller. It has seen it through multiple power cuts, some lasting over two hours. Highly recommended!
Reply to
Tony van der Hoff
So can the 10400mAh unit be plugged in all the time and keeping the pi running when power fails without a glitch or overcharging the batteries? I've looked at a lot of battery packs and few of them are suitable for UPS operation.
--

Rick
Reply to
rickman
It's 2016, not 1976. Switching regulators are available for pennies that solve this problem. Low cost, low noise with a 6-24V input headroom, ready to go.
Maxim will have a part for handling everything you need to detect power fail, brown outs, shutdown request, power on reset, battery isolate etc. Search their website.
Reply to
mm0fmf
It certainly works IME. Mine's been running reliably for 2 years now. I imagine it'll need replacing some time, but the battery is not showing any signs of weakening.
Reply to
Tony van der Hoff
[]
My experience is the same as Tony's - you can charge and discharge at the same time, so it performs an uninterruptable power supply function.
--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor
Of course you charge the cap to the max voltage it can handle and then regulate the cap voltage to 5v using a switching converter.
As the energy content of the cap increases with the square of the voltage, you can gain a lot this way. Commonly available buck converters can handle up to 40v, where a cap holds 64 times more energy than at 5v. (plus the fact that you can discharge it much more than 500mV this way)
Reply to
Rob
There isn't an upper limit on the time it takes. The Pi is a general-purpose computer that can run a wide range of software including buggy software that locks-up and never quits. The software you run needs to be able to identify the need for shutdown, execute a safe shutdown procedure and then signal that it is safe to turn the power off. Alternatively the provider of the shutdown procedure needs to tell you how long it takes to run. Amongst other things that depends on which model of Pi you choose.
How much power it needs while running also depends on the software it is running. If the Pi is running compute-intense or video processing tasks then it will use more juice, again depending on which model you choose.
One possibility is to use the PiUPS with a 18650 lithium cell and just run until the battery dies. Tell the software developer how long the UPS will run and rely on them to fit within that constraint.
Switching to a Pi Zero would reduce current consumption a lot. Will the Zero do the job?
--
Bernard Peek 
bap@shrdlu.com
Reply to
Bernard Peek
Also it will depend on what filing systems you have mounted, USB drives and network filing systems may take time to dismount.
---druck
Reply to
druck
That's pretty good. Like I said, most of these battery packs won't power a device while plugged in.
--

Rick
Reply to
rickman
You could, but if you're not careful this starts resembling a project in itself. SMPS chips have simplified things a lot but they are still nowhere near the drop-in-and-don't-think-about things the linear regulators are, and personally I find the finer points of inductor selection in particular always involves details I can't be bothered with, for a hobby project at least.
I'm reading this requirement as a necessary evil as part of something else rather than an end unto itself. In that light a commercial UPS can be had for £50, which will probably power the Pi and any associated equipment for at least an hour. That puts an upper limit on what it is sensible to expend in time and effort before you even consider the bill of materials. Something simple and cheap that you can take from thumbnail sketch to working prototype in at most an afternoon is the order of the day here.
I'll admit I'm certainly no expert there. There's a lot of information on battery charging up online, but a lot of it is of questionable authority, much seems to be based on rumour and speculation, and many sources contradict each other. Indeed, you don't even get the same story from different manufacturers.
Attempting to piece together the most credible material a while back I gained the impression that while charging NiCd at C/50 for ever and a day won't be an issue that approach isn't recommended for NiMH. Instead a periodic maintenance charge is advocated, e.g. C/10 for an hour a day.
But then again, that's little more than speculation on MY part, which isn't really any different to the material I've already been disparaging of, so I'm certainly always interested in any well-informed insights from authoritative sources.
Regardless of the exact technique used, though, you still have some level of intelligence needed: you at least need to detect the end of the initial or restoration charge and switch into maintenance mode, whatever that means. Again, not necessarily difficult but probably an unwelcome distraction from the main thrust of building something else. The beauty of a gel cell is the simplicity of float charging: plug it into a constant voltage source and it'll be 90% charged six hours later. You then leave it connected to that same unadjusted source for the life of the battery.
--
Andrew Smallshaw 
andrews@sdf.org
Reply to
Andrew Smallshaw

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.