Part 2 · Chapter 14
Relay driver circuit and the flyback diode
A relay coil is an inductor, so switching it off with a transistor produces a voltage spike far above the supply. A flyback diode across the coil, cathode to the positive supply, clamps that spike to about one diode drop above the supply and keeps the driving transistor safe.
Why a relay coil needs a driver
A relay coil draws tens of milliamps or more, which is too much for a microcontroller pin, so a transistor switches the coil current. The pin drives the transistor's base through a resistor, and the coil sits in the collector circuit. The relay itself is described in the relay simulator, with its pull-in and drop-out voltages, which create the hysteresis that stops the contact from chattering.
Sizing the transistor driver
Worked example: a 12 V relay with a 400 Ω coil and a 5 V logic signal.
1. Coil current: , with a coil power of 0.36 W. 2. Base current for a forced gain of 10: . 3. Base resistor: . Use the standard 1.5 kΩ, which gives about 2.9 mA. 4. A small-signal NPN transistor rated for at least 100 mA is more than enough.
The reasoning behind the forced gain and the base resistor is in the guide on the BJT as a switch and amplifier. A MOSFET works the same way and needs no base resistor, only a gate resistor and a pulldown.
What happens when the coil is switched off
The current in an inductor cannot change instantly, because the voltage across it is . When the transistor turns off, the 30 mA in the coil has nowhere to go. The coil voltage reverses and grows until something conducts, typically the transistor's collector breaking down at tens or hundreds of volts. That kills a transistor rated for 40 V.
The energy at stake is . For a coil of, say, 0.5 H carrying 30 mA that is only 0.225 mJ, but delivered in microseconds it is enough to damage the transistor, and the spike also couples into other circuits as noise. The same behaviour appears in the RL time constant when a coil is opened.
The flyback diode
Connect a diode across the coil with its cathode on the positive side and its anode on the transistor side. In normal operation it is reverse-biased and does nothing. When the transistor turns off, the coil voltage reverses, the diode conducts and the coil current circulates through the coil and the diode, decaying with the time constant .
For the example, if the 0.5 H assumption holds. The collector now sees only the supply plus one diode drop, about 12.7 V, instead of a spike.
Choosing the diode:
- Its reverse voltage rating must be above the supply voltage, with margin.
- Its forward current rating must be at least the coil current. A 1N4148 (see the PN diode simulator presets) handles a 30 mA coil, and a 1N4001 handles coils up to an amp.
- Speed is not critical, since the pulse is slow.
The diode's forward behaviour is explained in the guide on reading a diode I–V curve.
Side effects and alternatives
A flyback diode makes the relay release slower, because the coil current decays through the diode instead of collapsing quickly, so the contact opens later. This matters when contacts switch heavy loads, since a slow opening increases arcing and wear. A Zener diode in series with the flyback diode lets the coil voltage rise to the Zener voltage, which speeds up the decay. Other options are an RC snubber across the coil, or a TVS diode.
On an AC coil a diode cannot be used, and an RC snubber or varistor is used instead. Also check the contact rating, which is separate from the coil protection: the contacts see the load's own inductive spike.
Try it in the simulators
Open the relay simulator and raise the coil voltage slowly to see the pull-in point, then lower it to see the drop-out point. Then open the NPN BJT simulator and see how the base current moves the operating point between cutoff, the active region and saturation, the on and off states a relay driver relies on.
Coil resistance and contact rating
The coil is a resistor as far as steady-state current is concerned: coil current is the coil voltage divided by the coil resistance, so a 12 V relay with a 400 Ω coil draws 30 mA and dissipates 360 mW. The contacts have their own limits, listed as a maximum current and voltage. Exceeding the contact rating causes arcing, welding or rapid wear, and inductive loads such as motors and solenoids need a derated figure because breaking them produces a voltage spike.
Sources and further reading
- P. Horowitz and W. Hill, "The Art of Electronics", sections on inductive loads and relays.
- A. S. Sedra and K. C. Smith, "Microelectronic Circuits", chapter on bipolar junction transistors.
- IEC 61810-1, "Electromechanical elementary relays: General and safety requirements".
Try it in the simulator
Frequently asked questions
- Why does a relay need a flyback diode?
- The relay coil is an inductor. When the driving transistor turns off, the coil produces a large voltage spike that can destroy the transistor. The diode gives the coil current a path and clamps the voltage to about the supply plus 0.7 V.
- Which way round does the flyback diode go?
- Across the coil with the cathode (the banded end) towards the positive supply and the anode towards the transistor. It is reverse-biased in normal operation.
- Which diode should I use for a relay coil?
- A 1N4148 is enough for coils up to about 100–200 mA. A 1N4001 or similar suits larger coils. The reverse voltage rating must exceed the supply voltage.
- Does a flyback diode slow down the relay?
- Yes. The coil current decays more slowly, so the contacts open a little later. A Zener diode in series with the flyback diode or an RC snubber makes the release faster.
- Can a relay switch more current than its coil draws?
- Yes, that is its purpose. A coil may draw 30 mA while the contacts switch 10 A or more, provided the load stays within the contact rating. The current and voltage ratings of the contacts, not the coil, set the limit, and inductive loads need a lower figure.