Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: ADC library conflicts with Audio library dac output

  1. #1

    ADC library conflicts with Audio library dac output

    I am trying to use a teensy 3.6 to read an analog input and put signals to the dac pins using the soundwave synthesis library and AudioOutputAnalogStereo dacs

    Running each one of these alone works fine, however the moment I setup "ADC *adc = new ADC();" the dac output using AudioOutputAnalogStereo stops working.

    Any idea on what the conflict between the two is and how to resolve it?

    Thanks

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,860
    as the forum rule states, please provide a runnable sketch that demonstrates the problem. You can't use analogRead() with Audio lib's AudioInputAnalog,
    see https://www.pjrc.com/teensy/gui/?info=AudioInputAnalog

  3. #3
    Not trying to do analogRead with AudioInputAnalog. Trying to do analogRead with the ADC and output to the dac with Audio lib

    Very simple, this works:

    Code:
    #include <Audio.h>
    
    AudioSynthWaveformSine   sine;
    AudioOutputAnalogStereo  dacs;
    AudioConnection          patchCord1(sine, 0, dacs, 0);
    AudioConnection          patchCord2(sine, 0, dacs, 1);
    
    
    //#include <ADC.h>
    //ADC *adc = new ADC();
    
    void setup() {
      AudioMemory(10);
      dacs.analogReference(INTERNAL);
      
      sine.frequency(120);
      sine.amplitude(0.6);
    }
    
    void loop() {
      
    }
    Uncomment the two ADC related lines (two comments in the text) no more ADC output (other outputs work fine).
    Last tested with teensyduino 1.42

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,860
    Since DACs are also analog pins (A21, A22), the ADC library initializations might conflict with Audio lib DAC ... more study required.

    can you use the Teensy analogRead()? That might avoid a conflict. a simple analogRead(A0) in your sketch does not
    seem to kill the DAC in my testing

  5. #5
    Quote Originally Posted by manitou View Post
    Since DACs are also analog pins (A21, A22), the ADC library initializations might conflict with Audio lib DAC ... more study required.

    can you use the Teensy analogRead()? That might avoid a conflict. a simple analogRead(A0) in your sketch does not
    seem to kill the DAC in my testing
    That is what I resorted to at the moment, the only thing is that it does not allow me to control any settings not the dac (number of bits, conversion speed and averaging).

    Thanks

  6. #6
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,860
    analogReadAveraging(1);
    analogReadResolution(8);
    changing conversion speed would require manipulating the ADC registers ....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •