12v car supply wrecking havok on Arduino Mega/LCD module

I have a genuine Arduino Mega 2560 that is using 12volts from a car battery (regulated) down to 5 volts.

On the same car battery there is another circuit that shares NOTHING in common with mine except source voltage, how ever this circuit controls a large electric fan and relay. When that fan kicks on, everything is all good but when it cuts off, MY Arduino and LCD display garbage and sometimes the controller is stuck in a random state.

So my first thought is fly-back inductance from the fan? well the fan has the zener diode built in along with the relay it is using also has the protection build in. (think when the cars ECU cuts the electric fans on in a car. cause this is the scenario). Ive tried putting a capacitor on the power rails of my breadboard to filter spikes and a/c, no dice. My eventual plan was to have my relay module control the bigger relay for the fan, however even sending ground THROUGH the relay on my circuit without actually hooking the module up to my board, causes garbage.

Its also random, as in sometimes the fan kicking on and off has no effect and then on the 12th time, BAM garbage and stuck state.

I have tried with the vehicle engine not running and with it running.

I have also tried different fans to perhaps see if the internal protect circuitry in the fan is no good. No dice.

I have tried different relays on BOTH sides, and no dice.

Id honestly be okay with my micro-controller not controlling the fan at all, however even with it completely disconnect from EVERYTHING IN THE VEHICLE except power, it still does it.

I don't understand whats going on, Can someome please help me? As every time the fan is cutting off I feel like its a voltage spike then hard drop. I wish I had a scope here as this could easily help identify the problem.

Also just found out my arduino mega is fried, and I have worked with micro-controllers all of my life. This is the 3rd time using an "arduino" brand microcontroller. Is there some kind of sensitivity or shift-register im not aware of? I have another one I am going to reattach the screen to try again.

I am at a loss and really want to use an arduino for my customer instead of PIC (moral reasons).

NOTE: THIS BEHAVIOR IS NOT EXPERIENCED WITH THE SAME LCD MODULE BUT INSTEAD POWERED BY A pic24HJ64GP502 micro-controller

This is likely to be electrical interference , but seeing your circuit would help.

For car stuff you need to be careful of how inputs and outputs are wired, and build a power supply front end that helps reduced noise .

I have used things such as a diode ( polarity protection) feeding 100uF in parallel with .1 ceramic , 9v (7809) . regulator followed by capacitors again, then into Vin.

A fly in the ointment here is the bit about the fan - worth a flyback diode across and across the coil of any relay your Arduino is switching it with - need your circuits again!

Digital inputs/outputs ideally need optical Isolation or relays , analog in with capacitive filtering, maybe protection diodes ( use internal reference for more headroom protection, as the input is still protected upto 5v). Don’t power anything using the Arduino 5v output . Be careful off routing cables and earthing .

It is easy to kill the processor by feeding a spike of higher voltage onto any pin - this is not just an Arduino problem, it’s universal.

Obviously a power issue.

Big fan, big inductive load, big power spikes. As it's when it switches off, that's obviously the reverse voltage spike caused by the collapsing magnetic fields in the motor.

Does this fan have a proper flyback diode in place, preferably right at the fan itself? Same for the relay, that could also be the culprit depending on how everything is wired exactly. Relays also need a flyback diode.

Then some serious decoupling is required on your Arduino side. An oversized Pi filter comes to mind, that will keep most of the noise out. Add a 100 nF at the input for high frequency noise, and maybe two diodes for reverse voltage protection. (one reverse biased between power and GND, one forward between power and your input filter).

Fly in the ointment? Sorry, english is not my first language. I would show a picture of my circuit but its very simple, just power in. also digital telephones with cameras are not widely used here.

My real question is how come the cars ECU is not bothered by the electrical intereference, or why isn't the PIC controller bothered by it?

Also the power filtering, sounds as if I need a dc-dc buck convertor. To go from 10-16vdc from the car system to a clean 5v.

Do buck convertors have built in filtering?

If not how am I suppose to filter this power with somthing other than diodes and capacitors? As I have already tried this and nothing worked.

And my digital and alaog inputs need to be opti isolated. how is that possible?

The fan has the protection circuitry along with the relay. Multiple fans and relays have been tested for this reason.

After continuing to read forum posts here, it seems I need a special automotive power supply for the arduino mega. However I cant find any for sale, nor any schematics on how to built it with labeled parts.

Also if I was to interact with the vehicle such as reading a thermistor input voltage, how to do i protect the analog input from those spikes?

How does a fuel injection computer read cam and crank sensors along with the analog voltage going in from engine temperature?

agentruley: Also the power filtering, sounds as if I need a dc-dc buck convertor. To go from 10-16vdc from the car system to a clean 5v.

Do buck convertors have built in filtering?

Usually yes - but not for this bad a power supply. Have a look at a car phone charger. Those have filtering in place, as they're designed to be used in cars and keep the phone attached to them alive.

And my digital and alaog inputs need to be opti isolated. how is that possible?

Digital inputs are easy: use an optocoupler. Analog not so much, should be possible though.

Ohhh Good Idea! I didn't think to use a phone charger! They are all over the place!

Thank you!

I most likely still need to figure out other filtering and protection but I am going to try with the phone charger powering the board and the LCD screen as well.

I will post back after testing and re-wiring.

I hope this helps a little bit. I haven't started using mine yet but I bought this shield for a similar project for my motorcycle. The electrical system is pretty noisy and I thought the possibility of using a small battery to act as a UPS would be beneficial.