Protecting transistor from DC motor/Relay current spikes

sairfan1

Joined May 24, 2012
85
I setup two small circuits on breadboard with BD139 transistors to drive a 12v 0.2A motor and 24v 0.15A Relay to learn transistors, I can switch ON transistor through base resistor using 3.3v PSU.

I know when motor/relay stops it can push back some current and i believe its called current spikes,
For motor generally ceramic capacitors are used and for relay a diode

I want to learn how can i calculate value for capacitor for motor and choose diode for relay, can we also use electrolyte capacitors to avoid these spikes?

Joined Jul 18, 2013
27,648
You can use a reverse biased rectifier across both relay coil and motor, 1N4007

Irving

Joined Jan 30, 2016
3,496
and motor,
Not if the motor is to be reversed. For that use two zener diodes each rated at 2x motor volts back to back, or a single bi-directional TVS diode, across the motor terminals.

sairfan1

Joined May 24, 2012
85
I always get confused for diode polarity against motor or relay terminals, can you please advise rule of thumb to connect diode and taking care of polarity against negative/positive terminals.

Joined Jan 15, 2015
7,220
I always get confused for diode polarity against motor or relay terminals, can you please advise rule of thumb to connect diode and taking care of polarity against negative/positive terminals.
Cathode side of diode to positive side of motor or relay coil unless you have a bi directional motor in which case you would use back to back Zener diodes as was mentioned. Diodes used in an application like this are commonly called a flyback or freewheeling diode.

Ron

dcbingaman

Joined Jun 30, 2021
978
Diode current rating for relay needs to be greater than the relay current. When relay turns off, current will flow at about the same amount into diode at first and then decaying to zero. I would recommend a diode of at least twice the current rating of the relay. Also keep in mind when the relay turns off you will have Vcc+0.7V on the collector (drain) of the transistor for a short period of time.

Joined Jul 18, 2013
27,648
I always get confused for diode polarity against motor or relay terminals, can you please advise rule of thumb to connect diode and taking care of polarity against negative/positive terminals.
In your OP you mentioned a relay and a motor (singular) this is why my recommendation of the 1n4007 connected reverse biased diode across either of them.
0.2amp motor and 0.15a relay
Google, there are many similar examples to pick from.

crutschow

Joined Mar 14, 2008
32,918
can you please advise rule of thumb to connect diode and taking care of polarity against negative/positive terminals.
The diodes, whether Zener and/or regular types are always connected so that no current flows through them when the normal voltage polarity is applied to the device.

MisterBill2

Joined Jan 23, 2018
15,689
If this is a learning project, consider that you can also greatly reduce all the turn off spikes by slowing the rate of change for the switching action. It does not take much speed reduction to provide a lot of spike reduction. Increasing the switch-off time from one microsecond to one millisecond will give a 1000 times reduction, because E= L x ( dI/dT )= inductance times the change in current divided by the time interval for that change. Just a useful bit of calculus there.

crutschow

Joined Mar 14, 2008
32,918
Diode current rating for relay needs to be greater than the relay current. When relay turns off, current will flow at about the same amount into diode at first and then decaying to zero. I would recommend a diode of at least twice the current rating of the relay.
I consider that unnecessarily conservative.
The current only goes through the diode for the short time it takes the relay coil magnetic field to collapse, so the surge current rating of the diode is more appropriate to use for diode sizing.
Thus it is generally sufficient to use a diode that has a constant current rating less than the relay coil current rating and still not damage the diode, as long as its surge rating is well above the relay coil current.

dcbingaman

Joined Jun 30, 2021
978
I consider that unnecessarily conservative.
The current only goes through the diode for the short time it takes the relay coil magnetic field to collapse, so the surge current rating of the diode is more appropriate to use for diode sizing.
Thus it is generally sufficient to use a diode that has a constant current rating less than the relay coil current rating and still not damage the diode, as long as its surge rating is well above the relay coil current.
Yea, I tend to be way to conservative. I agree that the surge current rating is more appropriate for sizing.

Irving

Joined Jan 30, 2016
3,496
The schematic below is typical of a motor controlled by relays for run/stop and fwd/rev. It may not be representative of your circuit but should be helpful. It shows how flyback diodes D1, D2 should be deployed to protect Q1, Q2 from switching transients. D3, D4 shows back to back zener diodes for spike suppression while D5 is a bidirectional transient suppressor which may be a better option for larger motors.

sairfan1

Joined May 24, 2012
85
Is there some formula to calculate Zender or standard diode value for certain voltage? like circuit could be 6v, 12v or anything.

Irving

Joined Jan 30, 2016
3,496
Standard diodes just need to carry the surge current due to the back emf (voltage) generated when the relay is switched off. A good rule of thumb is their surge rating should be 10x the relay operating current. For most small switching relays a common 1N4148 diode suffices, for a larger automotive relay or a contactor any of the 1N400x series works fine.

For small motors, say up to 12v and 1A running current, 1Watt zener diodes rated at 1.5x motor volts generally works for noise suppression with a 100nF, 50v ceramic disc capacitor directly across the motor terminals. If the motor is directly driven by transistors or MOSFETs other techniques may be more applicable.

For larger fractional horsepower motors a bidirectional TVS diode with a clamp voltage 1.5x motor voltage can be useful, but as before if driven directly by transistors or MOSFETs other techniques may be more applicable.

On that last point, modern MOSFETs generally have built-in protection, normal transistors don't.

MisterBill2

Joined Jan 23, 2018
15,689
Looking back at the first post, I see a big error that has not been mentioned even once: When the inductive load is switched off, it is a VOLTAGE spike that is produced. Since the circuit has just been switched off, (opened), how could it be a current spike? And the formula for calculating that voltage spike magnitude is: E=L (dI/dT), where E= The voltage generated, L= the inductance of the coil, and dI/dT= the rate of change of the current, which with a mechanical switch is often very fast. The current of the spike is limited by the resistance of the coil and the total energy stored in the collapsing magnetic field. So a very interesting relationship exists between the speed at which the current is switched off and the voltage of the spike. A fast switching transistor driven by a fast base signal, can produce a larger inductive kickback voltage spike BECAUSE it switches off so rapidly. The rapid switching is chosen because as the transistor goes from full on to fully off, it passes through a linear conduction part of it's operating curve, where more power is lost in the transistor. At all times, the power lost as heat is : (collector current) x (voltage between emitter and collector, Vce). That is why switching transistors are driven into saturation very quickly, and then switched off quickly by pulling the base to emitter voltage to zero quickly.
So it is very possible to reduce that inductive kickback spike by switching a bit slower, using a slower transistor and not reducing the base to emitter voltage so fast. So there are some interesting ways to eliminate that spike, or at least to reduce it to a trivial level, without using any suppression diode or shunt device across the coil.

Irving

Joined Jan 30, 2016
3,496
So there are some interesting ways to eliminate that spike, or at least to reduce it to a trivial level, without using any suppression diode or shunt device across the coil.
Agreed, switching slew rate is one option, though the trade off is usually increased switching losses and heat generation. In the case of a relay you also have to guard against relay chatter if the slew rate is too slow. Slew rate control also generally requires a lot more components compared to a simple flyback diode. On the +side, slew rate control can help with EMI issues. However I can't ever recall seeing it deployed in response to relay/solenoid emf suppression; flyback diodes are cheap & simple.

Sinusoidal pwm used for stepper motors is arguably a form of slew rate control, but done for other reasons.

Last edited:

Ian0

Joined Aug 7, 2020
8,403
Standard diodes just need to carry the surge current due to the back emf (voltage) generated when the relay is switched off. A good rule of thumb is their surge rating should be 10x the relay operating current.
Not sure about the current surge. The relay is carrying a current which is determined by its internal resistance. When the transistor switches off, it does what all inductors do - the current would like to continue flowing unchanged, and so we provide a diode so that it can. I don’t see how a current surge can occur.

Ian0

Joined Aug 7, 2020
8,403
If you want the relay to switch off really quickly, a diode in series with a zener will hurry it up. Zener diode = supply voltage.
That allows it to make a small spike, but makes the current reduce to zero much more quickly.
It does require a transistor with twice the voltage capability.

MisterBill2

Joined Jan 23, 2018
15,689
Agreed, switching slew rate is one option, though the trade off is usually increased switching losses and heat generation. In the case of a relay you also have to guard against relay chatter if the slew rate is too slow. Slew rate control also generally requires a lot more components compared to a simple flyback diode. On the +side, slew rate control can help with EMI issues. However I can't ever recall seeing it deployed in response to relay/solenoid emf suppression; flyback diodes are cheap & simple.

Sinusoidal pwm used for stepper motors is arguably a form of slew rate control, but done for other reasons.
A diode across a relay connected backward accidentally will cause a huge amount of grief, I discovered a few years ago when the replacement relay provided by a customer had an internal diode that I was not aware of. And as for the slower slew rate, just increasing the switching time to one millisecond instead of one microsecond should be enough, and for any application driving a small relay the heat generation will not be an issue. And it may only require selecting a slower transistor or possibly adding a small (0.001mfd) capacitor, base to emitter. Since most relay response times are over TEN milliseconds chatter should not be an issue.

Ian0

Joined Aug 7, 2020
8,403
A diode across a relay connected backward accidentally will cause a huge amount of grief, I discovered a few years ago when the replacement relay provided by a customer had an internal diode that I was not aware of
Agreed. Especially plug-in relays, where you think two models are equivalent, but one has a built in diode, and you have wired the panel thinking that the two coil pins are interchangeable, and put your own diodes on the relay base. Unplug the relay to test it, and it tests OK. Plug it back in and it doesn’t work. Annoying.