In most electrical circuits with a relay, a diode is connected in parallel to the coil of the relay. Why? Is it always a good practice?
Since an inductor (the relay coil) cannot change it's current instantly, the flyback diode provides a path for the current when the coil is switched off. Otherwise, a voltage spike will occur causing arcing on switch contacts or possibly destroying switching transistors.
Is it always a good practice?
Usually, but not always. If the relay coil is driven by AC, a bi-directional TVS-diode (or some other voltage clamp) and/or a snubber (series RC) need to be used. A diode would not work in this case as it would act as a short-circuit during the negative half-cycle of the AC. (See also Red Lion SNUB0000 for application info)
For DC driven relays, a diode is usually used, but not always. As Andy aka pointed out, sometimes a higher voltage than what is allowed by a diode alone is desired for faster turn-off of the relay (or other such as solenoids, flyback transformers, etc.). In this case, a uni-directional TVS-diode is sometimes added in series with the flyback diode, connected anode to anode (or cathode to cathode). A series resistor could be used in place of the TVS-diode, but the clamping voltage is more deterministic if the TVS-diode is used.
If a MOSFET is used as the switching element, normally you still need the flyback diode as the body diode is in the opposite direction to do any good. An exception to this is a MOSFET that is "Repetitive Avalanche Rated" (such as IRFD220). This is normally drawn with a zener diode symbol for the body diode. These MOSFETs are designed to clamp the voltage at a level they can withstand, allowing the higher voltage for quicker coil turn-off. Sometimes an external uni-directional TVS-diode (or zener) is placed in parallel with the MOSFET for the same purpose, or if the MOSFET cannot handle the "Repetitive Avalanche Current" or "Repetitive Avalanche Energy", or if the avalanche breakdown voltage is higher than desired.
Is it always a good practice?
It's nearly always good practice and it's very effective BUT, if you are needing a relay that deactivates as quickly as possible then there are alternative methods. The reason it is slow is because when the circuit to the relay coil opens, all the energy stored in the relay coil forces a current thru the flywheel diode until that energy is "spent".
The diode acts like a short circuit with a small forward volt-drop and with the resistance of the relay (maybe 100 ohms), it will delay the relay de-activating a few extra milli-seconds. This is not usually a problem but, if it is, then putting a resistor in series with the diode means the energy is "spent" significantly quicker.
The down side is that your controlling transistor has to "suffer" a voltage pulse that is significantly more than Vsupply + 0.7V - it may be twice the supply voltage when using a resistor but, in most circuits, finding a transistor that can be adequately rated is not usually a problem.
When the current through a coil is switched off, the coil (being an inductor) will try to maintain the current. When there is no path for this current the voltage across the coil will increase rapidly, and the current will find a path, right through the isolation of a chip or transistor, destroying that component. The diode provides a path for this current, so the energy stored in the coil can be dissipated safely.
So yes, it is a good idea to provide a discharge path.
A diode parallel to the coil is probably the most often used way, but there are other ways, like a snubber (R+C) or a zener diode to ground. A resistor in series with the diode can make the relay fall off faster.
When an electromechanical relay is de-energized rapidly by a mechanical switch or semiconductor, the collapsing magnetic field produces a substantial voltage transient in its effort to disperse the stored energy and oppose the sudden change of current flow. A 12VDC relay, for example, may generate a voltage of 1,000 to 1,500 volts during turn-off. So it is a common practice to suppress relay coils with components which limit the peak voltage to a much smaller level by providing a discharge path for the stored magnetic energy.
Using just a freewheeling diode is not always the best practice. Here are a few suppression methods:
- A bilateral transient suppressor diode
- A reverse-biased rectifier diode in series with a zener diode C. A metal-oxide-varistor (MOV).
- A reversed-biased rectifier diode in series with a resistor.
- A resistor, when conditions permit its use, is often the most economical suppression.
- A reversed-biased rectifier diode.
- A resistor-capacitor "snubber". Generally the least economical solution and no longer considered a practical solution.
- A bifilar wound coil with the second winding used as the suppression device. This is not very practical since it adds significant cost and size to the relay.
The suggested technique for relay coil suppression is to used a reverse biased rectifier diode and a series zener diode in parallel with the coil. This permits the relay to have optimum release dynamics and a good contact life.
Whenever current flow through a coil of wire stops, a voltage spike is created. This spike results from the collapsing of the magnetic field around the coil. The movement of field across the coil produce very voltage spike which can damage electronic components. This is when clamping diode comes into play. By installing C diode in parallel with coil, a bypass is created for the electrons during the time circuit is open or current through coil stops.
As others have mentioned, the diode is connected "anti-parrallel" , i.e. it is wired in "backwards" so it does not conduct in normal operation. It's primary purpose is to limit the voltage appearing across the relay when it is turned off, which in turn limits the voltage across the switching element (bipolar transistor or MOSFET or relay contacts) which protects the switching transistor from failing due to overvoltage. The diode only works in DC circuits, an alternative is needed for AC circuits (e.g. a varistor or resistor + capacitor. The drawback of using a diode is that the turn_off is a lot slower than turn_on of the relay (or solenoid) , this could be a problem for a relay as it's contacts will open slowly, and possible arc. It might be an advantage for a hydraulic solenoid, as the valve will close slowly without water hammer. If an alternative higher supply voltage is available, then the diode could be connected to this; for example powering the relay from 12v, and having the diode go to 24v means the switch on and switch off times would be roughly similar, and the stored energy is dumped into the 24v supply. If the coil is to be switched repeatedly then a lot of energy will be wasted with the simple diode circuit, a slightly more complex arrangement can recover most of the energy. Another drawback is the diode circuit does not limit the voltage rate of change, known as dV/dT, this can be a problem if the switching element is a set of contacts, as it will cause the contacts to arc over, in that case a snubber using resistor + Capacitor or Resistor+Capacitor+Diode would be needed to limit the "off state dV/dT". The high dV/dT can also create EMI , and general purpose diodes like 1N4001 are very slow switching, so can easily generate a 5nS wide high voltage pulse before snapping on, so a clamp diode should be a schottky diode to avoid EMI. Just having a clamping diode across the coil does not prevent all failure modes, for example plugging and unplugging the coil into a socket while active or bridging the transistor with jumper clips can damage the switching transistor due to the extreme dV/dT involved.