Page 1 of 1

Is it possible to customise the duty cycle setting in this demo?

Posted: Tue Jun 17, 2025 8:57 pm
by canary_wharfe
Got the PWM working in Lorlin32 Lite at my target Fq. of 1Hz.
The thing is any PWM Set Duty Cycle macro I use appears to get over-ridden by the low level settings in the component PWM. In the current code I get a duty-cycle of 50% which I can live with but would have preferred to have custom control over the duty cycle e.g. 20/80 mark / space. Is there an easy way of doing this and still retain my 1Hz PWM Fq? TIA.

Re: Is it possible to customise the duty cycle setting in this demo?

Posted: Wed Jun 18, 2025 2:12 pm
by medelec35
Hello.
I have modified your project so PWM duty ranges from 0 to 100% when POT ranges 0 - 4095
The PWM duty is only set when the pot changes value.
If pot value is too unstable on ESP32, use the GetAverageInt function instead

Re: Is it possible to customise the duty cycle setting in this demo?

Posted: Wed Jun 18, 2025 11:05 pm
by canary_wharfe
Thanks Martin. That is a very elegant bit of code. Thanks also for introducing me to the maths map component. I have managed to pull out snippets of your demo and get the PWM duty cycle function working now. :-)

Re: Is it possible to customise the duty cycle setting in this demo?

Posted: Thu Jun 19, 2025 8:03 am
by medelec35
You're welcome, that's great!
I'm glad I have helped you to continue your project.