[sdiy] PWM or DAC better for audio out?

Noah Vawter nvawter at media.mit.edu
Thu Jun 2 19:51:04 CEST 2011


On Jun 2, 2011, at 12:54 PM, Olivier Gillet wrote:
> Which brings me to another thing that is not cool with PWM : you need
> to double the modulation frequency for every bit of resolution you
> add. To get 16-bits, 44.1kHz audio with naive PWM, you would have to
> work at close to 3 GHz. To get good resolutions, try sigma-delta
> modulation instead...

yup, in the popular AVR platforms (arduino, etc.), clock freq of 20 MHz
so one can make a table of max pwm freq vs. bits.  eg.

sample rate Fs = Fc/2^b  where Fc=20 MHz, and b = # of bits, e.g. 8-16

for(b=8;b<17;b++)
r/2^b
78125.00000000000000000000
39062.50000000000000000000
19531.25000000000000000000
9765.62500000000000000000
4882.81250000000000000000
2441.40625000000000000000
1220.70312500000000000000
610.35156250000000000000
305.17578125000000000000

so as you can see, 8-bits makes Fs=78kHz, which is great, really.
but 9 bit quickly drops to 39KHz, which is audio range
then 10-bit makes Fs~=20kHz, so, sub audio range.
and it just gets worse from there.
16-bit PWM @ 20MHz, only results in 305 Hz!  or 150 max freq!!!

If you really know what you are doing, you can run 8-bits at 78KHz,  
and use a multiple-order sigma-delta DAC in *software* and perhaps get  
1-3 extra bits out of it.   I have turned 12-bit codecs into 16 this  
way.




>
> Olivier
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy




More information about the Synth-diy mailing list