Battery backup and automatic shutdown and startup
#1
Hi,

I did a quick search of the forum but didn't find anything that touched directly on this topic, but if I missed it, point me to the existing posts. 

I know the Pine64 has a built-in battery charging circuit and if I read the specs correctly, should be able to run off the battery, at least for a short amount of time.  I'm looking at developing a system where occasionally the power will flicker, and I want to have battery backup to keep it running through the bumps but if the power shuts down for longer than a certain amount of time I'd like to shut the unit down cleanly, and then when power is restored boot back up again.  For the Raspberry Pi, modmypi sells a little integrated UPS unit that about does what I want.  Could something similar be set up for the Pine64?  At the moment I'm just looking at the options and the Pine64 is a very attractive.

thanks.

Michael
#2
(05-04-2016, 09:08 PM)caseih Wrote: Hi,

I did a quick search of the forum but didn't find anything that touched directly on this topic, but if I missed it, point me to the existing posts. 

I know the Pine64 has a built-in battery charging circuit and if I read the specs correctly, should be able to run off the battery, at least for a short amount of time.  I'm looking at developing a system where occasionally the power will flicker, and I want to have battery backup to keep it running through the bumps but if the power shuts down for longer than a certain amount of time I'd like to shut the unit down cleanly, and then when power is restored boot back up again.  For the Raspberry Pi, modmypi sells a little integrated UPS unit that about does what I want.  Could something similar be set up for the Pine64?  At the moment I'm just looking at the options and the Pine64 is a very attractive.

thanks.

Michael
No need UPS, just attach a 3.7V Lithium Battery to Pine A64 board.
#3
(05-05-2016, 12:54 AM)tllim Wrote: No need UPS, just attach a 3.7V Lithium Battery to Pine A64 board.

tllim, is there anything one can access in software from linux gpio, i2c  etc that one can tell from software if the pine is powered by battery or DC in?
#4
Right. I know it can run off battery. That's not was I was asking about.

I need to know if the Pine is powered from battery, and if so, I need to initiate a complete shutdown after a certain amount of time, and then when power is restored, boot back up again.

To summarize. Is it possible to:
1. detect in software if running on battery so I can halt the system
2. completely power down the pine from software
3. turn on when power returns

I realize I could theoretically install a big battery, but I actually want the ability to shut it down by pulling the power for a long period of time (say 20 to 30 seconds).
#5
(05-05-2016, 06:59 AM)caseih Wrote: 1. detect in software if running on battery so I can halt the system
2. completely power down the pine from software
3. turn on when power returns

I realize I could theoretically install a big battery, but I actually want the ability to shut it down by pulling the power for a long period of time (say 20 to 30 seconds).

Sure. There's the PMU, you can use the arisc mailbox interface to talk to it (might require that you write the appropriate driver before). Then you can read out all the values/states you're interested in. Rule of thumb: the older the SoC the better software support. See here for 4 year old combination of A20/AXP209. So maybe come back next year or in 2018.

Powering down by software is simply shutting down the OS when reaching critical battery voltage (you're most probably not able to readout now unless you write the driver). And powering up is done when re-insert 5V through Euler pins 4 and 6.

HTH!
#6
(05-05-2016, 06:59 AM)caseih Wrote: Right.  I know it can run off battery.  That's not was I was asking about.  

I need to know if the Pine is powered from battery, and if so, I need to initiate a complete shutdown after a certain amount of time, and then when power is restored, boot back up again.

To summarize.  Is it possible to:
1. detect in software if running on battery so I can halt the system
2. completely power down the pine from software
3. turn on when power returns

I realize I could theoretically install a big battery, but I actually want the ability to shut it down by pulling the power for a long period of time (say 20 to 30 seconds).

Even though tllim hasnt had time to get back to us, perusing the boot log from my pine shows me a few noteworthy things. 

Code:
no battery, limit to dc
no battery exist
usbcore: registered new interface driver ums-usbat
The first two are early in boot, I believe before the kernel starts while in u-boot. The last one is well into linux starting but I am unsure if it is what it sounds like.

First is from u-boot-pine64/board/sunxi/common/power_probe.c

Second is from u-boot-pine64/board/sunxi/common/power_check.c
#7
So it seems like while the capabilities are theoretically there, there's probably not yet a good way to do this in the software, which is a common problem with all these proprietary ARM SoCs.

I'm thinking the best way to proceed is probably to do power management separate from the Pine (or Pi or whatever)  Maybe another microcontroller can monitor power, and signal the pine when power goes away so Pine will do a proper software shutdown, and then the microcontroller can cut the power entirely to the board until mains returns, after which it would power the Pine back on.

Question for anyone that knows. Can the Pine64 be powered from the 5v pin exposed in the Pi-compatible expansion port?  If so then the Pico UPS that has already been developed for use with the Pi should work with the Pine64.  That would give me the software link I need.

Anyway I think I'll pick up a Pine64 to play with in the meantime. 

thanks.

Michael
#8
tllim, no idea about my questions? When booted into linux or android is there any way via software to tell which type of power the pine is running on?
#9
(05-08-2016, 09:54 PM)rahlquist Wrote: tllim, no idea about my questions? When booted into linux or android is there any way via software to tell which type of power the pine is running on?

There is way but I have not resource to explore.
#10
(05-09-2016, 08:55 AM)tllim Wrote:
(05-08-2016, 09:54 PM)rahlquist Wrote: tllim, no idea about my questions? When booted into linux or android is there any way via software to tell which type of power the pine is running on?

There is way but I have not resource to explore.

Thats fine tllim just so long as I know there is a way I will look into it and see if I can figure it out. You keep doing other things that are more urgent like shipping boards and smoothing ruffled feathers.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Anyone know can play how long the LITHIUM BATTERY CASING? joe 4 3,012 03-06-2017, 12:01 PM
Last Post: xalius
  Battery and the PlayBox JoeHz 6 4,143 09-13-2016, 12:18 AM
Last Post: gperez1234
  Startup Woes abasel 9 6,327 07-28-2016, 06:34 AM
Last Post: z4v4l
  Photo data backup Jimmy Chiau 7 3,653 01-29-2016, 09:35 PM
Last Post: Jimmy Chiau

Forum Jump:


Users browsing this thread: 1 Guest(s)