orderly shutdown of embedded server on power loss

Discussion in 'General Electronics Chat' started by halley, Dec 28, 2012.

  1. halley

    Thread Starter Member

    Dec 27, 2008
    11
    0
    Thinking about putting an embedded server (Raspberry Pi based) into the trunk or dash of a car.

    Regulating 12VDC down to 5V is not difficult, and the device will automatically go through its 10~30sec bootup sequence just fine. Most people would have no problem just killing the power and letting the device halt, but that's not a best practice. It takes up to 20sec for the system to shut down orderly, once commanded to do so. This ensures any files on the SD card have been closed properly.

    I figure I can make some kind of power cache from a small inline battery or ultracapacitor, but I need to (1) avoid interruption of power to the main unit, while (2) giving a TTL signal to the GPIO pins that reflects whether there is power available or not. A software daemon or ISR can then watch the signal change and invoke the orderly shutdown.

    What's the best kind of circuit to perform this?
     
  2. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Two diodes to combine the two power sources, and a comparator to check the voltage on the main line. Very simple and easy to accomplish.
     
    PackratKing likes this.
  3. halley

    Thread Starter Member

    Dec 27, 2008
    11
    0
    Last edited: Dec 28, 2012
  4. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    This should work. You can use for example LM393 for the comparator.
    Note the backup battery needs to have lower voltage than the main supply.
     
    Last edited: Dec 28, 2012
  5. halley

    Thread Starter Member

    Dec 27, 2008
    11
    0
    Thanks for your help, kubeek! Really appreciate it.

    I dug through my tackle box and I found a couple DIP LM393s in there... don't think I've had occasion to use them yet.
     
Loading...