I am working on the Automatic Irrigation System from Make. I am having trouble understanding the purpose and placement of a particular diode in this schematic. Make states that in order to protect the MOSFETs from flyback voltage generated by the collapsing magnetic field when a relay is turned off we should use a diode.
Why is it placed in the opposite direction of flow pointing negative to positive. Is this just a loop to cycle any flyback back through the relay, while still allowing current to pass the relay when the MOSFET switch is closed.
Thanks in advance...and yes I popped the first post cherry!
Because when the field collapses in the relay coil, it generates a pulse of the opposite polarity of the current that was flowing through the coil which the diode then "dumps". There are a number of approaches to dealing with those spikes (a Google search for snubbers will find you a lot of good information). The different approaches all have various side effects to consider - the diode can slow down the relay operation although that is not likely to create a problem in your case. Another one I often will use where I am not operating the relay very fast is to use a bit of an RC network on the base/gate of the drive transistor that slows down the turn on/turn off times. Since the field is not collapsing as fast, the resulting inductive kick is much smaller. One of the downsides to that can be heating in the drive transistor since it is now in the linear region for a longer time.
When the current through the relay coil is interrupted the magnetic field around it collapses rapidly, the coil goes from being a consumer to a generator while the field is collapsing and for a short time the voltage across it can reach several hundred volts, the voltage is reversed and is negative at the top in relation to the bottom and the now forward biased diode short circuits the current produced preventing a surge through the attached circuits. If the diode were reversed, it would be a short circuit itself.
As a simple test to understand what is happening, take your relay coil with two wires you can use to connect to a 12 volt battery for example. Holding onto the bare ends of the wire you are going to connect to the battery, connect the wires to the posts - you will not feel the 12 volts at all and the relay will close. Now still holding onto those bare ends, disconnect from the battery - you will feel the kick from the relay coil as the field collapses - significantly more than 12 volts (but not going to hurt you).