PWM on PC Fan



  • Hello,

    i'm sorry if my english isn't very good. I want to know if it is possible to control the speed of a PC fan with PWM function.

    Cedric


  • Hero Member

    It will depend on the type of fan you use. Most of the fan's are 12v and some of these have a separate control/ pulse line.
    Should be easy with mosfet and pwm

    "Anything" can be controlled with MySensors



  • I'll use fans with 4-pin. I understand that I must use a PWM signal of 25kHz.



  • I have MySensors project that has PWM and fan 60mm 12V. Problem is with high frequency noise coming from the fan caused by PWM. I solved this by puting 2200uF electrolytic capacitor. Down side is that when you set pwm at about half in my case fan works at 100% but you can map value to 0-120 instead of 0-255 for pwm and it will work OK. I started with lower values of capacitor until noise disappeared and then tested where is 100% of speed vs PWM value.


  • Mod

    @cedru 4pin PWM fans are easy to control.
    Only gotcha is setting the arduino PWM frequency to 25KHz.
    One solution is to install the TimerOne library by Paul Stoffregen. You can find it here.
    Include it in yout sketch and initialize the PWM in the setup() method:

    #define PWM_PIN (10)
    #define PWM_FREQ_HZ (25000) 
    #define PWM_CYCLE_US (1000000/PWM_FREQ_HZ)
    
    Timer1.initialize(PWM_CYCLE_US);
    Timer1.pwm(PWM_PIN, 1023); 
    

    Then change the duty cycle whenever you want:

    int16_t duty = 123;
    Timer1.setPwmDuty(PWM_PIN, duty);
    


  • perfect !

    a big thank you from France


Log in to reply
 

Suggested Topics

  • 4
  • 9
  • 9
  • 274
  • 5
  • 1

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts