Go Down

Topic: Adjusting resolution of duty cycle for higher PWM frequencies (Read 1 time) previous topic - next topic



So I was looking for how to change the PWM frequencies on the Arduino Mega 2560 and I came across this useful page: http://sobisource.com/?p=195
Now I want to know what will happen to the resolution of duty cycle at let say 31250 Hz? with what precision can I adjust the duty cycle?



Using the default value for any frequency will give you the full 8 bit resolution. However, if you up the comparator value to get an exact frequency then there are less steps between zero and that value. Worst case you will get no PWM capability.

For example if you set OCR2A to be 51 to give a frequency of 38.4KHz, then OCR2B can only take on a value between one and 50. So in this case you an only get 49 different values of duty cycle.


Thanks for the reply
But what do you mean about the default values? Do you mean these:
0×01                                  1                                31250 hz
0×02                                  8                                3926.25 hz
0×03                                 32                             976.5625 hz
0×04                                 64                             488.28125 hz
0×05                                 128                           244.140625 hz

If I set the frequency to 31250 Hz, do I have 256 resolution in duty cycle?



But what do you mean about the default values? Do you mean these:

Yes, set the pre divider to any of these to get the full 255 resolution on the PWM.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131