Pages: [1]   Go Down
Author Topic: Using PWM DAC vs. R2R for sound synthesis  (Read 64 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm planning on building a synthesizer but I can't use R2R, which is the only DAC I've seen used on audio generation instructables, since it takes up so many pins. I've discovered PWM to analog which seems so much simpler but have never seen it be used in DIY arduino synths. Do you guys have any idea if it will work and if so what values do I need to use to have as little delay as possible while still being able to use a wide range of frequencies.

I've attached a quick schematic of the circuit I am talking about.


* PWM.png (10.93 KB, 618x291 - viewed 4 times.)
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 332
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I have used PWM before. Although not a requirement, it does help to have a low pass filter to make it act more like a DAC as you get a waveform that is not just a high frequency square wave. It does work and I have used it for audio synthesis. One advantage PWM has is that you can just write to an 8-bit register. Also 16-bit pwm is possible although I am not sure how well this would compare against a real 16-bit DAC. The reason why this matters as in the ability to simply write to an 8-bit register is that with r2r DAC you will need to shift the data so that only the pins with the resistors are affected. This means a performance increase. Also you could use a real DAC that uses the SPI protocol if PWM proves to be of less quality than desired although I have had no issues with quality. An SPI dac also has the advantage that you just need to write to an 8-bit register and the write does not stall the AVR in any way so you can calculate the next byte while the previous one is sending time your code so that the previous byte is really done sending. Even at very high samples rates this will not be a concern unless you starting doing around 1MHZ sample rate which would be hard to calculate synthesis at that rate.
Logged

Pages: [1]   Go Up
Jump to: