Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Al Williams

Dr. Dobb's Bloggers

The Mortal (Relay) Coil

March 22, 2013

Last time, I mentioned that there are still some applications where a relay might make more sense than a solid state switching element. Granted, relays aren't (and shouldn't be) as ubiquitous as they once were, but there are still a few reasons you might need to put a relay in a modern circuit.

More Insights

White Papers

More >>


More >>


More >>

A basic relay has two major parts: a coil and a set of contacts. When you energize the coil, the magic of magnetism makes the contacts go from their normal position to an alternate position. Some relays will have normally open or normally closed contacts. Others will have one set for each. Like a switch, you can have multiple poles of contacts and you often hear about a relay's "form" when talking about the contact arrangement.

Given the paragraph above, it would seem that using relays is a piece of cake, right? Energize the coil somehow and wire the contacts like you would a mechanical switch. Great theory, but the apparent ease of use of relays, in my opinion, is one of the things that has contributed to relays getting a bad name for being unreliable.

The relay coil is an inductor, and driving it from a microcontroller has certain considerations. Those are well known, for the most part, and not what causes the problem. The problem is in the switch contacts. You can buy relays with different types of contact material and each one is made to switch different kinds of circuits. I am always surprised how many people just assume any relay will switch anything. For the most part, though, any relay will switch almost anything for awhile. As long as the contacts can handle the voltage and the current, the real cost will be in long-term reliability and degraded performance.

Driving the coil is not a big deal, although since a coil is just a length of wire, you will only find a few you could directly drive from a microcontroller. Even if you can, I don't like to subject my I/O ports to that much stress, so I almost always use a circuit like the one seen below. The L1 component represents a relay coil (for a Teledyne 412-12 relay).

The Mortal (Relay) Coil

The diode in the circuit is very important. If you look at it, it appears to be "backwards"—that is, current shouldn't flow through the diode. Normally, that's true. The problem is the relay coil is an inductor. One of the properties of an inductor is that it generates an opposing voltage when it sees a change in voltage and the amount of voltage it generates is mostly determined by the rate of change.

I once again used CircuitLab to model what would happen if you omitted the diode. As you can see in the plot below, the peak voltage applied to the transistor can exceed 150V! This is probably a little pessimistic since CircuitLab generates impossibly steep square waves on the input. However, since the transistor has a rated Vceo of 40V, even if that estimate is off by half, the transistor will lead a short brutal life. On the other hand, the same circuit modeled in Spice with a 1 nanosecond rise and fall time showed a 7,000 volt spike! So maybe CircuitLab is actually optimistic. Either way, that transistor is going to blow.

The Moral (Relay) Coil

The addition of D1 clamps the voltage to just a little higher than V2 (you can see the effect in the plot below). This is a very common design. So much so that you can actually buy your relays with this diode built into them, if you like.

The Moral (Relay) Coil

That leaves one other piece of the puzzle: the contacts. Some relays are made to switch dry, for example. That means the contacts are optimized to switch with no current flowing through them. Others are made to switch high currents.

The reason this is important is that life isn't as neat and clean as our schematic diagrams. Conceptually, the contacts don't touch and then they do. Case closed. But the reality is different. As the contacts get close to each other, they eventually will draw a little spark between them as the electricity charges the capacitor temporarily formed by the contacts and the air (or other gas) between them.

The spark is a good thing and a bad thing. Over time, contacts will oxidize (rust) and the resistance of the contacts will go up. A little spark (or arc) can clean that film off, resulting in lower contact resistance. However, it can also pit the contact, literally disintegrating the metal. When the contact's surface area is impaired, resistance will go up and eventually the contact will fail.

Next time, I will talk more about selecting relay contacts before we get back to some more 21st century technologies.

Related Reading

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.