Show Posts
|
|
Pages: 1 [2] 3 4
|
|
16
|
Products / Arduino Due / Re: DAC support
|
on: January 05, 2013, 11:36:30 am
|
Hi V, And commenting out the initial delay like so: void setup() { while (true) { analogWrite(DAC0, 240);
for (int i = 0; i < 8; i++) { analogWrite(DAC1, 240); delayMicroseconds(20); analogWrite(DAC1, 120); delayMicroseconds(80); }
analogWrite(DAC0, 0); analogWrite(DAC1, 0); delay(9); } }
void loop() { }
gives the outputs shown below. Jim
|
|
|
|
|
17
|
Products / Arduino Due / Re: DAC support
|
on: January 05, 2013, 11:24:50 am
|
Hi V, The following works as expected here, with outputs as per the earlier scope 'screenshots': void setup() { while (true) { analogWrite(DAC0, 240); delayMicroseconds(200);
for (int i = 0; i < 8; i++) { analogWrite(DAC1, 240); delayMicroseconds(20); analogWrite(DAC1, 120); delayMicroseconds(80); }
analogWrite(DAC0, 0); analogWrite(DAC1, 0); delay(9); } }
void loop() { }
What do you get? Jim
|
|
|
|
|
18
|
Products / Arduino Due / Re: DAC support
|
on: January 05, 2013, 09:16:11 am
|
@vdorr OK, I'm using 1.5.1r2. The following works as expected here, giving independent control of the two DACs: while (true) { analogWrite(DAC0, 240); delayMicroseconds(200);
for (int i = 0; i < 8; i++) { analogWrite(DAC1, 240); delayMicroseconds(20); analogWrite(DAC1, 120); delayMicroseconds(80); }
analogWrite(DAC0, 0); analogWrite(DAC1, 0); delay(9); }
Several people in this forum seem to have had trouble and have possibly blown their DAC output(s) by following an Audio example with a loudspeaker (which I haven't tried). For anyone following with an 'early production' Due like me, please note that the constant 'DAC0' (66) corresponds to pin 'DAC2' on the board header, and 'DAC1' (67) corresponds to pin 'DAC1'. Attached are screenshots from a Rigol scope. N.B. I'm using x10 probes. HTH Jim
|
|
|
|
|
20
|
Products / Arduino Due / Re: Timer Interrupts on Due
|
on: January 05, 2013, 05:05:25 am
|
@WomensFashionArt Yep, your understanding is correct. The software delay I inserted (the 'for' loop) is irrelevant, as the 'digitalWrite' is causing the 2 us odd delay I wanted to get a reasonable pulse out. I know how easy it is easy to miss something when you're head-scratching, like the toggle 'I = !I'  The Due Timer code contributed by others in this thread will be very useful. Re. your other query: Also, we need to synchronise the start of these pulses with some other Due's so that they all output synchronised pulses. Can anyone help us with that? Do we simply re-start the timer and, if so, how?
I would output a pulse each cycle from a digital pin on the 'master' Due, and connect it to an unused digital input on each 'slave' Due. You then need to use a hardware interrupt, i.e. an ISR, on each slave Due to reset each slave timer. I'm afraid I haven't got suitable code for the Due handy, but maybe someone else has? Jim
|
|
|
|
|
22
|
Products / Arduino Due / Re: Timer Interrupts on Due
|
on: January 05, 2013, 04:13:25 am
|
@WomensFashionArt Just tried your sketch here unmodified and I get a nice 10 KHz (100 us cycle) square wave output on pin 13, as measured on our Rigol scope. But on further investigation I see that the timer interrupt is in fact at 20 KHz (50 us), but you are toggling the output state in the handler, so each cycle you see is twice 50 us = 100 us. Try this instead and you'll see a 2 us pulse at 20 KHz: void TC3_Handler() { TC_GetStatus(TC1, 0);
digitalWrite(13, 1); // ON
for (int i = 0; i < 10; i++) int j = i;
digitalWrite(13, 0); // OFF }
HTH Jim
|
|
|
|
|
28
|
Products / Arduino Due / Re: Is my board dead
|
on: December 26, 2012, 02:35:52 pm
|
|
Worrying...
Does the ARM chip still get hot when you have just the board connected via USB to a PC (nothing else at all)?
Jim
|
|
|
|
|
29
|
Products / Arduino Due / Re: Debouncing button with sam3x registers
|
on: December 24, 2012, 12:48:16 pm
|
|
Hi,
You might get some ideas from a header file with lots of 'debounce' mentions, component_supc.h, in:
... \arduino-1.5.1r2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3sd8\include\component
But I'm afraid I don't yet know how this part of the Arduino 1.5 tree relates to anything else...
Jim
|
|
|
|
|
30
|
Products / Arduino Due / Re: PWM Pins don't work
|
on: December 22, 2012, 09:51:30 am
|
|
Hi Mirek,
Sorry, misread your name...
With the test sketch below, I get the expected outputs on a scope on pins 3 to 13 continuously, but strangely intermittent activity on pin 2 - I'll investigate further when I have time.
Jim
#include "Print.h"
int count = 1; int ledPin = 13; // LED connected to digital pin 13
// Run once, when the sketch starts. void setup() { Serial.begin(115200); Serial.println("Blink"); count = 0;
// initialize the digital pin as an output: pinMode(ledPin, OUTPUT); }
void loop() { // Write to PWM pins. for (int pin = 2; pin <= 13; pin++) { analogWrite(pin, 255); delay(1); analogWrite(pin, 0); delay(1); }
delay(100);
count++; }
|
|
|
|
|