Description of project:
I want to controll the speed of a PC fan by varying the duty-cycle on the PWM/4th pin of the fan. I will be testing to see if I can do this with an Arduino UNO and an external power supply for the fan, see attached wiring diagram “Schematic”. For testing I am using a fan from Intel, E97378-001. Reading the Tach pulses from the fan on Arduino pin 2 to determine speed.
I am using the library “Arduino PWM Frequency Library”, version from post #126 here, to achieve an output frequency of 25kHz on pin 3. This is the frequency that should be used, Extract from wikipedia:
The control signal is a square wave operating at 25 kHz, with the duty cycle determining the fan speed.
To change the speed I use Serial Monitor from Arduino IDE to send numbers 0 to 255 followed by an S. The number sent will be used in the analogWrite function. The “S” is just to determine when I am done sending the number.
Now to the problem:
I am able to control the fan speed (I have an external RPM measurement tool to verify my readings.), but what I think is weird is that I am at a 100% duty-cycle when I analogeWrite(3, 40), the range is currently 0 to 40, why not 0 to 255?
I tried measureing the duty-cycle when the frequency is 500Hz, then the range is 0 to 250. but it doesn’t go all the way up to 255, or to say it in another way, the duty-cycle is 100% between 250 and 255 when the frequency is 500Hz and between 40 and 255 when the frequency is 25kHz , why is that?
To measure the duty-cycle I connected pin 3 to pin 2, see attached code DutyCycle.ino and the schematic DutyCycleRead.png.
To control fan and read it’s speed see attached code Fan_control.ino and schematic Schematic.png
Note: I did try googeling a lot, but I guess I didn’t know how to formulate myself since I couldn’t find anything about it.
DutyCycle.ino (1.48 KB)
Fan_control.ino (1.65 KB)