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

Thread: Cannot get Teensy Audio shield line out to produce sound

  1. #1
    Member
    Join Date
    Feb 2021
    Location
    netherlands
    Posts
    28

    Cannot get Teensy Audio shield line out to produce sound

    Trying to get some sound out of my audio shied using the wavfile playing Arduino example.

    Works fine through the headphones jack. And I have heard it play via the connected amp Adafruit MAX 98306.
    Maybe i broke something maybe i did some bad wiring (see pics) but now there's only silence (headphones still work and sound very good).

    I tried several small speakers 4 and 8 ohms.

    I'm pretty new to electronics, maybe I wired it wrong? I did check that the amp gets 4.77 Volts. But on the outputs terminals I measure super small voltage. Hope I'm measuring it correctly but it fluctuates between 0.05 and 0.7 volts.

    Have I made the right connections? I don't know how to further debug this issue...

    Click image for larger version. 

Name:	IMG_3164.jpg 
Views:	12 
Size:	98.4 KB 
ID:	23852Click image for larger version. 

Name:	IMG_3162.jpg 
Views:	15 
Size:	180.7 KB 
ID:	23853Click image for larger version. 

Name:	IMG_3163.jpg 
Views:	13 
Size:	115.8 KB 
ID:	23854

  2. #2
    Junior Member
    Join Date
    Jul 2017
    Posts
    18
    L+ and L- is the left differential input.
    Connect it this way:
    L- -> GND
    L+ -> Teensy Line out L
    R- -> GND
    R+ -> Teensy Line out R

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    964
    Quote Originally Posted by Jeroen View Post
    Trying to get some sound out of my audio shied using the wavfile playing Arduino example.

    Works fine through the headphones jack. And I have heard it play via the connected amp Adafruit MAX 98306.
    Maybe i broke something maybe i did some bad wiring (see pics) but now there's only silence (headphones still work and sound very good).
    You've not shown your code.

    Have you called "sgtl5000_1.lineOutLevel();" or similar to configure the line outs? Have you checked
    there's a signal on the line outs using AC volts setting of multimeter between gnd and L/R outs?

  4. #4
    Member
    Join Date
    Feb 2021
    Location
    netherlands
    Posts
    28
    Here's the code:

    I have changed the wires as per your suggestions (thanks!)

    Code:
    // Simple WAV file player example
    //
    // Three types of output may be used, by configuring the code below.
    //
    //   1: Digital I2S - Normally used with the audio shield:
    //         http://www.pjrc.com/store/teensy3_audio.html
    //
    //   2: Digital S/PDIF - Connect pin 22 to a S/PDIF transmitter
    //         https://www.oshpark.com/shared_projects/KcDBKHta
    //
    //   3: Analog DAC - Connect the DAC pin to an amplified speaker
    //         http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
    //
    // To configure the output type, first uncomment one of the three
    // output objects.  If not using the audio shield, comment out
    // the sgtl5000_1 lines in setup(), so it does not wait forever
    // trying to configure the SGTL5000 codec chip.
    //
    // The SD card may connect to different pins, depending on the
    // hardware you are using.  Uncomment or configure the SD card
    // pins to match your hardware.
    //
    // 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 playWav1;
    // Use one of these 3 output types: Digital I2S, Digital S/PDIF, or Analog DAC
    AudioOutputI2S audioOutput;
    //AudioOutputSPDIF       audioOutput;
    //AudioOutputAnalog      audioOutput;
    AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
    AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
    AudioControlSGTL5000 sgtl5000_1;
    
    // 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);
    
      // Audio connections require memory to work.  For more
      // detailed information, see the MemoryAndCpuUsage example
      AudioMemory(8);
    
      // Comment these out if not using the audio adaptor board.
      // This may wait forever if the SDA & SCL pins lack
      // pullup resistors
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_1
    
          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 playFile(const char *filename)
    {
      Serial.print("Playing file: ");
      Serial.println(filename);
    
      // Start playing the file.  This sketch continues to
      // run while the file plays.
      playWav1.play(filename);
    
      // A brief delay for the library read WAV info
      delay(5);
    
      // Simply wait for the file to finish playing.
      while (playWav1.isPlaying())
      {
        // uncomment these lines if you audio shield
        // has the optional volume pot soldered
        // float vol = analogRead(15);
        // vol = vol / 1024;
        // sgtl5000_1.volume(vol);
      }
    }
    
    void loop()
    {
      // playFile("JOINED.WAV"); // filenames are always uppercase 8.3 format
      // delay(500);
      playFile("SDTEST2.WAV");
      delay(500);
      playFile("SDTEST3.WAV");
      delay(500);
      playFile("SDTEST4.WAV");
      delay(1500);
    }
    Still no sound. How exactly do I measure the voltage?

    And another question: can the Teensy and the AMP share the same ground?

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,604
    You need
    Code:
      sgtl5000_1.unmuteLineout();
    Pete

  6. #6
    Member
    Join Date
    Feb 2021
    Location
    netherlands
    Posts
    28
    I tried measuring the voltage on the L+ and GND using my multimeter on V~ 200V (there is no lower setting) but it says 0.

  7. #7
    Member
    Join Date
    Feb 2021
    Location
    netherlands
    Posts
    28
    I tried this, no change

    Code:
    // Simple WAV file player example
    //
    // Three types of output may be used, by configuring the code below.
    //
    //   1: Digital I2S - Normally used with the audio shield:
    //         http://www.pjrc.com/store/teensy3_audio.html
    //
    //   2: Digital S/PDIF - Connect pin 22 to a S/PDIF transmitter
    //         https://www.oshpark.com/shared_projects/KcDBKHta
    //
    //   3: Analog DAC - Connect the DAC pin to an amplified speaker
    //         http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
    //
    // To configure the output type, first uncomment one of the three
    // output objects.  If not using the audio shield, comment out
    // the sgtl5000_1 lines in setup(), so it does not wait forever
    // trying to configure the SGTL5000 codec chip.
    //
    // The SD card may connect to different pins, depending on the
    // hardware you are using.  Uncomment or configure the SD card
    // pins to match your hardware.
    //
    // 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 playWav1;
    // Use one of these 3 output types: Digital I2S, Digital S/PDIF, or Analog DAC
    AudioOutputI2S audioOutput;
    //AudioOutputSPDIF       audioOutput;
    //AudioOutputAnalog      audioOutput;
    AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
    AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
    AudioControlSGTL5000 sgtl5000_1;
    
    // 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);
    
      // Audio connections require memory to work.  For more
      // detailed information, see the MemoryAndCpuUsage example
      AudioMemory(8);
    
      // Comment these out if not using the audio adaptor board.
      // This may wait forever if the SDA & SCL pins lack
      // pullup resistors
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_1.unmuteLineout();
      sgtl5000_1.lineOutLevel(21);
    
      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 playFile(const char *filename)
    {
      Serial.print("Playing file: ");
      Serial.println(filename);
    
      // Start playing the file.  This sketch continues to
      // run while the file plays.
      playWav1.play(filename);
    
      // A brief delay for the library read WAV info
      delay(5);
    
      // Simply wait for the file to finish playing.
      while (playWav1.isPlaying())
      {
        // uncomment these lines if you audio shield
        // has the optional volume pot soldered
        // float vol = analogRead(15);
        // vol = vol / 1024;
        // sgtl5000_1.volume(vol);
      }
    }
    
    void loop()
    {
      // playFile("JOINED.WAV"); // filenames are always uppercase 8.3 format
      // delay(500);
      playFile("SDTEST2.WAV");
      delay(500);
      playFile("SDTEST3.WAV");
      delay(500);
      playFile("SDTEST4.WAV");
      delay(1500);
    }

  8. #8
    Senior Member
    Join Date
    Jul 2020
    Posts
    964
    Quote Originally Posted by Jeroen View Post
    I tried measuring the voltage on the L+ and GND using my multimeter on V~ 200V (there is no lower setting) but it says 0.
    You need a more useful meter I'm afraid, with millivolts AC (!)

    Where's the call to lineOutLevel(13)?:
    Code:
      // Comment these out if not using the audio adaptor board.
      // This may wait forever if the SDA & SCL pins lack
      // pullup resistors
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      sgtl5000_1
    
          SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);

  9. #9
    Member
    Join Date
    Feb 2021
    Location
    netherlands
    Posts
    28
    OK thanks. I just hooked up another amp and that works.

    Can't imagine I already smoked by my new Adafruit amp... seems weird, that's not easy to do I don't think..

    FYI, these lines can be removed, I still get sound

    Code:
    sgtl5000_1.unmuteLineout();
    sgtl5000_1.lineOutLevel(21);

  10. #10
    Senior Member
    Join Date
    Jul 2020
    Posts
    964
    The MAX98306 is a CMOS chip, so will be fragile w.r.t. static.
    The Adafruit breakout for it has no schottky protection diodes on the chip inputs so its vulnerable to this (same
    issue with the Teensy Audio Shield I'm afraid).

Posting Permissions

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