AGID
Posts: 37
Joined: Tue Mar 17, 2020 1:02 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun May 17, 2020 4:35 pm

pcmanbob wrote:
Sun Dec 24, 2017 11:49 am
Cant be sure because I cant see clearly but Ii think you might have things connected wrong.

your circuit should look like this ( diode left out for clarity )

Image

which matches this diagram

Image

for reference.

Image
@pcmanbob can I use 1N4007 diode instead of 1N4001 because that's what is available? Or is it risky?

Thanks

User avatar
rpdom
Posts: 18158
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun May 17, 2020 5:09 pm

IN4007 would be fine. It is only a version of the IN4001 that can cope with higher voltages for extended times, which is unimportant in this case.
Unreadable squiggle

stringsonfire
Posts: 1
Joined: Sun Oct 25, 2020 8:20 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Oct 26, 2020 9:22 am

Why a 470ohm resistor on the base? Does that depend on the fan and the transistor? How is it calculated?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13696
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Oct 26, 2020 10:55 am

stringsonfire wrote:
Mon Oct 26, 2020 9:22 am
Why a 470ohm resistor on the base? Does that depend on the fan and the transistor? How is it calculated?
Because without the resistor there would only be a (base-emitter) diode to GND between the GPIO output, and GND, which means that for voltages out of the GPIO greater than the diode forward voltage of typically 0.7 Volt, there is nothing to limit the current flowing into the base of the transistor, and you would blow up the GPIO driver.

The value of the resistor is such that the maximum current is limited to the current running through the collector (through the fan) divided by the amplification (beta) of the transistor, this insures that the transistor is driven fully open (saturated).
For example if the beta of the transistor is 100 times, and the fan is drawing 100mA then the basis current should be 100mA/beta = 1mA
so the resistor should be 3.3V - 0.7V = 2,6V (the voltage over the resistor) so now we can use ohms law to calculate the resistance.
R=U/I so R = 2,6V/1mA (0.001A) = 2600 Ohm.

In the above schematic the base current (with 470 Ohm) will be I = U/R so 2.6/470 = 5,5mA which guarantees the transistor is saturated (fully open), while the current is less than what the GPIO can deliver (15mA). Most often the base resistor is simply chosen to be a value so that the base current is something "reasonable".

lurk101
Posts: 400
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Oct 26, 2020 2:41 pm

pcmanbob wrote:
Tue Oct 10, 2017 9:24 am
No most DC motors of the type used in a pc fan can be speed controlled by using pwm applied to the supply voltage.
Er, no, not quite. The motors used in most PC fans are brushless and incorporate internal electronics to manage distribution of power to multiple coils. Such circuitry does not work well if supplied with PWM modulated power. If you really need to control fan speed, then a 4 wire fan is your best choice. These fans have a high impedance input wire that accepts a PWM signal easily provided by your Pi. No resistors, transistors, or diodes required.

I've always had good results with Noctua fans. The Noctua NF-A4x20 5V PWM model is one of the best choices if you value silence and quality.

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Oct 26, 2020 4:02 pm

lurk101 wrote:
Mon Oct 26, 2020 2:41 pm
Er, no, not quite. The motors used in most PC fans are brushless and incorporate internal electronics to manage distribution of power to multiple coils. Such circuitry does not work well if supplied with PWM modulated power.
I have never had any problems driving PC type 3 wire fans using PWM, the only problem with some of the cheaper makes is they don't reliably start at lower PWM settings, the work round that I use and many of the PC add on fan controllers use ( which by the way use PWM ) is to start the fan at 100% speed for 1 or 2 seconds and then reduce the speed.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

lurk101
Posts: 400
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Oct 26, 2020 6:47 pm

pcmanbob wrote:
Mon Oct 26, 2020 4:02 pm
lurk101 wrote:
Mon Oct 26, 2020 2:41 pm
Er, no, not quite. The motors used in most PC fans are brushless and incorporate internal electronics to manage distribution of power to multiple coils. Such circuitry does not work well if supplied with PWM modulated power.
I have never had any problems driving PC type 3 wire fans using PWM, the only problem with some of the cheaper makes is they don't reliably start at lower PWM settings, the work round that I use and many of the PC add on fan controllers use ( which by the way use PWM ) is to start the fan at 100% speed for 1 or 2 seconds and then reduce the speed.
My experience differs. In any case based on the initial post the goal is to turn the fan on or off, not variable speed. A fan with a built-in PWM control is still the easiest approach. Just wire that input directly (no resistor required) to a GPIO pin. Turn on the fan writing a 1 to the pin, and 0 to turn it off.

Return to “Other projects”