Controlling a Four-Wire 12 V Fan: PWM, Tachometer Feedback and Temperature Tests
A four-wire fan can provide variable cooling while reporting how fast it is actually turning. That is useful for a project enclosure, but the extra wires are signal interfaces, not alternative power connections. A reliable controller keeps fan power, speed command and speed feedback separate.
PMD Way's 80 × 80 × 25 mm 12 V DC fan is listed with a four-pin connection, PWM control and speed monitoring. The catalogue gives a current figure of 0.87 A. Use the actual fan label and datasheet to confirm supply requirements, startup current, connector pinout and signal levels before connecting a microcontroller.
Identify all four functions
A typical four-wire PWM fan has supply, supply return, PWM control and tachometer output connections. The PWM input requests a speed, while the tachometer reports rotation. Neither signal connection is intended to carry the motor's supply current.
Do not identify these wires solely by colour or by a connector photograph from another fan. Obtain the pin assignment for the actual model and check the connector viewing direction. Industrial fans and special variants can use different arrangements despite having four wires.
| Function | Required information |
|---|---|
| Supply | Operating voltage range, polarity and startup requirement |
| Return | Power return and signal reference arrangement |
| PWM input | Frequency, logic levels, input circuit and duty behaviour |
| Tachometer output | Output type, allowed pull-up and pulses per revolution |
Power the fan from a suitable supply
A microcontroller GPIO pin cannot supply a fan motor. Use a power source and wiring rated for the fan's operating and startup conditions, with protection appropriate to the circuit. A listed running-current figure should not be assumed to describe every transient or fault condition.
Keep the power wiring short and supported, and follow the fan manufacturer's decoupling guidance. Where the control interface requires a common reference, establish it deliberately rather than relying on an accidental connection through test equipment. Check that supply noise or voltage drop does not reset the controller when the fan starts.
For a conventional four-wire PWM arrangement, the fan remains powered while the separate control input sets its operating speed. Rapidly switching the supply is a different method and can interfere with internal electronics or speed feedback. Use the method documented for the selected fan.
Match the PWM input instead of guessing
Noctua's PWM specifications white paper gives a 25 kHz target for its documented interface and explains the associated electrical requirements. That is a useful manufacturer example, not proof that every four-wire fan accepts the same frequency or levels.
Check whether the input expects an open-collector or open-drain control stage, what pull-up is present and which voltage limits apply. A transistor interface may be required between the microcontroller and fan. Do not drive an unknown input directly from a GPIO or pull it up to the fan's 12 V supply without an explicit specification allowing that arrangement.
Also check what happens at zero duty, very low duty and with the control wire disconnected. Some fans stop, while others maintain a minimum speed. The behaviour is model-specific and affects both noise control and failure handling.
Measure speed using the tachometer specification
Many fan tachometer outputs use an open-collector circuit, which needs an appropriate pull-up. Sanyo Denki's DC fan sensor specifications illustrate the output arrangements and model-dependent details. Confirm the output voltage and current limits before selecting the pull-up and connecting a microcontroller input.
Do not assume every fan produces two pulses per revolution. Once the documented pulse count is known, speed can be calculated as RPM = 60 × pulse frequency ÷ pulses per revolution. For example, a 120 Hz signal from a fan specified at two pulses per revolution corresponds to 3600 RPM.
Use a timer or interrupt method suitable for the signal frequency and noise environment. Include a timeout for missing pulses instead of leaving the last valid speed on screen forever. At low speed, a longer measurement interval may produce a more stable reading, but it also delays fault detection.
Build a measured duty-to-speed table
Start with the fan mechanically secured and guarded against accidental contact. Test the documented full-speed command first, then step through several lower settings. Allow the speed to settle and record commanded duty, measured RPM, supply behaviour and any unusual noise.
Do not assume that 50% duty produces exactly half the maximum speed or half the airflow. The fan's internal controller, minimum operating speed and installed air resistance affect the result. Keep the measured table with the exact fan model and installation.
Analog Devices' fan speed-control discussion distinguishes control methods and explains why tachometer measurement must be considered alongside the drive scheme. Your own measurements should use the final method, not a different temporary power-switching arrangement.
Control temperature without constant hunting
For a simple enclosure controller, define a temperature target, a minimum dependable running command and a maximum permitted temperature. Increase cooling as the temperature rises, and use hysteresis or a deliberately slower response when reducing speed so small measurement changes do not cause constant acceleration and deceleration.
Place the temperature sensor where it represents the component or air condition you need to control. A sensor directly in the coolest incoming air may miss a hot component elsewhere. Compare temperature behaviour with the lid closed and the actual filters, vents and cable arrangement fitted.
Decide what the controller should do if the sensor fails or valid tachometer pulses disappear. Depending on the equipment, the appropriate response may be a maximum cooling request, an alarm or a controlled shutdown. Verify the fan's actual response rather than assuming a software command guarantees airflow.
Test the completed cooling system
- Check startup at the lowest documented supply condition expected in service.
- Confirm reliable rotation at the minimum intended command.
- Compare reported RPM with the expected range for the installed fan.
- Run the equipment at its demanding normal workload and log temperature.
- Test sensor and feedback fault handling through safe electrical simulation rather than physically stopping the blades.
- Inspect guards, cable clearance and mounting after the test.
Choose from the 12 V DC fan collection using both airflow needs and the documented control interface. A useful fan controller confirms that the fan is turning and that the equipment is staying cool; duty cycle alone tells you neither.