1
\$\begingroup\$

I have connected my pwm pin to my arduino like in this tutorial

http://fritzing.org/projects/reading-pc-fan-rpm-with-an-arduino/

enter image description here

It's working properly. I can read and set the speed using a sketch from this website:

http://www.beefrankly.org/blog/2011/12/21/read-out-4-pin-cpu-fan-speed/

int fanPulse = 0;
unsigned long pulseDuration;

void setup()
{
Serial.begin(9600);
pinMode(fanPulse, INPUT);
digitalWrite(fanPulse,HIGH);
}

void readPulse() {
pulseDuration = pulseIn(fanPulse, LOW);
double frequency = 1000000/pulseDuration;

Serial.print("pulse duration:");
Serial.println(pulseDuration);

Serial.print("time for full rev. (microsec.):");
Serial.println(pulseDuration*2);
Serial.print("freq. (Hz):");
Serial.println(frequency/2);
Serial.print("RPM:");
Serial.println(frequency/2*60);

}

void loop()
{
analogWrite(3,20);
delay(5000);
readPulse();
analogWrite(3,50);
delay(5000);
readPulse();
analogWrite(3,100);
delay(5000);
readPulse();
analogWrite(3,200);
delay(5000);
readPulse();
analogWrite(3,255);
delay(5000);
readPulse();
}

It seems to me, like I can only enter values higher than 127 and values lower than 127. There are no steps between them. The fan won't turn slower when I go from 126 to 0 or from 128 to 255.

Some results I get:

100: 

 pulse duration:19058
time for full rev. (microsec.):38116
freq. (Hz):26.00
RPM:1560.00


0:

pulse duration:19160
time for full rev. (microsec.):38320
freq. (Hz):26.00
RPM:1560.00


127:

pulse duration:9032
time for full rev. (microsec.):18064
freq. (Hz):55.00
RPM:3300.00


255:

pulse duration:9151
time for full rev. (microsec.):18302
freq. (Hz):54.50
RPM:3270.00

Is there some mistake I've made or is it possible my fan won't accept precise values? Can you recommend any 4 wired fans I could use for this or some other way? I thought about using a SG2524N to controll a two wired motor, but I'm not experienced with this. Thanks for your advice.

\$\endgroup\$
2
  • \$\begingroup\$ Are you sure that pin 3 is a PWM channel on your Arduino? Use a LED to test. \$\endgroup\$ Oct 10, 2013 at 1:19
  • \$\begingroup\$ I'm now using SoftPWM, still no change. I'm going to switch the fan and try again \$\endgroup\$
    – Wolfen
    Oct 10, 2013 at 8:20

1 Answer 1

3
\$\begingroup\$

Fans don't use stock pwm frequencies. The PWM control frequency needs to be 25khz. A 16mhz arduino can do this relatively easily through software. Just search "4 wire fan arduino" and there's quite a few posts on it, including sample code to set the prescaler frequency so the output PWM is at 25khz.

\$\endgroup\$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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