> > Google on "magic sine waves" and then let your jaw flop to the > > ground. This is sort of what you are proposing. > > Actually, Koen's proposal looked like straight PWM; I'm sure the > PICLIST archives contain numerous examples of PWM sine-wave > generation using a quarter-period lookup table. Lancaster's > "magic sine waves" are different in that they cancel harmonics. Lancaster's magic sine waves aren't magic and they aren't Lancaster's, but he has publicised them well enough that he deserves some mileage from the concept. A MSW with a given number of transitions is the minimum error PWM approximation that you can achieve to a perfect sine wave. I'm told (and haven't yet tried it)(but intend to) that you get the same sequences by setting a predefined error limit, setting your output to zero, summing the accumulated error wrt to a sine wave with respect to time and then flipping the output every time the error reaches the limit. Someone may wish to try this. The mean error overall will be less than the error limit that you use to toggle the output. RM -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads