External Speaker & Audio Shield Question

Status
Not open for further replies.

josephcesario

New member
Hi everyone -- I'm sure this is a very novice question but I'm having some problems playing a sound through external speakers, using Teensy 3.2 plus audio shield. I just want one of two songs to play when a button is pressed. (Code is pasted below.) Everything works perfectly fine when I play through the headphone jack of the audio shield, so I'm pretty sure the problem isn't the code. The problem is when I try to get it to play through the external speaker.

Circuit looks like this:

circuit.png

The speaker outputs just a loud fuzz noise. You can barely make out the song being played when the button is pressed, but the loud noise is just constant.

I've tried with a 4ohm 20w speaker and a 8ohm 3w speaker. Same problem with both. Also tried with 100k instead of 4.7k resistors going into the op amp. Didn't change the problem at all.

I've searched the forum (e.g.,
HTML:
https://forum.pjrc.com/threads/55720-Using-LM386-audio-amp-with-audio-shield-line-out
) and other online help. One problem I'm having is that the other examples I'm seeing are using the LM386 whereas I have the TLV2462 (
HTML:
https://cdn-shop.adafruit.com/datasheets/tlv2462.pdf
and
HTML:
https://www.adafruit.com/product/808#technical-details
), and I suspect that me not fully understanding this op amp is one major source of the problem.

Any help would be greatly appreciated, thank you!!

IMG_3155.jpg


Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>

// WAV files converted to code by wav2sketch
#include "AudioSampleCucaracha.h" 
#include "AudioSampleTarantellalow.h"      

// Create the Audio components.  These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioPlayMemory    sound0;
AudioPlayMemory    sound1;  // six memory players, so we can play
AudioMixer4        mix1;    // two 4-channel mixers are needed in
AudioOutputI2S     headphones;
AudioOutputAnalog  dac;     // play to both I2S audio board and on-chip DAC

// Create Audio connections between the components
//
AudioConnection c1(sound0, 0, mix1, 0);
AudioConnection c2(sound1, 0, mix1, 1);
AudioConnection c8(mix1, 0, headphones, 0);
AudioConnection c9(mix1, 0, headphones, 1);
AudioConnection c10(mix1, 0, dac, 0);

// Create an object to control the audio shield.
// 
AudioControlSGTL5000 audioShield;

// Bounce objects to read six pushbuttons (pins 0-5)
//
Bounce button0 = Bounce(0, 5);
Bounce button1 = Bounce(1, 5);  // 5 ms debounce time

void setup() {
  // Configure the pushbutton pins for pullups.
  // Each button should connect from the pin to GND.
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(10);

  // turn on the output
  audioShield.enable();
  audioShield.volume(0.5);

  // by default the Teensy 3.1 DAC uses 3.3Vp-p output
  // if your 3.3V power has noise, switching to the
  // internal 1.2V reference can give you a clean signal
  //dac.analogReference(INTERNAL);

  // reduce the gain on mixer channels, so more than 1
  // sound can play simultaneously without clipping
  mix1.gain(0, 0.4);
  mix1.gain(1, 0.4);
}

void loop() {
  // Update all the button objects
  button0.update();
  button1.update();
  
  // When the buttons are pressed, just start a sound playing.
  // The audio library will play each sound through the mixers
  // so any combination can play simultaneously.
  //
  if (button0.fallingEdge()) {
    sound0.play(AudioSampleCucaracha);
  }
  if (button1.fallingEdge()) {
    sound1.play(AudioSampleTarantellalow);
  }

}
 
Your chip is rated for 6V max poower, and you have a 9V battery. Already not good news.

Your amp is an op-amp, not a power amp. It needs gain and feedback resistors in order to set closed loop gain, otherwise it's just a fast comparator swinging wildy from fail to rail. You need an lm386, or my favorite a tda2822. But most importantly, learn how op amps work. Dave Jones has a great video on this on youtube "eevblog."
 
Status
Not open for further replies.
Back
Top