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.
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!