Relay Driver Failure and Missing Flyback Diode
A student uses a 5 V microcontroller output to switch a 12 V relay. The relay coil resistance is 400 Ω and is connected between the +12 V supply and the collector of an NPN transistor; the emitter is grounded. The transistor data gives hFE(min) = 100 and VCE(sat) = 0.2 V. The base is driven through a 1 kΩ resistor from the microcontroller pin, which can source 4 mA comfortably and has an absolute maximum of 20 mA. No diode is fitted across the coil. After a week the relay chatters and the transistor fails short-circuit between collector and emitter. The microcontroller still works. The student has spare 1N4007 diodes, 1 kΩ and 10 kΩ resistors, and a 2N2222 transistor. The relay contacts switch a 240 V desk lamp. Explain the failure and propose a corrected circuit.
1. Calculate the relay coil current at 12 V, the minimum base current for hard saturation using a forced beta of 10, and the actual base current with the 1 kΩ resistor. Is the transistor driven hard enough?
Read the worked answer
Coil current: I_C = (12 − V_CE(sat))/R_coil ≈ (12 − 0.2)/400 = 29.5 mA, often rounded to 30 mA.
For hard saturation, use a forced beta of about 10, not the datasheet h_FE. Minimum base current: I_B(min) = 30/10 = 3.0 mA.
Actual base current with 1 kΩ: I_B = (V_MCU − V_BE)/R_B ≈ (5 − 0.7)/1000 = 4.3 mA.
This is greater than 3 mA, so the transistor is driven hard enough. The available gain is 100 × 4.3 mA = 430 mA, far above the 30 mA coil current. The 4.3 mA also is below the microcontroller's 20 mA absolute maximum, although it is slightly above the 4 mA 'comfortable' figure. A 1.2 kΩ resistor would give (5 − 0.7)/1200 ≈ 3.6 mA, still above 3 mA with more margin for the MCU. The base resistor is not the cause of the failure.
2. Explain why the transistor failed and why the relay chattered. Include the path of the inductive kick and the function of the 1N4007.
Read the worked answer
The relay coil is an inductor. When the transistor is on, current builds in the coil and energy is stored as ½LI². When the transistor turns off, the coil current cannot stop instantly. The collapsing magnetic field generates a voltage V = L di/dt, with the collector going positive. The collector can be driven far above the 12 V supply, possibly hundreds of volts, exceeding the transistor's V_CEO (about 40 V for a 2N2222). The transistor then avalanches, heats and fails. A short-circuit collector–emitter failure is consistent with this.
Chattering can come from the same mechanism: each turn-off spike disturbs the supply and the MCU, and the transistor may be repeatedly stressed. A missing base pull-down also lets the base float during MCU reset, so the relay can switch randomly.
The 1N4007 must be connected across the coil, with its cathode to +12 V and anode to the collector. Normally it is reverse-biased. At turn-off it becomes forward-biased and clamps the collector to about 12.7 V, while the coil current circulates through the diode and coil resistance. The energy is dissipated as heat rather than in the transistor.
3. Propose the corrected circuit, including component values and layout/protection. State whether the 2N2222 is suitable and what else you would check for the 240 V lamp switching.
Read the worked answer
Corrected circuit: keep the relay coil between +12 V and the collector; emitter to 0 V; 1N4007 across the coil (cathode to +12 V, anode to collector); base driven through 1 kΩ or 1.2 kΩ; add a 10 kΩ resistor from base to emitter to define the off state. Add a 0.1 µF decoupling capacitor near the relay supply and keep the coil and MCU wiring separated.
The 2N2222 is suitable: I_C ≈ 30 mA is well below its 600 mA rating, and with the diode clamp the collector voltage is held near 12.7 V, below its 40 V V_CEO. Check the relay coil's actual resistance and rated current, because a different relay may draw more.
For the 240 V lamp, check that the relay contacts are rated for 240 V AC and for the lamp's cold-filament inrush current, which can be many times the steady current. Fit a fuse on the 240 V side, keep mains and low-voltage wiring separated, earth the metal enclosure, and use a snubber or MOV across the contacts if switching is inductive or noisy. Do not rely on the transistor's failure as the only fault path.