DAC

From Quantum kot
Jump to navigation Jump to search

[1]

 

 

Arduino nano

Internal arduino due

Fast, 5us steps even with simplest code

   analogWrite(DAC0, analogRead(A1));  // write the selected waveform on DAC0

On arduino due chip's analog reference is shortened to 3.3V power supply. The AREF pin is connected to the SAM3X analog reference pin through a resistor bridge (see ADVREF pin). To use the AREF pin, resistor BR1 must be desoldered from the PCB. The limits for Vref = 2.4-3.3 V [1]

DAC0 and DAC1 pins provide true analog outputs with 12-bits resolution (4096 levels) with the analogWrite() function. The huge disadvantage is that DAC output range is actually from 0.55 V to 2.75 V only. So all signals have offset of 500 mV.


DAC MCP4725

I2C serial transmission.

with arduino nano

Achieved pretty slow operation 250 us steps.  

/* SAMPLE AND HOLD with MCP4725 DAC board and arduino nano
 *  
 *  Connections:
 *  SDA -> A4 (arduino nano) 
 *  SCL -> A5 (arduino nano) 
 *  input signal -> A1 (arduino nano)
 *  logic signal -> D2 (arduino nano)
 */
#include <Wire.h>//Include the Wire library to talk I2C
#define MCP4725_ADDR 0x62 

int val=0;
int lookup = 0;//varaible for navigating through the tables

// Define various ADC prescaler

const unsigned char PS_16 = (1 << ADPS2);
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);

void setup()
{
  Wire.begin();
  pinMode(A1, INPUT);
  // set up the ADC
  analogReference(INTERNAL);
  ADCSRA &= ~PS_128;  // remove bits set by Arduino library

  // you can choose a prescaler from above.
  // PS_16, PS_32, PS_64 or PS_128
  ADCSRA |= PS_64;    // set our own prescaler to 64 
  attachInterrupt(digitalPinToInterrupt(2), blink, LOW);
  
}
//---------------------------------------------------

void blink() {

}

void loop()
{
  TWBR = 12;

  while(1)
    {
      val = analogRead(A1);
      Wire.beginTransmission(MCP4725_ADDR);

      Wire.write(64);                     // cmd to update the DAC
      Wire.write(val/16);// Wire.write(sintab2[lookup] >> 4);        // the 8 most significant bits...
      Wire.write((val % 16) << 4);// Wire.write((sintab2[lookup] & 15) << 4); // the 4 least significant bits...
      Wire.endTransmission();
      //lookup = (lookup + 1) & 511;
    }
     
}

with arduino due

DAC maxim 7545

Arduino nano

Requires to be connected. Clusters avalilable:

Pin # 0 1 2 3 4 5 6 7 8 9 10 11
Maxim pin # 15 14   13   12   11   10   9    8   7 6 5 4
Arduino nano                        
Mega 328                        
  LSB                     MSB

Arduino due