9
\$\begingroup\$

I'm working on a project where I will be controlling a variety of loads (relay, solenoid, motor) from an Arduino and I'd like to make sure I build in enough protection for the microcontroller and other components. I've see a variety of solutions using transistors and adding decoupling capacitors, flyback diodes, and zener diodes. I'm wondering how one would choose between one or a combination of these options?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Not a direct answer to question. But you may want to watch this video to see actual waveforms and how diode protection works. No demonstration for capacitor case. \$\endgroup\$ – Alper Dec 6 '14 at 7:58
11
\$\begingroup\$

I'm wondering how one would choose between one or a combination of these options?

It's easy, if you understand how inductors work.

I think the problem most people have is that they hear words like "inductive voltage spike" or "back-EMF" and reasonably conclude something like

So, when an inductor is switched, it's for an instant like a 1000V battery.

schematic

simulate this circuit – Schematic created using CircuitLab

Indeed in this particular situation, this is more or less what happens. But the problem is that it's missing a critical step. Inductors don't just generate really high voltages to spite us. Look at the definition of inductance:

$$ v(t) = L\frac{\mathrm di}{\mathrm dt} $$

Where:

  • \$L\$ is inductance, in henrys
  • \$v(t)\$ is the voltage at time \$t\$
  • \$i\$ is current

This is like the Ohm's law for inductors, except instead of resistance we have inductance, and instead of current we have rate of change of current.

What this means, in plain English, is that the rate of change of current through an inductor is proportional to the voltage across it. If there is no voltage across an inductor, current remains constant. If the voltage is positive, than the current becomes more positive. If the voltage is negative, than the current decreases (or becomes negative -- current can flow in either direction!).

A consequence of this is that the current in an inductor can not instantly stop, because that would require an infinitely high voltage. If we don't want a high voltage, then we have to change the current slowly.

Consequently, it's better to think about an inductor in an instant as a current source. When the switch opens, whatever current was flowing in the inductor wants to keep flowing. The voltage will be whatever it takes for that to happen.

schematic

simulate this circuit

Now instead of a 1000V voltage source, we have a 20mA current source. I just arbitrarily picked 20mA as a reasonable value, in practice this is whatever the current was when the switch opened, which in the case of a relay is defined by the resistance of the relay coil.

Now in this instance, what must happen for than 20mA to flow? We've opened the circuit with the switch, so there's no closed circuit, so current can't flow. But actually it can: the voltage just needs to be high enough to arc across the switch contacts. If we replace the switch with a transistor, then the voltage needs to be high enough to break the transistor. So that's what happens, and you have a bad time.

Now look at your examples:

schematic

simulate this circuit

In case A, the inductor will charge the capacitor. A capacitor is just like an inductor with current and voltage switched: \$i(t) = C\: \mathrm dv/\mathrm dt\$, and so a constant current through a capacitor will change its voltage at a constant rate. Fortunately, the energy in the inductor is finite, so it can't charge the capacitor forever; eventually the inductor current reaches zero. Of course, then the capacitor will have some voltage across it, and this will then work to increase the inductor current.

This is an LC circuit. In an ideal system, the energy would oscillate between the capacitor and inductor forever. However, the relay coil has quite a lot of resistance (being a very long, thin piece of wire), and there are smaller losses in the system from other components, too. Thus, energy is eventually removed from this system and lost to heat or electromagnetic radiation. A simplified model that takes this into account is the RLC circuit.

Case B is much simpler: the forward voltage of any silicon diode is around 0.65V, more or less regardless of current. So the inductor current decreases and the energy stored in the inductor is lost to heat in the relay coil and diode.

Case C is similar: when the switch opens the back-EMF must be enough to reverse bias the Zener. We must be sure to pick a Zener with a reverse voltage higher than the supply voltage, otherwise the supply could drive the coil, even when the switch is open. We must also select a transistor which can withstand a maximum voltage between emitter and collector greater than the Zener reverse voltage. An advantage of the Zener over case B is that the inductor current decreases faster, because the voltage across the inductor is higher.

\$\endgroup\$
  • \$\begingroup\$ I'm not an electrical engineer and I don't have a great grasp of the underlying physics, but I understand that in case B with the diode, the current will circulate through the diode and inductor eventually dissipating the stored energy (due to the resistance in the inductor?) In case C with the zener diode, assuming the voltage is above the zener voltage, the energy would quickly go to ground. \$\endgroup\$ – Aleksander Dec 8 '14 at 6:43
  • \$\begingroup\$ I don't have a good understanding of case A with the capacitor. I'd think the cap is already charged when the transistor goes off, but below Andy says the current oscillates back and forth until it dissipates. I'm not sure why? I originally mentioned the cap because I've seen it used as a decoupling capacitor in the case of a brushed DC motor, and I was thinking of using a combination of the cap and the zener diode. \$\endgroup\$ – Aleksander Dec 8 '14 at 6:48
  • \$\begingroup\$ @Aleksander please see edits. \$\endgroup\$ – Phil Frost Dec 8 '14 at 13:22
5
\$\begingroup\$

There is another variation that is used to turn reduce the stored energy in the inductive load as quickly as possible. This I've seen used in relay circuits where fast off-times are required. The problem with the diode is that the energy held in the relay coil takes time to dissipate (because the current recirculates and diminishes slowly) whereas if a resistor was placed in parallel with the coil, the back-emf would be bigger but spend the energy more quickly.

For instance, a 50mA coil current would produce a peak back emf of 0.7volts on a diode but across a 1k resistor this would be 50 volts. This isn't a problem if the transistor is rated at 100 volts.

A modification of this idea is to use a diode in series with a resistor. Now the resistor doesn't take normal on current; it only handles the reverse voltage situation.

The bigger the resistor, the quicker the energy gets dissipated and the quicker the relay (or solenoid or whatever) turns mechanically off.

The capacitor version is also worth considering. The energy stored in the coil gets released when the transistor opens and this sweeps into the capacitor forming a peak voltage that is related to stored energy; the inductor has an energy stored that is: -

\$\dfrac{Li^2}{2}\$ and the capacitor formula is energy stored = \$\dfrac{Cv^2}{2}\$

When you equate these two equations you can calculate what the peak back-emf is when the transistor open-circuits. What you then find is that the current goes backwards and forwards between the coil and capacitor oscillating down to zero. The time it takes can be long (in micro and millisecond terms) but, the act of the relay coil current reversing after the 1st cycle of oscillation rapidly turns the relay off. Usually the relay's coil resistance is sufficiently high to ensure that the 3rd half cycle of oscillation doesn't have enough current to reactivate the relay coil.

So, the capacitor idea is sometimes (rarely) used. Sometimes it is used in series with a resistor to speed things a bit more.

The zener idea is also useful because, unlike the diode that forward conducts at 0.7 volts, the zener conducts but at (say) 12 volts thus speeding up the dissipation of stored energy much faster than a diode alone. Also, with a zener the max voltage point is more easily defined than with resistors and capacitors so there is some attraction to use it.

\$\endgroup\$
  • \$\begingroup\$ I wonder if there is a danger of reverse Vbe breakdown and long-term damage if the capacitor circuit is used with, say, a 24V relay. The turn on current is also only limited by the beta or Idss in the case of a MOSFET.. It could be quite large. \$\endgroup\$ – Spehro Pefhany Dec 6 '14 at 14:01
  • 1
    \$\begingroup\$ @spehro the cap has to be big enough in value to not let the peak voltage rise more than double the supply to avoid this. \$\endgroup\$ – Andy aka Dec 6 '14 at 14:12
2
\$\begingroup\$

The usual way is to use case B above. It's called a back-EMF diode or a flyback diode. The capacitor in A is unlikely to work. Case C is sometimes seen in H-bridges and in cases where the load is driven negative as well as positive, in which case the simple parallel diode cannot be used.

\$\endgroup\$
  • 1
    \$\begingroup\$ Why is the capacitor in A unlikely to work? \$\endgroup\$ – Phil Frost Dec 6 '14 at 12:13
  • \$\begingroup\$ @PhilFrost It does not clamp the back-EMF at any particular value, as a diode would. The peak voltage is therefore dependent on the capacitance and inductance in the circuit (hard to predict). Plus, the L-C circuit is capable of resonance (tuned circuit) which may cause problems. \$\endgroup\$ – John Honniball Dec 7 '14 at 9:53
  • \$\begingroup\$ Sure it does: the inductor has some stored energy, according to \$E = 1/2\:LI^2\$. In the worst case, all of this energy goes into the capacitor: \$E=1/2\:CV^2\$. The capacitance isn't hard to predict: it's printed on the capacitor; and the inductance, if it's not on the relay datasheet, is easily measured. What problems would resonance cause? Won't the resonance be significantly damped by the resistance of the relay coil? \$\endgroup\$ – Phil Frost Dec 7 '14 at 12:40
  • \$\begingroup\$ @PhilFrost What I mean is that just about any old diode will limit the back-EMF. To make a capacitor do so, we must measure coil inductance, and make a calculation. I'm not expecting most novice readers to go to all that trouble; I'm suggesting that they simply use a diode. \$\endgroup\$ – John Honniball Dec 7 '14 at 14:39
  • \$\begingroup\$ I think the confusing thing is that your answer says "unlikely to work", which is quite different from "is more complicated and in your case doesn't work any better than a diode". \$\endgroup\$ – Phil Frost Dec 7 '14 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.