Trybotics Logo

25 kHz 4 Pin PWM Fan Control with Arduino Uno © GPL3+

DESCRIPTION

I have been wondering about this project and how to control my 4 pin PWM fans. I had 5 laying around and thought mine as well give it a shot. The frequency values can be adjusted between 125 HZ -- 8 MHZ as well as a variable duty cycle. The circuit utilizes the mode 10 PWM phase-correct on timer 1 OCR1A (Pin 9) and ICR1 (Pin 10). Some debugging was needed to figure out this and I do own a handheld oscilloscope. It makes seeing the frequencies and duty cycles much easier and no guessing is involved. Here's the link: The Oscilloscope.

I do strongly advise you look up the datasheet for your fan as the control pin in my case was yellow (Which is normally referred as tach wire). Be sure to also find the acceptable frequency range for your chosen fan. You may need to change the code frequency to adjust to your needs. Finally you will need a good power supply (Mine is a converted ATX PSU from an old PC).

Description:

Description:

I have been wondering about this project and how to control my 4 pin PWM fans. I had 5 laying around and thought mine as well give it a shot. The frequency values can be adjusted between 125 HZ -- 8 MHZ as well as a variable duty cycle. The circuit utilizes the mode 10 PWM phase-correct on timer 1 OCR1A (Pin 9) and ICR1 (Pin 10). Some debugging was needed to figure out this and I do own a handheld oscilloscope. It makes seeing the frequencies and duty cycles much easier and no guessing is involved. Here's the link: The Oscilloscope.

I do strongly advise you look up the datasheet for your fan as the control pin in my case was yellow (Which is normally referred as tach wire). Be sure to also find the acceptable frequency range for your chosen fan. You may need to change the code frequency to adjust to your needs. Finally you will need a good power supply (Mine is a converted ATX PSU from an old PC).

Description:

Untitled fileArduino
const byte OC1A_PIN = 9;
const byte OC1B_PIN = 10;

const word PWM_FREQ_HZ = 20000; //Adjust this value to adjust the frequency
const word TCNT1_TOP = 16000000/(2*PWM_FREQ_HZ);

void setup() {
  
  pinMode(OC1A_PIN, OUTPUT);

  // Clear Timer1 control and count registers
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;

  // Set Timer1 configuration
  // COM1A(1:0) = 0b10   (Output A clear rising/set falling)
  // COM1B(1:0) = 0b00   (Output B normal operation)
  // WGM(13:10) = 0b1010 (Phase correct PWM)
  // ICNC1      = 0b0    (Input capture noise canceler disabled)
  // ICES1      = 0b0    (Input capture edge select disabled)
  // CS(12:10)  = 0b001  (Input clock select = clock/1)
  
  TCCR1A |= (1 << COM1A1) | (1 << WGM11);
  TCCR1B |= (1 << WGM13) | (1 << CS10);
  ICR1 = TCNT1_TOP;
}

void loop() {

    setPwmDuty(0);
    delay(5000);
    setPwmDuty(25); //Change this value 0-100 to adjust duty cycle
    delay(5000);
//    setPwmDuty(50);
//    delay(20000);
//    setPwmDuty(75);
//    delay(20000);
//    setPwmDuty(100);
//    delay(20000);
}

void setPwmDuty(byte duty) {
  OCR1A = (word) (duty*TCNT1_TOP)/100;
}

Description:

pwm_fan_ctrl_6xm3Jti8le.png
Pwm fan ctrl 6xm3jti8le


YOU MIGHT ALSO LIKE