reesim06
Posts: 7
Joined: Tue Sep 02, 2014 6:19 pm

Car PC on/off using GPIO

Tue Sep 02, 2014 6:41 pm

I'm running a B+ in my car which is powered by an m1-atx dc-dc psu as per this manual: http://www.mp3car.com/products/M1-ATX/M1-ATX-guide.pdf

At the moment everything turns on with the central locking opening and turns off 30 minutes after ignition-off. The car goes into hibernation at this point and almost all power is removed to save the battery.

I'd like to run the Pi on the 5v standby line from the PSU. Ignition-on signal sent to the PSU would then be sent to GPIO and the PSU-on signal would be sent to the PSU to turn it on fully.

Ignition-off would be sent to GPIO which would shutdown the Pi nicely but leave the PSU running till the cars hibernation kicks in.

I've seen the mausberry circuits and would probably invest were it not for them being out of stock.

Any thoughts or experience around? I've never done any coding for the GPIO but pretty good at re-engineering other code for my own use.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 12:32 am

Reading between the lines, I think you're saying that you've got a separate CarPC powered by this ATX PSU, and you merely want the Pi to act as an 'interface' between your car's ignition signals and the ATX PSU?
Because a whole ATX-capability PSU is obviously over-specced for running just the Pi (a simple cigar-lighter -> USB phone charger would do the job).

I assume you read the bit about "No matter how big your battery is, it will eventually drain your battery in a matter of days." ? Even though the Pi is low power, it still isn't 'free' of battery-drain ;)
reesim06 wrote:Any thoughts or experience around? I've never done any coding for the GPIO but pretty good at re-engineering other code for my own use.
There's sample code which you might be able to adapt at https://www.pi-supply.com/pi-supply-swi ... -examples/ and lots of other GPIO tutorials at http://raspi.tv/rpi-gpio

reesim06
Posts: 7
Joined: Tue Sep 02, 2014 6:19 pm

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 8:26 am

There's no PC connected, just the Pi plus a bunch of other stuff powered off the PSU (touchscreen, USB charging sockets etc).

Basically i'm trying to shutdown the Pi nicely so that no damage is done by the instant-off that will occur with using the hibernation mode and/or a lighter-socket adaptor.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 9:26 am

When I made my car PC, many years ago, I used a PIC microcontroller to handle an LCD module and keypad, and to monitor the ignition.

The PC was connected to the battery, and its PSU had a single control line toturn it on and off. The pPIC was also connected to the battery, and was always 'on', but it consumed very little power.

The PIC monitored the ignition line and turned the PC on and off as follows:

When the ignition came on, turn on the PC. Keep the PC on for at least one minute, even if the ignition turns off again. This allowed the PC plenty of time to boot.

When the ignition turned off, send a special character to the PC serial port to indicate power will be cut. Do this continuously for 1 minute, then cut the power. This gives the PC plenty of time to detect at least one character then shutdown cleanly.

The serial port on the PIC was two-way. Characters sent from the PC where displayed on the LCD. Keypresses on the keypad were sent to the PC to cause some action. The special shutdown character could not be generated by the keypad.

reesim06
Posts: 7
Joined: Tue Sep 02, 2014 6:19 pm

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 10:12 am

Essentially, that functionality is a capability of the M1-ATX PSU i'm using. It has an ignition line which will then give power-on/power-off signals through the normal "PC" switching setup.

But this isn't completely compatible with the Pi, so I need to (in my head) use the GPIO to replicate the power switch on-off functionality of a PC to shutdown the Pi nicely rather than just ripping the power out.

First thing I need to research is the PC-on/PC-off signals from the PSU to check if it's a momentary signal or a signal/no-signal situation. Then I can use the signal or falling edge to call a Raspbian/BMC shutdown script.

fruitoftheloom
Posts: 23132
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 10:21 am

Rather than negativity think outside the box !
RPi 4B 4GB (SSD Boot)..
Asus ChromeBox 3 Celeron is my other computer...

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 10:31 am

Ah! Got it.

I just read the manual here:
http://www.mini-itx.com/store/informati ... manual.pdf

My guess is that you should choose option 1, and hook up the M1-ATX power output line to the Pi, then connect J6 or J8 to a GPIO (maybe with an opto-isolator or at least a level-shifter). Then, write a program to monitor that GPIO. If it goes low then you should issue a shutdown command, and you have 45 seconds before the power is cut.

...is my interpretation of the situation.

Edit: Ah, you have the same manual. Yes, you need to know if J6/J8 are momentary or continuous signals.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 10:40 am

You might be able to monitor J2. It's for controlling an amplifier, but it might turn on and off at desirable times.

reesim06
Posts: 7
Joined: Tue Sep 02, 2014 6:19 pm

Re: Car PC on/off using GPIO

Wed Sep 03, 2014 12:32 pm

Cheers gents, will be on the multimeter this evening to check and reply just in case anyone is in a similar state.

I have a feeling it's not really required and instant on/off won't do any damage. But there's functionality in there that might be useful with peripherals.

Return to “General discussion”