Wiring Arduino to car 12v - 14.4v

Hi, I’m wanting to wire my arduino Mega into my car and i have a few questions.

I have a DC - DC step down buck converter (See attachments for image) comprising of a LM2596s IC so the plan was to wire that in set to around 9v when car is running.

Question A) Will this alone be enough to power/protect the arduino or will i need some other components to filter out any spikes that may occur etc.

Question B) I’m wanting to use a few pins on the arduino as inputs and one of them is for the handbrake. The handbrake when off is open circuit and when on the handbrake wire is connected to ground. If i have the buck converter wired to power the arduino can i directly wire the handbrake wire to an input pin and do an INPUT_PULLUP? or will i need to run the ground wire through a form of step down.

Essentially the wiring would be like this:

(12v +) ----------------- (Buck Converter +ve IN)
(12v - ) ----------------- (Buck Converter -ve IN)
(12v - ) ----------------- Pin 10
(Buck Converter +ve OUT) --------------- (Arduino VCC in)
(Buck COnverter -ve OUT)----------------(Arduino GND)

I’m having a blank and cant work out if there would be an issue with using the car 12v ground to connect with the arduino directly after the VCC on arduino is being determined by the Buck Converter.

Please let me know if there is an issue and how i can overcome this.

Cheers

i need some other components to filter out any spikes that may occur etc.

Yes, you can expect spikes of well over 100V, and possible polarity reversals. Many automotive protection circuits use a TVS diode, as in (B):

See http://www.eetimes.com/document.asp?doc_id=1279734

I use the 1.5KE series, which can handle about 1.5 kW and cost less than $1.

can i directly wire the handbrake wire to an input pin and do an INPUT_PULLUP?

Maybe, but ground loops and radiative electrical interference can be serious problems. At the very least use shielded cable for the lead.

jremington: Yes, you can expect spikes of well over 100V, and possible polarity reversals. Many automotive protection circuits use a TVS diode, as in (B):

See http://www.eetimes.com/document.asp?doc_id=1279734

I use the 1.5KE series, which can handle about 1.5 kW and cost less than $1.

Perfect i will get some tvs diodes tomorrow

jremington: Maybe, but ground loops and radiative electrical interference can be serious problems. At the very least use shielded cable for the lead.

Any ideas on how to wire the handbrake wire to the arduino safely? or any switch for that matter coming from the car's ground to use as an input on the arduino?

I forgot to mention it wont be wired directly to battery will be wired to Accessory (When starter motor is cranking power will be off and only come back when car released )

Is there a way to use the car chassis ground as inputs on arduino or would i have to run a wire from arduino ground all the way to switch all the way back to arduino pin?

Car electrics are indeed notoriously "dirty". Hence all the protection circuits in place. Keep it completely isolated.

For your handbrake, you may use a mechanical microswitch that is triggered by the handbrake. Alternatively attach a small magnet to the handbrake, and have it trigger a hall effect sensor or reed switch.

For your buck converter, I understand it's output can be regulated, and you want to connect it to the Vin of the Arduino (and let the on-board regulator take care of the 5V level). In that case, you better dial it down to about 7V, then the regulator has less voltage to drop, produces less heat, and makes the whole thing more reliable (less risk of the regulator overheating). Also do add a pretty big capacitor to the regulator output (maybe even the input? But there you have the voltage spike issue?) to bridge power supply dips.

wvmarle:
Car electrics are indeed notoriously “dirty”. Hence all the protection circuits in place. Keep it completely isolated.

For your handbrake, you may use a mechanical microswitch that is triggered by the handbrake. Alternatively attach a small magnet to the handbrake, and have it trigger a hall effect sensor or reed switch.

For your buck converter, I understand it’s output can be regulated, and you want to connect it to the Vin of the Arduino (and let the on-board regulator take care of the 5V level). In that case, you better dial it down to about 7V, then the regulator has less voltage to drop, produces less heat, and makes the whole thing more reliable (less risk of the regulator overheating). Also do add a pretty big capacitor to the regulator output (maybe even the input? But there you have the voltage spike issue?) to bridge power supply dips.

My car has a handbrake switch in it thats what ive tested and its open when disenganged and closed to ground when engaged.

I’m wondering can i connect ground directly to arduino pins or is it possible to cause issues. i dont want to have to run a wire from arduino ground pin all the way 5m to the front of the car to a whole new switch then all the way back another 5m to pin 10 if i dont have to. or even if i put a whole new switch in can i run it from car ground to arduino? or any switch for that matter?

I will regulate the buck converter to around 7v but dont know if car is off then it will be seeing 12v in on converter if car is running it will be seeing 14.4v on converter so im assuming output will change so was going to do 7v when not running and see if it goes up to maybe 9 or so when running seeing as recommended output for mega is 7-12v?

wvmarle: Also do add a pretty big capacitor to the regulator output (maybe even the input? But there you have the voltage spike issue?) to bridge power supply dips.

and i think the converter has caps on the input and output for this? I uploaded a pic of the same one on the first post

darcy_d: My car has a handbrake switch in it thats what ive tested and its open when disenganged and closed to ground when engaged.

I'm wondering can i connect ground directly to arduino pins or is it possible to cause issues. i dont want to have to run a wire from arduino ground pin all the way 5m to the front of the car to a whole new switch then all the way back another 5m to pin 10 if i dont have to. or even if i put a whole new switch in can i run it from car ground to arduino? or any switch for that matter?

Maybe you can read the handbrake switch through an optocoupler. That way you can keep your Arduino safely isolated from the car electrics and its voltage spikes, without the need of additional wiring.

I will regulate the buck converter to around 7v but dont know if car is off then it will be seeing 12v in on converter if car is running it will be seeing 14.4v on converter so im assuming output will change so was going to do 7v when not running and see if it goes up to maybe 9 or so when running seeing as recommended output for mega is 7-12v?

Doesn't take much to find that out, does it? Connect it to a variable power supply and measure the output at various input voltages. A properly regulated converter produces the same output regardless of the input voltage (which, depending on the circuit, may even be lower than the output voltage) - subject to the converter's limits of course.

darcy_d:
and i think the converter has caps on the input and output for this? I uploaded a pic of the same one on the first post

Ah, missed it. Better post it inline:
4270fab7916ab10b53a4764ea8303c32ab1668d5.jpg

Anyway, that are just HF bypass caps. Very useful, but they don’t do anything to bridge dips.

I was more thinking in line of a 220-470 uF electrolytic or tantalum cap - both sides, if safe to do on the input, input side is actually better as it can much longer supply a sufficient voltage to the converter to do its job, but spikes can kill a capacitor. Electrolytic should be safer for use on the input side. Both types are fine on the output side.

wvmarle:
Maybe you can read the handbrake switch through an optocoupler. That way you can keep your Arduino safely isolated from the car electrics and its voltage spikes, without the need of additional wiring.

I’ll look into that what would be benefit of optocoupler vs transistor? Never used an optocoupler before

wvmarle:
Doesn’t take much to find that out, does it?
Connect it to a variable power supply and measure the output at various input voltages. A properly regulated converter produces the same output regardless of the input voltage (which, depending on the circuit, may even be lower than the output voltage) - subject to the converter’s limits of course.

No it doesnt at all and that wasnt really an issue i can easily resolve that depending on how it performs. i dont have any of that with me right now as its at my shed which ill be going there tomorrow but my shed is over an hour away and no shops around so wanting to organise all the stuff i need today so i can work on it tomorrow.

wvmarle:
Ah, missed it. Better post it inline:

Anyway, that are just HF bypass caps. Very useful, but they don’t do anything to bridge dips.

I was more thinking in line of a 220-470 uF electrolytic or tantalum cap - both sides, if safe to do on the input, input side is actually better as it can much longer supply a sufficient voltage to the converter to do its job, but spikes can kill a capacitor. Electrolytic should be safer for use on the input side. Both types are fine on the output side.

Ah sorry, My mistake.

Ahh got you now no worries ill get a few of those as well

darcy_d: I'll look into that what would be benefit of optocoupler vs transistor? Never used an optocoupler before

Read this. The advantage is that there is NO electric connection between your Arduino and the switch, it's fully isolated. Any voltage spike that comes in over the car chassis will have no effect. You may need to add additional protection as described above to this part as well, though LEDs can handle spikes quite well. Don't forget the current limiting resistor on the LED side. The output side can be wired as you would a regular switch: between input pin and Arduino GND, enable input_pullup. Make sure it's wired in the correct direction.

wvmarle:
Read this.
The advantage is that there is NO electric connection between your Arduino and the switch, it’s fully isolated. Any voltage spike that comes in over the car chassis will have no effect. You may need to add additional protection as described above to this part as well, though LEDs can handle spikes quite well. Don’t forget the current limiting resistor on the LED side.
The output side can be wired as you would a regular switch: between input pin and Arduino GND, enable input_pullup. Make sure it’s wired in the correct direction.

Ah of course didnt give that a thought due to both sides independent got you now i was thinking in my head they both achieve the same thing not actually how it achieves it. That seems like a good way to go. Thanks for that!

Sorry having an off day today not all there haha. Thanks for your help

No worries :-) Can't know everything.

For your capacitors: those silver things on the PCB may actually be those input and output capacitors. Markings are a bit ambiguous, though. I guess 100 uF, 50V on the input side, 220 uF, 35V on the output side. Try and dig up more info on your converter board to make sure.

(a quick Google search on "100 50V RVT" later...)

Yes, that are capacitors. Aluminium electrolytic type. 100 uF resp. 220 uF. So that's taken care of.

wvmarle: No worries :-) Can't know everything.

For your capacitors: those silver things on the PCB may actually be those input and output capacitors. Markings are a bit ambiguous, though. I guess 100 uF, 50V on the input side, 220 uF, 35V on the output side. Try and dig up more info on your converter board to make sure.

Haha yeah i know basics - moderate electronics and some advanced electronics but havent done a huge amount on this sort of thing really fine delicate signals etc only done a few electronics causes through mechanical engineering at uni and a little beyond that but we're all learning i guess. A day you don't learn something is a day wasted right? haha.

Yeah good old chinese lack of info haha

wvmarle: (a quick Google search on "100 50V RVT" later...)

Yes, that are capacitors. Aluminium electrolytic type. 100 uF resp. 220 uF. So that's taken care of.

Perfect So a few diodes and some optocouplers later and i should be sweet :D

Thanks for your help

Why complicate things.

INTP: Why complicate things.

It's getting hardwired in the boot and it's a stand alone thing plug power in and done looking to do it properly

Although I guess I could pull one apart and wire the contacts to 12v and output on ish to arduino directly

darcy_d: Although I guess I could pull one apart and wire the contacts to 12v and output on ish to arduino directly

In which case you still need to add your protection circuits and all... This is normally sold as phone charger, for that application short power glitches are not an issue. So in the end more work and possibly more cost than the buck converter.