Pages: [1]   Go Down
Author Topic: How to you write to the second DAC?  (Read 1925 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 14, 2013, 10:42:58 pm by shteii01 » Logged

Canada
Offline Offline
Newbie
*
Karma: 1
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
analogWrite(DAC1,0);
. Thus all the
Code:
dacc_write_conversion_data(DACC_INTERFACE, value);
will be writing to DAC1. If you change that to
Code:
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
« Last Edit: February 16, 2013, 12:37:04 am by mcleung » Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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





Logged


Austria
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 124
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I will have a look into it.
Logged

CA
Offline Offline
Newbie
*
Karma: 2
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  /* 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:
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Works well smiley
Thanks
Logged

Pages: [1]   Go Up
Jump to: