EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

PWM Resolution

Started by Cap'n Ahab August 23, 2006
I have been experimenting with PWM on a PIC 16F877A.  Initially, I used
an example program that came with my development board & tweeking the
values to see what effect they had on the trace of my oscilloscope.

Having done that, I am now attempting to get a waveform to my
specifications.  I am having a little difficulty in understanding the
Microchip datasheets (or maybe it is just general ignorance!).  I just
cannot fathom out what is meant by PWM Resolution.

I am a novice to electronics, but I understand that, say, a 10-bit A/D
converter would give you a reading of 0-1023 or an 8-bit one a reading
between 0-255, but the datasheet gives a formula to work out the
*Maximum PWM Resolution* in bits.  I don't fully understand why that is
a variable.

ATM, I am guessing that the higher the frequency of the PWM the less
resolution you have available to specify the duty cycle. So with a low
frequency PWM, you could have 10-bits of resolution i.e. the duty cycle
could be 1/1024 of the period.  A much higher frequency, may only allow
you to have 3-bit resolution i.e. 1/8 of the period.

Am I on the right track?


Thx in advance,

Cap'n Ahab

Cap'n Ahab <space.invader@lycos.com> wrote:

> ATM, I am guessing that the higher the frequency of the PWM the less > resolution you have available to specify the duty cycle.
Exactly. If you want to specify the duty ratio to a resolution of n bits, the sum of the low-time and high-time counts is 2^n. That makes the frequency of your PWM signal: f_pwm = f_clk / 2^n because it takes 2^n cycles of the input clock to complete on repetition of the PWM signal. So: the more bits of resolution you want, the lower the frequency of the PWM signal will be. Or, if the PWM signal frequency and the maximum clock frequency is determined by hardware concerns, the best you can possibly do in terms of duty ratio resolution is n = log_2(f_clk / f_pwm) bits. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.

The 2024 Embedded Online Conference