Page 1 of 1

Generate digital PWM (Duty Cycle control)

Posted: 20 May 2018 22:23
by janjoh
WHat is the best way to generate a digital PWM signal? Purpose is control of PWM controlled fan.

I understand that timers/servo library appears buggy right now?

Re: Generate digital PWM (Duty Cycle control)

Posted: 23 May 2018 00:07
by PoltoS
You can use GPT and Servo (they are no buggy), but much easier is to use analogWrite to drive one of the four PWM pins

Re: Generate digital PWM (Duty Cycle control)

Posted: 23 May 2018 08:34
by janjoh
PoltoS wrote:
23 May 2018 00:07
You can use GPT and Servo (they are no buggy), but much easier is to use analogWrite to drive one of the four PWM pins
Analogwrite does not work for me with these fans. They require a true "return to zero" signal and i have not been able to find a way to decrease the pwm frequency properly to acheive this. AnalogWrite for all intents and purposes generates an analog level, not a discernable duty cycle. IN most applications this is a plus. But in this case, it is a minus :)

Re: Generate digital PWM (Duty Cycle control)

Posted: 23 May 2018 20:34
by PoltoS
analogWrite generates real return to zero, but at 488 Hz. If the input capacity is to big, your signal will become smoother like real analog.

For your case use FastPins and delays

Re: Generate digital PWM (Duty Cycle control)

Posted: 26 May 2018 13:37
by janjoh
Hm, i wonder what would happen with an external pulldown resistor...