avr-gcc-list
[Top][All Lists]

## Re: [avr-gcc-list] ATmega16 PWM

 From: Joerg Wunsch Subject: Re: [avr-gcc-list] ATmega16 PWM Date: Mon, 16 Jul 2007 07:15:04 +0200 (MET DST)

```"Thomas D. Dean" <address@hidden> wrote:

>   What is the PWM frequency vs the modulation frequency?

The PWM frequency is the frequency the pulse train runs with:

U
^   ++      ++     +--+    +--+   +----+  +----+
|   ||      ||     |  |    |  |   |    |  |    |
|   ||      ||     |  |    |  |   |    |  |    |
|   ||      ||     |  |    |  |   |    |  |    |
+---++------++-----+--+----+--+---+----+--+----+-> t
|<- T ->|

f = 1 / T

The above is a sample PWM signal with three different PWM levels, the
corresponding modulation signal would look like:

U
^
|                               ----------------
|              ----------------/
|-------------/
+------------------------------------------------> t

Now, if you don't simply ramp the modulation signal up but have it
repeat with its own frequency, that would be the modulation frequency.

>   How many samples do I need of the modulation wave to produce a
>   satisfactory PWM?

If you want to reconstruct the modulation signal afterwards, the
Nyquist or Shannon theorem is your limit: the sampling (PWM) frequency
must be more than twice the highest modulation frequency.  The closer
your ratio between both is, the harder it becomes to create the
high switching frequency of the PWM, making both frequencies at least
1:10 is a good idea as it allows for simpler filters.  With 1:10, a
simple 2-pole filter (20 dB / decade slope) will give you 20 dB
suppression of the PWM frequency.  If both frequencies are spaced
1:20, the same filter will already suppress the PWM frequency by 40
dB.

--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

```