PC fan, 4-pin PWM
A 12 V computer fan you can slow down and read back: a duty cycle on PWM sets it, TACH pulses twice a turn.
- 4 pins
- 8 settings
- In 1 project
The PC fan, 4-pin PWM in brief
What it is, and every setting the properties panel gives it.
A four-pin PC fan runs from its own 12 V and talks to a board on two wires of its connector: GND (black), +12V (yellow), TACH (green) and PWM (blue). TACH is an open collector that pulls low twice a turn, so rpm is falling edges a second times 30; give it INPUT_PULLUP on an Uno interrupt pin (2 or 3), or any ESP32 GPIO, which is safe because the fan only pulls it low. PWM is pulled up inside the fan, and open or high is full speed. The spec wants 25 kHz: Timer1 gives it on pin 9 of an Uno, and ledcAttach(pin, 25000, 8) on an ESP32. Mokxi models the duty-to-speed line (the default fan turns 600 rpm at 30 percent and under, 1800 at 100), Noctua and Arctic models that stop at the bottom of the range, a three-pin fan whose speed follows its supply, the 7 V starting voltage, a 1.5 second spin-up and a current that rises with the cube of the speed. The classic mistake is reading TACH with no pull-up and counting noise. The PWM frequency (any is averaged), the noise, the airflow and the start-up surge are not modeled.
- Family
- Outputs
- Pins
- 4
- model
- custom (or Noctua NF-A12x25 PWM, Arctic P12 PWM PST, 3-pin 12V DC fan)
- wires
- 4
- max_rpm
- 1800
- min_rpm
- 600
- min_duty
- 30
- stop_below
- 0
- current
- 0.15
- inertia
- 1500
4 pins
Named as the editor names them, so a wire lands where you expect it.
How to control a 4-pin PC fan with an Arduino
Only two of the fan’s wires go to the Uno: PWM (blue) to pin 9 and TACH (green) to pin 2, plus GND. The +12V wire goes to a 12 V adapter, whose minus meets the Uno’s ground. No transistor is needed, because the fan has its own controller.
Intel’s fan spec asks for 25 kHz, so the sketch sets Timer1 itself: ICR1 = 639 is 16 MHz / 640, and OCR1A sets the duty. TACH pulls low twice a turn, so count falling edges with attachInterrupt for a second and multiply by 30 for rpm. The Noctua in this project spins at 2000 rpm at 100 percent, holds 450 rpm down to 20 percent, and stops at 0.
Read TACH with INPUT_PULLUP. It is an open collector, and with no pull-up the pin floats and the count is noise. Leave PWM unwired and the fan runs flat out, as the spec requires.
On an ESP32, ledcAttach(pin, 25000, 8) makes the 25 kHz without touching timers, and TACH is safe on a 3.3 V pin because the fan only ever pulls it low.
pinMode(PWM_PIN, OUTPUT);
TCCR1A = (1 << WGM11) | (1 << COM1A1);
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);
ICR1 = 639; // 25 kHz
OCR1A = 320 - 1; // 50 percent
pinMode(TACH_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(TACH_PIN), countPulse, FALLING);What is true about the PC fan, 4-pin PWM, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
Open is full speed. Nothing on PWM runs it flat out, as the spec requires.
Two pulses a turn. 1800 rpm is 60 pulses a second on TACH.
The starting voltage. Under 7 V across it, the figure 12 V fan datasheets print, it does not turn.
Not modeled
The PWM frequency (any frequency is averaged), the noise, the air, the start-up
surge, and the exact current curve: the draw is 15 % of current for the
electronics plus the rest times the speed cubed, an approximation.
From PC fan, 4-pin PWM, in full.
See the PC fan, 4-pin PWM in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the PC fan, 4-pin PWM in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the PC fan, 4-pin PWM
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.