Considering the sine wave PWM generated, I wonder about the totally unpredictable harmonics from the combination of several different pulse width along the stream. Square waves are terrible to deal to avoid harmonics, except when you know exactly the fundamental fo's and the harmonics composition, otherwise, as a sine wave generator with variable frequency, it is a real pain. The most comprehensible approach to avoid them is using PWM cycles in the order of several MHz with prime numbers as the base for level control, so they will not repeat or cause alliasing. Of course, a high "Q" active filter would be the best solution to avoid harmonics, but again, or the fo is fixed or the active filter is programmable too, what increase the cost. In this case, the D/A solution (16 bits at least) turns to be much more economically attractive. There is another technique that I call "Rolling Triangles" (nothing to do with Rolling Stones...:), that is; A triangle face is flat, as flat is a digital signal, or a linear ramp generated by a constant current circuit. Rolling a Triangle, means that your program would set the triangle face angle according to the sine value, or signal rotational angle, and this is done by controlling charging current. Suppose you slice a 90¡ angle in 90 triangles, equally distributed in rotation, 1¡ per triangle, you would have the first quadrant of your sine-wave. To reduce the abrupt angle change between one triangle and another, several other small triangles are inserted at the transition, you can think as interpolation. I use to say that the biggest mistake people do when looking at a sine wave, is thinking about sine(x) functions, because it is related to a flat point of view of who is laid on the floor. According to the wheel point of view, it is just a plain and pure rotation, so the triangle explanation makes effect. The interaction of those triangles with a common panel (the floor, and the witness eyesight) we are able to see only a bi-plane sinewave, when other polarization in different dimensions are not allowed, as the magnetic and electric fields modulating a base electrical signal. It wouldn't be nice to be able to see this multidimensional sine wave interacting with several other signals? I first used the expression "Rolling Triangles" when produced a 3 phase 60Hz sine-wave, based on programmable constant current generators, and high speed processors integrating more than 50 thousands small triangles per cycle. I was never able to do it with PWM, even with oscillators close to MHz. Later on I found out that changing the 60¡ angle of each triangle vertice and connect thousands in a net style, it was possible to draw and plot practically *any* 3 dimensional electrical surface representation. Isn't interesting how many different ways you can do the same thing? I use to say that there are several ways to skin a cat, you can really be a winner if you end up with very few scratches... Wagner. Scott Dattalo wrote: [some snip below] > In addition, if you can use harmonic cancellation, then the constraints on > the analog filter may be relaxed. PWM generated waveforms relax the filter > constraints by maximizing the switching frequency. If the PWM carrier is > 100 times the sinewave you're trying to generate, then you're analog > filter is much easier to design. There aren't any harmonics (to an > approximation) between the sine wave frequency you're generating and the > carrier frequency of the PWM. > > Magic sine waves explicitly remove these harmonics by strategically > placing the pulses (or edges). The pulses, when viewed individually, > contain harmonics at the fundamental (of the sine wave being generated) > and at all integer multiples above. But when the pulses are taken > together, the 2nd, 3rd and so on harmonics are cancelled. The number of > harmonics cancelled depends on the quantization of time for the edges. For > example, in the previous post, I had a graph of a 12-bit pulse stream > 010110100000. The second and third harmonics were exactly cancelled, but > there is a 4th and 5th harmonic present. Doubling the number of pulses to > 24 allows a pulse stream to be created that will cancel the 4th harmonic. > In general, if you have a pulse stream containing n! pulses, then it's > possible to exactly cancel the first n harmonics. However, n! grows rather > quickly. It's simply not practical to attempt to cancel the first 10 > harmonics (after the fundamental) by creating a pulse stream containing > 10! or 3,628,800 pulses. > > Consequently, if you wish to cancel the first 10 harmonics but with a > pulse stream containing only a 1000 pulses, you're not going to achieve > your goal. However, you may discover a particular stream that exactly > cancels the 2nd, 3rd, and 4th, and attenuates the 5th through 10th > harmonics by 20dB. From that you may design an appropriate analog filter.