Arduino reset when contactor drops out

I'm Using an arduino to control a heat pump. The heat pump has a 3kw compressor and a 100 watt fan both 240 volts, each of these are controlled by thier own 240v contactor with built in overloads etc.
The arduino uno switches two arduino relays on 12v module. These two relays switch 240volts to the two contactors. Everything works perfectly most of the time but occasionally the arduino resets itself this seems to happen more on the de-energising of the relays.
The arduino is powered from a 240 volt to 12 volt power supply.
The relay shield is a 12v Relay module.
How can I prevent this happening.
Many thanks for any help.

Post schematics of the relay shield and a wiring diagram of the complete setup (including power supply, etc.).

First guess is missing fly-back diode.

These two relays switch 240volts to the two contactors.

The contactors have a 240VAC coil?

The relay board probably has a "flyback diode"* already so there's probably nothing "wrong" with your setup but you are probably getting a glitch through the 12V power supply. (If the contactors have 12VDC coils, they also need flyback diode.)

The best solution may be a separate power supply for the Arduino.

It's also possible that you're getting a glitch in the power line, although I would expect that when the motor pump kicks-on. You can try your without the heat pump connected and/or without the contactors connected to isolate where the problem is coming from.

If you have an AC power-line glitch, a capacitor (1000uF or more) across the DC power supply will help to hold-up power to the Arduino if the AC drops-out briefly. (Or, that capacitor may solve other power-related problems.)

  • When there is current flowing through a coil and you suddenly break the circuit, the magnetic field collapses and the coil becomes a "generator" and it "tries" to keep the current flowing by supplying a reverse voltage. The voltage can be very-high as it tries to push current through an infinite resistance. The reversed diode provides a low-voltage path for the current until the magnetic filed has dissipated all of the stored energy.

Interesting headache! I see two immediate possibilities, conducted or radiated emissions or both. Put the arduino in a shielded grounded box. Be sure the enclosure housing the contractors is closed. The relays (two relay board) must not be in the same enclosure with the arduino. Be sure your power supplies have plenty of high frequency bypass capacitors. If the contractor is DC use a clamp diode, if AC use a snubber network. If possible use a solid state relay with zero cross to drive the contractors. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

DVDdoug:
The best solution may be a separate power supply for the Arduino.

OP- Try running the Arduino temporarily on battery. If the problem goes away, then you are looking for a power issue.

Lynton:
I'm Using an arduino to control a heat pump. The heat pump has a 3kw compressor and a 100 watt fan both 240 volts, each of these are controlled by thier own 240v contactor with built in overloads etc.
The arduino uno switches two arduino relays on 12v module. These two relays switch 240volts to the two contactors. Everything works perfectly most of the time but occasionally the arduino resets itself this seems to happen more on the de-energising of the relays.
The arduino is powered from a 240 volt to 12 volt power supply.
The relay shield is a 12v Relay module.
How can I prevent this happening.
Many thanks for any help.

You are switching a large inductive load and whenever the circuit is closed (and more so when it's opened), there are large voltage spikes, RF noise and in general a lot of EMI (electromagnetic interference).

The Arduino, running on only 5 volts, doesn't need much noise to upset the logic and cause a crash or reset.
I suggest two things:

  1. Try what SteveMann suggested - run the Arduino on an isolated battery and see if this helps. It probably will, which will prove what I (and he) suspect. If this works out, then:

  2. Place the Arduino and it's power supply into an aluminum box to shield it. Use feed-through capacitors to keep noise from back flowing from the contactors to the relay board.

Hope this helps.

(Edit to add): What DVD Doug: "If you have an AC power-line glitch, a capacitor (1000uF or more) across the DC power supply will help to hold-up power to the Arduino if the AC drops-out briefly. (Or, that capacitor may solve other power-related problems.)" is another good suggestion.

Try this too.

Hi,

These intermittent "EMC" problems are very common. That's "ElectroMagnetic Compatibility"...
See Wikipedia: (HERE)

Here is a section I wrote about what to consider in a design: Arduino-Project-Planning-Electrical - ArduinoInfo

Let us know what you find out...

Thanks for all the suggestions. I haven't managed to get to it due to work commitments.
The arduino uno runs from a 240 to 5v supply.
The uno outputs a switched grnd signal to the arduino relay shield.
The relays switch 240 volts to the heat pump contractors.
If it's a back emf caused by open circuiting the contactors this would be on the 240v line, could this spike upset the arduino being its fed via a 5 volt power supply.
I can't see how the contactors reset the uno being there about 20metres away.

Do you have any kind of snubber across the relay contacts? Across the contactor coil? Post a wiring diagram.

Lynton:
I can't see how the contactors reset the uno being there about 20metres away.

Regardless as to whether you can imagine it or not, it can.
It may even be via RF radiation.
Answer is in the above suggestions.