Audio Player with External Battery Inconsistency

Status
Not open for further replies.
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);
}
 

Attachments

  • Code.cpp
    1.5 KB · Views: 53
  • Battery_Voltage.jpg
    Battery_Voltage.jpg
    85.3 KB · Views: 55
  • Battery_Voltage_Charging.jpg
    Battery_Voltage_Charging.jpg
    72.5 KB · Views: 62
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);
 
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.
 
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.
 
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.
 
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 :)
 
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 :)

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.
 
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?
 

Attachments

  • Voltage Controllers.png
    Voltage Controllers.png
    24.9 KB · Views: 89
I know this is a very old thread, but in case anyone ran into the same problem that I had, the audio inconsistency happened because the pins themselves were faulty. This was nobody's fault but my own, and I think it most likely happened because I was running the speakers straight from the DAC pins at the start (overdrawing current and killing the pins). I think maybe then when I tried to run with amplifiers the pins were already damaged enough to cause this inconsistency (which was getting worse over time). Either way, I am pretty sure it was a result of my own initial stupidity. So, if you are wondering what the real consequences of running your speakers straight from the board were, let me be an example.

As soon as a changed to another teensy, everything worked like a charm.
 
Drawing high current can cause CMOS latch-up, perhaps damaged pins can lead to a tendancy for spontaneous latch-up? Only removing power
can get you out of latch-up.
 
After trying my best to understand, it seems like a very convincing idea:

1. There was an increase in heat from the DAC pins
2. It is wholly possible that the latch-ups would happen when current had been drawn for a little bit of time and the pins heat up just slightly for the latch-up to occur
3. Nothing could get the pins back except restarting
4. The loud buzzing sound and no sound results would make sense with the latch-up prevention circuitry either working/failing in the teensy (either completely filling the audio line, or stopping all data)


The only question I have is why latch-ups would happen less often when I gave the teensy more voltage (when charging the battery). From what I understand, more voltage means that there will be a greater current draw and a subsequent likelihood for latch-ups. Maybe it was the voltage instability in the battery that caused the latch-ups. Or, it might be that the amplifiers, when they were receiving less voltage, were drawing more current leading to latch-ups more quickly, rather than when they were receiving more voltage and did not have to draw as much current from the pins to meet their power specifications. This also makes sense in that when I turned the volume on the amplifiers down, latch-ups did not happen, or took longer to happen.

I will say though that it's amazing that the latch-ups happened after a few seconds, and not immediately. It is very interesting that the latch-ups would be so specific to a temperature that you could almost guess when it was going to happen.
 
Status
Not open for further replies.
Back
Top