# 1N4007 diode in fan speed control project

I was making a fan speed control by temperature with the Arduino.

I am dealing with this circuit:

I couldn't figure out what the purpose of the 1N4007 diode is.

What is the purpose of it specifically in this circuit?

• Lookup "fly-back diode" Jan 10, 2018 at 18:40
• Why the cap across the transistor? Jan 10, 2018 at 19:25
• PWM demodulation, I would guess. Jan 10, 2018 at 19:26
• Your bd139 is going to run hot if you pwm with a 100 uF cap Jan 10, 2018 at 21:30

The diode prevents the NPN from blowing up when it turns off with current still flowing through the fan inductance.

A diode in this configuration is called a fly-back diode. The inductance of the fan means the current can not stop immediately when the transistor turns off. With no diode there that would generate a LARGE positive voltage at the top of the transistor, enough to destroy it. The diode provides an alternate path for the current to go as it decays. The voltage at the top of the transistor is then limited to about 12.7V.

• Hey, you've gone from plain Trevor to the stylish self-styled Trevor_G - were we getting over-Trevored for user names or have you finally tied the knot? :-) Jan 10, 2018 at 20:05
• @TonyM ya I finally hit a question from a different Trevor .. Jan 10, 2018 at 21:18

The current answer is very good, I'm just adding this because it took me a long time to "get" this concept and I wanted to share the way it finally got through to me.

An inductive load (like a motor or relay) acts a bit like an inductor.

An inductor briefly resists changes in current across it. If the voltage supplied to the load quickly increases, the current across the load does not increase suddenly but rises more gradually. Because of the relationship between voltage and current, this means that the voltage dropped across the load is briefly high, as an initial burst of energy is absorbed by the load. If the voltage supplied to the load is dropped suddenly, the load's current does not drop straight away, as a similar burst of energy continues to be released out of the load before petering out. The voltage drop over the load therefore briefly spikes to a high negative value, with the normally negative side of the load exhibiting a large positive voltage for a short time relative to its positive side.

The issue with this is the side effects it can have on surrounding circuitry. If the negative side of the load briefly spikes in voltage that can damage a semiconductor terminal that is there, such as a transistor.

A flyback diode's regular state is that it passes no current as it's reverse biased and within its tolerated reverse voltage. But if the negative terminal is briefly positive in regard to the positive terminal, then the diode allows current flow in order to drop that positive voltage to a safe level.