The Comvette Project - diy BOSE Replacement for C4e Corvettes
Project Blog Post


Power Manager

Like most computers, the Raspberry Pi doesn't like to be shut down by having it's power cut off. If you cut the power to a Raspberry Pi you risk corrupting your operating system or other files. So, Graceful Shutdowns Are A Must!

In the early C4 Corvette, when the ignition is switched OFF, all the systems in the car are shut down. This is going to cause problems for the Raspberry Pi. So a "Power Manager" of some sort is needed to insure that the Raspberry Pi is shut down in an orderly way to avoid file corruption.

The Power Manager has access to the cars switched and unswitched power sources. By monitoring the switched power source, the Power Manager can continue to power the Raspberry Pi after the ignition has been switched OFF.

The Power Manager and the Raspberry Pi communicate back and forth via two GPIO lines. One is the "shutdown request" line and the other is the "shutdown complete" line.

  • The Power Manager can send a signal to the Raspberry Pi on the "shutdown request" GPIO line to request that the Raspberry Pi begin an orderly shutdown.

    The Raspberry Pi must be configured to run a small daemon at startup that responds to shutdown requests and executes an orderly shutdown of the Raspberry Pi.

  • The Raspberry Pi can send a signal to the Power Manager on the "shutdown complete" GPIO line to tell the Power Manager that it has successfully shutdown.

    The Raspberry Pi must be configured to send a signal to the Power Manager when it has successfully shutdown. This is accomplished by making a small modification to the Raspberry Pi's /boot/config.txt file as shown below:

    # Set GPIO pin 25 to HIGH when system is shutdown. This is used by
    # the Comvette Power Manager.

The rules that govern the Power Manager are as follows:

  • When the ignition switch enters the ACCESSORY or RUN position, the program powers-up the the Raspberry.

  • When the ignition switch enters the OFF position, the program enters a grace period wherein the Raspberry Pi remains powered-on in case the driver returns the ignition switch to the ACCESSORY or RUN position. This allows the ignition switch to transition from ACCESSORY thru OFF to RUN or vice-versa from RUN thru OFF to ACCESSORY without triggering a shutdown of the Raspberry Pi.

  • If the ignition switch re-enters the ACCESSORY or RUN state before the grace period expires, no shutdown of the Raspberry Pi is attempted.

  • If the grace period expires without the ignition switch returning to the ACCESSORY or RUN position, an attempt to shutdown the Raspberry Pi is made.

  • When a shutdown attemp is made, the program enters a shutdown period wherein the Raspberry Pi is monitored for a successful soft shutdown. If the Raspberry Pi signals that a soft shutdown is complete, the Raspberry Pi is then powered-off. A soft shutdown is always preferred over a hard shutdown.

  • If the shutdown period expires, and the Raspberry Pi has not signaled that a soft shutdown has completed, the Raspberry Pi is powered-off for a hard shutdown. A hard shutdown should be avoided but if a soft shutdown does not occur, the Raspberry Pi is powered-off to avoid draining the car battery.

Power Manager Wiring Diagram:

Power Manager Wiring Diagram

A note about the Power Manager hardware:

The Power Manager is built around an Arduino compatible Adafruit Trinket microcontroller running the Comvette Power Manager Sketch.

The Trinket is a 3.3 volt device. All signals going in or out of the Trinket's GPIO pins have to be 3.3 volts. But an automobile is a 12 volt system. This voltage mismatch has to be addressed in order for the Trinket to monitor the state of the ignition switch.

So how do we let the Trinket know when the ignition switch is in the "Run" or "Accessory" position if we can't connect a 12 volt signal to the Trinket without destroying it?

The Trinket can be powered by any voltage between 4 and 16 volts. It has an on-board regulator that will reduce the voltage down to a safe 3.3 volts. That's fantastic because we can power the Trinket directly from the car's 12 volt system. But that doesn't address the mismatch between the car's voltage and the Trinket's need for all GPIO signals be 3.3 volts.

Some mechanism is needed to lower the car's 12 volts down to a Trinket compatible 3.3 volt level. I've seen several different approaches used to achieve this using voltage regulators, zener diodes etc. I chose to take a simpler approach. The Power Manager employs a small 12 volt relay that is activated whenever the ignition switch is in the "Run" or "Accessory" postion. The relay when activated, takes 3.3 volts from the Trinket's own voltage regulator and connects it to one of the Trinket's GPIO pins. The Trinket is safely isolated from the 12 volt signal but sees 3.3 volts appear on it's GPIO pin whenever there is 12 volts applied to the relay.

The switch marked "Manual Power Control" performs the same function as the the relay. It takes 3.3 volts from the Trinket's own voltage regulator and connects it to one of the Trinket's GPIO pins. The purpose of this switch is to allow you to power-up the Comvette infotainment system without requiring the key to be in the ignition switch. This is handy if you're at a car show or cruise-in and you want to leave your car unattended with the Comvette infotainment system running but don't want to leave your key in the ignition.

Get the Comvette Power Manager Sketch


Have a question about this project? Need help? Send a message by clicking the "Contact Us" button below. I'll try and answer any questions you may have.

Contact Us

Copyright © 2017-2021 (((ECHO))) Development

Contact Us
* required fields



Captcha image
Can't read this image? Get another


Message Sent!

Thank you for contacting us. We will reply soon!