Inductors, Transformers and Relays
Parts that use magnetic fields: inductance and energy storage, the L/R time constant, voltage spikes when current is interrupted, flyback diodes across coils, transformers and turns ratios, and how relays work and how to drive them safely from a logic pin.
1. Inductors
An inductor is a coil of wire. Current through it creates a magnetic field, and the coil opposes any change in its current. Its inductance L is measured in henries (H); typical parts are µH to mH.
| Idea | Capacitor | Inductor |
|---|---|---|
| Opposes change in | Voltage | Current |
| Stores energy in | Electric field | Magnetic field |
| Passes | AC (blocks steady DC) | DC (resists fast AC) |
| Energy | ½ C V² | ½ L I² |
- A coil of 100 mH carrying 0.5 A stores 0.5 × 0.1 × 0.25 = 12.5 mJ.
- In a circuit with a resistor, the current rises with a time constant tau = L / R. A 100 mH coil with 50 Ω of resistance has tau = 0.1 / 50 = 2 ms.
- Series inductances add; parallel combine like resistors in parallel (when the coils do not couple magnetically).
- Uses: power supply filters and switching regulators (inductor plus switch), chokes that block noise, radio tuning, relays, motors and solenoids (all contain coils).
2. The voltage spike
Since a coil resists a change in current, switching it off abruptly produces a very large voltage, because V = L × (change in current) / (change in time). If 70 mA through a 100 mH coil is cut in 1 µs, the induced voltage is 0.1 × 0.07 / 0.000001 = 7,000 V in theory; in practice the spike is limited by stray capacitance and arcing, but it is still easily hundreds of volts and will destroy a transistor or a microcontroller pin.
The fix is a flyback (freewheel) diode wired across the coil, reverse-biased in normal operation:
+V ----+---------+
| |
[coil] (diode) cathode to +V, anode to the transistor side
| |
+---------+
|
collector of the switching transistor
When the transistor turns off, the coil’s current keeps flowing through the diode in a loop and decays safely. Use one across every relay, motor, solenoid or buzzer coil that is switched by a transistor. A 1N4007 or 1N4148 suits small relays; for faster switch-off a Zener in series with the diode is sometimes used.
3. Transformers
A transformer has two coils on a shared magnetic core. An alternating current in the primary creates a changing magnetic field that induces a voltage in the secondary. For an ideal transformer:
Vs / Vp = Ns / Np Is / Ip = Np / Ns
- 1,000 turns on the primary and 50 on the secondary, with 230 V in, gives 11.5 V out: a step-down transformer. The secondary can supply 20 times the current of the primary (power in ≈ power out).
- Transformers do not pass DC, and real ones lose some power as heat, so the primary draws a little current even with no load.
- Mains transformers also provide isolation between the mains and the low-voltage side, which is important for safety. Use only certified, enclosed ones; never build mains circuits without proper training.
- Small switch-mode power supplies use high-frequency transformers, which are much smaller and lighter.
4. Relays
A relay is an electrically operated switch. A small current in a coil magnetically moves a contact, so a low-voltage circuit controls a separate load, with galvanic isolation between the two.
| Term | Meaning |
|---|---|
| Coil voltage and resistance | For example 5 V and 70 Ω; current = V / R = about 71 mA |
| COM, NO, NC | Common, normally open and normally closed contacts |
| Contact rating | Maximum load voltage and current (for example 10 A at 250 V AC, with a lower DC rating) |
| SPST, SPDT, DPDT | Poles and throws: how many circuits and positions |
Points to know:
- The coil often needs more current than a microcontroller pin can supply (usually 20 mA or less), so drive it with a transistor and add the flyback diode.
- Mechanical relays are slow (milliseconds), make a click, and wear out. Solid-state relays (SSRs) switch silently and last longer but have their own voltage drop and heat.
- Never switch mains with a hobby board unless it is properly enclosed, rated and wired by someone qualified. Use a certified, isolated module.
- Respect the DC rating: a contact rated for 10 A AC may only handle 1 to 2 A of DC at the same voltage, because DC arcs persist.
5. On your bench
- Measure the coil resistance of a relay with the multimeter and calculate the coil current at its rated voltage. Compare it with the coil current from a 20 mA pin limit.
- Switch the relay with a push-button directly from a 5 V supply, listen for the click, and check with the continuity mode that the NO contact closes.
- Build a transistor switch for the coil (transistor lesson next) and put the flyback diode across the coil in the wrong and right way: with the diode in the correct way the circuit works, and on the scope you can see the spike when the diode is removed (only with a supply of 5 to 12 V and a scope with a probe you trust).
- Measure the primary and secondary resistance of a small low-voltage transformer, and write down the turns ratio from its label.
6. Hands-on lab: coils, relays and transformers
7. Common mistakes
| Mistake | Better |
|---|---|
| Driving a relay coil straight from a microcontroller pin | Use a transistor or a relay driver module |
| No flyback diode across a coil | Always add one, cathode toward the positive side |
| Putting the diode in backwards | It must be reverse-biased in normal operation |
| Switching DC loads at the AC contact rating | Use the DC rating, or a different relay |
| Working on mains with hobby wiring | Use certified, enclosed parts and a qualified person |
| Expecting a transformer to work on DC | It needs AC |
8. Key takeaways
- An inductor resists changes in current, stores ½LI², and has a time constant L/R.
- Switching a coil off creates a voltage spike; protect with a flyback diode across every relay, motor and solenoid.
- A transformer scales AC voltage by the turns ratio (Vs = Vp × Ns / Np) and gives isolation.
- A relay is a coil-operated switch: check coil voltage and current, COM/NO/NC and the DC contact rating; drive it with a transistor.
Why can a relay coil destroy a transistor even if the relay's load is small?
The coil, not the load, causes the damage. When the transistor turns off, the coil’s stored energy has nowhere to go and produces a spike of tens or hundreds of volts at the collector, far over the transistor’s rating. A flyback diode across the coil gives the current a safe path and clamps the voltage to about 0.7 V above the supply.
Can You Explain It?
Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.
- Explain why switching off an inductive load creates a voltage spike and how a flyback diode stops it.
- Describe how a transformer changes voltage and why it does not work on DC.
- List what you check before using a relay, including coil current and contact ratings.
🧪 Want to practise this on your own computer? See how to set up your lab →