Home / Circuit lab / Relay flyback diode

Relay coil flyback diode simulator

Switch off a relay coil and it fights back with a voltage spike that can destroy the transistor driving it. See how big the spike is, then fix it with a diode.

Intermediate

coilfrom pinD1

Challenges

  1. With no protection, change the coil or the stray capacitance until the spike goes over 5,000 V.
  2. Fit protection that keeps the collector under 15 V.
  3. Release the relay at least five times faster than a plain diode, while keeping the collector under 45 V.
  4. Find the zener voltage that pushes the collector over the transistor's 45 V rating.

Controls

Readings

Why a coil kicks back

A relay coil is an inductor. Current flowing through it builds a magnetic field, and that field stores energy, ½ × L × I². An inductor resists any change in its current: V = L × di/dt. When the transistor switches off, it tries to stop the current almost instantly. A huge rate of change means a huge voltage, and the coil drives its current onwards into whatever it can, here the tiny stray capacitance at the transistor's collector. The voltage shoots up until the coil's energy has been dumped.

In the simulation, a 12 V relay with no protection can reach a couple of thousand volts. In a real circuit the transistor breaks down first, typically somewhere above its rating (45 V for a BC337), and the energy is dumped inside the transistor. Do it a few thousand times and the transistor fails, often short circuit, so the relay then stays on.

The flyback diode

A diode across the coil, with its cathode to the positive supply, does nothing while the transistor is on, because it's reverse-biased. When the transistor turns off, the coil's current simply carries on round through the diode. The collector rises to only about 0.7 V above the supply, and the energy is used up slowly in the coil's own resistance. Every transistor, MOSFET or microcontroller-driven relay, solenoid or motor needs one. Many relay modules have it built in. The relays guide shows how to wire one.

The catch: slow release

With only a diode, the current dies away with the coil's time constant, L ÷ R. While the current is still flowing, the relay stays pulled in, so it releases late and its contacts open slowly. That increases arcing and wear on the contacts, and matters for fast or high-current switching. Contactor and relay makers point this out in their data.

Faster release with a zener

Put a zener diode in series with the flyback diode and the coil current has to push against the zener voltage too. The coil's energy is dumped much faster, so the relay releases sooner. The price is a higher collector voltage, supply + 0.7 V + zener voltage, which must stay safely under the transistor's rating. That's the balance the challenges ask you to find. Other options include a resistor in series with the diode, or a transient voltage suppressor (TVS) diode.

How this simulation works

The coil is an ideal inductance in series with its resistance, and the transistor is a perfect switch that drops 0.2 V when on. Without protection, the circuit is the coil ringing with the stray capacitance, solved numerically, and the model deliberately ignores the transistor breaking down, to show how big the spike would try to be. With protection, the diode drops a constant 0.7 V and the zener holds its rated voltage, and the release time is exact for that model. Real coils' inductance changes as the armature moves, so the release time is a guide. Check your relay's datasheet for its coil resistance.

Keep exploring