Electromagnet activation causes reset

Hi everyone,

I am currently working on what is probably best described as a catapult, of sorts, and I have run into an issue where the arduino either resets or loses functionality whenever I supply power to my electromagnet.

Some background:

The arduino controls a 5V optically isolated relay, which is on a separated 5V wall wart. Power is supplied to the arduino by USB. The relay, in turn, controls a 12V circuit supplying power to a holding electromagnet. This magnet is used to hold/release the catapult arm. I use a potentiometer and an LCD screen to control the time of release, etc. When I turn the system on, the magnet is immediately powered, and remains so until the arm is released. The goal is to be able to repeat this several times in one "session" with time-actuated release.

The issue: About 50% of the time, the arduino locks up immediately after the first release. In these cases, the LCD suddenly displays a mess of unrecognizable characters, and I immediately lose serial communication. If I disconnect the electromagnet, this is no longer a problem. The relay has built-in diodes to protect the arduino, probably ruling out any blowback issues.

Could the sudden change in magnetic field be causing my issue? If so, how would I shield the arduino? Alternatively, I guess the impact of the catapult arm could be causing some sort of issue, but that's much harder to test.

Any insight you may have would be very much appreciated!

Electrical interference causes Arduinos to reset. If the relay is electromechanical, you may need spark suppression. You need flyback diodes on the electromagnet and other coils.

For more informed help, post a photo or scan of hand-drawn circuit diagram (not Fritzing).

I have a flyback diode on the relay (it’s built in), but I don’t currently have one on the holding magnet. I will definitely give that a shot, thank you!

Below is my current schematic (sorry, I still need the fritzing training wheels; I’m a biologist):

Fritzing diagrams are horrible, and should not be viewed as "training wheels".

They don't even follow the rules. For example: are the grounds all connected together?

ragman922: I have a flyback diode on the relay (it's built in), but I don't currently have one on the holding magnet. I will definitely give that a shot, thank you!

You definitely need it, otherwise you have a broadband spark-transmitter. However for a clean fast release you may do better to use a higher voltage snubbing arrangement - either a zener back-to-back with an ordinary diode (acts like a high-forward voltage diode), or a TVS diode.

The higher the voltage of such a device the faster the magnetic field collapses. Of course you don't want it too high, or you're just sparking the relay contacts still. If a plain diode is causing too sluggish a release, consider one of these methods.

You can also just use a resistor in parallel with the electromagnet, although your relay has to carry extra current while the magnet is on, it can snub the turn off. Try a resistor that is about twice the resistance of your electromagnet perhaps, which a suitable power rating (or it'll overheat).