Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I use a simple serial connection to tell the Due what to output into an analog output pin. However, the outputs are offset about 550mV (as seen on an oscilloscope) and the maximum value of 255 gives ~2.7V. What am I missing? Why can't the DAC output 0V - 3.3V mapped onto 0 - 255 values?

int output = DAC1; // analog output pin
String inData;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  while (Serial.available() > 0) {
    char value = Serial.read();
    inData += value;
    if(value == '\n'){
      val = inData.toInt(); // 0..255
      analogWrite(output, val);
      Serial.println(val);
      inData = "";
    }
  }
}
share|improve this question
    
What is the voltage on VDDANA? –  Ignacio Vazquez-Abrams Mar 20 at 22:27
    
how do I check that? –  aaaaaa Mar 20 at 22:31
    
With the black lead of the DMM on ground and the red lead on VDDANA, with the DMM in DC volts mode. –  Ignacio Vazquez-Abrams Mar 20 at 23:36
    
it reads about 4.2V, if by VDDANA you mean Vin pin. I don't know where to measure VDDANA otherwise –  aaaaaa Mar 21 at 1:11
    
The datasheet for the MCU gives its pinout. –  Ignacio Vazquez-Abrams Mar 21 at 1:11

1 Answer 1

up vote 2 down vote accepted

I don't know how old this thread is, anyway I thought it doesn't hurt to give some insight because I experienced the same problem. Look at: http://www.atmel.com/Images/Atmel-42187-ATSAM3X-and-ATSAM3A-Series-Checklist_AP-Note_AT03462.pdf page 13: DAC0 and 1 voltage lays between 1/6 ADVREF and 5/6 ADVREF which corresponds to approximately ADVREF=3.2v; Span is (4/6)*3.2 = 2.1v for periodic signals, Offset can be removed by using a small decoupling capacitor which will act as a high pass filter. Hope this helps

share|improve this answer
    
Thank you for help! Numbers on atmega datasheet do make sense, they are close to what I see on oscilloscope. –  aaaaaa Mar 24 at 18:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.