Schematic Question

Could someone explain the purpose of the diode at d3 and d1 of the attached relay circuit? I can't figure it out.

These are inductive kickback diodes.

Watch this video:

I planned to eliminate the led. What happens if I am using a transformer and not a battery? Where does the voltage spike go?

You can omit the LED with no problem.

You need the kickback diodes for inductive loads.

When the transistor turns off, the magnetic field in the coil collapses and creates a burst of current.
(electromagnetic theory; move a magnet thru a coil of wire creates current; conversely, if current flows thru a coil, a magnetic field is created (electromagnet); change the magnetic field, and the coil tries to keep the current flowing, hence the burst of current when the drive current is taken away)

Current x resistance = voltage. Without the diode, the curent sees the high resistance of the turned off transistor, which can create a voltage spike that can damage the transistor.
The diode is there to route the current burst back into the power supply and the coil where it can dissipate without causing a big voltage spike.

You are not using a "transformer"; that is 2 windings on a coil to transform AC to a different level of AC (like 120VAC down to 12VAC). A wallwart combines the effect of a transformer with an AC to DC converter to make the DC voltage that Arduino and components are using.

I assume eliminate the resitor at r3 as well, but where does the access voltage bleed to?

The LEDs and their series resistors can be safely removed.

There is no excessive voltage.

You need D1 And D3.

With no LED, there is no path for current to flow. Hence the current flow is only thru the coil when the transistor turns on, and briefly thru the diode when the transistor turns off and the coil briefly generates some current.

There is no excess voltage, the same as there is no excess voltage when you unplug an appliance in your house. Parallel connections all see the same voltage.

Sorry. I am confused. I watched the video and if I understood, access energy in the coil would cause a voltage spike when the transistor gate closes, if it has nowhere to go. The diode routes the access energy back somewhere. If I eliminate the led and resistor, it would be go back to the wallwart. That's ok?

Yes, that is okay. It will dissipate between the supply and the coil.

tsperry88:
Sorry. I am confused. I watched the video and if I understood, access energy in the coil would cause a voltage spike when the transistor gate closes, if it has nowhere to go. The diode routes the access energy back somewhere. If I eliminate the led and resistor, it would be go back to the wallwart. That's ok?

Not when the transistor gate closes, but when it opens. Nothing is going back to the wall wart. The kickback diode is in parallel with the coil. The kickback current never goes out of that circuit - just through the diode and the coil. All the energy is dissipated in the coil and the diode.

Edit - that's one reason why it's often suggested to place the diode physically across the relay coil connections.

One subtlety is that as the diode clamps the voltage to a low value, the current subsides much more slowly,
and sometimes this is a problem (typically for solenoids being used as mechanical actuators which you
want to respond rapidly).

In this case a bidirectional TVS diode is often used instead - higher clamping voltage, faster current fall.

Any inductive load can generate spikes at 100's of volts or more if not clamped or snubbed somehow, this
is a trace from a medium sized electric motor terminals when a 12V battery was removed - the scale is 50V
per division, this is over 200V of transient in a fraction of a microsecond:

Note that DC motors typically a lot less inductance than solenoids as they have relatively few turns of
thick wire - a solenoid in the same situation would dump much more energy.

CrossRoads:
When the transistor turns off, the magnetic field in the coil collapses and creates a burst of current.
(electromagnetic theory; move a magnet thru a coil of wire creates current; c

Technically not quite correct. The collapsing magnetic field creates voltage

In your schematic diodes D1 and D3 are commonly called freewheeling diodes, flyback diodes, kickback diodes, clamping diodes and likely about a half dozen other names. Simple answer to your question is no, they can't be removed. Take a real good look at the scope image MarkT posted in post #12.

Your relay coils are inductors and when you turn on your transistors magnetic lines of flux emit outward from the coils, the relays pull in and things stay that way. Take a look at your LEDs which are also diodes, D2 and D4. When a relay coil is energized the LEDs are forward biased so the LEDs illuminate. However, diodes D1 and D3 are not forward biased so they are not conducting or really doing anything. When a relay coil is deenergized the magnetic field collapses as mentioned and this results in a large negative spike exactly as seen in the image MarkT posted in post #12. On a simple 12 VDC relay coil that negative voltage spike can be hundreds of volts. There it is on the scope image.

The problem now becomes what to do with this large negative voltage spike? I can tell you this, transistors Q1 and Q2 will not be happy about having a huge negative going voltage spike across their collector, emitter junction. A voltage easily high enough to break them down and game over for your transistors which you are using as a switch powering an inductor (relay coil). Really bad things happen :frowning: .

Now notice how D1 and D3 are in the circuit as to Anode (arrow) and Cathode (line) sides with respect to the LEDs. A simple diode is a uni directional current device, they are a One Way affair. For a common diode it will conduct when the cathode side is more negative than the anode side by about 0.7 volts give or take but you get the idea. So the idea here is for D1 and D3 to clamp that large negative voltage spike and their removal will result in you needing a large pile of transistors because each transistor may only take 1 or 2 hits and it's gone.

Yes, you can remove the LEDs and their current limiting resistors R1 and R3 as they are only there as a visual indicator of when your relay coils are energized but no, you can't remove D1 and D3.

Over the years semiconductor diode technology has come a long way. As mentioned there are diodes available with faster response times and there are TVS (Transit Voltage Suppression) diodes designed for snubbing inductive voltage spikes as MarkT mentions.

This is pretty over simplified and there is much more to it but hopefully you get the general idea.

Ron

tsperry88:
Sorry. I am confused. I watched the video and if I understood, access energy in the coil would cause a voltage spike when the transistor gate closes, if it has nowhere to go. The diode routes the access energy back somewhere. If I eliminate the led and resistor, it would be go back to the wallwart. That's ok?

D1 and D3 route the spike as a current back through the coil.
The spike never appears on the power supply.
The LEDs have nothing to do with suppressing the spike.
Tom... :slight_smile:

D1 and D3 route the spike as a current back through the coil.

Sorry, but that's possibly going to confuse people.

There is only a voltage spike, the diodes clamp the spike to about 0.7V maximum. They truncate
the spike, it doesn't vanish or turn into a current.

The current doesn't spike, it decays smoothly down to zero, but is abruptedly steered into the diode
when the transistor switches off. The current is diverted from the transistor and supply to the diode
as soon as the diode is forward biased.

Good article on how the voltage spike is created here. I stand corrected about my earlier answer; the collapsing magnetic field creates voltage instead of current.

Molecular Expressions: Electricity and Magnetism - Inductance.

Inductance is a property of an electric circuit by which a changing magnetic field creates an electromotive force, or voltage, in that circuit or in a nearby circuit. Inductance is also defined as the property of an electric circuit that opposes any change in current. In 1831, Michael Faraday, an English scientist, discovered that a changing magnetic field in a circuit induced a current in a nearby circuit. Joseph Henry, an American scientist, independently made this discovery at about the same time. The generation of an electromotive force and current by a changing magnetic field is called electromagnetic induction. The operation of electric generators is based on the principal of inductance.

When the current in a circuit is switched off, the induced magnetic field begins to collapse. As the field is collapsing, it generates voltage in the direction that momentarily prolongs the main current flow. When the induced magnetic field is fully collapsed, the induced voltage and current flow cease.

So the diode is there to protect the switching device, the transistor in this case, from that induced voltage.

aarg:
Edit - that’s one reason why it’s often suggested to place the diode physically across the relay coil connections.

Which is of course, completely wrong! :cold_sweat:

Paul__B:
Which is of course, completely wrong! :cold_sweat:

I'm staying out of this one.