Carpc project - power supplies

 http://pacmans-revenge.blogspot.com/2018/04/carpc-project-power-supplies.html?m=1

Monday, April 16, 2018

Carpc project - power supplies

I recently uploaded a new video to show my custom-made carpc based on a Raspberry Pi. In the video, I had to leave a lot of information out for the sake of runtime, so, I decided to write a little series of posts to explore thoughts and ideas about this project.

This episode is about power supplies.

Disclaimer (sort of):
Be aware that this post is not self-contained. If you haven't seen the video, you probably won't get much out of this reading. Also, this is not a tutorial on how to build a carpc like the one I made. For that, I'd need much more time and space. I just want to document the thought process behind a few hardware and software choices, share some techno-ramblings, and provide you with some links to get you started using the components I used.

Have you ever modified your car with custom electronics? Are you planning to hack a Raspberry Pi into a device that was not intended to be modified? Have you ever started a simple project (such as adding music to your car), and somehow turned it into a huge, titanic undertaking?

Power supplies

 

Here's another potential deal breaker of the entire project. The carpc needs power, and the only source of power in the car is the battery. If power were the only issue here, I could do like everyone else and connect the carpc to the cigarette lighter. The issue is that the carpc would turn off abruptly when the engine stops, and that can damage my file system in the long run. I also doubt that the cigarette lighter is regulated, so I expect the voltage to fluctuate wildly around 12V, and spike up to 30V when the engine stops.

Not good.

In the end, I want to achieve four things:
  1. I want the carpc to power on automatically when the engine starts.
  2. I want the carpc to power off gracefully when the engine stops. This means closing all files and resources, and issue a shutdown from the OS, rather than pulling the plug.
  3. I want the carpc to be protected from the wild swings and spikes of the car battery voltage. The Pi should see a clean, regulated 5V at all times.
  4. I want to prevent the carpc from deep-discharging my battery, if I forget it on, or by means of electrical leakage across a long period of inactivity.
Mausberry Circuits' 2A car switch.
I was lucky enough to stumble on the perfect component for my needs: a 2A car switch from Mausberry Circuits. Unfortunately, the part is no longer available on their website, and it has been replaced by more capable units sustaining 3A of current.

The unit is essentially a DC-DC regulator stepping down the 12V DC of the car battery to a 5V DC usable by the Raspberry Pi. The device also contains a pre-programmed microcontroller that monitors the engine ignition line. When the engine starts, the microcontroller activates the regulator and powers on the Pi. The microcontroller communicates to the Pi using two GPIOs. One of them is asserted by the microcontroller when the engine stops. A shell script running on the Pi (provided by Mausberry Circuits) monitors this GPIO, and responds to the signal activation by closing all open files and shutting down the computer in a clean fashion. At that point, the microcontroller starts polling the other GPIO to determine when the Pi has finally shut off, and then disconnect the power entirely. This little board is well designed, and helps in protecting the Raspberry Pi against power surges, and the battery against deep discharges.

The example script provided by Mausberry Circuits simply shuts the Pi off. I modified the script to perform few additional operations. In particular, the script stalls the shutdown and attempts to connect to my own network via WiFi. If successful, it will attempt to synchronize the media USB key with the designated folder in my media server.

This means that I will be able to change the music and videos in my car simply by copying files to a folder in my home media server, and my car will automatically update itself every night when I hit home.

I hope I won't regret rushing to buy the 2A version. By my calculations, the system should burn approximately 1.8A at full steam, including the screen at full brightness. I'll let you know if it works.

UPDATE: It works!

Have fun,
Kradion.

Comments

Popular posts from this blog

A Short Guide To Metric Nuts and Bolts

CAN Bus Wiring Diagram, a Basics Tutorial

Best Free CFD Tutorial: FreeCAD Openfoam CFD Workbench