Sub topic 13
Switching off an inductor: voltage spikes and flyback diodes
This chapter assumes you know v = L di/dt, that inductor current cannot change instantly, the energy formula w = (1/2) L i², and the RL time constant L/R. It also assumes you can read a basic switch circuit.
Why opening a switch is dangerous
An inductor carrying current holds energy in its magnetic field. The law v = L di/dt says that any change in current produces a voltage. Current cannot jump, so the inductor tries to keep the same current flowing when you break its path.
Suppose a switch carrying 2 A through a 10 mH coil opens in 1 µs. The current falls from 2 A to 0 A in that time. The voltage the coil demands is:
L = 10e-3 # henries
di = -2.0 # current change in amperes (falls from 2 A to 0 A)
dt = 1e-6 # switch opening time in seconds
v = L * di / dt
print(v) # -20000.0 voltsThe result is -20 kV. The sign is negative because the current is falling. The coil produces a voltage that tries to push current in the same direction as before. In practice the voltage does not reach 20 kV. It rises until something conducts: an arc across the switch contacts, or a breakdown in a transistor. Either way the energy of 0.02 J has to go somewhere.
What happens inside the circuit
Take a source V, a resistor R, and an inductor L in series with a switch. While the switch is closed for a long time, the inductor acts as a short circuit at DC. The current settles at I = V/R.
At the instant the switch opens, the inductor current is still I. This follows from current continuity. If the switch is an ideal open circuit, no path exists for that current. The mathematics then asks for an infinite di/dt and an infinite voltage. Real circuits avoid infinity because of three effects:
- Arcing. The voltage across the opening contacts grows until the air breaks down. The current continues through the arc and decays as the arc dissipates the stored energy.
- Parasitic capacitance. Every switch, winding, and wire has some capacitance. The inductor current charges this capacitance, and the voltage rises quickly. The inductor and capacitance form a resonant circuit that rings.
- Semiconductor breakdown. If the switch is a transistor, the voltage rises until the transistor goes into avalanche breakdown. This can destroy the device if the energy is larger than the device is rated for.
A relay coil, a solenoid, a motor winding, and a transformer primary are all inductors. Each one produces this spike when you switch it off.
Where the energy goes
The energy before the switch opens is:
L = 10e-3 # henries
I = 2.0 # amperes
energy = 0.5 * L * I**2
print(energy) # 0.02 joulesThat is 20 mJ. The spike is the inductor delivering this energy. If you give the current no safe path, the energy goes into the arc or the semiconductor. If you give it a safe path, the energy dissipates gradually in a resistance you choose.
The flyback diode
A flyback diode (also called a freewheeling or snubber diode) is a diode connected in parallel with the inductor. It is oriented so that it is reverse biased during normal operation.
Here is how it works:
- Switch closed. The supply voltage is across the coil. The top of the coil is positive. The diode has its cathode on the positive side, so it is reverse biased and carries no current.
- Switch opens. The coil current wants to continue in the same direction. The coil voltage reverses polarity, because the coil now acts as a source. The bottom end of the coil goes positive relative to the top.
- Diode conducts. The reversed voltage forward-biases the diode. The coil current circulates through the loop made of the coil and the diode.
- Decay. The current decays as the coil resistance and the diode drop use up the stored energy.
The coil voltage is clamped to about one diode drop. For a silicon diode this is roughly 0.7 V in the reverse direction of the original polarity. The spike goes from kilovolts to under a volt.
The decay with a diode
With the diode in place, the loop contains the inductor, its winding resistance R, and the diode. If you treat the diode as an ideal short while it conducts, the current follows:
i(t) = I₀ e^(−t/τ), with τ = L/R
Here I₀ is the current at the moment of switching. This is the natural response of an RL circuit with no source. The code below computes it for a coil with L = 0.5 H, R = 100 Ω, and I₀ = 120 mA.
import math
L = 0.5 # henries
R = 100.0 # ohms (winding resistance)
I0 = 0.120 # amperes at the moment the switch opens
tau = L / R # 5 ms
for k in range(6):
t = k * tau
i = I0 * math.exp(-t / tau)
print(f"t = {k} tau: i = {i * 1000:.1f} mA")After one time constant the current is about 36.8% of its starting value, or 44.1 mA. After five time constants it is below 1%.
Trade-off: the diode slows the release
The diode solves the voltage problem, but it makes the current decay slowly. When the current has a slow path, it takes about 5τ to reach zero. This matters for relays and solenoids. A relay with a flyback diode drops out later than one without, because the magnetic field lingers.
If you need faster release, you can add a resistor in series with the diode. The coil current I₀ now flows through the added resistor R_s, so the peak voltage across the switch is approximately:
Vpeak ≈ Vsupply + I₀ × R_s
The time constant becomes L / (R + Rs). A larger Rs makes the decay faster, and it also makes the spike larger. You choose R_s so that the peak stays below the switch voltage rating.
| Method | Peak voltage across switch | Decay speed | Notes |
|---|---|---|---|
| No protection | Very high, limited by arc or breakdown | Fast | Damages contacts or transistors |
| Diode only | Supply voltage plus about 0.7 V | Slowest | Cheapest and most common |
| Diode plus series resistor | Supply voltage plus I₀ × R_s | Intermediate | Used when the release time matters |
| Zener diode in series with diode | Supply voltage plus the Zener voltage | Fast | Clamps at a chosen level |
| RC snubber across switch | Limited by the capacitor | Depends on the values | Suitable for AC loads and contacts |
Polarity and placement
Two mistakes are common.
- Diode backwards. If you place the diode with the wrong orientation, it conducts when the switch is closed and shorts the supply. This can destroy the diode and the supply. Check that the cathode connects to the more positive side of the coil during normal operation.
- Diode too far from the coil. Wire inductance between the coil and the diode adds a small inductance in the loop. A long wire can let a brief spike through. Mount the diode directly across the coil terminals.
Also check the ratings. The diode must handle the full coil current I₀ at the moment of switching, and its reverse voltage rating must exceed the supply voltage.
Checking the result in a simulator
The SPICE netlist below models the circuit with a diode. The switch is a voltage-controlled switch that closes for 20 ms and then opens. You can remove the diode line to see the spike limited only by the switch model.
* Coil switched off with a flyback diode
V1 in 0 12
S1 in sw ctl 0 SW
R1 sw out 100
L1 out 0 500m
D1 0 out DFLY
VCTL ctl 0 PULSE(5 0 0 1u 1u 20m 40m)
.model SW SW(Ron=0.01 Roff=1e9 Vt=2.5)
.model DFLY D(Is=1e-14 Rs=0.1)
.tran 10u 60m
.endHere the diode anode is at ground and the cathode is on the coil's top node out. Watch the coil's top node voltage and the current through L1. With the diode, the node stays within about a volt of the ground after opening, and the current decays with τ = 5 ms.
Summary of design rules
- Find the worst-case current I₀ in the coil and the energy (1/2) L I₀².
- Decide whether the release time matters. If not, use a diode alone.
- Choose a diode rated above I₀ in forward current and above the supply voltage in reverse voltage.
- Place the device directly across the coil.
- If you use a series resistor or Zener, check that the clamp voltage is below the switch's voltage rating.
Exercise
A solenoid has L = 200 mH and winding resistance R = 20 Ω. It carries 0.6 A from a 12 V supply. A flyback diode, treated as an ideal short, is across it. The switch opens at t = 0. How long does the current take to fall to 0.1 A, and how much energy was stored at t = 0?
Show answer
The time constant is τ = L/R = 0.2/20 = 10 ms. The current follows i(t) = 0.6 e^(−t/τ). Setting this to 0.1 A gives e^(−t/τ) = 1/6, so t = τ ln 6 = 10 ms × 1.792 = about 17.9 ms. The stored energy is (1/2)(0.2)(0.6)² = 0.036 J, or 36 mJ.
Exercise
The same solenoid is protected by a diode in series with a 100 Ω resistor instead. What is the approximate peak voltage across the switch just after opening, with the 12 V supply still connected, and what is the new time constant?
Show answer
The coil current of 0.6 A flows through the 100 Ω resistor, which gives 60 V. The switch sees about Vsupply + I₀ × Rs = 12 + 60 = 72 V. The loop resistance is 20 + 100 = 120 Ω, so τ = 0.2/120 = about 1.67 ms, six times faster than with the diode alone.