Pwm set frequency and duty cycle in Arduino or similar board.
-
- Posts: 116
- http://meble-kuchenne.info.pl
- Joined: Tue Dec 08, 2020 4:36 am
- Has thanked: 2 times
- Been thanked: 2 times
Pwm set frequency and duty cycle in Arduino or similar board.
How can I create a PWM with variable frequency from 1hz to 200hz for example and within each cycle have a duty cycle from 1 to 99%? There is a similar card on Amazon that once the pwm is set in hz or khz also makes the pwm adjust from 1 to 99%. Can it be done with an Arduino uno or Mega 256 or an Esp 32 wroom? If so, can you give me an example in flowcode 9 or a video on YouTube? Thanks a lot Alessandro.
-
- Matrix Staff
- Posts: 1882
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 484 times
- Been thanked: 661 times
Re: Pwm set frequency and duty cycle in Arduino or similar board.
Hello,
I don't think the PWM on the Arduino can be made to run as slow as 1Hz and you might find that it's difficult to get that sort of range using hardware PWM.
Have you considered using software PWM using a timer interrupt? That might be a bit more flexible and provide more options.
There is an example of software PWM here but please let us know what you think and how you're getting on if you give this a go.
https://www.flowcode.co.uk/wiki/index.p ... ftware_PWM
I don't think the PWM on the Arduino can be made to run as slow as 1Hz and you might find that it's difficult to get that sort of range using hardware PWM.
Have you considered using software PWM using a timer interrupt? That might be a bit more flexible and provide more options.
There is an example of software PWM here but please let us know what you think and how you're getting on if you give this a go.
https://www.flowcode.co.uk/wiki/index.p ... ftware_PWM
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel