Monday, February 7, 2011

Review of Arduino DAC solutions

I was in a need of an analog output output for my Arduino, and I found quite many different digital-to-analog converter (DAC) solutions by googling around. So finally I decided to gather them on one page as a reminder for myself and a guide for others. So here it comes!


R-2R ladder DAC

The most common way to build a DAC is to use a R-2R ladder circuit. Make: Online has a photo-guide for building one. However, this DAC has no output buffer, which would make this circuit a bit more reliable and working with all kinds of loads.

MAKE: Online's DAC shield

Make: Online - Proto-DAC shield for Arduino
A Direct digital synthesizer build using a R-2R ladder DAC - This is worth a look if you're interested in outputting audio.


R-2R ladder DAC with output buffer

For the best results, you should use an output buffer in the DAC. The buffer separates your R-2R ladder from the load you connect it to and makes the result non load dependent. Here's maybe the best tutorial I've seen for a R-2R DAC with an output buffer. It uses a common LM358 operational amplifier that can be driven from single supply. Note that in order to get the full output range to work with this circuit, you need to have a higher than 5V supply for the LM358. Of course, another way to get around this problem is to use a 5V supply but put a simple voltage divider in front of the op amp. Then you'll get lower than 5V output but don't lose fidelity.


Ikalogic's R-2R DAC with an output buffer.

Ikalogic's very good page on R-2R DACs



The 2 cent DAC by raalst



A very clever solution utilizing the integrated pullup resistors on the Atmega chip. You need only 1 resistor and as many output pins as you want bits. The output is a bit crude but 500kHz could be reached. The internal pullups are specified to be minimum 20kohms and maximum 50kohms so the result might not be the most accurate.

Arduino Forum - The 2ct DAC


Simple 10-bit DAC by avdweb



This design uses only two output pins, and the circuit is fairly simple, utilizing an op amp. The max settling time is 20ms, which is way too low for audio output. But the settling time could be enhanced with a circuit modification...

Arduino Forum - Simple 10-bit DAC
avdweb - Simple 10-bit DAC



Using the PWM as a DAC

Of course, you can also use the PWM outputs to get an analog output signal from the Arduino. Just put a low pass filter after the PWM output to get a nice & smooth output with a frequency range up to 16kHz, according to this Lab3 experiment.

A direct digital synthesizer realized with Arduino's PWM output.

Lab3 - Arduino DDS using PWM



Resistor/PWM hybrid DAC



This is a good explanation on how to combine two PWM outputs in order to double the bit resolution. So combining two 8-bit arduino PWM outputs you can get a 16-bit PWM output! Remember Arduino's limits if you plan on going down this road. I mean, the Atmega chip is just 8-bit...

http://www.k9spud.com/traxmod/pwmdac.php
Link doesn't work? Try this one via the Wayback Machine



SPI-interfacing two Microchip MPC4921 DAC chips with Arduino

Stepan Schulz used SPI to interface two MPC4921 12-bit DAC chips. This saves you pins compared to the R-2R ladder. Using the onboard SPI of the Arduino like Stepan, you need 5 pins, but you can save one (maybe even two) if you code the SPI code by hand.

Stepan's post on the Arduino forum
See the code here
MPC4921 datasheet


Audio shield with MCP4921 DAC



Adafruit industries' Wave shield is an audio shield for Arduino that also uses the MCP4921 SPI DAC chip. You can play back 12-bit 22kHz wav files. This means the maximum output frequency is 11kHz.

Adafruit Industries - Wave shield


Midivox - synthesizer shield with the MCP4921

Another shield that uses the MCP4921 DAC chip. This one's quite cool, it's a monophonic synthesizer with MIDI input and the synth engine has an attack / release generator and a cool filter! Proves that the Arduino can be used to generate synth sounds.

Narbotic instruments - Midivox - A synth shield featuring the MPC4921.


DAC using AD420 16-bit serial-input DAC

Shaduzlabs.com has a good article for using the AD420 with Arduino. There's schematics, pictures and a code example.

Shaduzlabz.com - High-accuracy 16-bit DAC for Arduino
AD470 datasheet


That's it for now. Thanks for reading! Please comment, if you have anything to add!

[Edit: randy pointed out this site with some hints for Arduino audio DAC solutions. Thanks!]

13 comments:

  1. Cool! I've been playing around w/ the AD5330, but this provides some handy alternatives.

    ReplyDelete
  2. Have you looked at this article?

    http://www.uchobby.com/index.php/2008/01/08/arduino-audio-dac-options/

    ReplyDelete
  3. Nice post! I was currently looking for DAC solutions for my Arduino for a project I was working on and spotted a post on twitter sending me here. Lots of good info.

    ReplyDelete
  4. I got flashback from the end of 90nties when circutboards with the resistors where connected to the paralel port to give the PC a 8 bit sound output.

    ReplyDelete
  5. Very helpful information, THANKS! I'm interested in the Resistor/PWM hybrid DAC, but the URL to the article is no longer accessible. Do you have a copy or another URL you can post?

    ReplyDelete
  6. Thanks for notifying me on the dead link issue! I put a link to wayback machine under it.

    ReplyDelete
  7. I know this is really old but check out this awesome tutorial on the PWM method; http://www.youtube.com/watch?v=YaRDbw38x7Q

    ReplyDelete
  8. I tried the Resistor/PWM hybrid DAC method. I didn't really think about it, but I got unstable voltages. I checked it out, and raising the PWM outputs gradually I saw a saw-tooth output! Rethinking this idea cannotg work, because when you add a low voltage to an higher one, you will always end up with a voltage in between! So forget it!

    ReplyDelete
  9. The resistor/PWM hybrid DAC should work fine. You just have to use a lowpass filter!

    Also the control of the two PWM outputs is crucial - you need clever code to output that 16bit value...

    ReplyDelete
  10. OK. I tried resistor/PWM hybrid DAC once again, since everywhere I found that you can add voltages using a summing opamp circuit - though I don't understand how you can add voltages that come from the same source... The problem was that used resistors in my voltage divider of 470 Ohm and 120 kOhm, giving that saw-tooth output. Using 1 kOhm and 270 kOhm I got an irregular line that went up, but without the dowmhill periods. Using 3,9k Ohm and 1 MOhm the line went up completely smooth. My lowpass filter is a capacitor of 100uF. Sorry for my misunderstanding...

    ReplyDelete
  11. Great resource. Thank you for taking the time to put this together.

    ReplyDelete
  12. Nice list. but hardly the DAC's I would like to use as an Audiophile DAC.

    ReplyDelete
  13. I'm building a Goldilocks Analogue with a dual channel MCP4822 DAC.

    http://feilipu.me/?s=Goldilocks+Analogue

    Testing on the most recent iteration looks good.

    ReplyDelete