6
\$\begingroup\$

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?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ I can't see any decoupling capacitors and you' ll be producing some nice current pulses switching solenoids on and off. Try a few big electrolytics across the supply to smooth out the bumps. \$\endgroup\$ Jun 14, 2013 at 18:07
  • \$\begingroup\$ Karl's answer about grounding is important; ground is pretty much the only route that interference can make it back to the Arduino. \$\endgroup\$
    – pjc50
    Jun 14, 2013 at 18:35
  • \$\begingroup\$ What does the "ARDUINO IN" switch suppose to do? In other words, why is it shorting out the 5V power supply? \$\endgroup\$
    – jippie
    Jun 14, 2013 at 19:46
  • \$\begingroup\$ @pjc50 mutual inductance is another route. \$\endgroup\$
    – Phil Frost
    Jun 14, 2013 at 19:56
  • \$\begingroup\$ The general advice here is probably as good as specific as one could be: electronics.stackexchange.com/questions/53914/… \$\endgroup\$
    – Phil Frost
    Jun 14, 2013 at 19:59

4 Answers 4

5
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ each power supply comes from a separate transformer off the wall AC. \$\endgroup\$
    – zacaj
    Jun 14, 2013 at 18:39
  • 1
    \$\begingroup\$ Then it's almost certainly a grounding issue. \$\endgroup\$ Jun 14, 2013 at 18:52
3
\$\begingroup\$

I'd say over 90% of problems like this are earth related. If the return path for solenoid current through the mosfet shares the same ground as the arduino, "stuff" is going to happen. Maybe I've seen this up to ten times on badly laid out PCBs, breadboards and prototype constuctions.

I'm not saying "definite". I am saying if there is any doubt about ground/earth then it needs to be improved.

\$\endgroup\$
3
  • \$\begingroup\$ The MOSFET only has one ground, despite it switching a 25V current and being controlled by a 5V, so wouldn't they have to share the same ground? How would I 'improve' it? \$\endgroup\$
    – zacaj
    Jun 14, 2013 at 18:37
  • 2
    \$\begingroup\$ The return path (0V) of all the MOSFETs should connect together at one point. This is called a star-point and this is where the 25V power supply 0V makes its only connection. This should also be the only place where the logic supply makes its 0V connection. All other logic 0V connections ONLY connect to the logic 0V thus they connect at points where there can be no MOSFET current. \$\endgroup\$
    – Andy aka
    Jun 14, 2013 at 18:45
  • \$\begingroup\$ Try to make the logic 0V connections short and preferably use an earth plane. If a prototype set-up then do your best to minimize lengths of the logic supply BUT keep it seperate from those mosfets. \$\endgroup\$
    – Andy aka
    Jun 14, 2013 at 18:48
2
\$\begingroup\$

There appear to be three main areas of concern here:

  • FET gate drive directly from an Arduino.
  • Proximity of the solenoids to the switches.
  • Unknown filtering on the 25V.

Gate Drive for FETs.

Main concern is turning the FETs off. The Arduino has to handle all the charge from \$C_{\text{gs}}\$ and \$C_{\text{gd}}\$ with the change of \$V_{\text{ds}}\$ as the FET turns off. It's doubtful the ATMega was designed for that, and the current pulses along with parasitic inductance could cause ground bounce. That could cause erratic behavior of the chip. It would be best to return the gate charge to the source of the FET much more directly rather than through the Arduino.

Resistance in the gate circuit is also a concern. R3 is 150 Ohms, I'm guessing \$R_{\text{drv}}\$ (inside the Arduino) is 50 Ohms, and \$R_g\$ (inside the IRF530) is ~ 7 Ohms. That's 207 Ohms total, which is too much to keep the FET from turning back on during turn off. When the FET turns off there is a dV/dt on \$V_{\text{ds}}\$, driven by the solenoid inductance (\$L_s\$). The rise time of \$V_{\text{ds}}\$ will be set by solenoid inductance acting with \$C_{\text{ds}}\$ of the FET. In this case \$L_s\$ is 1uH and \$C_{\text{ds}}\$ is 350pF, so the expected rise time to 25V of \$V_{\text{ds}}\$ would be 35nsec. Calculations following the guidelines shown here result in 3.2 volts appearing on the FET gate during turn off, which would be enough to turn the FET back on at least partially.

Both of these problems with the gate circuit could be solved by adding a pnp transistor to pull down the gate during turn off. Here is an example circuit to give you an idea.

enter image description here

This is an emitter follower pull down for the gate that effectively divides gate circuit resistance by transistor \$\beta\$.

Solenoid and FET Switch Proximity.

You say the solenoids are 2 or 3 feet away from the switches. That's a problem because there will be stray inductance in the cable. There could easily be 100 or 200 nH of parasitic inductance. If the catch diodes for the solenoids are directly around the solenoids, then the cable inductance will ring with \$C_{\text{ds}}\$ of the FET and will need to be damped with an RC snubber at the FET, or managed somehow.

This a distribution problem for the solenoid circuit. Loop area of the solenoid 25V and return path need to be greatly reduced. The cable could be shortend, or the cable could be twisted (one or two turns per inch would probably do it), to cut down cable inductance.

Filtering on the 25V.

No filtering is shown on the 25V, but there needs to be enough local capacitance to handle the solenoid switching currents. Can't say more than that without knowing more about the supply.

\$\endgroup\$
0
\$\begingroup\$

You use 1N4007 general-use diodes, which are slow-response diodes. For solenoids I would use fast flyback diodes, which are more capable to reduce the inverse voltage induced by the solenoids when the drivers cut off the current through them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.