Electronic – arduino – Solenoids causing Arduino to malfunction despite protection diode

arduinoflybackmosfetsolenoid

schematic

simulate this circuit – Schematic created using CircuitLab

I have an Arduino Mega that I'm attempting to control some solenoids and LEDs with.

The LEDs are 3.3V, controlled through an open drain shift register
and MOSFETs

I wasn't sure how best to represent the Arduino in Circuitlab, so I used some switches to represent the I/O pins.

Basically, the problem is that, after I fire the solenoids a few times, stuff starts acting weird. First, the shift registers will start resetting to random status sometimes when a solenoid is fired. If I just push new data to them, they work fine again until another solenoid fires. After a while, the Arduino will start thinking it's getting inputs (I have the internal pull up resistors enabled, so it's thinking it's input pins are being grounded when they're not). If I power off the circuit and turn it back on, everything will work fine for a while more, but I have no idea what's causing this, and I'm worried I'm slowly frying the components somehow…

Also, whilst browsing similar questions, I saw one person say that you should try to put your MOSFET as close to the solenoid as possible. Currently my MOSFET is mounted on the board with the arduino, but the solenoids are 2-3ft away. Could that cause this?

Best Answer

Those are common symptoms of layout problems, or possibly power supply issues if your 5V supply is derived from your 25V (like through a buck regulator). You want to make sure the ground paths are separate for your 5V and 25V sides, then meet at exactly one point as close as possible to the supplies. If that's not sufficient, the next step would be completely isolating the circuits with an optoisolator.