Cooling Fan RPM Sensing

I'm using PWM on a brushless cooling fan for a computer. I put a 680uF capacitor on the PWM output to smooth out the voltage by the time it gets to the fan. However, RPM sensing doesn't work out well at all! I was using pulseIn() function to read the RPM. At full speed it works, at low speed it reads it part of the time, at medium speed it shows the RPM as being faster than full speed. Makes no sense. Is there any possible way to make this work with PWM?

Unless the PWM interferes with pulseIn(), I can't think of anything ATM. Could we see the code? Are you waiting for it to go high then low or low then high? Are you taking multiple readings and averaging them?

unsigned long duration;
void setup(){
 Serial.begin(115200);
 analogWrite(11, 10);//Fan on 10/255
}
void loop(){
 duration = pulseIn(18, HIGH);
 Serial.println(duration);
}

High/Low, Low/High, I'm confused on that one, but I have a 10k resistor from +5V to the RPM signal wire on the cooling fan. Averaging no at the moment, maybe I should. In the code, I'm having analogWrite 10 to pin 11.

When set to 255, works fine (full speed), I get maybe 5500rpm. When I set to 10, then I get a lot of values at 2000rpm or so, but then it jumps to 4000 or higher. I can use if/then to get rid of values higher than 2500, then its ok. Set the speed to 30, and I get consistent 6055rpm which is higher than full speed. Makes little sense.

How does the sensing wire work? Is it HIGH half the time and LOW half the time, is it normally HIGH and has LOW pulses, or LOW normally with HIGH pulses?

war_spigot:
How does the sensing wire work? Is it HIGH half the time and LOW half the time, is it normally HIGH and has LOW pulses, or LOW normally with HIGH pulses?

I'm not sure, but from looking at the actual tachometer signal from a diagram here: Fan Speed Control Its looking normally high, and low part of the time. I wish I had a scopemeter to see properly.

If you want to vary the fan speed, best thing is to use a 4-pin fan with a PWM control input. Then you don't need to use a transistor to drive the fan (as long as you don't want to stop it completely - PWM fans don't need to go below 30% speed to meet the Intel spec) and the tach output will still work.

There are plenty of PWM fans to choose from, for example search on "Arctic F8 PWM fan".

From that link:

There is also another caveat to low frequency PWM. Looking back to our illustration of our 3 wire fan with a tachometer output we can see that the tachometer output will only be present when power is applied to the fan. Power is only applied when our pulses are positive at 12 Volts. Therefore our output pulses as speed will be chopped up a little.

Unless that capacitor is providing power throughout the whole "off" part of the PWM, then that would account for the high frequencies(the tach signal is going low more often than it should because there's no power).

I'd say either do what dc42 said and buy one with a PWM line, or get a seperate hall effect sensor and make you're own RPM sensing.