5v DC Fan Control with PWM

Thread Starter

SILENT001

Joined Jan 14, 2016
35
Good day, I apologise if this is not in the correct place as I am not sure where this question should be posted. So here is my question.
I want to control a 2 wire 5v DC Fan using PWM from a Raspberry Pi 3. I have got it working with a basic NPN Transistor and changing the Duty Cycle of the PWM on the Raspberry Pi but the issue is it is very noisy at low speed. I read today that a FET might be the solution but I am still very limited on my electronics knowledge and thought I would ask people who know things to help out.

If someone can suggest a circuit for me to work with. Something very basic that will allow me to control the fan speed with the PWM of a 2 wire fan. I don't wish to use a 12v fan or a 4 wire fan as they are too expensive and way larger in size to what I currently have. The 5v pin of the Raspberry Pi will be used to supply the fan with power. As it stands the fan runs fine on my Raspberry Pi having it directly connected on the GPIO pins but I want control of this. The software side I can write and figure out but the only issue I have is with the electronic control circuit. The circuit should possibly be universal and all that it needs to do is give a constant voltage to the fan of a certain voltage that gets veried using PWM. Thanks in advance.
 

Thread Starter

SILENT001

Joined Jan 14, 2016
35
Hi LesJones. Thank you for your reply. If I remember correctly it is relevant to the frequency but I haven't tested this again. I could attempt to do it again some time but I don't think I have any working transistors left. It's normally when the speed is less the noise is like a buzzing sound. I can't explain it but what I can remember is that there was a link with the noise and the PWM frequency.
 

Thread Starter

SILENT001

Joined Jan 14, 2016
35
The script I was using at default used 1KHz. I will have to try it again tonight and see if it is less at 20KHz but I do remember that there was no way of getting the noise away with changing the frequency. If the Duty Cycle was below 80% it causes a buzzing sound that I am sure is from the pulses and this I wish to convert to a smooth voltage
 

Alec_t

Joined Sep 17, 2013
14,280
.... and it is possible that your PWM frequency is clashing with the internal commutation.

Here's a circuit you could try, for smoothing the PWM :-
PWMsmoother.PNG
 
Last edited:

Sensacell

Joined Jun 19, 2012
3,432
2 wire DC brushless fans normally don't like PWM.

There are chips inside that switch the coils synchronously with the rotation of the armature, when you interrupt the current with PWM, the chips can get reset and cause the erratic operation, and make terrible noises.

A linear voltage control will work better, or the attached circuit, which attempts to synchronize the PWM with coil commutation.
 

Attachments

Thread Starter

SILENT001

Joined Jan 14, 2016
35
Thank you everyone for your replies. I am sorry I am still very new and don't know much. What you guys are saying makes sense so I went and did some more research and found that to convert the PWM to a fixed smooth voltage I need a RC filter but the fun comes in working out the values I need to eliminate the noise and make the voltage as smooth as possible. I don't want an over complicated circuit that I need to build. Would anyone be able to help me on getting the correct values for the cap and the resistor so that I am able to use a frequency of 1KHz and provide a voltage between 0 and 5 volts. I didn't get around to testing again. I actually need to take my fan out and take it to work where we have a adjustable power supply that could help me in working out what is the smallest voltage the fan can handle without not spinning. I'm not sure if this would help in working out the values I need but if I understand everything correctly the best way to solve my noise issue is to make the PWM voltage linear so that it doesnt cause problems with the fans built in circuit. Please correct me if I am wrong. Also would a rectifier diode be able to smooth the voltage as well as the PWM signal I almost the same as an ac signal?
 

Thread Starter

SILENT001

Joined Jan 14, 2016
35
Hello all, sorry for the late response have been rather busy.

.... and it is possible that your PWM frequency is clashing with the internal commutation.

Here's a circuit you could try, for smoothing the PWM :-
View attachment 146521
I tested the above and used a BC182B transistor instead of a 2N2222.
It has removed the noise from the fan. I had increased the PWM frequency also to 30KHz as this allowed me to still turn the fan with a Duty Cycle of 1%.
The only issue I have now is that the fan is not running at 100% speed even with a Duty Cycle of 100%.
Without anything attached just the fan directly connected I am drawing 140mA of current is drawn from the fan. With the above diagram the current drawn by the fan is 80mA so that is almost half even with 100% Duty Cycle. How can I improve this? Could it be the transistor?
Thank you in advance.
 
Last edited:

Alec_t

Joined Sep 17, 2013
14,280
I tested the above and used a BC182B transistor instead of a 2N2222.
You're lucky the transistor survived. It's rated maximum current is only 100mA. That's why the 2N2222 was suggested.
Try the circuit below, which will put a higher voltage across the motor.
MotorDriveMod.PNG
 

Thread Starter

SILENT001

Joined Jan 14, 2016
35
Hi, Thanks Altec_t for all your help so far. So I removed the BC182B and replaced it with a D2058Y (it was all I had lying around) and boom it gave me 120mA current draw at 100% duty cycle at 40KHz PWM. Also when I tested the design again last night after my failed attempt on Sunday I accidentally built it as you had it in your latest diagram. I also need to add some more info here that might be of some use. So my PWM signal is at 3V3 with a maximum current draw allowed of 3mA. The fan is connected to a 5V source that has a maximum current draw of 200mA. Not sure if this info would help to improve the RC Filter and picking the correct transistor for the job. So once I got the fan running almost at full speed I decided to map the current draw at 40KHz and drew up a graph giving me my control range roughly. After that I found a script for CPU temp control for a Raspberry Pi and used that. I saw the person was using 25Hz so I decided to give that a try and mapped that out as well. Below is the graph with the bottom being the percentage duty cycle and the left being the mA current draw.

upload_2018-10-30_21-47-14.png

I'm still going to play with the frequency to try get a better curve with almost liner control range but before I do that I was wondering if there is a way to improve this somewhat with the newly provided information?
 

Alec_t

Joined Sep 17, 2013
14,280
If your PWM can provide only 3mA safely at 3.3V then R1 should be a higher value (say ~1kΩ) to protect the PWM source. That might, however, reduce the fan current unless the transistor has a reasonably high current gain.
40kHz seems exceptionally high for fan control.
 
Top