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

Thread: quad problems with 2 audio shields and teensy 3.2

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    2

    quad problems with 2 audio shields and teensy 3.2

    Hi,

    I am running into audio problems doing the 2 audio shield w. teensy 3.2 setup.

    I am using the standard test code example, included at the end of this post.

    I have removed the pin 15 capacitors on each shield

    I have done all the mods to the second shield described in the sparkfun tutorial (linked from the quad page):

    I get the message playing file 1 & playing file 2.

    The 1/2 channel card works fine. Nothing at all on the 3/4 channel card. There appears to be no data on pin 15. If I temporarily short the pin 22 pad to the pin 15 pad, I get channels 1/2 playing on the 3/4 shield, as you would expect. I built two different boards - each with the same problem. I also tried a modified board I had successfully used in the past - this also didn't work.



    I also tried setting pin 15 to output mode (not in the example).

    I've tried running at 96 Mhz and also 72 Mhz.

    Has something changed re. the support for the Teensy 3.2?

    Here is my code. Thanks to anyone who has some ideas!

    Shawn


    Code:
    AudioPlaySdWav           playSdWav1;
    AudioPlaySdWav           playSdWav2;
    AudioOutputI2SQuad       audioOutput;
    AudioConnection          patchCord1(playSdWav1, 0, audioOutput, 0);
    AudioConnection          patchCord2(playSdWav1, 1, audioOutput, 1);
    AudioConnection          patchCord3(playSdWav2, 0, audioOutput, 2);
    AudioConnection          patchCord4(playSdWav2, 1, audioOutput, 3);
    AudioControlSGTL5000     sgtl5000_1;
    AudioControlSGTL5000     sgtl5000_2;
    
    // Use these with the Teensy Audio Shield
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(20);
    
      pinMode(15, OUTPUT);
      
      sgtl5000_1.setAddress(LOW);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.85);
    
      sgtl5000_2.setAddress(HIGH);
      sgtl5000_2.enable();
      sgtl5000_2.volume(0.85);
    
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
    
      
     if (!(SD.begin(SDCARD_CS_PIN))) {
        // stop here, but print a message repetitively
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      
    }
    
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(20);
    
      pinMode(15, OUTPUT);
      
      sgtl5000_1.setAddress(LOW);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.85);
    
      sgtl5000_2.setAddress(HIGH);
      sgtl5000_2.enable();
      sgtl5000_2.volume(0.85);
    
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
    
      
     if (!(SD.begin(SDCARD_CS_PIN))) {
        // stop here, but print a message repetitively
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      
    }
    Last edited by Theremingenieur; 12-10-2018 at 04:43 PM. Reason: Added code tags for better readability

  2. #2
    Junior Member
    Join Date
    Nov 2018
    Posts
    2
    oops - looks like a bad paste on the code. Here it is again:

    Code:
    // Quad channel output test
    // Play two WAV files on two audio shields.
    //
    // TODO: add info about required hardware connections here....
    //
    // Data files to put on your SD card can be downloaded here:
    //   http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
    //
    // This example code is in the public domain.
    
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    AudioPlaySdWav           playSdWav1;
    AudioPlaySdWav           playSdWav2;
    AudioOutputI2SQuad       audioOutput;
    AudioConnection          patchCord1(playSdWav1, 0, audioOutput, 0);
    AudioConnection          patchCord2(playSdWav1, 1, audioOutput, 1);
    AudioConnection          patchCord3(playSdWav2, 0, audioOutput, 2);
    AudioConnection          patchCord4(playSdWav2, 1, audioOutput, 3);
    AudioControlSGTL5000     sgtl5000_1;
    AudioControlSGTL5000     sgtl5000_2;
    
    // Use these with the Teensy Audio Shield
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    
    // Use these with the Teensy 3.5 & 3.6 SD card
    //#define SDCARD_CS_PIN    BUILTIN_SDCARD
    //#define SDCARD_MOSI_PIN  11  // not actually used
    //#define SDCARD_SCK_PIN   13  // not actually used
    
    // Use these for the SD+Wiz820 or other adaptors
    //#define SDCARD_CS_PIN    4
    //#define SDCARD_MOSI_PIN  11
    //#define SDCARD_SCK_PIN   13
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(20);
    
      pinMode(15, OUTPUT);
      
      sgtl5000_1.setAddress(LOW);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.85);
    
      sgtl5000_2.setAddress(HIGH);
      sgtl5000_2.enable();
      sgtl5000_2.volume(0.85);
    
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
    
      
     if (!(SD.begin(SDCARD_CS_PIN))) {
        // stop here, but print a message repetitively
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      
    }
    Last edited by Theremingenieur; 12-10-2018 at 04:44 PM. Reason: Added code tags for better readability

  3. #3
    Junior Member
    Join Date
    Aug 2018
    Posts
    4
    Hello ShawnDecker,

    We seem to have the exact same issue, did you find any solutions?

    We have tried several codes: one that is similar to yours and an other generating four sine waves with different frequencies that were dispatched between the four outputs (thus one sine wave per output, the code is below).

    What we do not understand is that the code works half the time which leads to think that it is an hardware issue rather than a software.

    We should also specify that we did the mods necessary to stack the two audio shields and that we do not have any shorts on the solders that we made ^^

    Thank you in advance for your time and hopefully for your solution

    Here is the code reading files from the SD card:

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioPlaySdWav           playSdWav1;     //xy=116,79
    AudioPlaySdWav           playSdWav2;//xy=118,155
    AudioMixer4              mixer1;         //xy=345,69
    AudioMixer4              mixer2; //xy=347,134
    AudioMixer4              mixer3; //xy=347,200
    AudioMixer4              mixer4; //xy=348,265
    AudioOutputI2SQuad       i2s_quad1;      //xy=542,162
    AudioConnection          patchCord1(playSdWav1, 0, mixer1, 0);
    AudioConnection          patchCord2(playSdWav1, 1, mixer2, 0);
    AudioConnection          patchCord3(playSdWav2, 0, mixer3, 0);
    AudioConnection          patchCord4(playSdWav2, 1, mixer4, 0);
    AudioConnection          patchCord5(mixer1, 0, i2s_quad1, 0);
    AudioConnection          patchCord6(mixer2, 0, i2s_quad1, 1);
    AudioConnection          patchCord7(mixer3, 0, i2s_quad1, 2);
    AudioConnection          patchCord8(mixer4, 0, i2s_quad1, 3);
    AudioControlSGTL5000     sgtl5000_1;     //xy=601,433
    AudioControlSGTL5000     sgtl5000_2;     //xy=605,387
    // GUItool: end automatically generated code
    
    
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    
    void setup() {
      Serial.begin(9600);
      
      AudioMemory(120);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_1.setAddress(HIGH);
      
      sgtl5000_2.enable();
      sgtl5000_2.volume(0.5);
      sgtl5000_2.setAddress(LOW);
      
    mixer1.gain(0,0.5);
    mixer2.gain(0,0.5);
    mixer3.gain(0,0.5);
    mixer4.gain(0,0.5);
      
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
      delay(100);
    }
    
    void loop() {
      if (playSdWav1.isPlaying() == false) {
        Serial.println("Start playing1");
        playSdWav1.play("SDTEST2.WAV");
        delay(10); // wait for library to parse WAV info
        
      }
     if (playSdWav2.isPlaying() == false) {
        Serial.println("Start playing2");
        playSdWav2.play("SDTEST1.WAV");
        delay(10); // wait for library to parse WAV info
      }
      }
      
    
    
    
    Here is the code generating sine waves on each channel:
    
    
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformSine   sine1;          //xy=192,76
    AudioSynthWaveformSine   sine2; 
    AudioSynthWaveformSine   sine3;          //xy=192,76
    AudioSynthWaveformSine   sine4;//xy=196,112
    AudioOutputI2SQuad       i2s_quad1;      //xy=438,93
    AudioConnection          patchCord1(sine1, 0, i2s_quad1, 0);
    AudioConnection          patchCord2(sine2, 0, i2s_quad1, 1);
    AudioConnection          patchCord3(sine3, 0, i2s_quad1, 2);
    AudioConnection          patchCord4(sine4, 0, i2s_quad1, 3);
    AudioControlSGTL5000     sgtl5000_2;     //xy=361,211
    AudioControlSGTL5000     sgtl5000_1;     //xy=363,172
    // GUItool: end automatically generated code
    
    // GUItool: end automatically generated code
    
    
    
    void setup() {
      // put your setup code here, to run once:
        AudioMemory(12);
        
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_2.enable();
      sgtl5000_2.volume(0.5);
    
      sine1.frequency(200);
      sine2.frequency(600);
       sine3.frequency(400);
      sine4.frequency(500);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
    }
    Last edited by Theremingenieur; 12-10-2018 at 04:44 PM. Reason: Added code tags for better readability

Posting Permissions

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