Bloody fascinating Scott... ...killed an hour and a half on that one page and I still don't really have it, although I've got a sort of an "almost there" sort of buzz... ...could be just brain cells burning out... ...now where did I put those aspirin... If I got all that correctly, in practical terms, "Magic" sinewaves are better when you are switching lots of power (like a motor driver or power amp) and PWM is better when power efficiency is less important but you DO need: A) lower uP clock speed and code complexity or B) higher output frequencies or C) more even variations in amplitude such as when you need D) summation of multiple frequencies to one output (digital mixing). Is that right? Has anyone made a motor driver that uses "Magic" sinewaves? --- James Newton (PICList Admin #3) mailto:jamesnewton@piclist.com 1-619-652-0593 PIC/PICList FAQ: http://www.piclist.com or .org -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Scott Dattalo Sent: Friday, May 18, 2001 08:42 To: PICLIST@MITVMA.MIT.EDU Subject: Re: [EE]: Square Wave Pulse Converted to Sine Wave Pulse 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 -- 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