A PWM (Pulse Width Modulation) fan is a type of cooling fan that uses PWM signals to control its speed. By varying the duty cycle of the signal, the fan can operate at different speeds, allowing for efficient cooling and reduced noise levels. PWM fans are widely used in applications where precise temperature control and energy efficiency are critical.
The PWM fan typically uses a 4-pin connector. The pinout is as follows:
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection for the fan |
2 | VCC | Power supply for the fan (typically 12V DC) |
3 | Tachometer | Output signal for fan speed monitoring (provides pulses proportional to RPM) |
4 | PWM | Input signal for speed control (3.3V or 5V PWM signal) |
Below is an example of how to control a PWM fan using an Arduino UNO:
// Define the PWM pin connected to the fan
const int pwmPin = 9; // Pin 9 supports PWM on Arduino UNO
void setup() {
// Set the PWM pin as an output
pinMode(pwmPin, OUTPUT);
}
void loop() {
// Gradually increase fan speed from 0% to 100%
for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle++) {
analogWrite(pwmPin, dutyCycle); // Set PWM duty cycle
delay(20); // Wait 20ms before increasing duty cycle
}
// Gradually decrease fan speed from 100% to 0%
for (int dutyCycle = 255; dutyCycle >= 0; dutyCycle--) {
analogWrite(pwmPin, dutyCycle); // Set PWM duty cycle
delay(20); // Wait 20ms before decreasing duty cycle
}
}
Note: The analogWrite()
function generates a PWM signal with a frequency of approximately 490 Hz on most Arduino pins. While this is sufficient for basic control, some fans may require a higher frequency (e.g., 20 kHz). In such cases, you may need to use a library or configure the Arduino's timers manually.
Fan Not Spinning:
Fan Speed Not Changing:
Fan Produces Audible Noise:
Tachometer Signal Not Detected:
Can I use a 3-pin fan with PWM control? No, 3-pin fans do not have a dedicated PWM pin. Speed control is achieved by varying the supply voltage, which is less precise.
What happens if I set the PWM duty cycle to 0%? Most fans will stop spinning. However, some fans may require a minimum duty cycle (e.g., 20%) to start spinning again.
Can I use a 5V power supply for a 12V PWM fan? No, the fan will not operate correctly. Always use the specified voltage for the fan.
How do I measure the fan's RPM using the Tachometer pin? Count the number of pulses from the Tachometer pin in one second. Multiply this value by 30 to calculate the RPM (most fans produce 2 pulses per revolution).