Page 1 of 1

Help with Fast PWM

Posted: 28 May 2020 22:24
by matst
Hi

Received my z-uno today and are trying to control a fan that has pwm speed regulation. It need 25khz pwm.

I guess the best approach would be Fast PWM?
Does anyone have an example with comments? I have some trouble understanding zunoFastPWMSet

Br
Mats

Re: Help with Fast PWM

Posted: 29 May 2020 00:23
by matst
Based on the reference i expected the below code to give 50% at 25khz, but the fan does not behave as it should. I don't have an oscillometer.
4mhz / 25khz = 160

Code: Select all

pinMode(PWM3, OUTPUT);

zunoFastPWMInit(0);       // 0 for 4 MHz (tick is 0.25 μs) and ZUNO_GPT_SCALE1024 for 31.25 kHz (tick is 32 μs)
zunoFastPWMSet(80, 80); // Low and high level time in timer ticks.
zunoFastPWMEnable(1);     // Start
The fan runs fine on a Arduino (with modified PWM frequency)

Re: Help with Fast PWM

Posted: 29 May 2020 22:15
by PoltoS
Please note that FastPWM is on PWM0 pin.

Re: Help with Fast PWM

Posted: 04 Jun 2020 21:06
by matst
That solved my issue. Thanks!