0

This question is not same as the other one and this is more about employing the pwm signal to drive a CPU fan;

I am trying to follow the answer by Edgar Bonet on the question Need help to set PWM frequency to 25kHz and generate the same 25khz on pin 8 of arduino mega which is controlled by TIMER 4 and use this pwm signal to control the speed of a 4-wire cpu fan(with black, yellow, green and blue wires);

Following is my updated code for generating the pwm signal on timer 4

void analogWrite25k(int value)
{
    OCR4C = value;
}

void setup()
{    
    TCCR4A = 0;
    TCCR4B = 0;
    TCNT4  = 0;        
    TCCR4A = _BV(COM4C1)  // non-inverted PWM on ch. C
          | _BV(WGM41);  // mode 10: phase correct PWM, TOP = ICR4
    TCCR4B = _BV(WGM43)   
         | _BV(CS40);   // prescaler = 1
    ICR4   = 320;      // TOP = 320

    // Set the PWM pin as output.
    pinMode( 8, OUTPUT);
}

void loop()
{
    analogWrite25k(10);
    for (;;) ;  // infinite loop
}

I have connected pin 8 on the mega to the pwm input on the fan(blue wire) but I dont see any variation in fan speed and fan seems to run at full speed;

I dont really have any means or tools to verify if its really generating a 25khz pwm signal but fan speed is not changing or if its not generating a 25khz pwm signal because of which there is no change in the speed of fan;

I am stuck at this point and any help on this would he highly appreciated;

  • can you fan accepts such a high frequency PWM signal? – dandavis Sep 16 '17 at 20:30
  • yes, its a cpu fan used for intel cpus and the fan datasheet says the signal needs to be ideally 25KHz – techniche Sep 16 '17 at 20:35
  • you should be able to measure duty cycle with a DMM or even an LED; if it's getting adjusted, it would imply operation... – dandavis Sep 16 '17 at 20:43
  • i dont have a DMM, how can it be measured with an LED? and the fan speed should be noticeable ideally since I tried values as low as 5 and 10 for duty cycle and I dont see any variation in fan speed; – techniche Sep 16 '17 at 20:44
  • the LED gets dimmer at low duty-cycle values. make sure to (dramatically) limit current when testing. – dandavis Sep 16 '17 at 20:47
1

I've just tested your setting with older "Alpine 64 GT" CPU Fan and it works as expected. I've just added parsing integers sent from serial monitor, so I don't have to change code anymore.

void analogWrite25k(int value)
{
    OCR4C = value;
}

void setup()
{    
    TCCR4A = 0;
    TCCR4B = 0;
    TCNT4  = 0;

    // Mode 10: phase correct PWM with ICR4 as Top (= F_CPU/2/25000)
    // OC4C as Non-Inverted PWM output
    ICR4   = (F_CPU/25000)/2;
    OCR4C  = ICR4/2;                    // default: about 50:50
    TCCR4A = _BV(COM4C1) | _BV(WGM41);
    TCCR4B = _BV(WGM43) | _BV(CS40);

    Serial.begin(115200);

    // Set the PWM pin as output.
    pinMode( 8, OUTPUT);
}

void loop()
{
    int w = Serial.parseInt();
    if (w>0) {
      analogWrite25k(w);
      Serial.println(w);
    }
}
  • you have connected the pwm line of fan directly to pin 8 of mega right? or is there any additional circuitry? – techniche Sep 17 '17 at 8:59
  • amazon.in/Terabyte-CPU-Cooler-intel-LGA775/dp/B01BDOI9KE/… thats the fan I have; could it be that the fan has 4 wires but is not a pwm fan??? these fans are used as CPU fans so I thought they must definitely respond to pwm; any thoughts? – techniche Sep 17 '17 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.