gxmark
Posts: 22
Joined: Mon May 20, 2019 3:04 pm

RPi 4 12V pwm fans - Schematic

Fri Aug 14, 2020 7:23 pm

Hi guys,

I am using a RPi to control 2 12 V PWM fans.

Please see the below schematic and let me know if I missed something.

Image
Attachments
fans.png
fans.png (19.62 KiB) Viewed 870 times

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Fri Aug 14, 2020 9:19 pm

I don't know what fans you're using but a 3 wire fan is generally power supply and tacho (or locked rotor signal). You can't control it by doing anything to the tacho line. A normal PC 4 wire fan, the PWM control is pin 4 (1 is ground, 2 is 12V, 3 is tacho, 4 is PWM).

If what you have is not standard fans, you'll need to provide some spec information - but even then I'm not sure what could make what you show right, because the transistor will sink some current when it's on, but the diode is going to block any current for it to sink (and that's assuming the fans have an internal pullup on the PWM line).

sparkyhall
Posts: 168
Joined: Mon Aug 27, 2012 9:14 am

Re: RPi 4 12V pwm fans - Schematic

Fri Aug 14, 2020 10:00 pm

Assuming the fans you have can be controlled by PWM the diode seems unnecessary and as drawn is round the wrong way. The circuit you have drawn will do nothing.

gxmark
Posts: 22
Joined: Mon May 20, 2019 3:04 pm

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 1:00 pm

Is this betterImage
Attachments
fan2.png
fan2.png (18.57 KiB) Viewed 759 times

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 4:09 pm

This circuit will try and apply a 3.3V signal to the fan pin 2, but as previously noted, without knowing anything about the fan, whether that will actually achieve anything is anyone's guess. Also, if the fan pulls up its pin 2 above 3.3 V, you're going to pull the Pi's 3.3 volt line up too, which might damage it. (Not knowing anything about the fan, I don't know whether it will pull it up, or how high it will pull it, but I note that a standard PC 4-wire fan will normally pull the PWM line up to 5V or so, if it can).

If you're trying to get a PWM higher-current drive than direct on the Pi GPIO, I'd use the first circuit, remove the diode and add a resistor pulling up to whatever the fan needs (standard 12V PC fans notionally require a 5V PWM, but they are normally very tolerant of that so 3.3V would work). If the fan has its own internal pull-up you don't even need the resistor - just take the diode out.

But as stated - if it's a 3-wire fan, it probably doesn't have a PWM control line. If it's a 3-wire fan, it's probably the case that you can't control it from teh third wire.

gxmark
Posts: 22
Joined: Mon May 20, 2019 3:04 pm

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 4:34 pm

Thanks for your reply.

The fan model is AFC1212D-F00

https://www.digikey.com/product-detail/ ... lectronics

drgeoff
Posts: 11239
Joined: Wed Jan 25, 2012 6:39 pm

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 4:40 pm

gxmark wrote:
Sat Aug 15, 2020 4:34 pm
Thanks for your reply.

The fan model is AFC1212D-F00

https://www.digikey.com/product-detail/ ... lectronics
That says 4 wires.
Quis custodiet ipsos custodes?

Brandon92
Posts: 923
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 4:49 pm

gxmark wrote:
Sat Aug 15, 2020 4:34 pm
Thanks for your reply.

The fan model is AFC1212D-F00

https://www.digikey.com/product-detail/ ... lectronics
You can indeed control the fan with the pwm signal the is showed in the datasheet. If this fan has a internal pull up resistor, then you can indeed control it via a npn transistor (or N mosfet). But this will invert you control signal. So a 100% duty cycle in the Rpi is a 0% duty cycle for the fan.

By the way, when you draw a schematic. It is not considered nice to draw in a components :geek:

Image

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Sat Aug 15, 2020 5:09 pm

OK. So that says it does have a PWM input (yellow wire) with a voltage high level of between 2.8V and about 20V, and low level has to be below 0.8V.

It doesn't specify if the fan pulls this line up itself, or how it pulls it up (i.e. how strong), so first thing I'd do is connect up the power supply and put a multimeter to measure voltage across the yellow wire and black wire and see what you get. If it's more than 3.3V then you don't want this connected direct to the Pi, so try your first circuit with the diode removed.

If that doesn't work, delete teh diode and add a (say) 2k-ohm resistor from pin 1 of the NPN to the +12V, that will give it a strong pull up. Note that then the drive is inverted (i.e. 0 duty cycle on the GPIO will be full speed fan, 100% duty cycle GPIO will be fan off).

If the voltage measurement was no more than 3.3V use your multimeter and measure the current if you connect the yellow wire to the black wire. If that's comfortably below 16 mA (which is what the GPIOs can source or sink) then you're probably safe to connect the yellow wire direct to a GPIO. If you do this don't add any resistors pulling it up to 12V or you will fry the Pi. If you don't want to risk that, I'd go with first circuit, diode removed, and 2k resistor pulling up to 12V.

(Note 'probably safe' - I'm not actualy guaranteeing it, since the data sheet doesn't specify, it might do something like deliver higher voltage if the fan stalls at one particular point, or something like that, so you might still decide to use the drive circuit on the off-chance that it might sacrifice itself to protect the pi).

gxmark
Posts: 22
Joined: Mon May 20, 2019 3:04 pm

Re: RPi 4 12V pwm fans - Schematic

Mon Aug 17, 2020 10:10 pm

Hello Again.

I connected the fan to 12V.
The voltage on the PWM line(yellow) is 6.39 Volts
I have a BZX55C3V3 zener diode and a 330 Ohm resistor on the GPIO pin for pin protection.


Will I damage the pin if
1. Control it through the pwm line without additional resistor and NPN transistor?
fanV.png
fanV.png (193.16 KiB) Viewed 585 times

Brandon92
Posts: 923
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: RPi 4 12V pwm fans - Schematic

Tue Aug 18, 2020 8:33 pm

If it was up to me I would use a MOSFET (transistor) to control the FAN. Because that zenerdiode need arround 5mA to operate correctly and I don't think that you will get that amount of current out of the FAN.

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Wed Aug 19, 2020 7:03 am

If the fan pulls its line up to 6.39 open circuit I wouldn't connect it direct to the GPIO (there is a possibility that you won't damage teh Pi, but you really don't want to apply more than 3.3V to a GPIO pin). So yes, I'd use a transistor to drive the PWM wire.

I'd use a bipolar tansistor, i.e. your first circuit (but without the diode). The fan apparently pulls up, so that might be the only change you need to the circuit - though you might need astronger pullup if that doesn't work.

The reason I wouldn't use a MOSFET is that you need a fairly unusual one to turn on fully from a 3.3V signal. The MOSFET spec will quote a V.GS(th) which is supposedly the 'threshold' voltage when it turns on, but is actually better thought of as the voltage at which it starts to turn on, and for efficient switching you want several volts more than that. Actually, you can get MOSFET that will be mostly switched on by these level signals, and your fan will probably work if you use one that's only partly switched on, but that's what I'd do.

Remember that with your circuit you'll invert the signal, so high on the GPIO turns into low at the fan, so if you have the GPIO doing say 25% duty cycle, the fan will see 75% duty cycle.

pidd
Posts: 1288
Joined: Fri May 29, 2020 8:29 pm
Location: Birkenhead, Wirral, UK
Contact: Website

Re: RPi 4 12V pwm fans - Schematic

Wed Aug 19, 2020 9:51 am

With the original circuit he will not see much at all as the diode is back-to-front.

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Wed Aug 19, 2020 7:36 pm

pidd wrote:
Wed Aug 19, 2020 9:51 am
With the original circuit he will not see much at all as the diode is back-to-front.
I wonder if that's why I said "I'd use a bipolar tansistor, i.e. your first circuit (but without the diode)"?

pidd
Posts: 1288
Joined: Fri May 29, 2020 8:29 pm
Location: Birkenhead, Wirral, UK
Contact: Website

Re: RPi 4 12V pwm fans - Schematic

Wed Aug 19, 2020 7:58 pm

achrn wrote:
Wed Aug 19, 2020 7:36 pm
pidd wrote:
Wed Aug 19, 2020 9:51 am
With the original circuit he will not see much at all as the diode is back-to-front.
I wonder if that's why I said "I'd use a bipolar tansistor, i.e. your first circuit (but without the diode)"?
I don't know, there was no explanation.

I know some of my responses can be interpreted as sarcastic (or whatever), it is never intended.

achrn
Posts: 437
Joined: Wed Feb 13, 2013 1:22 pm

Re: RPi 4 12V pwm fans - Schematic

Thu Aug 20, 2020 6:36 am

pidd wrote:
Wed Aug 19, 2020 7:58 pm
achrn wrote:
Wed Aug 19, 2020 7:36 pm
pidd wrote:
Wed Aug 19, 2020 9:51 am
With the original circuit he will not see much at all as the diode is back-to-front.
I wonder if that's why I said "I'd use a bipolar tansistor, i.e. your first circuit (but without the diode)"?
I don't know, there was no explanation.
That error in the circuit has already been discussed. For example, I said "the transistor will sink some current when it's on, but the diode is going to block any current for it to sink". I don't think it necessary to recap (and explain again) the entire thread in each new posting.

pidd
Posts: 1288
Joined: Fri May 29, 2020 8:29 pm
Location: Birkenhead, Wirral, UK
Contact: Website

Re: RPi 4 12V pwm fans - Schematic

Thu Aug 20, 2020 9:20 pm

achrn wrote:
Thu Aug 20, 2020 6:36 am
That error in the circuit has already been discussed. For example, I said "the transistor will sink some current when it's on, but the diode is going to block any current for it to sink". I don't think it necessary to recap (and explain again) the entire thread in each new posting.
Which is contradictory and confusing. "the transistor will sink some current when it's on" vs "but the diode is going to block any current for it to sink". #lastpost

Return to “General discussion”