I have four 6V, ~80mA Relays mounted on a Perfboard which are being controlled by the 2N2222 Transistors.
The basic problem is that after mounting everything the diodes can't fit in easily.
Is the Flyback Diode really necessary?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
-- EDIT --
If you can figure out a way to ramp the inductor's current down bit by bit without using PWM, with a MOSFET with a sufficiently high
current blocking voltage rating you may be able to get away without the flyback diode. However this would require you to control this ramping precise enough not to ramp its current down too quickly and the turn down time can be very unbearable.
-- ORIGINAL POST --
TL; DR: It is necessary - it is critical you can say. It makes your circuit last longer.
Theory: Flyback diode.
Extended ELI5 answer:
Relays are switches controlled by an electromagnet, and electromagnet is essentially a BFI - big f***ing inductor. Inductors do not allow the current through it change rapidly. The bigger the inductance it have, the harder it will fight to keep its current constant, drawing energy it stored in the form of its magnetic field.
Consider we are using a mechanical switch to control this relay. When it is constantly kept powered, it is saturated and act simply as a small resistor, passing, let's say, 500mA of current.
Now switch it off. An opened switch poses several GΩ of resistance in the circuit, being essentially an air gap. However the current across the inductor cannot drop immediately, and to keep this several amps of current flowing the inductor from changing the inductor induces enough voltage to break the air down into plasma across the open switch contacts and force the current to arc across. That is several kV (!!) of voltage and a fire hazard. (!!!)
Now let's say we have a transistor instead of a mechanical switch. I am using my personal favourite
2N7000 N-MOSFET here. With the control driven high, the coil is in a similar saturated state acting as a small drain resistor.
When the gate is suddenly grounded the similar situation will happen across the MOSFET's drain and source pins, easily break the transistor down to conduct that induced current. Such a voltage pike will take out a signal transistor after several rounds of switch-off spikes if not outright. For BJT's like
2N2222 the situation is even worse as one single Zener zap and your transistor is gone.
Now we have a diode reverse parallel with the coil there. I used
1N5819 Schottky which allows faster switching and better suited with motors that need PWM control, for relays slower
1N4007 can be used but it have a higher forward voltage. The same start situation, coil saturated. In this state, the diode is reverse biased and do not affect the circuit.
The instant the transistor is off, the current begin to flow through the diode. The transistor will only see a drain-source voltage of at most a few volts higher than the supply voltage.
This is an extended explanation why you need a diode antiparallel across the coil. It keeps your circuit from being fried by an inductive voltage spike from the coil.
Without the diodes the 2N2222 transistors will die fairly quickly - the voltage lash can (briefly) exceed several hundred volts, which is not great for a transistor rated to maybe 50V.
You could probably solder the diodes onto the back of the board, across the relay coil pins.