Driving a 4-pin computer PWM fan on the BTT Octopus using Klipper

Regular fans for 3D printers have just two wires, power and ground, and we vary the average supply voltage to the fan using PWM to change its speed.

However 4-wire computer fans like Noctuas are different, these fans expect a steady 12V power supply and a separate 5V PWM signal to set their speed. Check the pinout of your fan’s connector here:


The steady 12V supply is easy, on the BTT Octopus we can just set the voltage selection jumper on one of the always-on fan headers (like FAN6) to 12V, and connect the power and ground of the fan to that fan connector like normal. Note that you don’t need to use a fan header for this, any source of 12V you have handy will do fine.

However to add a 5V PWM signal for speed control we have to do something a little extra. On the Octopus, like on most 3D printer boards, the PWM fan control switches a MOSFET which either connects or disconnects the negative (ground) pin of the fan header. If we connect this negative pin to the PWM input of the fan, then when the MOSFET is closed the PWM pin will be pulled to ground by the MOSFET and the fan will see 0V, and when the MOSFET is open the pin will be pulled up by the fan’s internal 5V pull-up, and the fan will see 5V. This is exactly what we need.

On a PWM fan header (e.g. FAN5), first remove all of the voltage selection jumpers (to avoid the output being pulled up to an erroneous and possibly damaging voltage through the onboard green LED). Then connect the PWM pin (the “negative” pin of that fan header) to the fan’s PWM input so:

Note that the PWM signal is inverted (i.e. setting 0% fan speed will actually give us 100%), so we also need to invert the pin definition to fix this by adding a “!” in front of the pin name in Klipper like so:

[temperature_fan exhaust_fan]
# 4-pin computer PWM exhaust fan - FAN5
pin: !PD15
control: pid
pid_Kp: 40
pid_Ki: 0.2
pid_Kd: 0.1
max_power: 1.0
min_speed: 0
max_speed: 1
shutdown_speed: 0.0
kick_start_time: 2.0
target_temp: 50
sensor_type: ATC Semitec 104GT-2
sensor_pin: PF5
min_temp: 5
max_temp: 100
gcode_id: C

# The official PC fan spec calls for 21-28kHz PWM frequency, but my Noctua at least was happy with the default 100Hz software PWM. So if your controller doesn't support hardware_pwm then try leaving these two lines out:
hardware_pwm: True
cycle_time: 0.00004 # 25 kHz

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.