Help me select an option to generate 25 kHz PWM

Hi guys,

I'm running Mega with Marlin firmware (as my 3d printer controller) which to my understanding has its PWM set to 1 kHz.
I want to control a 4-wire fan (Pfc0612de) with PWM from 30% to 100% and to reduce noise I've decided to use the manufacturer's recommended 25 kHz (I won't need to read the tacho). I think I won't need to worry about phase and only need to control the duty cycle and frequency(?)

After searching I came up with a couple of options but I don't know which is easier or more plausible so here I am :grinning:

  1. change Mega's timer :
    I don't know If there are any unused timers by Marlin or not, and if there are, is it possible without affecting its other functionalities?

  2. using a standalone driver with 25 kHz output like MAX31790 (which I can't source, any alternatives?) :
    I'll have to send Marlin's fan control commands through I2c

  3. using PLL frequency multiplier from 1 to 25 kHz :
    3.1. 4046 with divide by 25 (2 MOD-5 7490) (0.3$ + 2x0.5$= 1.3$)
    3.2. lm565 with divide by 25 (2 MOD-5 7490) (4$ + 2x0.5$= 5$) (don't know if it's any better or not)
    I don't know if PLL preserves the duty cycle or not

  4. using another MCU (Attiny85 or ATmega328) to read the 1 kHz PWM and generate 25 kHz accordingly (4$) :
    with the same price as 3.2, I'll have unused pins for 2 more fans?

any help/guidance would be appreciated

My thinking …. Your link is to a brushless motor , which must therefore have a built in speed controller . The PWM input , I think is just to speed control it and therefore
PWM frequency may not affect it at all . The data sheet allows for a very wide range of PWM.( 30-300kHz)
I assume you have connected the motor to a suitable steady 12v DC supply ( say 2A min) and an Arduino PWM pin ( “analog output” ) to the pwm wire , with a common ground between the Arduino and motor supply.

I’ve never changed PWM frequency and someone may be along to help , or google it

hey hammy
thanks for the quick response
yes, it has built-in speed control, and I can run it with 1 kHz as it supports 30-300k Hz.
my main concern is the noise it'll make so I wanted to use the recommended 25 kHz
and those options are the ones I came up with after googling it :grinning:

It's pretty easy to adjust PWM frequency, Just need to determine the type of PWM needed and work through the steps.
Here is an excellent guide: Secrets of Arduino PWM

You don't need change the timer, you only should change the prescaler.
For example, for Timer1 on Mega you should add to the setup() this line:

TCCR1B = (TCCR1B & 0b11111000) | 0b00000001;

After that you can use analogWrite() in it usual way, but the PWM on pins 11 & 12 will run in 31.4 KHz

won't it affect Marlin firmware's functionality?

won't it affect other parts of the code using timer1?

of course yes, if others parts of your code are sensible to timer frequency change. But you always can choose another timer.

that was part of the question :grinning:

I need to achieve this without making fundamental changes to the code and its functionality as a 3d printer controller, that's why most of the options I came up with, are hardware.
of course, I'd prefer option 1 if it's possible as it has no additional cost, but ...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.