logo

Could not compile stylesheet for simplistic. Using last compiled stylesheet.
Question

Detecting power supply disconnect via software

posted in IGEP BERLIN
Sunday, April 27 2014, 03:30 AM
Stefanek
Stefanek
Offline
0
Hi!

My berlin boards have the standard rechargable battery and when the external power supply is
disconnected the board continues running on battery power. When this happens I would
like to perform last "housekeeping" operations in my software and cleanly shutdown the OS.

So the question is:

Is it possible to detect the "power supply disconnect" / "running on battery power" event
via software? Maybe by monitoring some file in /sys... ?

Thank you very much!

Accepted Answer

Wednesday, April 30 2014, 11:16 AM - #permalink
0
Hi Stefanek,

I guess that your IGEP BERLIN contains an IGEP COM MODULE. IGEP COM MODULE cannot monitor power status, so I propose monitoring PWR_IN signal with INPUT4 (GPIO18):

Connect a wire cable as the image attached.

Into "/sys/class/gpio/gpio18/value" values will be:

HIGH when battery (VBAT) is used as a source
LOW when power plug (PWR_IN) is used as a source

Cheers!
Attachments:
The reply is currently minimized Show
Responses (3)
  • Accepted Answer

    Stefanek
    Stefanek
    Offline
    Saturday, May 03 2014, 07:01 AM - #permalink
    0
    This works flawlessly.
    Thank you very much :)

    Now we'd like to go a couple of steps further.

    We've noticed that issuing a "poweroff" command shuts the OS down but
    doesn't fully power-off the board: it remains "alive" on battery power
    and all the leds remain lit.

    Is there a way to fully power off the device via software?

    We would also like to be able to turn on the device when power is applied,
    without pressing the power switch. Is there a way to do so?

    Keep in mind that we supply power to the device via the PWR_IN pin you
    mentioned in your answer. Our ideal system behaviour is:

    - startup once PWR_IN power is applied, without any user intervention
    - when PWR_IN power is removed switch to battery
    - if PWR_IN comes back within a certain amount of time then
    use it and continue running
    - if PWR_IN does not come back then cleanly shutdown the system
    (and this is already working by implementing the hints you provided).

    Thank you!

    --

    Szymon
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, May 06 2014, 12:46 PM - #permalink
    0
    Hi Stefanek,

    I am testing a candidate solution. As soon as i have some news, I am going to reply
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 08 2014, 11:52 AM - #permalink
    0
    Hi Stefanek,

    I reply your questions below:

    We've noticed that issuing a "poweroff" command shuts the OS down but doesn't fully power-off the board: it remains "alive" on battery power and all the leds remain lit.
    When OS is halted, power source signals are keeping alive and ICs remain active.

    We would also like to be able to turn on the device when power is applied, without pressing the power switch. Is there a way to do so?
    Yes, but you should modify internal HW.

    Keep in mind that we supply power to the device via the PWR_IN pin you mentioned in your answer. Our ideal system behaviour is:
    I designed a HW patch that solves partially your ideal implementation, but applying this patch, you will lose the warranty.
    - startup once PWR_IN power is applied, without any user intervention
    - when PWR_IN power is removed switch to battery
    - if PWR_IN comes back within a certain amount of time then use it and continue running
    - if PWR_IN does not come back then cleanly shutdown the system (and this is already working by implementing the hints you provided).

    The main limitation is: system can bootup again until battery is fully discharged.

    I supose that you use a IGEP BERLIN RB3. This patch consists in:

    Mount R101 (0R): disable power on switch.
    Umount R124, R113 and R114; mount R118 (0R): enables 5V step-up
    Mount D1212 (1KR): force GND value when power-in is not present

    The attached diagram shows the external connectivity.

    IO:
    INPUT4 (GPIO18): read power_in external source level.
    OUT3A and OUT3B (GPIO17): control a SPDT relay to manage external power source

    Behaviour:
    - When power is applied, external relay is not active and IGEP BERLIN bootup.
    - When PWR_IN power is removed switch to battery and GPIO18 input switch to HIGH level
    - Before halt, Switch GPIO17 output to HIGH level to enable external relay. This ensures that battery is not charged when OS is halted
    - When battery is fully discharged and external power is active, system will boot up again, because external relay switch to LOW.

    I hope it helps
    Attachments:
    The reply is currently minimized Show
Your Reply

SUPPORT


This email address is being protected from spambots. You need JavaScript enabled to view it.
This email address is being protected from spambots. You need JavaScript enabled to view it.
IGEP Community Wiki
IGEP Community Forum
IGEP Community Online Chat