…a sinewave generator using PWM

by Stephen Hobley on February 9, 2011

Post image for …a sinewave generator using PWM

I was reading up on filter design when I came across an article on the Lab3 site….

The results were impressive, using just Pulse Width Modulation generate an accurate 8-bit sine wave. The key is a good low pass filter – most of the time I’ve been using as RC filter, but this uses a Chebyshef low pass with a cutoff at 12 kHz. This one was built using some parts salvaged from an old TV.

These images show the PWM output along with the filtered sine wave – easier than using a dedicated DAC.

Another neat trick I learned from Lab3 was to set a pin high during the interrupt handler routine – then you scope the pin while it’s running and see exactly how much CPU is being consumed.

This is interesting, as it makes it possible to (cheaply) implement something I’ve been thinking about building for a while…

More to come on this.

Share

{ 3 comments… read them below or add one }

Michael February 10, 2011 at 12:09 am

Nice! That could come in handy… curious to know what the %THD / harmonics look like on the signal… ie, could I use this for audio THD measurement instead of the ancient sine wave generators I’ve got now?

Michael

How to make a Tesla Coil December 7, 2011 at 1:28 am

Nice job!! Who would think that a pwm can be use in sinewave generator. It looks really amazing, thanks for posting it.

shrinidhi June 11, 2012 at 12:59 am

How to generate the sine wave from PWM wave..and give me the details regarding the sinetable values..is ther any formula for computing a values in the sine table..plz help me out regarding this….

Leave a Comment

Comments links could be nofollow free.

Previous post:

Next post: