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

Thread: Teensy 3.2 no audio out on dac pin

  1. #1
    Junior Member
    Join Date
    Jun 2018
    Posts
    4

    Teensy 3.2 no audio out on dac pin

    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/English...ter/GyverSaber
    Last edited by Azure Skies; 06-09-2018 at 02:27 PM.

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,589
    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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,475
    Delete this line

    Code:
      pinMode(A14, OUTPUT);
    Also, try running File > Examples > SD > listfiles to make sure Teensy really can access your SD card.

  4. #4
    Junior Member
    Join Date
    Jun 2018
    Posts
    4
    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?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,475
    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.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,475
    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.

  7. #7
    Junior Member
    Join Date
    Jun 2018
    Posts
    4
    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?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,475
    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.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,475
    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....

  10. #10
    Junior Member
    Join Date
    Jun 2018
    Posts
    4
    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!

Posting Permissions

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