Project tutorial
25 kHz 4 Pin PWM Fan Control with Arduino Uno

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

Control the speed of your PWM fan easily. No need for other circuits.

  • 1,534 views
  • 0 comments
  • 11 respects

Components and supplies

Apps and online services

About this project

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).

Code

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;
}

Schematics

pwm_fan_ctrl_6xm3Jti8le.png
Pwm fan ctrl 6xm3jti8le

Comments

Similar projects you might like

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 43,699 views
  • 13 comments
  • 44 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 11,952 views
  • 6 comments
  • 34 respects

Enable Alexa Control to your Ceiling Fan

Project tutorial by Jithin Thulase

  • 4,294 views
  • 5 comments
  • 11 respects

Control Music Volume and Ledbar Using Slider of 1Sheeld

Project tutorial by ahmed ismail

  • 2,053 views
  • 2 comments
  • 14 respects

Arduino UNO Mini-Weather Station

Project tutorial by Igor Fonseca Albuquerque

  • 45,046 views
  • 28 comments
  • 101 respects
Add projectSign up / Login