cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

Hi,

i want to generate pwm  for diffrent %of duty cycle.

I know the formula of dutycycle is 

                      dutycycle=100 x compare value/period.

But this formula is giving wrong results in som ecases.

For example.

    i want to generate a dutycycle of 50%  ,

then my settings are   compare value=1,set period=2ms ,input fequency is 1000HZ .According to the formula it has to give  50% duty cycle.

But in the configuration window it shows the wavesorm of 70% .

so,please help me to resolve the issue

Thanks in advance.

0 Likes
Reply
1 Solution
Esteemed Contributor II

You wrote

                      dutycycle=100 x compare value/period.

this is not quite correct

                      dutycycle=100 x compare value/period value

is better.

So the period value should be set to 19 (giving a period of 20 pulses) the input clock to 10kHz and the compare value to 10.

Always leave some room for adjustings, you could have choosen as well

Period value = 199, input clock 100kHz, compare value = 100.

This settings would allow for a 1% resolution setting of the duty cycle.

Bob

View solution in original post

0 Likes
Reply
1 Reply
Esteemed Contributor II

You wrote

                      dutycycle=100 x compare value/period.

this is not quite correct

                      dutycycle=100 x compare value/period value

is better.

So the period value should be set to 19 (giving a period of 20 pulses) the input clock to 10kHz and the compare value to 10.

Always leave some room for adjustings, you could have choosen as well

Period value = 199, input clock 100kHz, compare value = 100.

This settings would allow for a 1% resolution setting of the duty cycle.

Bob

View solution in original post

0 Likes
Reply