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

Thread: Audio Player with External Battery Inconsistency

  1. #1
    Junior Member
    Join Date
    Mar 2020
    Posts
    6

    Audio Player with External Battery Inconsistency

    Hello,

    I am currently using a teensy 3.6 with 2 of these amplifiers to drive two 8 ohm speakers. They teensy is being powered by a voltage controlled LiPo battery outputting around 4V (voltage controllers). When I play a wav file, sometimes the audio cuts out or cuts to a lot of static. The teensy also stops accepting input from the pins (at least the button that I have connected stops working and serial communication is also stopped). I also checked to see if audio would continue through a usb connection, after these occurrences, but that also does not happen. However, the teensy as a whole stays on. This happens with much more frequency when the teensy is connected only to the external power source. Right now, it happens consistently about 2 seconds after a wav file starts playing. I have however had times when it has worked through only the external battery, but they are rare.

    I originally thought that it might have to do with the clock speed either drawing too much current or too little current, so I tried running the teensy at both 16MHz and 180MHz, however neither seemed to solve my problem. I also thought it might have to do with a loose connection somewhere leading one of the amplifiers drawing more current that it was supposed to, but after resoldering everything, the problem was still there. I thought it might be an audio memory problem with me not giving enough memory. So I increased the memory, and the problem was still there. I then thought it might be a problem with the teensy running at lower clock speeds because of a voltage input of less than 5V, so I tried to change that but I could not find information on forcing clock speeds on the teensy 3.6 (I only found it for the teensy 2.x and lc). I have attached the code (which I know is pretty bad), voltages from the battery (second image is while charging), and videos of the problem (and one of the teensy working when the battery is being charged). The videos are stored here, because I can't upload them. If you would like me to take pictures of the soldering in more detail (at great embarrassment to myself), I would be happy to do so.

    Thanks for all the help in advance.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    AudioPlaySdWav           playWav1;
    AudioOutputUSB           audioOutput;
    AudioOutputAnalog        dac;
    AudioConnection          patchCord1(playWav1, 0, audioOutput, 0);
    AudioConnection          patchCord2(playWav1, 1, audioOutput, 1);
    AudioConnection          patchCord3(playWav1, 0, dac, 0);
    
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    
    const int ledPin = 13;
    
    void setup() {
      Serial.begin(9600);
      pinMode(A8, INPUT);
      pinMode(15, INPUT);
      pinMode(14, OUTPUT);
      digitalWrite(14, HIGH);
      pinMode(12, INPUT_PULLUP);
      pinMode(ledPin, OUTPUT);
      digitalWrite(ledPin, HIGH);
    
      AudioMemory(100);
    
      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);
        }
      }
    }
    
    void playFile(const char *filename)
    {
      if(!playWav1.isPlaying()) {
        playWav1.play(filename);
      }
      else {
        playWav1.stop();
        playWav1.play(filename);
      }
    }
    
    bool checkButton(int val) {
      if (val == 1023) {
        return true;
      }
      else {
        return false;
      }
    }
    
    String getFile (int val) {
      
      int a = round(val/46.5) + 1;
      return (String(a) + ".WAV");
    }
    
    void loop() {
    
      if (checkButton(analogRead(15))) {
        playFile(getFile(analogRead(A8)).c_str());
        Serial.println(getFile(analogRead(A8)));
      }
      delay(1000);
    }
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Battery_Voltage.jpg 
Views:	1 
Size:	85.3 KB 
ID:	19370   Click image for larger version. 

Name:	Battery_Voltage_Charging.jpg 
Views:	1 
Size:	72.5 KB 
ID:	19371  

    Attached Files Attached Files

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,578
    Try to re-format the SD card with the official formatter: https://www.sdcard.org/downloads/formatter/

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,979
    Not sure if it is confusing anything but using the BUILTIN:
    Code:
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    These lines seem like they should be removed:
    Code:
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);

  4. #4
    Junior Member
    Join Date
    Mar 2020
    Posts
    6
    Thanks for the response.

    I reformatted the SD card, and unfortunately it has not solved the problem. I would like to point out again that problem does not usually happen with the battery is being charged, and in my research I think I found something that said the teensy has an auto shut off function if too much current is being drawn. I don't know if this is true or not but I think the problem is is somehow related to power draw.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,979
    If power caused the Teensy to shutdown - it would come back with a restart.

    I suppose there would be a bigger voltage drop if it was drawing too much current. Perhaps monitor the 3.3V output from the Teensy - but a meter may be too slow to show true behavior.

  6. #6
    Junior Member
    Join Date
    Mar 2020
    Posts
    6
    I have also removed those lines of code, and the darn problem persists.

  7. #7
    Junior Member
    Join Date
    Mar 2020
    Posts
    6
    If power caused the Teensy to shutdown - it would come back with a restart.
    That is what really has me thrown off. The built-in led stays on. I should also say that when I do restart the teensy, I can restart the audio to have it turn off again.

    I tried to monitor the output, and there may have been a slight drop to 3.28, around the time of audio cut off, but I'm gonna chalk it up to randomness.

    Also to clarify what I meant about the auto shut off function, I read that the audio from the on board DACs may be cut if there is not a high enough speaker impedance or there is too much current draw from the DACs.

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,578
    Quote Originally Posted by sachiniyer View Post
    I read that the audio from the on board DACs may be cut if there is not a high enough speaker impedance or there is too much current draw from the DACs.
    Do NOT connect speakers directly to the DACs. They are not built for that. You need amplifiers.
    If you like your Teensy, don't do it

  9. #9
    Junior Member
    Join Date
    Mar 2020
    Posts
    6
    Quote Originally Posted by Frank B View Post
    Do NOT connect speakers directly to the DACs. They are not built for that. You need amplifiers.
    If you like your Teensy, don't do it
    Quote Originally Posted by sachiniyer View Post
    I am currently using a teensy 3.6 with 2 of these amplifiers to drive two 8 ohm speakers.
    Yup . I have to be honest and say that I originally did this, and I could hear the life being sucked out of the board. I guess I was referring to amplifier impedance if that is even a thing.

  10. #10
    Junior Member
    Join Date
    Mar 2020
    Posts
    6
    I also just went to check the voltage controllers to see if they had any specs I should be worried about, and it seems like there is a "3A over-current protection current". Could this be the source of my issue?
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Voltage Controllers.png 
Views:	1 
Size:	24.9 KB 
ID:	19377  

Posting Permissions

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