45. Design a relay driver

Circuit

Loading simulator…

Design Approach

A 5 V control signal cannot directly supply a 12 V relay coil. A low-side MOSFET supplies the coil current, while a diode provides a safe path for the coil’s stored magnetic energy when the MOSFET turns off.

How the Circuit Works

  1. Drive the coil through Q1. The supplied N-channel Q1 switches the low end of relay K1 to ground. The solution supplies VCC = 12 V to the other coil terminal and adds RG = 330 Ω in series with CTRL_IN at the gate.
  2. Give the gate a default state. RPD = 100 kΩ pulls the MOSFET gate LOW when the control signal is absent. When CTRL_IN = 5 V, Q1 turns on and coil current approaches:12V100Ω=120mA\frac{12\,\mathrm{V}}{100\,\Omega} = 120\,\mathrm{mA}
  3. Use the relay contacts. The solution adds a separate V_LAMP = 12 V rail to the relay’s normally open contacts and 12 V, 5 W lamp L1. Energizing the coil closes the contacts and powers the lamp without routing lamp current through the control pin.
  4. Suppress turn-off voltage. D1 is connected across the coil, reverse-biased during normal operation. When Q1 turns off, coil current circulates through D1 rather than generating an uncontrolled drain voltage spike. For L = 100 mH and Rcoil=100Ω\mathrm{Rcoil} = 100\,\Omega, a rough decay time constant is 1 ms, supporting the specified ≤10 mA within 3 ms check.

Verify the Circuit

Set CTRL_IN = 5 V, let the relay settle, and confirm approximately 120 mA coil current and lamp ON. Switch to 0 V and inspect coil current at 3 ms, MOSFET drain-source voltage during switching (≤16 V), and lamp OFF by 30 ms.

Key Learnings

  • Relay coils are inductive, so their stored energy must be managed during turn-off.
  • A conventional flyback diode protects the MOSFET but also slows coil-current decay and contact release.