PC Fan not responding to high frequency PWM

Hi there!
I'm working on a project where I need to control the fan speed of a 3-pin 12V PC fan (Thermaltake Pure 20). The fan is powered by a 12V power supply that goes through an n-channel MOSFET (IRF520) which I control with my Arduino Nano. I'm trying to use PWM on the gate to control the voltage supplied to the fan and in that way control the fan speed. It works perfectly fine with the default PWM frequency of 488Hz and all the way up to 8kHz but since the frequency is in the human hearing range, the fan makes an audible hum. To combat this I tried changing the frequency on pin 3 to 31.4kHz with the following code:

TCCR2B = 0b00000001;
TCCR2A = 0b00000001;

Now the fan only turns when a constant HIGH signal is sent to the gate analogWrite(3, 255) and anything below 255 makes the fan stop spinning. I checked with a multimeter and even though it reads voltages in the range of 7-11V the fan won't spin (it did spin with 7V at lower frequencies). I also checked the frequency over the fan with the multimeter, which read 31kHz as expected. Is there something I can do to make the fan spin at a higher frequency or am I out of luck here?

Thanks in advance

Hi @cogitare8

To output 31.25kHz PWM on timer 2 with analogWrite(), you only need to change the timer2's prescaler by adding the following lines of code to the setup() portion of your sketch:

TCCR2B &= ~_BV(CS22);	// Increase the timer2 PWM frequency to 31.25kHz
TCCR2B |= _BV(CS20);

Hi, I added those to lines to setup() but it didn't change anything. I already checked with a multimeter prior to adding those lines that the Arduino was indeed outputting a 31kHz signal so adding them made no difference.

So there are two possibilities here.

One is that the fan does not want to respond to the higher PWM frequency due to the inductance of its coils.

The other is that using the wrong FET is not generating a proper PWM output. Of course, we can't say as we don't know the details of your secret circuit. :grin:

As it is only a three pin fan, you can't simply use a PWM logic signal to control it.

Hi,
I hope you realise that the fan is a brushless fan and has a BUILT IN PWM system to control the fan.
A three wire is supply, gnd and tacho output.

If you want to control the speed you will need a four wire fan, supply, gnd, tacho and speed signal input.

The internal control system probably does not like a high frequency current to work with, when it is designed for DC current.

Google;

difference between three and four wire fans

Tom... :smiley: :+1: :coffee: :australia:

Wouldn't call it "PWM", that may confuse the issue; it is simply electronic commutation.

My point.

You are up late again, Tom! :rofl:

Hi, thanks for the responses! Here's my very secret circuit and the code :grin:

int PWMsignal;

void setup() {
  TCCR2B = 0b00000001;
  TCCR2A = 0b00000001;

  pinMode(3, OUTPUT);
  
  Serial.begin(9600);
}

void loop() {
  PWMsignal = map(analogRead(A0), 0, 1023, 0, 255);
  analogWrite(3, PWMsignal);

  Serial.println(PWMsignal);
}

I'm aware that the fan itself can't be controlled with PWM directly but I was under the impression that by adjusting the voltage supplied to the fan with a transistor I could regulate the fan speed. The code and circuit above do work just as expected if I just remove the two lines that adjust the frequency but then it makes the hum/tone I'm trying to get rid of.

That is a seriously weird circuit! :astonished:

What are you using as a 12 V power supply?

Hehe I’m fairly new to electronics so any suggestions for improvements would be welcome. For the 12V power supply I use a 60W wall adapter that takes 230vac and outputs 12vdc. The Arduino is powered with USB.

OK, so this will in general work, but only due to the isolation in the grounds.

Point is - the circuit you posted is clearly wrong and if it is actually how you have wired it, may be part of the trouble you are having. Care to check it is actually how you have it wired?

Hi,
IRF520 is not a logic level MOSFET.

Been out to radio club construction night, then had to get some medication for grandsons at 24hr chemist, then home and I had an attack of the munchies....

Now at work... Coffeeeeeeee.... :coffee: :coffee: :coffee: :coffee: :coffee:

Tom... :smiley: :+1: :coffee: :australia:

2 Likes

Hi again guys,
Sorry for the late response, life got in the way :frowning:. You were right Paul, the circuit I posted is not right. It seems that I mixed up the drain and the source of the MOSFET and forgot to put in the pull-down resistor I have between gate and source. I'm quite new to this so if there's something else wrong I would really appreciate some help :smiley:. However, since the circuit works fine (except for the noise) at a lower PWM frequency I would assume the issue isn't in the circuit.

The term logic level was new to me so I looked it up and if I understand it correctly it's when a transistor is designed to operate with only 5V or less on the gate? (A voltage that a microcontroller can supply.) When looking at the datasheet for an IRF520 it says that the Gate Threshold Voltage is min 2V and max 4V, don't know if that matters. Do you think a logic level transistor will solve the issue?

As it happens, it is essentially irrelevant!

We repeatedly have to point out that the Gate Threshold Voltage is the voltage below which the FET turns off. It is quoted as a figure of several microamps.

If you want it to switch power to something, you need the gate voltage at which the source-drain resistance is quoted.

Ok, thanks for clearing things up. I'll go and order a logic level transistor to see if it solves the issue.

It worked! Thanks for all the help :grinning:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.