Tags
hardware arduino schematics MIDI dac 

 
High-accuracy 16 bit DAC for Arduino

August, 02th 2009
Analog Devices AD420 serial input 16bit DAC
A 16 bit DAC solution for your Arduino! The schematic is very simple, it's just the DAC (Analog Devices AD420), a few capacitors and an operational amplifier used as voltage follower in order to provide some buffering to the DAC output. The DAC is not very cheap (around 15-18$!) but it allows to obtain a good resolution in order to satisfy all your accuracy needs... I've built the circuit using a smd-to-dil pcb adapter, but the DAC is also available in a breadboard-friendly PDIP package.

The AD420 needs a power supply of 12V to 32 V, and, since Arduino is equipped with a voltage regulator, I'm using a single 13.6 V power supply connected both to DAC board and Arduino V-in pin. You can use any op-amp to buffer your DAC output, but you have to check that it can be powered with at least 12V (the LM358N I've used accepts a power supply ranging from 3V up to 32V). The accuracy can be improved further by using some more external circuitry such as a precision voltage reference, this project is just a "basic" usage of the AD420!
Below you will find the source code I've used to test the DAC board.

The schematic also includes a voltage regulator, in the current prototype I'm not using it but if you want to use a power supply greather than 14V i would suggest it (otherwise just remove IC3, C5 and C6 from the schematic).
AD420 Serial Input 16bit DAC example
  1. /*---------------------------------------------------------*/
  2. /*   AD420 Serial Input 16bit DAC example                  */
  3. /*   Vincenzo Pacella - www.shaduzlabs.com                 */
  4. /*---------------------------------------------------------*/
  5.  
  6. //arduino output pins
  7. #define LATCH 7
  8. #define CLOCK 8
  9. #define DATA  9
  10.  
  11. //2 uS of clock period (sample rate = 30.3 KHz)
  12. #define HALF_CLOCK_PERIOD 1  
  13.  
  14. uint16_t j=0;
  15.  
  16. void setup()
  17. {
  18.   pinMode(DATA, OUTPUT);
  19.   pinMode(CLOCK,OUTPUT);
  20.   pinMode(LATCH,OUTPUT);
  21.  
  22.   digitalWrite(DATA,LOW);
  23.   digitalWrite(CLOCK,LOW);
  24.   digitalWrite(LATCH,LOW);
  25. }
  26.  
  27. void writeValue(uint16_t value){
  28.  
  29.   //start of sequence
  30.   digitalWrite(LATCH,LOW);
  31.   digitalWrite(CLOCK,LOW);
  32.  
  33.   //send the 16 bit sample data
  34.   for(int i=15;i>=0;i--){
  35.     digitalWrite(DATA,((value&(1<<i)))>>i);
  36.     delayMicroseconds(HALF_CLOCK_PERIOD);
  37.     digitalWrite(CLOCK,HIGH);
  38.     delayMicroseconds(HALF_CLOCK_PERIOD);
  39.     digitalWrite(CLOCK,LOW);
  40.   }
  41.  
  42.   //latch enable, DAC output is set
  43.   digitalWrite(DATA,LOW);
  44.   digitalWrite(CLOCK,LOW);
  45.   digitalWrite(LATCH,HIGH);
  46.   delayMicroseconds(HALF_CLOCK_PERIOD);
  47.   digitalWrite(LATCH,LOW);
  48.  
  49. }
  50.  
  51.  
  52. void loop()
  53. {
  54.   //a 0 to 5V triangular waveform
  55.   for(j=0;j<65535;j+=5){
  56.     writeValue(j);
  57.   }
  58.   for(j=0;j<65535;j+=5){
  59.     writeValue(65535-j);
  60.   }
  61.  
  62. }