Trouble with DAC Output Teensy LC

Status
Not open for further replies.

jayackley

Member
Hi All,

I'm having trouble getting audio output on a TeensyLC from the DAC pin. It was bouncing around in my toolbox for a while and if I've damaged it somehow I don't mind replacing it, but it seems to be working otherwise so I'm wondering if anyone had any troubleshooting suggestions.

Specifically, I'm able to get a tone from an 8ohm speaker connected up to the DAC pin with the following code:
Code:
void setup() {
Serial.begin(9600);
pinMode(A12,OUTPUT);
}

void loop() {
tone(A12,220,100);
delay(1000);
}

But the following code (which I found on this forum a while back, and was making a series of alternating tones on this TeensyLC a couple weeks ago), is giving me total silence:

Code:
#include <Audio.h>
#include <Wire.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=418,255
AudioOutputAnalog        dac1;           //xy=582,250
AudioConnection          patchCord1(waveform1, dac1);

// GUItool: end automatically generated code
elapsedMillis sinceFormChange;

// 
//define WAVEFORM_SINE              0
//define WAVEFORM_SAWTOOTH          1
//define WAVEFORM_SQUARE            2
//define WAVEFORM_TRIANGLE          3
//define WAVEFORM_ARBITRARY         4
//define WAVEFORM_PULSE             5
//define WAVEFORM_SAWTOOTH_REVERSE  6
//define WAVEFORM_SAMPLE_HOLD       7
//define WAVEFORM_TRIANGLE_VARIABLE 8

int forms[5] = {WAVEFORM_SINE, WAVEFORM_SAWTOOTH, WAVEFORM_SAWTOOTH_REVERSE, WAVEFORM_TRIANGLE, WAVEFORM_SQUARE};
int currentForm = -1;
void setup() {
  AudioMemory(10);
  sinceFormChange = 2001; // don't wait for the first update
}

void loop() {
  delay(100); // to be replaced with reading pots and switches
  if (sinceFormChange > 2000) {
    waveform1.begin(forms[++currentForm]);
    waveform1.frequency(100);
    waveform1.amplitude(0.8);
    sinceFormChange = 0;
    if (currentForm >= 4) {
      currentForm = -1;
    }
  }
}

I apologize if I'm being dense about something here, but this has completely stumped me two nights in a row and I'd love to be able to have some leads on troubleshooting or go ahead and order a replacement board if that's my best bet.
 
Your second code does generate the 5 waveforms on my Teensy LC pin A12.
I'm afraid you might have killed the A12 pin by loading it with an 8Ω speaker.

Paul
 
Thank you, Paul - for taking the time to test it. Glad to know I'm not imagining things here.

I'm afraid you might have killed the A12 pin by loading it with an 8Ω speaker.

I didn't realize this was a risk, could you (or anyone) point me toward anything that would help me know what are appropriate audio outputs to use with the DAC pin on the TeensyLC?

Thanks again,
Jay
 
The pin might be damaged, but it might also be perfectly fine and you don't hear anything because the DAC has a relatively high output impedance which can't drive enough power into your speaker to be heard.

Most PC computer speakers work fine, since they have an amplifier built in. You should connect a 10 uF capacitor between the plug tip and the A12 pin, just in case the speakers don't like DC voltage offset. Of course connect the plug's sleeve to GND.
 
Thanks Paul, I don't have a 10uF capacitor on hand, but just tried your suggested approach with an amplified speaker and rotated through 47pF, 100pF, 220μF and no capacitor. For each of those the tone() function works just fine, but the waveform1.begin() approach is giving me total silence. Does it make sense that it could be damaged in a way where the A12 works for tone, but the DAC doesn't work even though it's on the 'same' pin?

IMG_4087.jpg

(and I'd be remiss if I didn't take the opportunity to thank you for everything you've done to develop these tools and resources! I'm having an absolute blast with a teensy 3.5 that I'm using to power a homebrew synthesizer)
 
Correct, battery powered speaker and it's able to play sound from the DAC pin on my Teensy 3.5 without a problem. Unless you have any other troubleshooting suggestions I'll plan on replacing the Teensy LC. If you'd be interested I could mail this one back to you guys if you'd like to investigate. Thanks again for everything!
 
To close the loop on this I got a new Teensy LC and the DAC is working as expected. The original must have been damaged somehow. Thanks to those who weighed in.
 
Status
Not open for further replies.
Back
Top