EN

Flyback diode for relays and coils

Voltage on the transistor and release time with each way of protecting an inductive load

Calculator

Coil
V
Ω
mH
% of I
Protections compared
Ω
V
V
V

Coil current after the transistor opens

If you do not know the inductance, small 5 to 24 V relays are usually between 0.1 and 1 H; it can be measured with an LCR meter or from the time constant with an oscilloscope. The calculated time is how long the current takes to fall to the release level; the contact then takes a few more milliseconds to separate because of the relay mechanics.

Why it is needed

A coil opposes changes in current. While the transistor conducts, the current I = V/R creates a magnetic field that stores energy. When switched off, the coil tries to keep that current flowing and generates whatever voltage it takes:

\[ v = L\,\frac{di}{dt} \qquad E = \tfrac{1}{2}\,L\,I^2 \]

If the current has nowhere to go, di/dt is huge and the voltage on the collector or drain rises to hundreds or thousands of volts in microseconds, until something gives: the transistor breaks down, an arc jumps or interference is radiated that resets the microcontroller. A transistor can survive a few of these hits and fail weeks later, which makes the fault hard to diagnose.

How the diode works

The freewheeling (flyback) diode is placed in parallel with the coil, with the cathode towards the positive. While the transistor conducts, the diode is reverse-biased and does nothing. When it opens, the coil current keeps flowing through the diode and the voltage on the transistor is limited to the supply plus about 0.7 V. The energy is dissipated gradually in the coil's own resistance:

\[ i(t) = \left(I_0 + \frac{V_a}{R}\right) e^{-t R / L} - \frac{V_a}{R} \]

Here Va is the voltage opposing the current in the discharge loop: 0.7 V with a diode alone, or 0.7 V plus the Zener voltage. The higher that voltage, the sooner the current reaches zero.

The drawback: release takes longer

With the diode alone, the current falls slowly and the relay takes longer to release. The contact opens slowly, more arcing occurs and it wears out sooner, especially with DC loads. In solenoid valves and brakes the delay can be noticeable in the process. The solution is to discharge the energy at a higher voltage, without exceeding what the transistor can withstand:

ProtectionVoltage on the transistorReleaseNotes
DiodeV + 0.7 VThe slowestSimplest and cheapest. Fine for most signal relays
Diode + resistorV + 0.7 V + I·RsFasterRs of the order of the coil resistance; the peak grows with Rs
Diode + ZenerV + 0.7 V + VzVery fastBest balance between speed and voltage; the voltage is well defined
TVS or Zener across the transistorVTVSVery fastAlso protects against spikes coming in through the cable
RC network or varistorDepends on the valuesFastFor AC coils, where a diode cannot be used
MOSFET avalancheMOSFET breakdownThe fastestOnly if the datasheet guarantees repetitive avalanche energy EAS

Many relay modules and drivers such as the ULN2803 already include the diode; in the ULN2803 it only works if the COM pin goes to the positive of the coils.

Related: transistor as a switch, ULN2803 for relays and loads, optocoupler and RLC circuit.