Author Topic: DAC outputs on Arduino Due not working...  (Read 3994 times)

0 Members and 1 Guest are viewing this topic.

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
DAC outputs on Arduino Due not working...
« on: June 27, 2017, 10:42:17 am »
Hi all,

Something that I though would be easy to do, output values on the DAC, is proving very frustrating. I have the same issue on two Arduino Due boards. Whatever code I try from examples the outputs are always high impedance.

I've tried setting the DAC pins as outputs or nothing, changing the resolution etc. One issue I found online was to do with writing to the DACs too quickly however I only write it once. Both DAC outputs suffer from the issue.

Any advice would be great!
Thanks.

Some code:

Code: [Select]
void setup() {

  pinMode(DAC0, OUTPUT);
  analogWriteResolution(12);
  analogWrite(DAC0, 2048);
}

void loop() {

  if(digitalRead(SW_START) == 1)
  {
    enableDischarge(4);
  }

  else
  {
    disableDischarge(4);
  }

  delay(1000);
}
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: DAC outputs on Arduino Due not working...
« Reply #1 on: June 27, 2017, 11:08:45 am »
Have you tried pulling the analogWrite statement into the loop()?

Have you tried a simpler, 8-bit DAC code?

Code: [Select]
void setup() {               
  // initialize the digital pin as an output.
  pinMode(5, OUTPUT);     
}


void loop() {
  analogWrite(5,127);  //Set the PWM at 50 % on digital pin 5
}

Or other code examples:
https://www.arduino.cc/en/Reference/AnalogWriteResolution
 

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
Re: DAC outputs on Arduino Due not working...
« Reply #2 on: June 27, 2017, 11:36:27 am »
Have you tried pulling the analogWrite statement into the loop()?

Have you tried a simpler, 8-bit DAC code?

Code: [Select]
void setup() {               
  // initialize the digital pin as an output.
  pinMode(5, OUTPUT);     
}


void loop() {
  analogWrite(5,127);  //Set the PWM at 50 % on digital pin 5
}

Or other code examples:
https://www.arduino.cc/en/Reference/AnalogWriteResolution

I copied and pasted your code however changed the pin to 35 - but get nothing on the output :(
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: DAC outputs on Arduino Due not working...
« Reply #3 on: June 27, 2017, 12:56:09 pm »
try removing the pin definition, arm peripherals have far more features than you would expect on them, so it may be that its both outputtting on the dac, and outputting a 0 to the pin, thus grounding that output

for more references, see here https://forum.arduino.cc/index.php?topic=154965.0
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf