MCU freezes upon engine crank

Hi everyone. I hope you all are well.

I am working on a project where I am using the Arduino to control a compressor using a relay and a few valves using a high-side switch on a vehicle. Everything seems to be working fine but for example, if the compressor is running and the engine is cranked. This freezes the whole system and it becomes completely unresponsive and must be reset at the power supply. This keeps the compressor running and running and never turning off which a huge safety hazard as well. I thought it might be the undervoltage that is causing it but after doing some tests it is not undervoltage that hangs it. I even have a watchdog timer programmed which does not work either when the MCU hangs. Could it be some sort of EMI? Please let me know. Kind regards.

Post a diagram showing how everything is connected, especially how the Arduino is powered

Hi, please see how the arduino is powered from the car battery.

image

Hi, @omersaeed
Welcome to the forum.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

What voltage level are you supplying to Vin?

What model Arduino are you using?

Have you a DMM and can you monitor the output of the regulator when the problem occurs?

Can you please post some images of your project?
So we can see your component layout.

Thanks... Tom... :grinning: :+1: :coffee: :australia:

Welcome to the forum.

Can you test this without starting, running or stopping any of the heavy duty stuff you have hanging off the Arduino board? Like disconnect the wires driving any relays or solenoids or motors or the drivers you've used to lower them.

Faults like this are almost certainly a matter of EMI or power supply inadequacy or similar. We see works here, doesn't work there alla time.

So it would be of diagnostic value to prove that the logic is correct. Perhaps by having it on your nice work bench with a good power supply and only pushbuttons, LEDs and potentiometers as proxies for the real world stuff you want to get to.

Even better would be doing such a test entirely within a simulator, so I will mention

HTH

a7

Please post the code.

Use the IDE Autoformat tool to make it pretty if it isn't already.

Use the IDE Copy for Forum tool, then come here and paste it, where it should look like code:

void setup() {

}

void loop() {

}

TIA

a7

Then you should not be using an Arduino

1 Like

I guess you are expecting around 8V from your adjustable regulator. R1 in your schematic is usually set at around 120R. Your higher resistor values may be affecting regulation.

I'm still thinking that's what it is. Have you tried powering the Arduino from a separate power supply, or from your computer's USB port, or from a separate a battery?

You might need a back-up battery, or maybe a diode/capacitor circuit like this:
Half-Filter

It will work best with the circuit on the 12V side of the voltage regulator and you might need a bigger capacitor so the capacitor discharges more slowly and the voltage holds-up longer.

Voltage regulators make pretty-good "filters" but they can't "make voltage" when the voltage drops.

It could also be an input or output pin getting an over-voltage or negative-voltage glitch into the processor and somehow crashing it.

Maybe you can wire something into the reset circuit so it resets every time you crank the engine?

You probably need to "reverse the logic" (or something) to make it "fail safe" so the compressor is off when it fails. However you do that, it shouldn't rely on the microprocessor or software/firmware. For example, most relays are double-throw with normally-open or normally-closed contacts.

@omersaeed - I looked at the NCV1117STAT3G data sheet wondering if some small capacitors weren't in the reference circuit, placed in parallel with the 10 uF units.

There were none. But they do say

A 10 F ceramic or tantalum capacitor should be adequate for most applications

and since I heard that no one uses tantalum capacitors any more, I ask what kind of capacitor you have there and wonder above my pay grade if ceramic would be a better choice than tantalum of old fashioned electrolytic caps.

The datasheet also says

A minimum capacitance value of 4.7 F with an equivalent series resistance (ESR) that is within the limits of 33 milliohms (typ) to 2.2 ohms is required.

so to be thorough, you'd want to check that too. Even if it isn't the problem.

a7

Thank you everyone for replying. The input to the MCU after the voltage regulator is constant 5V even on engine crank so it is certainly not undervoltage. Which means the current capacitors should be fine to provide the MCU with constant 5V. So I am not sure what else could it be.

Also I have tested the system with a bench supply and tried to replicate the undervoltage when the engine is cranked. But it works absolutely fine with the bench supply. However, when powered using the car battery the MCU hangs sometimes when the engine is cranked.

An automobile electrical system is among the electrically nosiest systems.

  • On engine crank, the battery voltage can drop to below 6 volts when cranking hard in an cold environment. The voltage is approximately a sine wave being lowest at each compression cycle.

  • The "ground" can vary up to 2 volts from location to location in the vehicle.

  • Voltage spikes up to 1500 are quite common.

  • Periodic (not when starting) voltages can be as high as 50 Volts.

The grounding, input voltage protection and protection of all signals in and out needs to considered.

This was part of my responsibility when I worked at an automotive OEM.

A full schematic and physical layout need to be evaluated.

Hi, @omersaeed

WHAT MODEL ARDUINO ARE YOU USING?

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

What voltage do you measure on the 5V pin of the "MCU"?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

What is the circuit that drops the 8V from the regulator circuit you posted to the Vcc 5V you show coming from J1?

If you meant just leaving everything as it is in the vehicle and supplying good power from a bench supply, you can see why we might still thing your provision of five volts to the project is the main suspect.

There are things that can happen on the power lines that you just won't see on a DMM…

a7

Hi, from what you're talking about it seems like you are dealing with some transient voltage spikes from the vehicle electrical system, especially when cranking. I am not an expert in any way but I had to deal with something similar on one of my projects (an 8v battery running a small brushed motor was creating spikes up to 40v resetting/frying my microcontrollers). I asked about that on this thread and received pretty good help:

and I was ultimately able to fix it for my little project (check out my last post).
As @JohnRob said the voltage on a car electrical system can be all over the place (especially if you're also running a compressor or other "dirty" load) and our microcontroller doesn't really like that.
On top of that if you have access to an oscilloscope to check the voltage going into the microcontroller that would be even better for troubleshooting.
Hope this helps

Luca

Welcome to the wonderful world of automotive electronics. It is a very complex system with many things that have to be taken into consideration and appropriate application of the components. It is NOT a simple 12V system. Try these links:

There is a good app note AN2689 by ST on automotive electronics. reading it will help you a lot.

https://www.st.com/resource/en/application_note/cd00181783-protection-of-automotive-electronics-from-electrical-hazards-guidelines-for-design-and-component-selection-stmicroelectronics.pdf

Also take a look at this: Distilled Automotive Electronics Design | Analog Devices

These are a starting point, not a solution. I hope this is a one up application. At a minimum you will need a scope in the minimum of 500 Mhz range. You also need to understand failsafe and what it encompasses. You might want to download the AEQ series of specifications for automotive and its associated components. Good Luck. Is this going on a vehicle that will be on the public road?

First step solution:

Bring every wire in and out of your device to one point.
At that point put a 0.1µf capacitor (ceramic) from each wire to the ground wire.

image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.