I am designing a control box to switch 24V DC high speed solenoids at a max frequency of 200Hz. They will be controlled by an Arduino Mega through N channel, rfp30n06le MOSFETs.

Here is a photo of the planned circuit (highlighting only one MOSFET, as they're all the same).

questionable circuit vs. researched circuit

It is very convenient for me to attach the diode at the proto board, from drain to +, vs. attaching the diode to the individual leads of the solenoids. Will my flyback diode function properly if connected to Vcc and the negative lead of the solenoid, or does it HAVE to be connected directly to the positive lead of the solenoid?

Thanks for any help you can provide!

  • \$\begingroup\$ Not fly-back, but re-circulation diode it is. \$\endgroup\$
    – jay
    Nov 18, 2021 at 17:19
  • \$\begingroup\$ technically, the first two schematic diagrams are identical \$\endgroup\$
    – jsotola
    Nov 18, 2021 at 17:24

4 Answers 4


The more wire between the source of the "flyback" and the diode, the less effective the diode will be in clamping the energy produced by the inductor in the solenoid.

So while you can locate the diode away from the solenoid, you may find that it doesn't do anywhere enough suppression to prevent interference or even damage to your circuit.

These are much like bypass caps. You could ask, "Can I put all my bypass caps on the power supply instead of locating them all around the board next to my ICs?"

The answer is the same, yes, you could do that but they will be much less effective, perhaps even totally ineffective for their intended purpose.

  • \$\begingroup\$ Thanks for the reply. The primary objective of this diode is to prevent damage to the MOSFET from high potential spikes from the solenoid mechanism. It would be located right next to the mosfet, but further away from the solenoid. Would this serve it's purpose, or be entirely useless? \$\endgroup\$
    – rmather
    Nov 18, 2021 at 17:10
  • \$\begingroup\$ @rmather Have respect for the fast transient pulse current flowing through that diode. If that current has a long path it radiates electromagnetically, a potential noise hazard to nearby electronics, like your microcontroller. Both jwh20 and Andy advise quelling transients at their source - a good general principle that trumps wiring convenience. \$\endgroup\$
    – glen_geek
    Nov 18, 2021 at 18:48
  • \$\begingroup\$ It would not necessarily be "entirely useless" but its effectiveness would be compromised depending on how far it's located away as well as things like the impedance of the wires or traces conducting the pulse. Basically the longer the interconnect the less well it works. It's poor design practice to locate the snubbing diode away from the solenoid. If locating it is a problem there are any number of commercially available solenoids that have snubbing diodes built in. Perhaps you might consider one of those. \$\endgroup\$
    – jwh20
    Nov 18, 2021 at 19:27

Your first two circuit don't need to have a flyback diode unless there is some component you wish to protect as per your third diagram and, you've got a bit in a pickle with wires all over the place on that. It's not wrong, but, if you think of the diode needing to be across the inductive component then any stored energy in that component (due to currents and the resulting magnetic field) will be immediately quenched with the diode. Redraw: -

enter image description here

Now it's much clearer as to why the flyback diode is needed and where it is needed.

  • \$\begingroup\$ The reasoning for my diode placement was that these solenoids are manufactured with leads, not terminals, so without some sort of hack-job, I won't be able to install a diode as drawn. The closest I could do would require a long line for each one going across my control box, which is not ideal and would also result in poor performance. My question boils down to whether or not the cathode of the diode needs to be directly connected to the lead of the solenoid, or if I can connect it through the power supply instead. \$\endgroup\$
    – rmather
    Nov 18, 2021 at 17:37
  • \$\begingroup\$ @rmather the shorter the leads the better. If you can't then put the diode at the nearest possible convenient electrical point to the solenoid wiring. But, be aware that the loop inductance of the wiring could still produce a pulse on the drain that is significant relative to the source so, on that occasion, I would consider using a zener diode between drain and source - that would protect the MOSFET. The diode wouldn't necessarily protect the MOSFET except when closer to the solenoid. Alternatively, leave the diode where you can and snub wiring back emf with a 100 nF capacitor from D to S. \$\endgroup\$
    – Andy aka
    Nov 18, 2021 at 21:54

To abstract this out a bit, your question becomes "what can I put in the mystery box in the schematic below". You can probably put long wires in there -- but it's just not good practice to do so.


simulate this circuit – Schematic created using CircuitLab

An alternative approach is to protect your MOSFET (the switch in my schematic here) with a zener diode. This requires that you size the zener diode to match the supply voltage used (you usually pick a Zener voltage twice the supply voltage) and that your transistor is rated for a greater \$V_{DS_{max}}\$ than the zener voltage.

On the positive side, all of your protection is local to the FET, and because the reverse coil voltage is equal to the supply voltage instead of one diode drop, the coil will lose its magnetism faster and the solenoid will release faster.


simulate this circuit


While it is plain true that noise shall be quenched close to their source, there's a very common misconception on what is the most offending magnetic source in case of relay driving.

It is mostly believed that relay inductance is the "bad guy" down there and hence flywheel diode is to be placed close to relay. Unfortunately this is not true and the circuits tells a different story.

The coupling

There can basically be two different ways to have the noise magnetically coupled to one receptor circuit. A common connection shared or mutual inductance between offender and receptor. Couplings In both cases noise voltage is proportional to current derivative \$ \frac{\mathrm{d}i}{\mathrm{dt}}\$.

The coefficent is self inductance L in the first case, mutual one M in the second. Their are both correlated to the circuit physical dimensions, the smaller the lower. enter image description here So recapping it is best to have both:

  • small L and M and hence small circuits
  • low \$ \frac{\mathrm{d}i}{\mathrm{dt}}\$

as their product rules the induced noise.

Relay driving

When we come to analyze relay driving at turn-off we can look at the two mesh currents depicted below, the switch current and the relay one. enter image description here We can see that switch current is basically ruled by the device (BJT, MOS or integrated driver) turn-off behaviour. This can be found or ballparked from datasheets but it usually spans in the microseconds order of magnitude.

On the other hand relay current is ruled by its L/R time constant. This is harder to find in datasheets but is somehow releated to the published release time, at any rate it is usually well in the millisecond range.

It is now clear that the most offending mesh is the faster one, the blue switch current is around one thousand faster and such is the ratio between induced noises for a given coupling coeffcient. This is the one to be made physically smaller to reduce the induced noise.

It now comes easy that the blue mesh above includes the Vcc power supply too and that's a part of the problem too. Now it comes the role of supply decoupling capacitors. enter image description here


So, it is indeed true that noise should be stopped close its source but in this case the bad boy is not the relay inductance that by its nature tends to smooth the current. One should instead look at the switch that is very often optimized to be fast.

  • \$\begingroup\$ Noise isn't even close to what the problem is here, though--the problem is driving the switch into avalanche due to the inductive voltage spike when the switch turns off. Some switches have an avalanche rating and can be used without a freewheeling diode when you stay below that avalanche rating, but many switches aren't intended to be used like this, and driving them into avalanche will probably damage them. I'm not sure where you got the idea that this is about noise. \$\endgroup\$
    – Hearth
    Nov 20, 2021 at 15:33
  • \$\begingroup\$ ?? Both close to switch and close to relay fully address the avalanche issue (with slight differences). In any case the original question is exactly about freewheeling diode physical location. \$\endgroup\$
    – carloc
    Nov 20, 2021 at 18:24

Your Answer

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

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