Go Down

Topic: DigitalAnalogConverter DAC0 stoppt working correctly (Read 271 times) previous topic - next topic

Munkisun

Oct 11, 2013, 11:13 pm Last Edit: Oct 11, 2013, 11:31 pm by Munkisun Reason: 1
Hello, I testet the DAC0 and DAC1 on my DUE on the oscilloscope. Suddanly DAC0 stopped to work correctly. I changed Cables and tried both channels on the oscilloscope. For sure I also changed the variables in the code vor DAC0 and 1. =>
DAC0 still gives out a strange distorted weak Sinus.  There are no other electronics between the arduino and the Oszi. Here is the  the code i used. IN THE BEGINNING IT WORKED FINE...both signals were the same . I didnt do any changings =>Suddanly .

the code: but there is no problem with the code :-( look at the oszi picture OPEN IT!!! :-(

any ideas what happened?
Code: [Select]

int led = 31;

//1kHz
int sineX[] = {2048,2305,2557,2802,3034,3251,3449,3625,3777,3901,3995,4059,4092,4092,4060,3996,3902,3778,3628,3452,3254,3037,2805,2560,2308,2051,1795,1542,1297,1065,847,649,473,321,197,102,37,4,4,35,99,193,316,466,642,839,1056,1288,1533,1785,2041};
int sineY[] = {2048,2305,2557,2802,3034,3251,3449,3625,3777,3901,3995,4059,4092,4092,4060,3996,3902,3778,3628,3452,3254,3037,2805,2560,2308,2051,1795,1542,1297,1065,847,649,473,321,197,102,37,4,4,35,99,193,316,466,642,839,1056,1288,1533,1785,2041};
// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT);  
 pinMode(DAC0, OUTPUT);
 pinMode(DAC1, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
 for(int i = 0; i<50;i++){
     if(sineX[i]>4095||sineY[i]>4095) {
        sineX[i]=4095;
        sineY[i]=4095;
        digitalWrite(led, LOW);
       
    }
   analogWriteResolution(12);
   analogWrite(DAC0, sineX[i]);
   analogWrite(DAC1, sineY[i]);
   delayMicroseconds(14);
   
 }
}


Go Up