7

I am trying to build a simple fan controller (single fan). So far I have successfully created a circuit which powers the fan with an external 12v DC adapter and added a transistor (NPN) to switch it on and off. The transistor is connected to a PWM port on the Arduino.

When putting HIGH on the port the fan works perfectly at high speed, but when I want to lower the speed (say analogWrite(fanPin, 150)) it starts to make a humming noise. I believe this is caused by the use of PWM.

What is the best way to control the speed of the fan without (too much) noise?

ps. The fan is a Cooler Master 3-wire PC fan. Transistor is a P2N2222A.

Update: Here is the schema I am using:

schema

3
  • Martynas pointed out that I should include the circuit, I will do that later today when I get home from work.
    – Fieg
    Oct 15, 2014 at 8:01
  • 1
    Try using pins 5 or 6, as those pwm pins are running at twice the frequency of the other pwm pins.
    – Gerben
    Oct 15, 2014 at 15:28
  • 1
    When I try your suggestion the noise changes but isn't gone.
    – Fieg
    Oct 15, 2014 at 19:35

9 Answers 9

4

I had the same problem with a 5V fan. Something simple worked for me: To decrease the PWM frequency. You probably want to do this using pin 9 or 10 (for the Uno) as changing the frequencies of other PWM pins messes up the delay and millis functions. Details on how to do it and a very convenient function are provided in http://playground.arduino.cc/Code/PwmFrequency. In my case, using the lowest frequency possible (31250/1024 = 31Hz), I completely eliminated the hum for higher speeds and significantly reduced it for lower speeds. And by the way, I used the PWM pin to drive a MOSFET since the current of my fan was 140 mA, much higher than the 20 mA Arduino pins can safely provide.

1
  • I'd be interested in why this works. Is this sound due to some mechanical side effect of the motor or something more interesting like the hum produced by a transformer which (I believe) isn't mechanical. May 16, 2019 at 14:30
3

Try using pin 3 (or 11) and lower the prescaler of timer 2 using the following code in your setup;

//move from /64 prescaler to /32 prescaler
TCCR2B |= _BV(CS20);//set bit (remove this line for a /8 prescaler)
TCCR2B |= _BV(CS21);//set bit
TCCR2B &= ~_BV(CS22);//clear bit

Halving the prescaler will double the frequency.

3
  • When I try this I get a noise with a higher frequency.
    – Fieg
    Oct 18, 2014 at 15:49
  • 4
    The goal is to use a frequency high enough to not be audable by the human ear. Have you tried removing the line with CS20?
    – Gerben
    Oct 19, 2014 at 10:33
  • Yes, I tried that too, but I still hear an annoying noise.
    – Fieg
    Oct 19, 2014 at 11:37
3

It might help to use a capacitor to smooth your PWM signal.

See http://ww1.microchip.com/downloads/en/AppNotes/00771b.pdf

3
  • That document describes adding a capacitor to reduce slew rate while using an NPN transistor. Is there any way to slow the slew rate while using a MOSFET?
    – localhost
    Oct 21, 2016 at 2:41
  • There will be no real difference between using a capacitor to smooth the output from an NPN transistor and filtering the output of a MOSFET. From the point of view of the load, an NPN transistor (driven fully on or off) is a switch with a series resistor on it, where a MOSFET has very low resistance. The extra resistance of the NPN transistor would slow the charge rate for the capacitor a little, but you can pretty much ignore the difference.
    – Duncan C
    Jun 1, 2020 at 23:52
  • A capacitor is a crude low-pass filter. It starts to charge up during the ON cycle of the transistor, and starts to discharge when the transistor is off. Since it never fully charges or discharges, it evens out the peaks and valleys of the PWM signal to a rough average of the voltage that is fed to it. (Without a load, the capacitor will charge up to almost the full supply voltage since it during the ON cycle but doesn't really discharge.)
    – Duncan C
    Jun 1, 2020 at 23:56
0

coment add circuit to know what you have done

Does your circuit looks similar like:

Do you use resistor for transistor? Diode for fan?

enter image description here

I suspect that you do not have diode.

The purpose of the diode is to allow current that is flowing in the motor coil to continue to flow in the same direction when the transistor turns off. When the transistor turns off, the voltage at the transistor collector will rise as it was flowing out of the motor. From Vce(SAT) it will rise above the power supply voltage and stop only when the transistor breaks down (or when it starts to ring with parasitic capacitance). By putting a diode from the transistor collector to the +12V rail, you prevent the voltage across the transistor from exceeding 12V and and allow the motor current to continue to flow.

3
  • If you need to ask the original poster questions, please do so by commenting on the question itself. An answer isn't the right place to do that. Oct 15, 2014 at 8:55
  • @PeterR.Bloomfield i understand everything. Sorry for that, but i added an answer too. I would comment if not 44 rep. pts...
    – Martynas
    Oct 15, 2014 at 9:01
  • I added my schema. It's indeed very similar to yours. Only I had to connect the grounds to get it working.
    – Fieg
    Oct 15, 2014 at 18:42
0

There is also the possibility adding a capacitor bypassing the transistor. But you have to be careful, if the capacity is to big you could damage your transistor.

0

SAS is correct - lowering the PWM to 31Hz works great. Tested using a 12v fan. Before lowering the PWM, the sound from the fan was a loud "WHEEEEEeeeeeeeee" sound at any speed other than full speed. Low speed made the sound worse.

After lowering the PWM frequency, the noise is inaudible at higher speeds. At lower speeds you might hear a light "clicking" noise. The sound reminds me of the faint "clicking" noise you hear as the valves on a car engine open and close.

0

I can also confirm that SAS answer ist correct. I tested it with a 5V DC fan. I hear a very high noise at lower speed, but you have to listen closely, and a very fast clicking noise at higher speeds.

All in all i would say lowering the PWM to the suggested 31Hz did it for me but it is not a perfect solution.

0

I get that this post is 4 year old, but I successfully removed all fan noise with simple electrolytic cap and one ceramic on output, after adding caps you need to bias RPM. You can still get some relay low squeak coming from mosfet but only on low RPM

0

25kHz power PWM solved this problem for my 3-pin fan. Diode had no effect on noise, it fixes another problem (EMI).

2
  • Do you talk about 4-pin fans?
    – Sim Son
    Jun 1, 2020 at 11:35
  • @SimSon no, I did 25kHz to power line. 3.3V GPIO from MCU is connected to darlington transistor. Didn't check by scope, likely there are all kinds of basic electrical problems, so not proposing any particular circuit. But the general idea to go high frequency seems an obviously right choice for me.
    – temoto
    Jun 1, 2020 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.