Skip to content

Arduino: Read out and control a 4-pin CPU fan

Today I tried to read out the CPU speed information of a 4-wire CPU fan (Intel DTC AAL03) and additionaly I tried to control the fan speed by PWM.

The 4-wire system looks like that:

black – GND
yellow – +12VDC
green – pulse tachometer (for my Intel CPU cooler this is 2 pulses per revision)
blue – PWM value for controlling the fan

I used a external power supply for the +12VDC line. Power consumption was typically 30mA (min RPM) to 60mA (max. RPM) with some short 70mA bursts when changing PWM signal.

I used my signal generator to control the PWM value during my first tests. I tried out some duty cycles and the fan reaches min rpm at 20% duty cycle, that is exactly what the datasheet expects it to be. Max RPM is reached at 97% duty cycle.

If you don’t use PWM input at all the fan still runs at min. RPM speed 2250, max rpm was 4350.

I connected the green wire to my Arduino digital line 0. The fan expects an external pull-up to be present, so I used the internal one. You will need that pull-up resistor enabled, else you won’t get a
stable signal. Via the pulseIn() function you can get the time in microseconds between the pulses. As my fan uses 2 pulses per revision, I have to divide the value by 2.


int fanPulse = 0;
unsigned long pulseDuration;

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

void loop()
{
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);
delay(1000);
}

You can also use your Arduino for controlling the fan speed:

the datasheet of the fan says:
“PWM Frequency: Target frequency 25 kHz, acceptable operational range 21 kHz to 28 kHz”

Well…the arduino has a PWM frequency of: 490,2Hz (measured). So that shouldn’t work at all. But we are lucky and the fan doesn’t bother, it still works well and you can do some nice fan controlling with your arduino. In combination with a temperature sensor you can manage some really nice scenarios.


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();
}

sample output:

pulse duration:12178
time for full rev. (microsec.):24356
freq. (Hz):41.00
RPM:2460.00
pulse duration:11065
time for full rev. (microsec.):22130
freq. (Hz):45.00
RPM:2700.00
pulse duration:9472
time for full rev. (microsec.):18944
freq. (Hz):52.50
RPM:3150.00
pulse duration:7566
time for full rev. (microsec.):15132
freq. (Hz):66.00
RPM:3960.00
pulse duration:6869
time for full rev. (microsec.):13738
freq. (Hz):72.50
RPM:4350.00

Post a Comment

You must be logged in to post a comment.