When using a diode to deal with the back EMF from a solenoid, common advice is to put the diode as close to the solenoid as possible. Indeed, in pinball machines, I've seen diodes soldered directly to the solenoid's contacts.

I've got a solenoid valve that's sealed (IP 65). Instead of contacts, it comes with wire leads that at are each about 15 inches (almost 40 cm) long. I assume the diode should be closer to the solenoid, and that I should cut the leads much shorter. Is that correct? Or does the distance not matter as long as the diode is closer than the switching circuit that drives it?

Is there a reason solenoids aren't manufactured with snubber diodes built in? It seems the solenoid itself generally dictates the diode selection (at least for low-frequency activation that you would expect from valves).

(I've found answers to related questions, but not one that directly addresses the distance issue, especially when the solenoid comes with long leads.)

  • 3
    \$\begingroup\$ The long wires add a little bit to the inductance of the solenoid. And they add a little bit of resistance, too. But that could just as well be inside the solenoid itself and the parasitic values are likely much smaller than the solenoid's values. I wouldn't worry too much about it. Especially if this is a pinball machine. \$\endgroup\$
    – jonk
    Commented Mar 22, 2021 at 4:48
  • 1
    \$\begingroup\$ If you want faster relaxation of the solenoid, add a series zener arranged in the opposite polarity direction as the diode. Requiring a higher voltage causes a smaller time period needed in order to discharge the stored magnetic energy. \$\endgroup\$
    – jonk
    Commented Mar 22, 2021 at 4:50
  • \$\begingroup\$ Ah, let me see. (1) A solenoid is basically an inductor, that take DC current. (2) For hobbyist 12V, 0.5N, to say 4.5N, solenoids (I guess that is similar to pinball machines, The current passing through the inductor should be in range of 300mA to 4.5A. (3) When the solenoid is on the energy stored is 1/2 * L * I^2 (Note 1). (4) When you switch off solenoid current, the back EMF and huge but short time (Note 2) current flies back through the Shottky diode, (5) Now the wiring from solenoid input contacts to the diode should be short & thick, if possible, to avoid unnecessary heat energy loss. \$\endgroup\$
    – tlfong01
    Commented Mar 22, 2021 at 4:56
  • 1
    \$\begingroup\$ For EMI you often put the diode/varistor/snubber directly on the solenoid, in the valve connector. It's even nicer since they sell them ready to use \$\endgroup\$ Commented Mar 22, 2021 at 9:11
  • 1
    \$\begingroup\$ @jonk If you consider wires about are 1uH/m and solenoids are ~ 1H, there's no incremental effect except the loop radiation pattern, but the discontinuity from the switch current path and diode current path is the path where this transition radiates most if the diode is across the coil. and by reducing this unintended radiator as short as possible with twisted pair and with diode across switch as I answered. \$\endgroup\$ Commented Mar 24, 2021 at 10:22

2 Answers 2


In the absence of some means to dissipate the energy stored in a solenoid, when the solenoid is switched off, it can induce high voltage spikes. The free-wheeling diode is there to provide a current path to "snub" these voltage spikes.

If the solenoid is switched by a semi-conductor switch, then it is a primary function of the diode to protect that switch. Semi-conductors are not very tolerant to high voltage spikes. If the solenoid is switched by a relay, the voltage spikes might cause arcing and burning (or welding) of relay contacts. Additionally, one end of the solenoid is often connected to a power supply rail. Voltage spikes may travel through the power rail and damage other parts of a circuit, so the diode also has the responsibility to protect those other parts.

As fraxinus points out in a comment, high voltage spikes can cause breakdown in the insulation in the solenoid, and damage the solenoid itself, so the diode needs to protect the solenoid.

Also, as TonyStewartSunnySkyGuyEE75 points out in comments and in his answer, the collapsing magnetic field may induce voltage in other wires that are not directly connected to the solenoid circuit, i.e. through mutual induction.

The leads of the solenoid have inductive properties just as the solenoid does. To reduce the inductive effects of the leads they should be twisted together.

In the industrial equipment that I have worked on, the switches for solenoids were always enclosed in metal cabinets, whether the switching device was a relay or transistor. The diodes would be on the circuit board for the transistor, or the mounting socket for the relay. I have also seen a pin-ball machine which had diodes soldered directly to solenoids. One difference between these two cases is that the solenoids in industrial settings were environmentally sealed, whereas the pin-ball machine had open wiring underneath the playing surface, and the solenoids were environmentally exposed within that area. Another difference is that the distance between the switch and the solenoid was much greater with industrial machines. Yet a third difference was that, at the time, mosfets were quite expensive, quite prone to failure, and circuit boards in general were expensive. Far more expensive than a solenoid, even a solenoid activated valve. Thus, protecting the circuit-board was paramount. Although the pinball machine had several circuit boards, it mainly relied on electromechanical switches and relays, the relays being comparable in price to the solenoids.

Whether the freewheeling diode should be placed nearer the switching device, or nearer the solenoid, is a design decision whose answer depends upon quite a few factors. If one's main concern is to protect a circuit board, the diode should probably be on the circuit board. Otherwise, factors such as ease of testing, ease of fabrication, ease of access and replacement, concerns about electrical noise etc. may play a significant role in the decision of where to place the free-wheeling diode.

A final note, added at the suggestion of TonyStewartSunnySkyGuyEE75. A single diode is not the only method to "snub" a magnetic device. The peak voltage spike occurs immediately upon the opening of the switch. To reduce the amplitude of this spike, a capacitor may be added. A (non-zener) diode may not dissipate energy fast enough for some purposes. So, a resistor may be added to aid in energy dissipation. In short, a variety of topologies are available.

  • 2
    \$\begingroup\$ The diode / capacitor / both pretty much protect the solenoide as well as the switch. Back EMF of a tyipcal electromechanical solenoide is pretty much able to kill the solenoide itself. The insulation between windings is generally rated for "on" voltage and not much more. \$\endgroup\$
    – fraxinus
    Commented Mar 22, 2021 at 16:44
  • \$\begingroup\$ Good point. Please write an answer, and (if I agree) I will suggest that your answer be the accepted one. \$\endgroup\$ Commented Mar 22, 2021 at 16:57
  • \$\begingroup\$ IF one uses a relay with dry contacts to switch the solenoid, you want the diode directly across the coil leads and nowhere else , unless you understand the crosstalk of dI/dt= V/L when dt goes to near zero. Therefore -1 Even better is a RC snubber and Zener+diode if EMI impulse noise is an issue and solenoid return speed is an issue. \$\endgroup\$ Commented Mar 23, 2021 at 21:13
  • 1
    \$\begingroup\$ @TonyStewartSunnyskyguyEE75 the question says nothing about a relay, nor about wetted, nor dry contacts, etc. But if you want to downvote, that is your business. \$\endgroup\$ Commented Mar 23, 2021 at 21:55
  • \$\begingroup\$ THe question is about the optimum location for the diode ( for any application) > So on the technical reasons I gave there are times when it is the only right location. This is one of two reasons why it is never included across a solenoid or relay coil \$\endgroup\$ Commented Mar 24, 2021 at 1:10

Generally the difference is radiated EMI Since you want to have twist pair wires to reduce the EMI to lower the differential EMF , and the current comes from some switch, you want to continue the current path along the same twisted loop with the diode across the switch, as the current continues and the voltage collapses with current decaying. Diodes also slow down the solenoid return from T=L/Rdiode being larger than a snubber or Zener + a diode that can handle it.

  • so across the switch/ diode combo is best so you don’t get a large dI/dt between the switch and the diode across the coil , radiating an H field noise impulse.


There are many ways to protect a switch of any type from flyback arcs in air or high voltage on semis from turning off a magnetic coil current. The reasons given are one why it is not provided. The other is that are faster ways but more parts to create a dampened safe flyback.

Yet for light loads on relays, this diode across the switch is the most common.

  • \$\begingroup\$ Here I put in 2 diodes for you purpose to analyze charge flow simulation where abrupt stops implied high frequency dI/dt or power radiated dP/dt tinyurl.com/yz5ykbvm \$\endgroup\$ Commented Apr 11, 2021 at 22:03

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.