On Fri, 18 May 2001, David Cary wrote: > Have you heard about "Magic Sinewaves" ? It's a way of generating sine waves > from a 1 bit digital output, very similar to PWM, except that PWM has to use > *many* more edges to generate equivalent-quality sinewaves. Lancaster claims > that using fewer edges also reduces power transistor "switching loss". > > Don Lancaster's Magic Sinewave Library > http://www.tinaja.com/magsn01.html Yep, definitely heard about it. There ain't nothin' magic about it though. > Is there some connection between PWM, "magic sinewaves", and sigma-delta > converters ? In fact, there is. Take a look at: http://www.dattalo.com/technical/theory/sqwave.html In particular, the section titled: "011 Harmonic Content of a Periodic Pulse Train" discusses this very issue. Within this section are links to a couple of Octave (the GNU version of MATLAB) programs that assist in the synthesis and analysis of "magic sine waves". > > The only flaw I see with "Magic Sinewaves" is that it seems to work only with a > fixed number of samples/cycle. If I'm trying to generate several sinewaves > (DTMF), it looks like I'm forced to store a separate table for each possible > frequency (DTMF uses 8 frequencies), and output them independently on 2 > different pins. (With PWM, I can sum 2 analog values from a single table > (different offsets) and emit it from a single PWM output). Am I missing > something clever ? The difference between PWM synthesis of sine waves and harmonic cancellation techniques (like magic sine waves), is that the latter attempts to maximize the "carrier" frequency while the former attempts to minimize it. If you're controlling "things" that can't switch fast (say like large inverters) then you want to minimize the switching and would choose the magic sinewave approach. On the other hand, if you have a hardware PWM and just want to create a variable frequency tone, then you'd use the PWM technique. Another difference is that the PWM synthesis is flexible. It's conducive to dynamic algorithms (e.g. lookup tables). However, the pulse stream for a magic sinewave has to be pre-calculated - or I should say that generating optimum pulse streams is computationally expensive. Scott -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics