Hamburg, Germany
Offline
Newbie
Karma: 3
Posts: 3
member of Attraktor e.V. in Hamburg, Germany
|
 |
« on: October 29, 2012, 02:59:42 pm » |
Hey there, I tried the DACC on the Arduino Due, but it doesn't work as expected. I used the function analogWrite() for setting a new DAC value. The following code will work as expected: byte value; void loop() { analogWrite(DAC0, value++); }
Same applies if you replace DAC0 with DAC1. For some unknown reason, I couldn't get both DACs to work simultaneously. The following code does not work: byte value; void loop() { analogWrite(DAC0, value++); analogWrite(DAC1, value * 2); }
I think it has something to do with the code in hardware/arduino/sam/cores/arduino/wiring_analog.c. In the function analogWrite() there is the following lines: // Write user value ulValue = mapResolution(ulValue, _writeResolution, DACC_RESOLUTION); dacc_write_conversion_data(DACC_INTERFACE, ulValue);
I'm missing the channel selection before writing conversion data. Did someone else use the DACs before with analogWrite()? Is the reported behaviour bug or feature? mfg, Stefan.
|
|
|
|
|
Logged
|
-- member of Attraktor e.V. in Hamburg, Germany the largest makerspace in northern Germany come in and join us
|
|
|
|
Forum Administrator
Milano, Italy
Offline
Full Member
Karma: 19
Posts: 210
|
 |
« Reply #1 on: October 30, 2012, 03:30:02 am » |
smay4finger,
I fear that you're right, the analogWrite on DACs didn't work if you write on both DACs. I don't know why, but seems that nobody (including me) ever dreamed to test BOTH channels together.
I'll put the fix to this in the to-do list, before the next beta release 1.5.1 (that is very close).
C
|
|
|
|
|
Logged
|
C.
|
|
|
|
Hamburg, Germany
Offline
Newbie
Karma: 3
Posts: 3
member of Attraktor e.V. in Hamburg, Germany
|
 |
« Reply #2 on: November 01, 2012, 01:20:19 pm » |
Fix was trivial. Please find attached the patch for wiring_analog.c. Should I make bug report?
mfg, Stefan.
|
|
|
|
« Last Edit: November 01, 2012, 01:22:29 pm by smay4finger »
|
Logged
|
-- member of Attraktor e.V. in Hamburg, Germany the largest makerspace in northern Germany come in and join us
|
|
|
|
Forum Administrator
Milano, Italy
Offline
Full Member
Karma: 19
Posts: 210
|
 |
« Reply #3 on: November 02, 2012, 06:33:08 am » |
smay4finger,
thank for the patch I'm testing it in the next hours, in case may you open a pull request on github so i can merge it?
C
|
|
|
|
|
Logged
|
C.
|
|
|
|
Global Moderator
Milano, Italy
Offline
Edison Member
Karma: 10
Posts: 1098
Arduino rocks
|
 |
« Reply #4 on: November 02, 2012, 01:55:34 pm » |
Hi, I tested your patch and I think it works! I attach a sketch that generates a sine wave on both the DAC outputs phase shifted of pi. To prove I add the screen capture of the oscilloscope. +1 Karma is deserved 
|
|
|
|
|
Logged
|
F
|
|
|
|
Hamburg, Germany
Offline
Newbie
Karma: 3
Posts: 3
member of Attraktor e.V. in Hamburg, Germany
|
 |
« Reply #5 on: November 03, 2012, 06:48:13 am » |
I made a bug report here: http://code.google.com/p/arduino/issues/detail?id=1092Please use the patch attached to the ticket. There is also a bugfix regarding corruption of the data register, when writing too fast.
|
|
|
|
|
Logged
|
-- member of Attraktor e.V. in Hamburg, Germany the largest makerspace in northern Germany come in and join us
|
|
|
|
Forum Administrator
Milano, Italy
Offline
Full Member
Karma: 19
Posts: 210
|
 |
« Reply #6 on: November 03, 2012, 02:23:04 pm » |
Done, thank you.
C
|
|
|
|
|
Logged
|
C.
|
|
|
|
Freiburg, Germany
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #7 on: November 09, 2012, 01:40:12 am » |
"I tried the DACC on the Arduino Due, but it doesn't work as expected. I used the function analogWrite() for setting a new DAC value. The following code will work as expected:" byte value; void loop() { analogWrite(DAC0, value++); }
Hello, when i test the DAC on the DUE i measured an Outputvoltage from 0,55V (value 0) to 2,77V (value 255). I thought the DAC has a range from 0V to 3,3V?! Do anybody knows more or can help me? greets parasound
|
|
|
|
|
Logged
|
|
|
|
|
Basel
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #8 on: November 10, 2012, 07:05:51 pm » |
"Hello, when i test the DAC on the DUE i measured an Outputvoltage from 0,55V (value 0) to 2,77V (value 255). I thought the DAC has a range from 0V to 3,3V?! Do anybody knows more or can help me?"
Hi all! I would be interested in this too. Could not figure out yet why DAC range ist approx. 0,54V - 2.74V (both channels). andy_G
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #9 on: November 11, 2012, 09:02:27 pm » |
Hi parasound and andy_g,
I could find no information about the DAC range in the SAM3X datasheet. But on page 1059 of SAM3S datasheet, it is said that the voltage range of the DAC is from (1/6) x VADVREF to (5/6) x VADVREF. So I suspect, the same applies to SAM3U, and range is 1/6 x 3.3V = 0.55V to 5/6 x 3.3V = 2.75V, which is verified by your measures.
wibauxl
|
|
|
|
|
Logged
|
|
|
|
|
Freiburg, Germany
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #10 on: November 12, 2012, 08:20:15 am » |
Ok. Thank you wibauxl.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #11 on: November 12, 2012, 09:16:47 am » |
Hi parasound and andy_g,
I could find no information about the DAC range in the SAM3X datasheet. But on page 1059 of SAM3S datasheet, it is said that the voltage range of the DAC is from (1/6) x VADVREF to (5/6) x VADVREF. So I suspect, the same applies to SAM3U, and range is 1/6 x 3.3V = 0.55V to 5/6 x 3.3V = 2.75V, which is verified by your measures.
wibauxl
That seems pretty limiting. You mean one can't measure output signals between below .55 volt? There must be more to the subject then that? Lefty
|
|
|
|
« Last Edit: November 12, 2012, 10:24:55 am by retrolefty »
|
Logged
|
|
|
|
|
Forum Administrator
Offline
God Member
Karma: 43
Posts: 616
I find plain exciting
|
 |
« Reply #12 on: November 12, 2012, 10:22:56 am » |
@retrolefty
We're talking about the DAC here. The ADC works at voltages below 0.55v. As far as the DAC is concerned it's a pity to have such limits but I guess for audio applications there are way to circumvent the issue.
m
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #13 on: November 12, 2012, 10:30:41 am » |
@retrolefty
We're talking about the DAC here. The ADC works at voltages below 0.55v. As far as the DAC is concerned it's a pity to have such limits but I guess for audio applications there are way to circumvent the issue.
m
Well I don't yet own a Due and not up to the task just yet of taking on the huge datasheet for this uP, but they must talk about this range restriction if indeed it's a hardware based restriction. I just find it very hard to except at this time that there is a legitimate reason for this. I guess it could be compensated for with external op-amp with a -.55v offset, but still there just must be more to this subject then 'that's just the way it is'? It's really not a problem for audio type applications as one could just capacitance couple the signal, but for precision DC DAC applications, not being able to reach ground potential is a pretty big deal, no? Lefty
|
|
|
|
« Last Edit: November 12, 2012, 10:34:51 am by retrolefty »
|
Logged
|
|
|
|
|
Basel
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #14 on: November 12, 2012, 03:22:12 pm » |
...what would also make sense resolution-wise: LSB seems to be 0.5mV (measured) which is in line with wibauxl's theory ((2.75-0.55)/4096=0.537mV). This DAC behaviour -and te lack of it's documentation- is a little odd to my opinion, but at least there's an explanation that makes sense.
MANY THANKS FOR ALL YOUR INPUTS!!
andy_g
|
|
|
|
|
Logged
|
|
|
|
|
|