Lesson 01 Inductance for MCU & DC ~15 minutes ↑ Contents Reference sheet →

The current flywheel

Why opening a switch is more dangerous than closing one — and why the coil, not you, decides what voltage appears next.

Where this is going. By the end you should be able to open a relay datasheet and put a number on the transient your MCU circuit has to survive. That number is the input to every protection decision in the lessons that follow.

You have wired plenty of relay and motor circuits with a diode sitting backwards across the coil. This lesson is about what that diode is for — not the rule, the mechanism. Once you can see the mechanism you can size the part instead of copying it.

There is exactly one idea to hold onto, and everything else falls out of it.

Switch closed

A coil is a flywheel for current

A capacitor resists a change in voltage: put a step of voltage across one and it fights back by gulping current. An inductor is the mirror image. It resists a change in current. Push current into a coil and the coil pushes back; take current away and the coil pushes back just as hard, in the other direction.

The mechanical picture is a flywheel. You cannot spin one up instantly — you apply torque and the speed ramps. You also cannot stop one instantly, and if you try, something breaks. Current is the speed. Voltage is the torque.

The whole lesson, in one line V = L × (dI/dt) In words: the voltage across a coil is set by how fast its current is changing. Not by how much current flows — by how fast it is changing. dI/dt is just notation for “amps of change per second”; 40 mA vanishing in 1 ms is a dI/dt of 40 A/s.

Allegro MicroSystems states this as Equation 1 in AN296235, “Driving Inductive Loads” — the primary source for this lesson.

Read it forwards and it explains the boring half: hold a fixed voltage across a coil and the current ramps steadily upward, because a constant V demands a constant rate of change. That is why a relay does not pull in the instant you drive the pin.

Read it backwards and it explains everything dangerous.

The moment of opening

The coil is not asking permission

Rearrange the equation and it says: to make dI/dt large, the coil will produce a large V. It is not a request. Allegro puts it flatly:

From the application note

“Current flow in an inductor cannot be stopped instantaneously. If an external attempt is made to stop current flow, a circuit path must be provided to allow that current to continue to flow and decay in a controlled manner. Failure to provide a circuit path … leads to generation of a high voltage across the inductor, rapid current decay, and possible circuit damage.”

Your transistor turning off is an external attempt to stop current flow. The coil answers by raising the voltage at the switch node — and it keeps raising it until something, somewhere, conducts. If you have not chosen what that something is, the coil chooses for you. It usually picks your transistor.

No oscilloscope required. The panel below integrates the circuit equations directly, so you are looking at the same maths a scope would be measuring. Hit Sweep to redraw. The dashed trace is whichever mode you looked at last, kept for comparison.

Below is the exact circuit you have built a dozen times: a 12 V relay coil, a low-side switch driven by an MCU pin. Watch the node voltage at the instant the switch opens, then flip the clamp on.

Two things are worth noticing, and neither is the one people expect.

First, the current trace barely changes between the two modes at turn-on. The clamp does nothing while the switch is closed. All the drama is in the last few microseconds of the coil's life.

Second, with no clamp the voltage trace leaves the instrument. That is not a rendering bug — it is the point. There is no sensible scale that fits both the 12 V you designed for and the spike you did not.

Read the datasheet

Putting real numbers on it

Those simulator values are not invented. They come from the Omron G5V-2, one of the few small relays that publishes coil inductance rather than just resistance.

Omron G5V-2 datasheet, “Coil Ratings — Standard Models”. Values are quoted at 23 °C, ±10%.

Omron G5V-2, standard, 12 VDC coil
Rated coil voltage12 Vwhat you drive it with
Coil resistance288 sets the steady current
Rated current41.7 mA12 V ÷ 288 Ω, as expected
Inductance, armature off0.47 Hrelay released
Inductance, armature on0.74 Hrelay pulled in — use this one

First real design habit

A relay's inductance is not one number. The iron moves, so the magnetic circuit changes, so L changes — here by nearly 60%. When you analyse turn-off, the relay is energised and the armature is on. Use 0.74 H, the larger figure. Using the released value would under-predict the transient, which is the wrong direction to be wrong in.

How hard is this coil actually pushing?

Suppose the transistor kills 41.7 mA in one microsecond. That is a dI/dt of 41,700 A/s, and the equation returns:

V = 0.74 H × 41,700 A/s ≈ 31,000 volts

You will never measure 31 kV on that node, and that is exactly the right way to read this number. It is not a prediction — it is a measure of how badly the coil wants it. The voltage climbs, hits your transistor's breakdown rating long before 31 kV, and stops there because the transistor has started conducting whether it wanted to or not.

Stray capacitance on that node is a few tens of picofarads. At 41.7 mA it charges to 60 V in roughly 43 ns — which is why this looks like a vertical line on the scope, and why a slow measurement never sees it.

Meanwhile the energy the coil banked while it was on is

E = ½ L I² = ½ × 0.74 × 0.0417² ≈ 640 µJ Small on its own — but delivered in under a millisecond, into a piece of silicon the size of a grain of rice, every single time the relay switches off. Physics LibreTexts derives this formula.

The door

Give the current somewhere to go

The fix follows directly, and it is not “block the spike”. You cannot block it. The current is going to flow. The only decision available to you is where.

A diode across the coil, cathode to the positive rail, is reverse-biased and idle the whole time the relay is on. The moment the switch opens and the node starts to climb, the diode reaches forward conduction and hands the current a loop it can circulate in. Go back to the panel and select Flyback diode: the node stops at 12.7 V — the rail plus one diode drop — instead of leaving the screen.

The trade you just made

Look at Current to zero in the readout. Unclamped: about 0.6 ms. With the diode: about 7.4 ms, roughly thirteen times longer. Allegro's phrasing is that the rate of decay is proportional to the voltage the path clamps at — and 0.7 V is a very gentle brake. The relay's armature cannot release until that current has gone, so a plain diode slows the relay down.

That is the whole design tension of inductive-load protection, and it is why there is no single right answer: a lower clamp voltage is kinder to your transistor and slower to release the load. Every clamp you will meet — plain diode, diode plus resistor, zener, TVS, active clamp — is a different point on that one trade.

Lesson 02 takes that trade and turns it into a component you can order.

Retrieval

Check yourself

Answer before scrolling back. Getting one wrong now is worth more than getting it right by re-reading — the failed attempt is what makes the correction stick.

On the bench

See the kickback with no oscilloscope

You do not have a scope, but you can still prove the central claim with your own eyes: the coil produces a voltage higher than the supply ever could.

You need: one relay (any small DC relay — the coil is the part that matters), a single AA cell, a blue or white LED, and two bits of wire.

  1. Wire the AA's + terminal to one coil pin. Call that pin A.
  2. Connect the other coil pin — call it B — to the AA's terminal with a loose wire you can tap on and off.
  3. Now bridge the LED across the coil: cathode (short leg, flat edge of the rim) to pin A, anode (long leg) to pin B. That is exactly a flyback diode's orientation.
  4. In a dim room, tap the loose wire on and off against the battery terminal.

Predict before you tap. A blue LED needs about 3 V to light. Your supply is 1.5 V. Write down what you expect, then look.

Why an AA and not the bench supply. While the coil is energised that LED sits reverse-biased across the full supply, and most LEDs are only rated to about 5 V in reverse. At 1.5 V it is comfortable; at 12 V you would destroy it. Which is also the reason nobody uses an LED as a real flyback diode.

What you are watching is a diode doing its job, and telling you about it. Every flash is current that would otherwise have gone through your transistor.

Go deeper

Primary source

Allegro MicroSystems — AN296235, “Driving Inductive Loads” (PDF, ~8 pages).

Read the Introduction and Driving Inductive Loads sections — the first page and a half. That is the material in this lesson, stated by the people who build the driver chips. Stop when it reaches gate-driver configurations; that is lesson 03 territory. It is the highest-signal free source found so far for this mission, and everything in it is on-topic.