16 bit pwm

For general Flowcode discussion that does not belong in the other sections.
Post Reply
alanwms
Posts: 117
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

16 bit pwm

Post by alanwms »

Hello.
I notice the "note" in the pwm property macro that states "16 bit pics have a 16 bit period available"

The selections for changing the period are "set duty cycle" and "set duty cycle 10 bit"

How do I set a duty cycle 16 bit?
Ref PIC24FJ64GB002-I/SP

As an extra feedback - The notes only stay on long enough to read a few words. The note goes away after a fixed time period. Might be better to keep the note in play while the mouse is hovering over the subject?

medelec35
Matrix Staff
Posts: 1457
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 513 times
Been thanked: 473 times

Re: 16 bit pwm

Post by medelec35 »

Hi.
If you right-click on the PWM that's on the panel, then select help, you should see all the information within the Wiki.
alanwms wrote:
Thu Feb 17, 2022 7:40 pm
How do I set a duty cycle 16 bit?
You use SetDutyCycle10Bit.
It will allow 16bit as the period goes up to 65535, which is higher than the standard 10bit.
Martin

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: 16 bit pwm

Post by alanwms »

Thank you for the explanation - The help thing didn't run for me.

I'm attempting to get higher resolution from the PWM and notice that the rollover point value changes based on frequency. I thought that the input clock to this was derived from the system osc. But I change the clock speed and the roll over numbers don't change in the PWM.

Im fighting with:

I want higher frequency due to noise
I want higher resolution
I'm running RC osc at 8mhz.

Don't know if you have input for me?

medelec35
Matrix Staff
Posts: 1457
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 513 times
Been thanked: 473 times

Re: 16 bit pwm

Post by medelec35 »

The higher the clock frequency the higher you can have the PWM frequency with a greater resolution.
Is there a reason for such a low clock frequency?
As you increase the PWM frequency the maximum period decreases, which in turn decreases the resolution.
You will need to look at PWM Calculated period and that value is 100% duty.
As for the help, it should open a new Help and resources window within Flowcode.
Help Wiki for PWM.png
Help Wiki for PWM.png (140.32 KiB) Viewed 2183 times
Martin

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: 16 bit pwm

Post by alanwms »

Great Marin. Thanks.

Lower frequency is due to having no clock input. The help button for that doesn't work for me. But I can always go to the wiki and search.

I did think that the higher clock gives higher pwm freq with better resolution, but in the pwm properties box, things don't seem to change

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: 16 bit pwm

Post by alanwms »

I tested with a 20mhz clock input (crystal) got some good results. Thanks for your input Martin.

medelec35
Matrix Staff
Posts: 1457
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 513 times
Been thanked: 473 times

Re: 16 bit pwm

Post by medelec35 »

Hi
Your welcome.
The key thing to remember is the PWM duty can go from 0 = 0% to the maximum period register value = 100%
The exception being SetDuty10bit for non-16bit pics and the max will be 4 x period register.
For 16bit pic, if the period value is 65535 them 100% duty = 65535, 50% duty is 32767 etc.
As you increase the frequency the period register value decreases hence the lower resolution.
Martin

Post Reply