Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Generating sine waves with PWM

2005-12-05 by James Washer

I'm just starting to play around with sine waves using PWM and a lookup table. 

I'm concerned as to the maximum frequency of a sine that can be generated. Walking through an example, based on Fast PWM.

Xtal=9830400Hz
8bit Fast PWM
This gives PWM frequency of (9830400/256) 19200Hz.

So, if I wanted to generate a sine wave at 2200Hz, I'd only be changing the pulse width ~9 times per cycle. This seems completely inadequate.

As this is my first attempt at sine wave generation, I have a couple of questions

1) Does the math above seem correct, or am I mistaken in my limited understanding of using PWM

2) Assuming my math is correct, then there must be one rule-of-thumb for how how a frequency one can generate using fast-pwm for a given Xtal frequency. What is the rule?

3) Anything else you'd care to add/offer?

thanks

 - jim

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.