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

Thread: Help: Playing wav from teensy 3.6 built-in SD while still using audio shield

  1. #1
    Junior Member
    Join Date
    May 2017
    Posts
    10

    Help: Playing wav from teensy 3.6 built-in SD while still using audio shield

    Hi,

    I'm great at searching through these forums and usually find the answer to my issue ... but not this time (I've been playing with teensy's for years!).

    I'm just starting to play with wav's and the audioshield and hit an issue that's baffling me. I'm using a teensy 3.6 with the audio shield and I had this code (attached below) running fine off the audioshield's SD reader, but there was a crackling just before the wav would play ... I wasn't very happy with that so I decided to try the teensy 3.6 built in sd reader. I commented out the audioshield SD pin definitions and uncommented the teensy 3.6 SD pin definitions. I immediately got the error "BUILTIN_SDCARD" was not declared in this scope. I searched the forums and learned that if I delete the SD.h library it will work. I did that, and was able to play my wav off the teensy 3.6 built in SD card reader BUT the volume is so low, and the volume command is no longer doing anything.

    I'm hoping someone can help guide me on my way. The audioshield is still playing my wav file (I'm assuming because I loaded 16bit wavs), but it is definitely not amplifying my audio anymore.

    Thanks, I updated my teensyduino (1.36), all libraries (SD.h is 1.1.0) and my arduino IDE (1.8.2) this morning.
    *though updating SD.h is really weird, I choose update to 1.1.1 and click install and then it says I'm on version 1.0.8 ... 1.1.0 seems to stick*

    UPDATE: I restarted Arduino IDE and now I can't hear the wav file, even quietly.


    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    AudioPlaySdWav    bell1;
    AudioPlaySdWav    bell2;  
    AudioPlaySdWav    bell3;
    
    AudioOutputI2S     headphones;
    
    AudioConnection c1(bell1,0,headphones,0);
    AudioConnection c2(bell1,0,headphones,1);
    
    AudioConnection c3(bell2, headphones);
    AudioConnection c5(bell3, headphones);
    
    AudioControlSGTL5000 audioshield;
    
    // Use these with the Teensy Audio Shield
    //#define SDCARD_CS_PIN    10
    //#define SDCARD_MOSI_PIN  7
    //#define SDCARD_SCK_PIN   14
    
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   33  // not actually used
    
    void setup() {
      AudioMemory(10);
    
      // turn on the output
      audioshield.enable();
      audioshield.volume(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);
        }
      }
      pinMode(13, OUTPUT); // LED on pin 13
      delay(1000);
    }
    
    void loop() {
      if (bell1.isPlaying() == false) {
        bell1.play("123.wav");
        delay(10);
        Serial.println("play");
        digitalWrite(13,HIGH);
      }
    }
    Last edited by bujbot; 05-07-2017 at 10:16 PM. Reason: update

  2. #2
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Just to update. I went back and tried to load one of the basic tutorial examples (play sample while blinking) and I can't hear anything from the headphone jack but it blinks just fine.

    ... the teensy has just been on my desk all day, is it possible to kill the audio shield from just a few code changes and playing with libraries?


    UPDATE UPDATE: I think my audioshield is crap, could be the reason for the issues all day. I decided to try everything from the 3.6 alone and it's running as expected there (though faint I can hear it coming out of the dac). Does anyone know how to diagnosis an Audioshield? Kinda frustrated that it's not working considering this is the first time I've used it.

    Sorry for the multiple updates, if I hit a road block I usually keep going, trying to solve it.
    Last edited by bujbot; 05-07-2017 at 11:51 PM.

  3. #3
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,696
    how is shield attached to T3.6? maybe a photo?

  4. #4
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by manitou View Post
    how is shield attached to T3.6? maybe a photo?
    Sure thing. I used pins and headers so I could detach if necessary. .... tricky to get a picture with the best info. Pretty straight forward though.

    Click image for larger version. 

Name:	teensy 3.6 w:audio board.JPG 
Views:	1061 
Size:	91.6 KB 
ID:	10517
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	teensy 3.6 w:audio board.JPG 
Views:	248 
Size:	91.3 KB 
ID:	10516  

  5. #5
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,696
    OK pins and headers look good.

    Regarding SD library updates, if you use the IDE to update libraries, it only updates Arduino libraries and not Teensy. The Teensy SD library is at 1.0.8 and installs when you install Teensyduino. https://github.com/PaulStoffregen/SD (what OS are you using?). If there are multiple SD libraries, the IDE should tell you which one it is using.

    Not sure why things worked first and then not any more. You could do an I2C scan of the audio adaptor, but you need to add
    #include <Audio.h>
    AudioOutputI2S audioOutput;

    to the scan sketch to enable the codec. scan should report seeing 0x0a

    You can test the onboard SD with Examples>SD>listfiles (you need to edit to select CS MISO CLK for the audio adaptor)

    I don't know how to do low-level codec tests, maybe look at sketches in Examples>Audio>HardwareTesting or just running Examples>Audio>WaveFilePlayer (assuming you have Paul's WAV files on your SD), or software-generated audio like Examples>Audio>Synthesis>Guitar.
    Last edited by manitou; 05-15-2017 at 07:02 PM.

  6. #6
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by manitou View Post
    OK pins and headers look good.

    Regarding SD library updates, if you use the IDE to update libraries, it only updates Arduino libraries and not Teensy. The Teensy SD library is at 1.0.8 and installs when you install Teensyduino. https://github.com/PaulStoffregen/SD (what OS are you using?). If there are multiple SD libraries, the IDE should tell you which one it is using.

    Not sure why things worked first and then not any more. You could do an I2C scan of the audio adaptor, but you need to add
    #include <Audio.h>
    AudioOutputI2S audioOutput;
    to the scan sketch to enable the codec. scan should report seeing 0x0a

    You can test the onboard SD with Examples>SD>listfiles (you need to edit to select CS MISO CLK for the audio adaptor)

    I don't know how to do low-level codec tests, maybe look at sketches in Examples>Audio>HardwareTesting or just running Examples>Audio>WaveFilePlayer (assuming you have Paul's WAV files on your SD), or software-generated audio like Examples>Audio>Synthesis>Guitar.
    Thanks Manitou, I'll give it a shot and report back. The synthesis idea is a good one.

  7. #7
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by manitou View Post
    OK pins and headers look good.

    Regarding SD library updates, if you use the IDE to update libraries, it only updates Arduino libraries and not Teensy. The Teensy SD library is at 1.0.8 and installs when you install Teensyduino. https://github.com/PaulStoffregen/SD (what OS are you using?). If there are multiple SD libraries, the IDE should tell you which one it is using.

    Not sure why things worked first and then not any more. You could do an I2C scan of the audio adaptor, but you need to add
    #include <Audio.h>
    AudioOutputI2S audioOutput;
    to the scan sketch to enable the codec. scan should report seeing 0x0a

    You can test the onboard SD with Examples>SD>listfiles (you need to edit to select CS MISO CLK for the audio adaptor)

    I don't know how to do low-level codec tests, maybe look at sketches in Examples>Audio>HardwareTesting or just running Examples>Audio>WaveFilePlayer (assuming you have Paul's WAV files on your SD), or software-generated audio like Examples>Audio>Synthesis>Guitar.
    Thanks again for the suggestions manitou, no dice. Looks like the audio adapter is pooched. Kinda sucks considering I've never used it.

    I'm fairly certain my T3.6 will be adequate for what I'm doing, just no preamp on the dac.

    Thanks.

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    Just a quick sanity check, how are you listening to the output of your audio shield?

    The best way for testing is to plug in ordinary headphones. By ordinary, I mean headphones with a wire that goes right to a small speaker next to each ear, not wireless headphones or anything else with other electronics.

    If you test by making a connection to other equipment that is grounded (like your PC or a stereo system), you might be shorting the headphone VGND to earth ground, connected through the USB cable to a grounded PC. That would cause the headphone amplifiers to shut down. Anyone could easily conclude the audio shield doesn't work by doing such a test....

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    Another quick check involves measure the DC voltage on the 3 headphone wires, relative to Teensy's ground. When the audio shield is working (you must run a program which turns it on), all 3 ought to measure approx 1.6 volts DC.

  10. #10
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    Another quick check involves measure the DC voltage on the 3 headphone wires, relative to Teensy's ground. When the audio shield is working (you must run a program which turns it on), all 3 ought to measure approx 1.6 volts DC.
    Hi Paul, thank you for your suggestions. I was using just an ordinary pair of headphones, so I don't think that is it. But I will try your idea of measuring the voltage on the headphone wires. Thanks.

  11. #11
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,696
    Quote Originally Posted by bujbot View Post
    Thanks again for the suggestions manitou, no dice. Looks like the audio adapter is pooched. Kinda sucks considering I've never used it.
    Just to clarify, does "no dice" mean the I2Cscan failed to find 0xa, and the SD listfiles failed to work for the audio adaptor microSD, and none of the audio tests produced any sound ?

    (with the I2Cscan setup with the audio include and instantiation, you should, as Paul noted, see 1.6v on each of the three pads on the ear-bud jack)

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    If testing by I2C, remember the SGTL5000 chip stays in a low power reset mode until a clock signal appears on MCLK.

    Before MCLK starts, no response to any I2C communication is normal. You can't reliably test an audio shield by just using I2C if MCLK hasn't been turned on.

  13. #13
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by manitou View Post
    Just to clarify, does "no dice" mean the I2Cscan failed to find 0xa, and the SD listfiles failed to work for the audio adaptor microSD, and none of the audio tests produced any sound ?

    (with the I2Cscan setup with the audio include and instantiation, you should, as Paul noted, see 1.6v on each of the three pads on the ear-bud jack)
    Hi manitou,

    Sorry for the delay in response. Busy couple of weeks, only able to play on the weekends.

    Yes, I should have been more specific. I ran your code to test the audioboard from here: https://forum.pjrc.com/threads/42814...-shows-nothing

    It scans and finds nothing. "Scanning... done"

    Also, running any of the tutorial examples do not produce any sound (wav's are all on the SD card and are fine, was able to test them on the T3.6)

    I also checked for power on the 3 jack points and got nothing (0.01V to be exact).

  14. #14
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    Another quick check involves measure the DC voltage on the 3 headphone wires, relative to Teensy's ground. When the audio shield is working (you must run a program which turns it on), all 3 ought to measure approx 1.6 volts DC.
    Hi Paul,

    With the audioshield enabled I got 0.01V on the 3 headphone pins.

    I'm assuming this means the codec is no good?

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    That's definitely not good.

    Just above the headphone jack is a 3 pin voltage regulator. It turns 3.3V into 1.8V to power the SGTL5000 digital logic. Can you carefully measure its 3 pins. One should be 0V (ground) and the other 2 should be 3.3V and 1.8V.

  16. #16
    Junior Member
    Join Date
    May 2017
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    That's definitely not good.

    Just above the headphone jack is a 3 pin voltage regulator. It turns 3.3V into 1.8V to power the SGTL5000 digital logic. Can you carefully measure its 3 pins. One should be 0V (ground) and the other 2 should be 3.3V and 1.8V.
    Sure, so I get 0V at ground (and I checked continuity to another ground), 3.3V and 0.15V. Does this necessarily mean that the voltage regulator is the problem? couldn't the SGTL5000 having issues also show something similar?

  17. #17
    Junior Member
    Join Date
    May 2017
    Posts
    10
    I've also just noticed that the audioboard is getting fairly warm when I'm doing these tests. I don't want to damage my T3.6.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,205
    It's time to declare that audio shield dead. 0.15V on the 1.8V regulator output almost certainly means the SGTL5000 chip has been damaged.

  19. #19
    @paul, what do you think is the state of the audio shield when those pins measure 1.4V and 3.3V ?

Posting Permissions

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