Start Up and Shut Down Your Car PC



Start Up and Shut Down Your Car PC

Desktop and laptop computers both require some encouragement to power up and down smoothly in a vehicle.

While it's fairly easy to convert in-car power to run a computer, getting the computer to start up and shut down in the expected manner can be much more challenging.

The basic operation you are probably used to in a vehicle is that of the car radio: accessories such as the radio start up when the key is inserted and turned to the accessory or on positions and power down when the key is removed from the ignition. More recent cars have a lingering accessory feature, where the radio continues to play after the car has been turned off, until the car doors are opened.

It would have been easy to achieve this functionality with the computers of the early 1990s. The old AT power supplies (predating the modern ATX power supply specification) had a very intuitive switch on the front of the computer. If the switch was on, the computer was on. If the switch was off, the computer was off.

New motherboards make use of soft power switches that are controlled by software in order to implement power management. The front-panel switches on most computers don't actually cut power to the power supply; instead, they politely ask the motherboard to shut down or do whatever else the operating system wants. The new energy-saving features of ATX PCs enable them to sleep (go into a low-power mode) and hibernate (save the contents of memory to disk and completely shut down). What they often don't allow a computer to do is simply turn on when power is applied, and then turn off when it goes away.

Starting Up

Many computers have a "wake on power loss" feature in their BIOS settings. With this feature activated, they start back up automatically if they lose power while they were running. This feature is primarily designed for servers, where any power loss is usually accidental (due to blackouts, for instance). If, however, the computer is properly shut down through software (i.e., by choosing "shut down" in the operating system) and then power is lost and then reactivated, the computer rarely decides to power back up. This feature prevents most computers from predictably and consistently starting up when installed in a car without additional hardware to monitor the power states of the car and the computer.

A few motherboards actually do behave how we would like them to. The VIA EPIA-M motherboard [Hack #48] has the excellent feature that it will start up whenever power appears, whatever its prior state. Sadly, this board is several years old; its successors have the conventional behavior of powering up only if power was lost while the computer was on.

If you recall the first hack in this book ("Understand Car Electrical Systems" [Hack #1]), we made a PC power supply automatically turn on by shorting the green ATX wire to ground. Unfortunately, while this does turn on the power supply, and thus the hard drives and other devices, it does not make the motherboard turn onyou still have to press the power switch on the front of the computer.

Laptops have problems similar to desktop PCs. Laptops are programmed to notice and respond to the presence and absence of power, and a laptop's battery serves as a sort of built-in uninterruptible power supply (UPS). Although laptops can be set to sleep or hibernate after power is lost, when that power comes back, they don't wake upyou have to press specific keys or click the mouse.

Shutting Down

Shutting down appropriately would seem to be a simple problem. For laptops, it is: loss of power eventually results in the computer smoothly going to sleep, hibernating, or shutting down, depending on its settings. For a desktop PC, however, a sudden loss of power results in a rather violent cessation of whatever the PC was working on. PCs usually have dozens of files open while running, and if any data is being written to the hard disk or other devices when the computer loses power, this can screw up those files and may require you to run disk-repair programs to recover lost data. Occasionally, if the hard disk or other storage device is particularly unlucky, the sudden loss of power while writing can even cause hardware damage.

When applications primarily read data from the hard disk, as media player applications do, the risk of data corruption from sudden power loss is low. Also, when computers are powered off unexpectedly, they usually run a disk-fix utility when they boot up again, slowing down the boot process by several minutes. Many hackers simply disable this utility and abruptly cut power to their computers when the car turns off, without adverse effects.


The other problem with shutting down is that, unlike with car radios, you may not want your car computer to shut down just because you're leaving the car. Perhaps you're using it to send or receive data wirelessly [Hack #64] while you're parked, or you want to be able to record a radio program while you're not in the car, à la TiVo. (I'll cover this more in "Boot Your Car Computer on a Schedule" [Hack #47].)

Getting a computer to power on is not as simple as supplying it with power. For the computer to boot up, it needs to be triggered somehow, in addition to receiving power. The basic problem of starting up either a laptop or a desktop PC is to get the car to "press" the power button when the power first comes on. Similarly, when shutting down, the nice thing to do is to have the computer know that the power is going away, before it goes away.

Startup/Shutdown Controllers

Fortunately, commercial vendors have created products (with various names, such as "shutdown controller" or "power sequencer") to solve the problem of the in-car booting process. These devices all essentially do the same thing: perform a sequence of operations to control the state of a PC depending on the state of the car's power.

A company called iTuner Networks (also known as Mini-box, found at http://www.mini-box.com) created the iTuner power sequencer (ITPS). This device takes three lines in (switched 12V from car accessory, 12V always on, and ground), regulates the power to a clean 12V, and then "presses" the power switch on the computer when the car's accessory switch is turned on or off (see Figure).

The ITPS


If the car turns on, the ITPS will "press" the power switch to turn on the PC and let it start booting. When the car turns off, the power switch is hit againbut instead of immediately cutting power to the PC, the ITPS gives the PC another 45 seconds to shut down smoothly. If the computer hangs somewhere in the shutting-down process (as many user-oriented operating systems commonly do, for example by leaving up a dialog box that says "Do you want to save this document before quitting?"), the ITPS will cut the power after 45 seconds to ensure that the PC doesn't keep running and kill the car battery.

The ITPS doesn't include a power supply, but it does supply 12V to another power supply or a voltage inverter. ITPS units are relatively inexpensive (less than $40) and work extremely reliably. They draw very little power when the PC is off (around 10 mA).

The drawbacks of the ITPS are that it requires an input of over 13V (not always available with weak batteries when the car is turned off), and it can only pass about 60W (5A), so it can't be used with larger 120W or 200W power supplies. To solve these problems, Mini-box also just released their M1-ATX [Hack #42], which integrates ITPS startup controller functionality with a solid, compact 90W power supply. Improving on the ITPS, the M1-ATX has several jumpers that allow you to configure how long you want the computer to stay on after you shut down the carkey for sending and receiving data wirelessly [Hack #64].

Mpegbox (http://www.mpegbox.net) also makes a startup/shutdown controller: the microShutdown (uSDC20D), pictured in Figure. Not only does it do the standard job of turning on the car PC when the power is activated, but it has the additional benefits of measuring the automobile battery voltage and the ambient temperature inside your car PC case, and shutting down the PC if either the voltage is too low or the computer is too hot.

Mpegbox's microShutdown board


Dashwerks (http://www.dashwerks.com), makers of the Linux in-car software DashPC, also make a feature-rich startup controller board (Figure). It uses the Advanced Configuration Power Interface, or ACPI (http://www.acpi.info), to control starting up and shutting down the computer via the Wake-on-LAN connection. In addition, the unit interfaces with the serial port of the computer and communicates with software (such as DashPC or the open source Perl scripts provided at http://www.dashwerks.com/dw_dssc.php) to let the OS know when the car is on or off. The unit even allows the computer to control five other 12V devices, such as amplifiers or screens, through software.

As mentioned in "Power Your Car PC" [Hack #42], Opus Solutions makes 90W and 150W power supplies that combine power regulation and startup/shutdown control.

Carnetix (http://www.carnetix.com) makes an external power regulator and startup controller that also provides power regulation and survives engine cranking, like the Opus, but can work with any other power supply. It also has the unique feature of a delayed 12V outputthis line doesn't turn on the amplifier until after the computer is started, avoiding the loud "pop" that PCs sometimes output to the speakers when they first turn on.

Dashwerks's startup controller board


If you're using an inverter to power your car PC, you need to tie it to a switched 12V voltage source, so that it doesn't kill your battery when you're away from the car. However, if the inverter is simply connected to the ACC (on or accessory) 12V, you'll end up cutting power to your PC when the car turns off. To prevent this from happening, use a startup/shutdown controller with an inverter by wiring the 12V output of the controller to the input of the inverter. When the car power is activated, the inverter will power on; the ITPS, microShutdown, or similar unit will then activate the computer's power button.

Alternative Solutions

Most people building car PCs simply buy a startup controller, or a power supply with integrated startup control. Nonetheless, there are some circumstances where the startup controller doesn't do what you want. Here is some additional theory on computer startup and shutdown that you can use in creating a custom startup control system.

There are several things that can make a computer wake up:

  • Pressing the power switch

  • Wake-on-LAN (WOL)many PCI Ethernet cards or network cards built into motherboards can turn on a PC

  • Activity on the serial port

  • Pressing the "on" button on recent-model keyboards

  • Return of power after unexpected power loss

  • Timed wakeup based on a setting in the BIOS

To monitor all these conditions and power up successfully, the computer must have a small trickle of current, called standby power. All modern ATX power supplies provide this small 5V signal even when the computer is "off." (For more on standby power, see "Boot Your Car Computer on a Schedule" [Hack #47].)

4.1 Switches and long wires.

The simplest way to rig up your car computer is to run a switch to the dashboard and manually hit this power switch to power up the PC. You could even run the power switch, the reset switch, and the power LED and hard disk LED wires to the dashboard, drill small holes for them, and mount them in the dash. This technique requires long wires but the least amount of inventiveness, and it's a straightforward way to get things going.

If you are running wires to a laptop located under the seat or in the trunk, you need to find a way to remotely power the laptop. If you don't mind voiding your laptop's warranty (since you're reading this book, you probably don't), you can solder a pair of wires to its power button.

Take-apart instructions vary for any laptop, but once you have exposed the power switch, you can solder a pair of wires to the existing switch. You can then either run the wires through an existing hole or slot in your laptop, or poke a new small hole in the plastic casing. Since this is a small switch with probably only 1V going through it, you can use fairly thin wires (such as phone cord), run them to the dash, and hook them up with another switch installed in your dash, as shown in Figure.

4.2 Relay circuits.

Ideally, a car computer should act just like a car radioit should automatically turn on and off with the car, and be ready to use shortly after you start the vehicle without you having to press a power switch.

The first hack I ever came up with for automatic startup and shutdown was a relay circuit. Relays are simple voltage-activated switches used to isolate one power system from another. They don't take much circuit-building skill to use. If you look up the specifications of a Wake-on-LAN (WOL) header (the pins sticking up from the motherboard) in your motherboard manual, you will see that it is made up of pins for 5V, ground, and WOL. To get your computer to wake up, you simply have to connect the 5V and WOL pins for a moment (for this to work, WOL must also be enabled in the computer BIOS).

A small dashboard switch


For my hack, I used two relays. One relay was connected to the accessory 12V of the vehicle; it closed one switch and opened another whenever the car was on. The other relay was connected to the 12V of the computer power supply; it closed one switch and opened another whenever the computer was on.

I rigged up the two relays in sequence, so that the 5V pin connected to the WOL pin only when the car's accessory 12V was on and the computer was off. In other words, WOL is off when the car's 12V is off and when the computer is already on, but if the computer is off and the car is on, WOL will be triggered until the computer switches on (which activates the second relay, turning WOL off again).

One of the attributes of this solution is that it always keeps the computer on when the car is on. If you manually shut down the computer (i.e., choose "shut down" from an OS menu), it will dutifully shut down, and then the relay circuit will dutifully turn it back on.

This relay circuit is crude, but it works, and it only costs around $10 to build with Radio Shack parts. After I discovered the next solution, however, I stopped using this reliable but complex relay circuit.

4.3 Capacitors.

After six months of using the above relay solution, my friend pointed out an elegant solution that made me smack my forehead.

Capacitors are small, cylinder-shaped electronic devices that hold a voltage for a short time. Large capacitors can be used to keep your voltage levels stable [Hack #8], but this hack uses a tiny capacitor to create the effect of a momentary button press.

Capacitors work by filling up with electricity (up to their capacity, measured in farads) until they match the voltage that's being fed to them. They don't let any voltage pass through; they only fill up. Normally, when you press the power switch that connects to a motherboard, you are shorting (connecting) the power switch pins on the motherboard, which causes a voltage on one pin to travel to the other pin.

If you put a capacitor across these pins, as in Figure, when the motherboard first gets standby power (the trickle of 5V power from the power supply when the computer is off but plugged into a wall socket), the power switch will also have power. The capacitor will start to fill up, and during this filling period the other power pin will feel a surge in voltage, turning on the computer. Once the capacitor is filled (within a second or less) it doesn't change the voltage, so the computer will remain on until it is manually shut down or the power to the unit is cut.

In my experience, a 10uF capacitor works well with the EPIA M2 motherboards. Increasing that number increases the length of time for which the button is "pushed"; you may need to experiment with a couple of different capacitors for your particular motherboard. The capacitor has a little + and - diagram on its label, and these should correspond to the + and - pins on the power header on the motherboard.

This capacitor trick can be used for other soft power devices, too. For instance, some video displays have power switches and don't automatically turn on when power is supplied. To solve this problem, you simply solder a capacitor across the power switch. Now, instead of having to hit the switch, the unit will always turn on when it receives power.

4.4 Shutting down.

Although both the relay and capacitor solutions get the computer turned on, you also need some way to turn it off.

Manually powering down in software is one approach. If you choose "shut down" in your OS, the computer will turn off. If you used a capacitor to power up, it won't power on again until you turn the car off and on again. If you used a relay circuit and the car is still running, the computer will shut down and the WOL relays will cause it to power right back up, as mentioned earlier.

A 10uF capacitor acting as a power switch


However, depending on the driver to manually shut down the computer every time is a recipe for a dead battery. A more automatic solution is to use your OS's energy-saving features. Most OSs have a control panel where you can tell the computer to shut down after a set period of inactivity. If you set it for 30 minutes, the computer should usually shut down (or hibernate) about 30 minutes after you leave the car.

Yet another option is the simple hack I did for some versions of my company's (http://www.carbotpc.com) in-car computers. I wanted the ability to let our software determine when to shut down the computer, based on whether it was done downloading email or software from the house when the driver parked at the house at the end of the day.

I used a "car is on" relaysimply the ACC 12V and ground across a relay to tell the computer whether or not the car was on. Many small motherboards have one serial port on the back and another as a header on the board itself. In my hack, I ran pin 1 (the carrier detect, or CD, pin, usually used to notify the computer if a modem is online) through the relay switch to pin 4 (the data terminal ready, or DTR, pin, usually used to tell the modem the computer is ready). Since my motherboard has COM2 (the second serial port) on the inside, my software can simply open COM2 and monitor the CD line. If it's up, then the car's ACC 12V must be on, and our software doesn't shut down. If it goes down, our software knows the car is off; if it's off for long enough, and if all software updates and email downloads are finished, the software shuts down the computer.