Forcing Shutdown At 10% Battery Life


Pleng

Well-Known Member
Joined
Dec 28, 2006
Messages
3,030
ok so I often leave my Pandora on and forget to either plug it in or power down before I go to bed. This usually leaves me in the unfortunate position of having a totally flat battery when I wake up. I'm aware that this isn't particularly good for the battery and, considering the rate the battery discharges even when turned off, I'm not convinced that the emergency reserve is really enough.

So I'd like to prevent this happening. What I guess this calls for is some kind of script that cecks the battery level every, say 30 minutes, and forces a shutdown if it finds the level below 10%.

Does anybody know how I'd go about implementing this?

cheers!
 
If I recall correctly, ED showed off a gui in one of his videos that had two low power warning settings, (ie, at 10% and then 5%, but as I recall it was adaptable).
A command could then be called when it reached this point. Assuming it's still there and you can find it, simply set your two warning points (say 15 and 10% maybe?) and set the command for the lower one to be "shutdown"
 
Rightclick the battery monitor in the tray -> properties. There should already be "sudo poweroff" as critical "action". Of course it requires sudo and thus won't run if you are not currently sudo'd.

If you don't care about possible problems with this (don't ask me, maybe someone could elaborate?), do "sudo +s /sbin/poweroff" and remove the sudo from the battery monitor. Now it should shut down properly when the configured battery level is reached. BUT WARNING WARNING WARNING: I guess if you power it up again without adding power, it will simply poweroff again once the battery monitor has loaded. ;)
 
ye the problem with these solutions is that the Pandora is going to keep shutting itself down. I suppose I could circumnavigate that by simply keeping the Pandora in the boot menu for a few minutes before booting.

Anyway I think I'm gonna have to try it, because it seems that last time the battery ran out it corrupted my firmware. Apps are currently only running when they feel like it, other apps are not running at all :( Pandora love is starting to wear a bit thin
 
So there is no timer implemented yet? Usually you have settings for shutting off backlight and initiating other power saving modes via control panel. IIRC, I saw a post about a shut down script somewhere on TMO, so it should be possible to invent something that shuts down the device after a period of time without user input.
 
Pleng said:
ye the problem with these solutions is that the Pandora is going to keep shutting itself down. I suppose I could circumnavigate that by simply keeping the Pandora in the boot menu for a few minutes before booting.
If it's plugged in, it shouldn't trigger these critical alert things. At least, I would hope it doesn't. If it does, might be wise to file a bug report.
 
Last edited by a moderator:
Should be in there already..

http://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=blob;f=deployment/etc/pandora/conf/eventmap;h=a2cf5fc6bc444509c7c3f4dd9478d9fc5c01a06b;hb=75575c6109c5ceecd99dd38e815feefcc1becb6c
23 [battery]

24 # for LED-blinking when battery gets low

25 threshold 5 # in %age; at x%, we go into blink-mode as warning

26 check_interval 90 # in seconds to check threshold; should be a high 300s

27 blink_interval 2 # frequency of blink

28 blink_duration 50000 # how long a blink lasts, in uSecs

29 shutdown_threshold 1 # battery %age we force a shutdown (to save the SD!)

30 shutdown_script /usr/pandora/scripts/op_battlow.sh

hmm, at 1% battery, try to shut down.

(I know it happens, damned thing is annoying sometimes when it does that ;)

The real question is .. if you're doing something draining (ie: overclocked + audio streaming over wifi?), then maybe shutting down at 1% is not fast enough -- ie: if the check interval is 90 seconds, maybe its run to 0% before being checked? (ie: draining realy fast!)

Options..

- change the check interval to be more frequent (ever so tiny performance hit)
- or change the %age to be higher (ie: change it to 10% say)

You can edit your conf file in /etc/pandora/conf/eventmap, or change conf searchpath and stick the file on SD (say), with SD overriding nand..

jeff
 
Thanks. 1% is far too low - the battery looses about 6% charge overnight. I've set the threshold to 10%.

The only minor problem with the script checking every 90 seconds is that I'll never be able to use that last 10% of the battery. If it was checked every 20 minutes or so then I'd be able to restart the Pandora to get the last bit of juice in an 'emergency' if I was sure I'd be able to re-charge it soon.
 
Sounds like a better solution would be to have 2 different thresholds - then you could shutdown at 20% if in low-power state, which will ensure you always have an hour or so of use if you forget to power-off.
 
The sudo poweroff NEVER requires a password because in the pandora it will automatically go through. The OS already has an exception for this particular case only.

So yes if you change the menu to sudo poweroff at 10% it will poweroff.

(If you don't believe me try it. Enter it into the terminal. It will not ask for a password and just cut off)
 
Why don't we just have a nice "turn off after X hours in low-power mode"? I mean, I don't think that I would leave my Pandora on Low-Power for more than about 3 hours without at least flicking it open once or twice.

This is just my personal tastes, btw.
 
Trouble with that, in my case is that I never use the low power mode, because it doesn't really seem to have any advantage over just closing the lid/turning off the screen. And if the low power mode really WAS as good as had been hoped in that you could leave it for a day or two without having to charge it, then I would be leaving it for much greater intervals than 3 hours.
 
1% sounds safe enough, that's 6 minutes if running in 10 hour mode, 3 if you where doing something seriously power hungry that reduced the runtime to 5 hours, so in the worst possible case it will shut down with 1.5 minutes to spare (assuming the check just misses the change to 1% on it's last run), don't forget this is on top of whatever the battery manager leaves in the pack as it's safety margin, so even in the worst case you can't run the battery totally flat, the protection circuit won't let the cell go below about 3v, so it will always have some charge, even if the Pandora behaves as if totally dead.
 
As I I loose 6% charge over 10 hours with the unit turned off completely. Therefore if I forget so switch off frequently (which I do) at night then I figure there's some real risk of damage occuring to the battery. This is why I set my cutoff to 10%.
 
yeah, I wasn't too clear there, to clarify... even if you let it run totally flat, then leave it stood for a week, or a month, in the unit, the circuit inside the battery wrapping will just disconnect the Pandora from any available power in the cell until it gets recharged, a LiPo cell CAN'T be allowed to go below it's minimum voltage, if that happens the chemistry breaks down and you get a exothermic reaction that either sets fire to the cell or causes it to "balloon" (puff up in it's wrapping), that's why the makers of the cell fit this circuit, they don't want suing if your house burns down due to an overdischarged cell, so they make sure it can't happen, or at least, so they can prove they tried to prevent it.

the same protection is in place in your Netbook/Ipod/Laptop/Phone/Camera/GPS or even cordless tool if it uses Lion/LiPo or some of the other exotic high capacity cell technologies around now, so the cell IS protected, there's hardware protection as well as the Pandoras software shutdown (actually intended to protect the OS/Filesystem from damage rather than the power source) so the cell is protected, whatever you do (short of dismantling the pack to remove the protection circuit)
 
Pleng said:
As I I loose 6% charge over 10 hours with the unit turned off completely. Therefore if I forget so switch off frequently (which I do) at night then I figure there's some real risk of damage occuring to the battery. This is why I set my cutoff to 10%.
This seems quite a high drain rate. I saw about 1% loss from full over 12 hours. (although these delta measurements can't claim better then 2% accuracy)
If anyone fancies doing any discharge measuremnts over a period of more than 12 hours, please add to the talk page on the wiki under power modes.
 
Last edited by a moderator:
>below it's minimum voltage, if that happens the chemistry breaks down and you get a
>exothermic reaction that either sets fire to the cell or causes it to "balloon" (puff up in it's wrapping)

This part mostly wrong [edit: the chemistry DOES break down ~2.6V]
See rcgroups for all the gory details, only the rc people use 'naked' lipos
Puffing is usually from overcharging, sometimes excessive draw or excessive charge rate
An overcharged lipo is quite a fire danger, a flat lipo is NOT
A lipo with 1/2 charge in a crash may catch fire
Lipos should not be vigorously rattled, no matter the charge state
Consider them somewhat fragile
LiFePO4 is a MUCH better battery. eg A123 or like (in OLPC, first wide scale use)
And yes the modelers have started changing over, like Pandora, availability is the problem
Two Months
(rc = radio control)
dave
 
Back
Top