How to you write to the second DAC?

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

I am planning to use DAC in the future, so I found this helpful:

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: analogWrite() - Arduino Reference

Also:

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.

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 analogWrite(DAC1,0);. Thus all the dacc_write_conversion_data(DACC_INTERFACE, value); will be writing to DAC1. If you change that to 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

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

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

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

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

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

Thanks, I will have a look into it.

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):

  /* 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.,

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

Works well :slight_smile:
Thanks