fan PWM frequency


I have these fans for print cooling: XYJ24B3010H from XINYUJIE electronics, but they refuse to turn on any other setting than 100% (M106 S255).
Other type of fans on the same connection can be modulated. The board output voltage is OK, for example M106 S128 gives 13V and M106 S255 gives 24V.

In the configuration.h file setting PDM instead of PWM reduces fan power, but still only works at 100%.

The fan supplier does not react to my request for info.

Changing to another type of fan is not preferred, so I'm looking for a way to control the PWM speed in Repetier. Maybe changing the frequency could help.


  • Frequency is only 16hz. You need to use simple cheap fans with only power to have them work. 3 pin fans want a high pwm frequency on 3rd pin i think. Also many fans only woek over x% and stand still on less power.
  • Well, that's a nice problem if I want to keep using 24V and decent quality fans.

    Is there any other way, with a extension board maybe?

    By the way, my fans are of the 2-pin type.
  • edited March 2017
    simplest way is to add capacitor parallel to fan. around 2 to 10 microFarads should be ok.
    take care on polarity!
    had same problem with some small fans.
  • Ah! We were thinking the same way, but had not calculated a value yet. Thanks.
  • edited March 2017
    btw, the fans i have dont even start  at 50% pulse width and 900 Hz PWM frequency. so adding the cap is nothing else than
    building a kind of step down converter.

  • My fans are 24V 0,08W, and yours? How to calculate the desired capacity?
  • Excuse me, 0,08A that should be.
  • Repetier said:
    Frequency is only 16hz. You need to use simple cheap fans with only power to have them work. 3 pin fans want a high pwm frequency on 3rd pin i think. Also many fans only woek over x% and stand still on less power.
    But seriously, I'm doing a €30.000 project. Is it actually impossible to change to higher frequencies, or is it just not implemented?
  • edited March 2017
    i just tried ;-)  and as far as i know higher pwm is not possible. which hardware do you use?
    from my experience problem appears mostly on brushless fans, depending on their internal electronics.
    they cannot handle pwm on small pulsewidth.
    And as repetier already mentioned, cheap fans work best
  • It would be a shame to use cheap fans. How can I explain customers to bare with noise?

    But I'll be experimenting tomorrow with higher PWM and some capacitors.

    Other option is to use a resistor and 12V fans. Freaks me out but I need a solution.
  • With Sunon fans 12V in series same effect.

    How do I get out of this mess?
  • are you shure you use pwm capable pin? what hardware do you use?
  • I have the RADDS 1.5 board with Arduino Due.
  • A colleague wrote me some alternative lines in the commands.cpp file:

    From ine 1777:

            case 106: // M106 Fan On
                if(!(Printer::flag2 & PRINTER_FLAG2_IGNORE_M106_COMMAND)) {
                    if(com->hasP() && com->P == 1)
    //                   setFan2Speed(com->hasS() ? com->S : 255);
                        analogWrite(9, com->hasS() ? com->S : 255);
    //                    setFanSpeed(com->hasS() ? com->S : 255);
                        analogWrite(8, com->hasS() ? com->S : 255);
            case 107: // M107 Fan Off
                if(com->hasP() && com->P == 1)
  • did that solve the problem?
  • Thatonly works on very few boards and pins, You should better put that in setFanSpeed and setFan2Speed since these are also called from other functions!
  • No, did not solve anything. And yes it's crappy code, will remove it.
  • But still, the fan problem is there. I might need to design an extra analog output board. Quite annoyed to be honest.
  • Use Marlin! 
  • Unless you really need to Repeat, use Marlin! With Malin it is very simple to increase the PWM frequency. I use 3Khz. This limitation of PWM on Repetier is simply ridiculous.
  • Hmm, but Marlin is not stable on RADDS. Problem.
  • Add
    #define COOLER_PWM_SPEED 2

    to get 4 times the frequency in repetier. Same trick as on marlin if marlin is using software PWM. Marlin also supports hardware pwm only on special board/pin combinations.
  • 4*16Hz=64Hz no chance. 
  • Hey guys, today i connected a Air Pressure Pump to the Ramps Board for Cooling. Like this one:

    But after turning it on, i was shocked. From S50 to 230 the pump is "pulsing" and shakeing. I was clear the PWM frequence is bad, because i can see the LED flashing with the eye.

    Now i was looking how to increase the frequency and sadly only found this thread...

    Guys, PLEASE add some code to change the frequency soon. PLEASE!
  • edited April 2017
    as a pump is working against pressure it stops immediate when pwm pulse is gone.
    to get this running in a smooth way you´ll need pwm frequency in high kHz Range.
    that´s not possible on AVR as far as i know.
    (if Fans are started via Kickstart they keep moving caused by mass of propeller what´s totally different to your pump problem).

    i did a couple of tests with external pwm controllers and "problematic" fans so result for a smooth running
    i needed 20Khz ( i used TLC59711 controller from Adafruit ).
    May be that could work for your pump also, i don´t know.

    best solution from my point of view would be a pwm-controlled DC-DC converter.

  • edited April 2017
    I dont think i need khz, because the motor is big and has some inertia.
    The pump itself is small and produces 0,5bar. Not so much to fight against.

    200-500Hz would be nice...
    Why is that not possible?
    The Hotend Heater PWM can provide 122Hz. It's just a code thing. I see no hardware limit for 200Hz
  • Every doubling of frequency means only 50% of resolution. The higher frequencies were introduced to reduce flickering effects for led lights. Same code is used for fans. Main problem is that higher frequencies take more time in cpu so we can not print as fast as before if we increase this without resolution reduction. And since we already use more then 10 PWM outpins on some printers it is not possible to this all in hardware PWM.
  • edited April 2017
    Okay, but what is the problem to increase the fan frequency to, let me say, 256Hz with much less resolution? The resolution should not be a problem for fans or DC motor pumps, is it?

    I also had problems with LED flickering when my hotend was running at 15Hz. After increasing to 122Hz it was gone, and i have not seen any negative effects. (What do you expect to be negative at 122HZ and a Resolution of 32)

    I believe that kHz is not possible, but maybe 200-300Hz would help @venkel also?
  • It is no problem. In fact I have checked the code and max. was even 61Hz and not 122. Have updated dev version to now allow 244Hz and also added a setting for fan pwm to config tool directly below heater pwm speed. Hope that will do now.
Sign In or Register to comment.