Go Down

### Topic: 4 pin PWM fan output in RPM (Read 4955 times)previous topic - next topic

#### mooch444

##### Feb 09, 2012, 12:14 am
Hey guys,

I know topic has been covered a lot on this forum, but I have read through many of the previous posts and have not been able to solve my problem.  I am using a 12V, 4 pin (+12, ground, sense, control) Arctic F9 PWM fan (specs: http://formfactors.org/developer%5Cspecs%5CREV1_2_Public.pdf) with my Arduino Uno.  So far, I have been able to somewhat control the fan speed by varying the duty cycle on the PWM pin, but I would also like to be able to measure and output the fan speed in RPMs.  I have attached a jpg of the the setup I've been using. I also verified that the sense pin is outputting 5V in this setup using a volt meter. I have tried several codes from previous posts (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1152891511/0), but the only thing I am able to get out of it is 0 rpm, no matter what the fan speed actually is. I need to be able to accurately read the value across the entire fan speed range of 600 to 1800 RPM. I've only been using Arduino for a few weeks, so I'll admit that I'm pretty ignorant about this stuff but any help, hardware or software related, would be much appreciated.

Thanks

#### Verdris

#1
##### Feb 09, 2012, 12:23 am
How do you expect to measure fan speed without a piece of hardware actually looking at the fan and doing something like an optical measurement?

Without that, I think the best you'll be able to do is just throw some math to turn your PWM duty cycle into a fan speed.  The relationship is linear, so analogWrite(pin,255) should correspond to your max speed, while analogWrite(pin,127) should be 50% fan speed.

#### mooch444

#2
##### Feb 09, 2012, 12:31 am
As far as I can tell, the sense pin is supposed to output a value for the fan speed.  The specs say it is a tachometer output signal with 2 pulses per revolution.  If I just plug the wire straight into an analog pin, I get values around 330, but I have no idea what that is measuring (pulses maybe?).  Most of the other posts have tried to use interrupts to somehow convert pulses to RPMs, but I have been unsuccessful with them.

#### PeterH

#3
##### Feb 09, 2012, 01:13 am

As far as I can tell, the sense pin is supposed to output a value for the fan speed.  The specs say it is a tachometer output signal with 2 pulses per revolution.  If I just plug the wire straight into an analog pin, I get values around 330, but I have no idea what that is measuring (pulses maybe?).  Most of the other posts have tried to use interrupts to somehow convert pulses to RPMs, but I have been unsuccessful with them.

If it's a tacho output then it doesn't output fan speed, it just pulses and the frequency of the pulses corresponds to the fan speed. So you need to either read the value very frequently and detect when it changes between high/low and count the pulses that way, or connect it to an input pin that supports interrupts and attach an interrupt handler to the corresponding interrupt. Using interrupts is more likely to be successful, but from what you've written so far I suspect you have some learning to do before you're ready to tackle that.

#### Verdris

#4
##### Feb 09, 2012, 01:13 amLast Edit: Feb 09, 2012, 01:59 am by Verdris Reason: 1
If you're using analogRead() then the 330 corresponds to a voltage of (5*330)/1024.  Do you get two pulses per revolution as in one pulse per half revolution?  If that's the case you could do pulseIn() which measures the time between pulses.  But if it goes around a full revolution and then spits out two quick pulses, then you'll need to do interrupts, I think.

#### mooch444

#5
##### Feb 09, 2012, 02:19 am
I'm not opposed to using interrupts, I've been unable to find a sketch that works.  Is there any reason the sketches I mentioned earlier from the other post won't work?  Is there a difference between the sense pin in a 4 pin PWM fan and a 3 pin (Hall effect sensor) fan?

Go Up