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

Use this section to discuss your embedded Flowcode projects.
Post Reply
canary_wharfe
Posts: 108
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 12 times

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

Post 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.
Attachments
Potentiometer_ESP.fcfx
(17.97 KiB) Downloaded 6 times

medelec35
Matrix Staff
Posts: 1988
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 630 times
Been thanked: 660 times

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

Post 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
Attachments
Potentiometer_ESP v2.fcfx
(19.6 KiB) Downloaded 8 times
Martin

canary_wharfe
Posts: 108
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 12 times

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

Post 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. :-)

medelec35
Matrix Staff
Posts: 1988
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 630 times
Been thanked: 660 times

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

Post by medelec35 »

You're welcome, that's great!
I'm glad I have helped you to continue your project.
Martin

Post Reply