0

I am using an Arduino DUE. Using the analogWrite(DAC0, X) command I am writing an analog value to this pin. X = 0 - 255 as I understand it.

I am observing that when X is lower, the voltage on DAC0 is higher nad when X is higher the voltage is lower.

Is that expected?

My code is simple:

void setup() 
{
  analogWriteResolution(12);
}

void loop() 
{
  analogWrite(DAC0, 10 );  
}

migrated from electronics.stackexchange.com Feb 24 '18 at 6:36

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • voltage is lower ... how do you know what the output voltage is? ... you have not described how you are measuring the voltage. – jsotola Feb 24 '18 at 6:20
  • Using a DMM between the DAC0 pin and GND. – Neil Dey Feb 24 '18 at 6:27
  • I don't understand. How else does one measure voltage? – Neil Dey Feb 24 '18 at 6:33
  • @jsotola The load? I'm not sure what you are getting at. – Nick Gammon Feb 24 '18 at 6:59
  • Look, comments under questions are for clarifying the question, not trying to answer them obliquely or not. If you want to ask under what load the measurement was made, then ask it. – Nick Gammon Feb 24 '18 at 7:01
0

That doesn’t sound right. Try setting x to 0 and measure with DC. You should get ~0.56 V. Repeat with 4095, and you should get ~2.76 V.

Also, note that with analogWriteResolution(12) your range is not 8-bits (0-255), but 12-bits (0-4095).

The output should follow:

Vout = Vref * Xin(2N-1) + Voffset

where

  • Voffset = 0.56 V
  • Vref = 2.2 V
  • 0 ≤ Xin ≤ 4095
  • According to the page about analogWrite: Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs. - so that shouldn't be an issue. – Nick Gammon Feb 24 '18 at 6:58
  • @NickGammon Oops, that slipped passed me. I'll edit. Thanks – Blair Fonville Feb 24 '18 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy