I'm working on a project with similar constraints (even uses 2200Hz as one of the tones). There are not very many ways to improve things. I am using an 6-bt R-2R DAC driven by six port pins. Since the DAC output only has small steps in it, the harmonic content is much lower and the rate and filtering are much less demanding. You can add a smoothing filter with more sections (poles). I am actually using a 6-pole switched-capacitor filter that is "tuned" according to an external clock (also provided by the micro). A good filter like this can do wonders. With such a small number of samples (points) per cycle, a simple 2-pole active filter just won't hack it. You can decrease the TOP value (that is, reduce the number of bits) so that the PWM period is shorter and you can get more of them in per tone cycle. With such few samples, it makes little sense to try for a full 8-bits. Every halving of TOP (from the standard value of 255) drops one resolution bit and doubles the repetion frequency of the PWM, doubling the number of samples per tone cycle. Use the fastest possible main clock (that is, highest frequency crystal). This will give you the fastest possible PWM clock and that will give the highest possible PWM repetition rate. Not many other choices than these! That is why I chose not to use PWM for this kind of application. Jim Wagner --------------------------------------------------------------- The Think Different Store http://www.thinkdifferentstore.com/ For All Your Mac Gear ---------------------------------------------------------------
Message
Re: [AVR-Chat] Generating sine waves with PWM
2005-12-05 by Jim Wagner
Attachments
- No local attachments were found for this message.