Go Down

Topic: How to you write to the second DAC? (Read 2539 times) previous topic - next topic

clone45

Hello,

I'm surprised how difficult it has been to figure this out.  How can I write to DAC #2?  (I think I've blown out DAC #1.)

To write to DAC #1, I'm using: dacc_write_conversion_data(DACC_INTERFACE, value);

Thanks!
- Bret


shteii01

#1
Feb 15, 2013, 04:40 am Last Edit: Feb 15, 2013, 04:42 am by shteii01 Reason: 1
I am planning to use DAC in the future, so I found this helpful:
Quote
The Arduino Due supports analogWrite() on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.

from here: http://arduino.cc/en/Reference/AnalogWrite

Also:
Quote
DAC1 and DAC2
    These pins provides true analog outputs with 12-bits resolution (4096 levels) with the analogWrite() function. These pins can be used to create an audio output using the Audio library.

http://arduino.cc/en/Main/ArduinoBoardDue

mcleung

#2
Feb 16, 2013, 06:35 am Last Edit: Feb 16, 2013, 06:37 am by mcleung Reason: 1
You are using the direct writing to the DAC, which I've noticed to be much faster then using analogWrite.

If you look at your code, you should have "initialized" your DAC earlier with
Code: [Select]
analogWrite(DAC1,0);. Thus all the
Code: [Select]
dacc_write_conversion_data(DACC_INTERFACE, value); will be writing to DAC1. If you change that to
Code: [Select]
analogWrite(DAC2,0);, then you will be writing directly to DAC2. At least that is the case from my experience.

Let me know if it helps!

M

DuaneB

Be careful with your second DAC Output, A lot of us are blowing out the DAC.

As most DACs will be connecting to amplifiers it would make sense to modify a future version of the board to include a series current limiting resistor to protect these two high value pins - high value as in there are only two of them andf or some, they are the main reason for buying a Due.

Duane B

rcarduino.blogspot.com





Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

gbduino

From my experience and as documented:
The two DAC output are addressed as DAC0 and DAC1!
Unfortunately the common description of the board functions mentions DAC1 and DAC2 which might lead to misunderstandings.
both DAC seem to work only in a range of 1/6 .. 5/6 (0.55..2.75V) of the max. voltage of 3300mV

dodgerts

Hi,

I also wonder how to write to the second DAC and I agree that it is incredibly difficult to find anything about it.

However, for me the reason is not that I have blown out my first DAC, but I want to experiment addressing both DACs at the same time. Like for true stereo output for example. Unfortunately that means that mcleung's method won't help.

Does anyone have an idea on how to directly address the individual DACs using dacc_write_conversion_data? Or is there any other way without using slow analogWrite()?

Thanks a lot,
dodgerts

Gericom


Hi,

I also wonder how to write to the second DAC and I agree that it is incredibly difficult to find anything about it.

However, for me the reason is not that I have blown out my first DAC, but I want to experiment addressing both DACs at the same time. Like for true stereo output for example. Unfortunately that means that mcleung's method won't help.

Does anyone have an idea on how to directly address the individual DACs using dacc_write_conversion_data? Or is there any other way without using slow analogWrite()?

Thanks a lot,
dodgerts

Here you can find some information about the functions of the dac: http://asf.atmel.com/docs/latest/sam3x/html/group__sam__drivers__dacc__group.html
Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

dodgerts

Thanks, I will have a look into it.

BKM

You shoudl be able to use analogWrite() directly.  Or if you want to use the ATMEL API, something like the following will work (this writes to both DACs):

Code: [Select]
  /* write to DAC0 */
  dacc_set_channel_selection(DACC_INTERFACE, 0);
  dacc_write_conversion_data(DACC_INTERFACE, some_value);
  /* write to DAC1 */
  dacc_set_channel_selection(DACC_INTERFACE, 1);
  dacc_write_conversion_data(DACC_INTERFACE, some_other_value);


The above assumes you everything setup properly. You can do that with a single analogWrite() to channel, e.g.,

Code: [Select]
analogWrite(DAC0, some_value);
analogWrite(DAC1, some_other_value);


Also, note that the above only works in so-called user-selected channel mode (not tagged or flexible mode).   This is the default that analogWrite() puts the chip into.

Best,
Bruce


Go Up