DAC

Custom PCB Boards Getting Started Tips Timing Pulse Generation Object Exchange FAQ Programming Examples

 

bullet

Another interesting application for the Propeller is 1-bit DAC (digital to analog conversion) using delta modulation.  This is made possible by the high clock speed.

bullet

1-bit delta modulation uses a single Prop pin connected to an external capacitor through an external resistor.  The duty cycle of the Prop pin is varied to set the voltage on the capacitor.  The external capacitor and resistor basically filter out the high frequency output of the Prop pin, leaving just the DC level.

bullet

The  Demo Board already has the resistor and capacitors for 2 channels of DAC for stereo audio.  There are a few programs in Object Exchange that generate audio using this method.

bullet

Here's  SPIN code for a stereo tone generator for the Demo Board.

bullet

Here's  SPIN code for a mono WAV file player .  You need an SD card for this one.... 

bullet

Here's another player for 8-bit WAVs.  You don't need an SD card for tiny clips.

bullet

Here's an assembly version that can play stereo, 16-bit PCM wav files up to 48 ksps

bullet

Note:  Wave players posted to OBEX.

bullet

Note:  There's a newer assembly version posted in the forum that uses a newer FSRW... 

bullet

You need to connect an RC filter the output of the DAC pin.

bullet

This gets rid of the high frequency modulation, leaving just the DC or low frequency component.

bullet

Here's a partial schematic of the demo board showing the 10k resistors and 10nF capacitors used as the output filter.   The 10uF capacitor then blocks the DC level and passes audio frequencies on to the MAX4411 headphone audio amplifier.

bullet

   

bullet
I could be wrong, but I think the cutoff frequency of this RC filter is too low...  I might try lowering the resistance...
bullet

If you don't have the demo board, but have powered speakers (or a computer or sound system with "Line In" input), all you need is a resistor and a capacitor to get sound. 

bullet
 I used a 1k-Ohm resistor and a 0.1 uF cap like this:
bullet
  
bullet
I tested this with both the "Line In" connection on my computer and with the audio input of the Parallax 2.5" LCD display and it works OK.
bullet
These are probably not ideal values (just what I had lying around).  One should probably add a DC blocking capacitor to keep DC off the audio output (like the demo circuit above has).