Can EMI lead to the Arduino crashing?

Hello,
I’ve been diagnosing a strange crash problem in my setup and was wondering if it could “simply” be caused by EMI.

I try to control a valve using a logic level MOSFET. The valve is placed at some distance and is connected by a cable of around 12m. A large portion of the cable runs in a cable route along with a lot of other wiring, mostly mains.

  1. The first problem I noticed was the valve not turning off properly when the MOSFET’s gate pin is turned LOW. It would either crash the Arduino or turn HIGH some of the other output pins, which would for example light up some LEDs that I’ve connected. Could this likely be caused by my flyback diode not having sufficient properties, like being to slow? I’m currently using a 1N4007.

  2. The other strange thing is that the program doesn’t run as expected anymore as soon as the cable to the valve is connected. Problems occur randomly, LEDs begin to flicker or button presses aren’t recognized correctly. And the same thing as described above happens too, some output pins sometimes randomly turn on. I’ve not been able to recognize or reproduce any particular patterns.
    Research on the Internet made me wonder if those randomly occurring problems might be caused by interference of the mains power lines that run next to my cable. I think a good indicator is, that when I disconnect the cable to the valve from the main circuit, none of the problems seem to occur. But problems do happen when the cable is connected to the circuit, but not to the valve.

Could you guys give me any advice? I’m especially unsure about the second point.

I’ll attach the layout of the circuit’s part that controls the valve. I use a hydraulic valve with 2W at 24V. Power supply is a switching power adapter rated for 1000mA at 24V. So I don’t think I’m running into power issues. The 5V for the Arduino comes from a L7805CV voltage regulator with two 10uF capacitors. Those 12m indicate where the cable run along with the mains cables.

I use the Arduino standalone setup as described on the Arduino website.

Thanks in advance!

layout.jpg

The MOSFET you've selected has a Vgs of 18V, meaning that a 5V arduino will never fully "open" the gate so your mosfet is stuk somewhere between off and on, your valve not getting enough juice to function correctly.

Look for a logic level mosfet that turns fully on when there's 5V on the gate.

12 meter of cable makes one nice antenna for EMI interference to enter and wreak havoc on electronics or control signals. Either use shielded cable (shield connected on both sides to earth) or some other form of EMI supression to limit the transients. Try rerouting the cable to remove it from the mains cables as much as possible.

Leroy2007:
shield connected on both sides to earth

I don’t recommend this because it can create ground loops. Earth ground it only on the MCU end (really, you’re earth grounding the MCU and connecting the shield to it).

I would also put the fly back diode on the relay itself not 12 meters away on the board. Where you have it you have a great transmission line for radiating the EMI from the back EMF.

if it could "simply" be caused by EMI.

No doubt about that. Erratic behaviour is almost always caused by EMF or a lack of power supply decoupling between components, so a capacitors across that 24 volt supply and ground would no go amiss either.

I would also put the fly back diode on the relay itself not 12 meters away on the board. Where you have it you have a great transmission line for radiating the EMI from the back EMF.

At one time I would have agreed with that as it is ‘obviously’ correct. Except it’s not. Someone (I forget who) on here explained it and it took me a while and some experiments with an inductor to confirm it. When you interrupt the current through an inductor the inductor tries to maintain the current that was flowing just before the current was interrupted. If the inductor is open circuit it generates a high voltage spike to try to maintain the current into a resistance approaching infinity. If you put a diode across the inductor then it can maintain the current as it is no longer looking into an open circuit, but instead it’s looking at the near short circuit the diode provides. This means it can do what inductors do and maintain the current. When the supply current to the inductor is removed the current through the inductor continues at the same level it was before the interruption. It then decays exponentially towards 0A. There is no spike. So, you put the diode at the switch, that way the current decays exponentially in the long wires feeding the inductor, no spike, no EMI. If you put the diode at the inductor then the current in the long wires stops suddenly when the switch opens, generating EMI from the wires.

If you doubt this get an inductor, a low value resistor to measure it, an oscilloscope and try it.

I believe both of you are saying the same thing. Keep the diode at the switch because of the inductance of almost 80 feet of wire loop but put another at the solenoid. Isolate the wiring from AC mains. Try that first.

I believe both of you are saying the same thing.

We are not. GM is saying put the diode at the solenoid, I am saying put it at the switch. Not only do you not need one at the solenoid you should not put one there, only at the switch. The inductance of the wire will be covered by that one. Putting one at the solenoid means that when the current is suddenly interrupted by the switch the current in the connecting wires abruptly stops, emitting EMI. Putting the diode at the switch means the current in the wires decays slowly and exponentially to zero, emitting little or no EMI.

I can calculate this but need details of the wire gauge and the details of the solenoid, core, wire size, turns etc.

I've done some quick analysis and I agree with Perry but mutual inductance is a complex issue and we can still have problems.

OK, here it is again:


Even with the inductor, I find it surprising that even educated engineers can resort to "magical thinking" about the situation, with assertions about "current surges" and putting the diode as close as possible to the inductor because the inductor "generates" the surge.

That turns out to be an absurdity. What generates the transient is not the inductor but the switching device, either a mechanical contact or a semiconductor. The inductor - as a response - acts to maintain the instantaneous current flow by generating the "back-EMF". So you provide an alternative path for it to do so through the diode. It is still the case that the current through the inductor and its connecting wires does not change rapidly.

What does change rapidly is the current through the switching element and the power supply which suddenly drops to zero, and the current through the diode which as a consequence suddenly rises from zero to maintain that same current.

The significance of this is that if interference is going to be caused by electromagnetic radiation from a suddenly changing current, that suddenly changing current is located in the loop formed by the power supply (or the local bypass capacitor), the switching element and the diode but not the wiring between the diode and the inductor. The need is thus to minimise the length of that supply - switch - diode loop by placing the diode as close as possible to the switch and power supply (bypass). It is these three that must be close together. Suggesting you need to place the diode close to the inductor (or motor) is actually quite wrong! :astonished:

On the other hand, there is a voltage transient caused by the switching which can capacitively radiate interference. This impulse is - again - caused not by the inductor but by the switching element so it actually radiates - possibly counter-intuitively - from the switching element to the inductor however to all intents and purposes, all points on the wire connecting switch, diode and inductor experience the same transient so this is not affected either way by the location of the diode.

So now let's take a look at that transmission line. :grinning:

I won't consider resistance; the simple model of a transmission line is a series inductor and parallel capacitance. The capacitance can perhaps be considered at each end. Well, the transmission line inductance is in series with the primary inductor. If you put the diode at the switching device end, then the inductance acts with the primary inductance and as described, resists sudden changes in the current which is to say, minimises inductive transient radiation.

If you place the diode at the primary inductance end however, you have now created in the transmission line, a second inductor in series with the primary which will add to the voltage transient at the switching device and enhance inductive transient radiation. It may not in itself contain enough energy to damage the unprotected switching device.

Capacitance at either end of the transmission line will indeed serve to slow the voltage transient but will conversely cause a transient when the inductor is switched on. Capacitance toward the inductor end will tend to cause radiation from the transmission line while capacitance at the switching device end will increase more the current surge seen by the switching device.

Note the general principle that it is the transmission line which radiates interference due to switching transients and the current transients occur in that part of the transmission line which is on the switching device side of the diode, so placing that diode near the primary inductor causes all of the transmission line to be such a potential radiator while placing it at the switching device limits this to the loop originally described, formed by the power supply (or the local bypass capacitor), the switching element and the diode.

Thank you Paul, yes, it was you who I was referring to in post #5, sorry I could not remember who it was (and sorry but I will forget again :o ).

The significance of this is that if interference is going to be caused by electromagnetic radiation from a suddenly changing current, that suddenly changing current is located in the loop formed by the power supply (or the local bypass capacitor), the switching element and the diode but not the wiring between the diode and the inductor. The need is thus to minimise the length of that supply - switch - diode loop by placing the diode as close as possible to the switch and power supply (bypass). It is these three that must be close together. Suggesting you need to place the diode close to the inductor (or motor) is actually quite wrong!

So would that not apply to restive loads as well?

PerryBebbington:
(and sorry but I will forget again :o ).

No worries because you see - I will not (forget it). :grinning:

Grumpy_Mike:
So would that not apply to restive loads as well?

Well, it actually might as you certainly are generating a transient except that the nature of the load is different. The inductor is a pure current source; in the short term it is equivalent to a large voltage applied to a correspondingly large resistance. I have resisted the suggestion that it is "infinite".

Without the diode, the voltage will shoot past the supply voltage until something limits it; the energy of the inductor is discharged back into the circuit (with the diode, largely into the inductor's own internal resistance and all of the current has been instantaneously transferred to the diode). With a restive load, the current (instantaneously) falls to zero as the load terminal approaches the supply; there is no energy to dissipate and no transfer to a diode if fitted but there actually now is a transient in the transmission line current.

Leroy2007:
The MOSFET you've selected has a Vgs of 18V

The STP36NF06L is definitely logic level. The +/-18V is the absolute maximum gate-source voltage,
not the operating voltage.

You can tell its logic level as the Rds(on) specification says 0.05 ohms at Vgs=5V

I would not disagree with most of that. We have all seen how the EMI from a long neopixel strip can take down light aircraft.

But:-

The inductor is a pure current source;

As I see it from a physics point of view you pass current through an inductor and it builds a magnetic field round it. As the field is growing the magnetic lines of force ( which don't actually exist but is a convenient fiction ) cut the coil producing a voltage in the opposite direction to the current and slow the growth of the field down. This gives rise to the fact that the initial current is lower than it will eventually be when the field reaches its maximum. The sort of opposite of a surge.

As current continues to flow that field is maintained from collapsing by the energy in the current. Once the voltage is removed and the current stops flowing you have a magnetic field with no means of support, so the field starts to collapse. As the field collapses the magnetic lines of force cut the wires again and again produce a voltage which is in the opposite direction to the voltage producing the magnetic field. The coil then acts as a source of high impedance reverse voltage and forces a reverse current. The diode provides a low impedance path to drain that energy.

Now what is wrong with that explanation?

wolframore:
I believe both of you are saying the same thing. Keep the diode at the switch because of the inductance of almost 80 feet of wire loop but put another at the solenoid. Isolate the wiring from AC mains. Try that first.

If the cable has a well defined characteristic transmission-line impedance about the same as the winding resistance, the the inductive spike will be limited to 24V, ie 24V above the supply. A smaller characteristic
impedance will reduce this, larger will increase it. Diode at the relay end will quench it fully.

As it is the relay is about 300 ohms, most cables are around 100 ohms, so it won't be a big problem if there's
only a diode at the switch end.

Note if the diode is with the relay you have to connect the cable the right way round - a diode at the switch
end can't be reversed by accident.

Now what is wrong with that explanation?

The coil then acts as a source of high impedance reverse voltage and forces a reverse current.

The current is not in reverse, it is is the same direction as the original current. The inductor has swapped from being the load to being the supply, so the voltage reverses and the current continues in the same direction.

As I say, all sorts of "magical thinking" such as the "reverse current"! :grinning:

Grumpy_Mike:
Once the voltage is removed and the current stops flowing you have a magnetic field with no means of support,

"2. The other strange thing is that the program doesn't run as expected anymore as soon as the cable to the valve is connected. Problems occur randomly, LEDs begin to flicker or button presses aren't recognized correctly. And the same thing as described above happens too, some output pins sometimes randomly turn on. I've not been able to recognize or reproduce any particular patterns."

I think you guys have chased the squirrel up the wrong tree. How is any transient EMF in the 24-volt circuit going to get past the FET into the Arduino?

OP, is there any reason you can't put the 24V supply at the business end and just send data-level signal through an opto-coupler at the Arduino end?

SteveMann:
I think you guys have chased the squirrel up the wrong tree. How is any transient EMF in the 24-volt circuit going to get past the FET into the Arduino?

By proximity of the cabling of the 24 V circuit to the control wiring of the Arduino, and not keeping both wires to each power or control circuit running together everywhere as a pair.

Leaving loops in the wiring allows electromagnetic coupling of transients.