Teensy 3.2 no audio out on dac pin

Status
Not open for further replies.

Azure Skies

New member
Hey Everyone, I have been working on a custom lightsaber and I am using a teensy 3.2 as my controller. I Have an MPU6050 and an sd card reader wired up to my teensy as well as 2 buttons. I have the A+ pin of an Adafruit Mono 2.5W Class D Audio Amplifier (PAM8302) wired into the dac pin of the Teensy 3.2. I am using the Audio Library for Teensy and have set AudioOutputAnalog as dac. I have the teensy successfully reading the sd card however it does not seem to play the wav files off of my sd card. I tried the SamplePlayer sketch as a test and it had no issues playing audio out so Im not too sure whats wrong here.
My code is a rather modified version of the GyverSaber code.

**EDIT **
I have also tried the WavFilePlayer sketch as well but I still do not get any audio out.
**EDIT**
And while I am asking questions, GyverSaber uses a library called toneAC to create a frequency based on the movement of the MPU6050. However toneAC is not compatible with the teensy. Is there some other library I could use to do the same thing and output it to the same pin as the Teensy Audio library?

Here is a pastebin of my modified code: https://pastebin.com/xd9sgmEz

And here is the github for GyverSaber: https://github.com/AlexGyver/EnglishProjects/tree/master/GyverSaber
 
Last edited:
First, forum rule is to post some condensed and simple code which allows everybody to copy and paste it and to reproduce the error. This rule allows people to track down possible error sources before, and to prevent others from wild guessing.
Second, check your setup with an oscilloscope for wiring errors. Can you monitor some signal on the DAC put pin with it?
Third, if you are using the audio library, did you declare enough audio memory? If not, the whole engine will (naturally) remain mute.
 
Delete this line

Code:
  pinMode(A14, OUTPUT);

Also, try running File > Examples > SD > listfiles to make sure Teensy really can access your SD card.
 
So when I removed this line Paul I was able to get one of the SDTEST wavs to play. However I cant get the wav files i intend to use to play. Could it possibly be the audio files themselves?
 
Maybe. First, make sure you have version 1.42. A bug affecting WAV files with extra "junk" sections was recently fixed.

Next, make sure the files are 44.1 kHz and 16 bits. Stereo or mono is ok, but they must be the right sample rate.

If that doesn't do it, you're going to have to show us one of those WAV files.
 
As a final resort, look for SD_t3.h. If you edit that file you can enable a special Teensy SD card optimization. It probably won't matter for this simple one-file player, but if you have multiple WAV files playing simultaneously it can really help.
 
OK!!!! I think I got to the root of the problem! The audio files were not in the correct format! Thank you very much for the assistance Paul! While I am at it is there a way to generate a frequency and output it to the same dac pin used by the audio library?
 
Hope you'll show us a video when the project is done?

While I am at it is there a way to generate a frequency and output it to the same dac pin used by the audio library?

Sure, just put a waveform object in your design and use a mixer to add it to the SD card output.
 
You could also use the a couple of the modulated waveform and use another low frequency sine wave to modulate their phase, for a model of the original light saber....
 
Ohhhhhh!!! Thank you for that Paul! And Sure I can make a video when its done. I hope to show it off on Adafruit's show and tell soon too!
 
Status
Not open for further replies.
Back
Top