UKHeliBob:
What value are you using for setDutyCycle() and how did you determine the value to be used ?
Per the library, you simply pass a value 0-100 which represents the % speed (duty cycle) that you want to set the fan to.
Ron_Blain:
A typical PC 12 VDC fan will have a tachometer output of 2 pulses per revolution. The pulses are the result of a hall effect sensor(s). They normally rely on using an output which requires an external pullup to the fan.
I did end up discovering the bit about the pull-up resistor on my own before seeing your post. I was hoping that was my "voila!" moment, but alas... it didn't help. I tried a 10K and a 5K as Noctua's PWM docs say anything above 2.7K should suffice. I tied it to the +5V on the Uno.
So what does your new fan have? Pulses per rev?
According to Noctua's PWM docs, it's the standard 2 pulses per revolution.
Writing the code to PWM a fan is not all that difficult nor is reading the speed difficult. You may want to just try that and see what you get.
I looked into that, but it gets into territory beyond my current skills and understanding (timers, interrupts, etc). The library made things very straightforward so I could focus on the other parts of my code. I was hoping to continue using it.
The library you are using looks like the following:
Unfortunatley the meat of it is in FanController.cpp which flies right over my head and I can't make sense of 95% of what's in there in order to DIY.
And setting the speed isn't the issue, just reading the RPMs. I can tell the fan speed is proportional to what I set it to, but something about reading the RPMs on this particular fan.
Everyone was understandably asking for code, but I didn't have it ready to present since it was mixed in with the rest of the code which is mostly unrelated to the fan so it'd make it confusing for people. So tonight I wrote a separate short snippet just controlling the fan and reading the RPMs which is enough to demonstrate the problem:
#include <FanController.h>
#define SENSOR_PIN 2
// threshold in milliseconds between readings.
// A smaller value will give more updated results,
// while a higher value will give more accurate and smooth readings
#define SENSOR_THRESHOLD 500
// PWM pin (4th on 4 pin fans)
#define PWM_PIN 9
FanController fan(SENSOR_PIN, SENSOR_THRESHOLD, PWM_PIN);
void setup() {
Serial.begin(9600);
fan.begin();
fan.setDutyCycle(100); // percent, 0-100
}
void loop() {
Serial.println(fan.getSpeed());
delay(1000);
}
With the fan set to 100%, the reported RPMs are within spec (a bit over 3000). Set it to anything less than 100, and the RPMs report over 17000.
The original fan I was testing with was a Foxconn PV902512PSPF. With that one I got proportional RPMs to fan duty cycle, with a min RPMs of about 300 before the fan wouldn't spin at all. So the library was working perfectly.
Something weird about this Noctua fan.