Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 26

Thread: Teensy 3.1 DAC audio output

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    2

    Teensy 3.1 DAC audio output

    Hi Everyone,

    A bit of background: I have some experience with the Arduino and I've recently taken a rudimentary electronics class, but I'd like to talk through some questions for a small project that I want to put together using the Teensy 3.1.

    Question: What would I need to do to get a signal from the Teensy 3.1's DAC A14 pin to a line level that a mixing board could pick up? Will Teensy's 5 volts be enough to simply connect this pin and the ground on that same side of the board directly into a mixer, or should I consider putting together a simple amplifier (an op-amp I'm guessing?)

    From what I've read on the Audio Library forum is that I can probably accomplish what I'm looking for with the Audio Shield, but that I believe I should be able to expect to easily write a signal out to the the DAC on pin A14. Does this sound right?

    My goal is to just produce some simple FM synthesis, and I only need one channel of output, so I'd like to try to do it without the shield.

    Any advice would be greatly appreciated, or even just a confirmation that my expectations are right (that I can use the Audio library to send a signal out A14 and right into a mixer without any other amplification).

    Thank you!
    Andy

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,108
    The difference between what the audio shield puts out of it's line out, and what the onboard Teensy 3.1 puts out, is that the onboard DAC values are unipolar (they go from 0V to some positive voltage, e.g. 3V3 if the voltage rail is used as the reference). So the "middle" of the waveform is offset by half that voltage. This DC offset may give problems with your mixer. (I say may because mixer microphone inputs are AC coupled to get rid of the 48V phantom power used with condenser microphones, and because many budget and some midrange mixers implement 'line in' with a resistive pad followed by the mic preamplifiers. So some mixers are not troubled by a DC offset on line in).
    A way to deal with that is to use an op-amp non-inverting unity gain buffer. Using a pair of identical value resistors (e.g. 10k), send half of the DAC maximum voltage (i.e. the DC offset) to the negative input of the op-amp, which needs to be powered with a bipolar (+ and -) supply. Now you have an audio signal with no DC offset.
    Alternatively, you can use a capacitor to block DC.

    I believe that the Audio library can be used with Teensy 3.1 DAC output, as well as with external DACs. So the programming of your FM synthesis should be orthogonal to the choice of output device.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    You can probably just use a 1 to 10 uF capacitor. Connect the + side to DAC/A14 and the - side to your mixer's input.

    The audio library does support output to the DAC. See the PlayFromSketch example, which sends output to both the I2S and DAC.

    A small amount of ultrasonic (above 22 kHz) content will be present on the DAC output, because it's updating at 44.1 kHz with 12 bit resolution. If that's a problem for your system, you'd need a filter to remove it, which probably involves at least an opamp and other parts.

  4. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Hi Nantonos and Paul, this is such a helpful and clear description, thanks so much! I think I have a pretty good starting point now.

  5. #5
    Hi I'm trying to get that to work. How Exactly do I wire the audio output without the audio shield?
    Last edited by poltergeist; 01-28-2014 at 11:22 AM.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Quote Originally Posted by poltergeist View Post
    How Exactly do I wire the audio output without the audio shield?
    The simplest way requires just one 10 uF capacitor. Connect the + side of the cap to the DAC/A14 pin. Connect the - side to whatever will receive the audio. Connect the GND pin on Teensy to the ground on the whatever receives the audio.

    The DAC is capable of driving a line-level input, like the input to amplified computer speakers. It is not meant to directly drive headphones or speakers.

  7. #7
    i can't seem to get any signal..

    do i need to change something in the code to get the DAC output?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Quote Originally Posted by poltergeist View Post
    do i need to change something in the code to get the DAC output?
    Are you running the PlayFromSketch example? It only creates sound when the 6 pushbuttons are pressed. Did you connect any buttons to those 6 pins, and are you pressing them?

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Another quick sanity check is the DAC should have about 1.65 volts DC when configured for audio output with no actual sound playing. If it measures 0 volts DC, then something is wrong with the hardware. If you get 1.65V, it's probably working but no sound is playing.

    Obviously measure this at the DAC pin. The purpose of the 10 uF capacitor is to block that 1.65V from going into your amplifier (or whatever will amplify and output the sound).

  10. #10
    it measures around 0.8v to 1.05v

  11. #11
    Junior Member
    Join Date
    Apr 2014
    Posts
    5
    I'm playing audio from an SD card. It plays, but sounds very tinny (no bass). There's also a hum in the lower frequencies. I've added a 10uF cap (electrolytic) as suggested. Without it I have the same problem.

    Any help would be much appreciated.

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Quote Originally Posted by nicnic View Post
    It plays, but sounds very tinny (no bass). There's also a hum in the lower frequencies. I've added a 10uF cap (electrolytic) as suggested.
    From only this info, I'm guessing this may be a grounding issue. Is whatever amplifier you're using to drive the speaker really getting a proper ground? Maybe a photo of the wiring might help us to see what's wrong.

  13. #13
    quick question, can i use external reference for the DAC? i am using 3v external ref for the ADC inputs already.

  14. #14
    Member
    Join Date
    Aug 2014
    Location
    Anaheim CA
    Posts
    21
    You would be better off checking the grounds as per Paul's advice. That is firsat and second would be the value of the coupling capacitor... and it's polarity as well..
    The + end Must go to the DAC output. and the ground between the speaker driver and the DAC output... Both are critical.

    Doc

  15. #15
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Hi, any update on this?

    I can read this from the datasheet but what does it actually mean? Can you connect in-ear headphones or a "tiny" speaker directly?

    • HP Output - 45 mW max into 16 ohm load @ 3.3 V
    • HP Output - 100 dB SNR (-60 dB input) and -80 dB THD+N (VDDA = 1.8 V, 16 ohm load, DAC to headphone)
    • LINEOUT - 100 dB SNR (-60 dB input) and -85 dB THD+N (VDDIO = 3.3 V)

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Quote Originally Posted by neutron7 View Post
    quick question, can i use external reference for the DAC? i am using 3v external ref for the ADC inputs already.
    Yes, the on-chip DAC can use the AREF voltage. In the audio library, use dac1.analogReference(EXTERNAL), where "dac1" would be the name of the AudioOutputAnalog object for the DAC.

    Quote Originally Posted by nop View Post
    Can you connect in-ear headphones or a "tiny" speaker directly?
    No, the DAC is not rated for more than 1 mA output.

    However, you can connect anything you want, but it might damage the hardware. I tried it here some time ago. It didn't seem to damage the Teensy 3.1, and I did get a tiny bit of audible output. The output seemed to work fine when I reconnected it to amplified speakers.

    Still, connecting a low impedance load like headphones or a speaker is way outside the spec and should not be done.

  17. #17
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Thanks Paul, I stumbled into this thread and confused the internal Teensy 3.1 DAC and the Audio board DAC.

    The specs I posted above was from the SGTL5000 which can drive headphones, right?

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Quote Originally Posted by nop View Post
    The specs I posted above was from the SGTL5000 which can drive headphones, right?
    Oh, I misunderstood your question. The rest of this thread seemed to be about the Teensy 3.1's DAC, labeled "A14/DAC" on the reference card.

    Yes, the audio shield based on SGTL5000 has 2 outputs, a headphone jack meant to drive 33 ohm headphones, and a line-level out meant for high impedance.

  19. #19
    Junior Member
    Join Date
    Oct 2014
    Posts
    1
    Hey Paul,
    Sorry to resurrect this dead thread but I'm interested in generating audio with the DAC and the PlayFromSketch example seems to have disappeared. Any chance I could get a copy of it? Also, just curious, are you planning on implementing the on-board DAC into the Audio library?

  20. #20
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    Hi Paul,
    I am new to this forum and not sure if this queston was addressed already.

    I just purchased a Teensy 3.1 with the intention to use the onboard DAC for generating sweep tones and just realized that "AudioSynthToneSweep" is designed for the audio adapter board. Is there a library that does have this function ?

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    The audio library is a collection of objects you can connect together in almost any way. It's not a fixed purpose library that works with only one type of output hardware. You can simply connect the signal to a DAC object to get the sound on the DAC pin, or to the I2S object to send to the audio board, or to a PWM object, or to any combination of these.

    See File > Examples > Audio > SamplePlayer for an example. It sends the audio to both the DAC pin and Audio board simultaneously.

  22. #22
    Junior Member
    Join Date
    Feb 2015
    Posts
    3
    Quote Originally Posted by PaulStoffregen View Post
    The audio library is a collection of objects you can connect together in almost any way. It's not a fixed purpose library that works with only one type of output hardware. You can simply connect the signal to a DAC object to get the sound on the DAC pin, or to the I2S object to send to the audio board, or to a PWM object, or to any combination of these.

    See File > Examples > Audio > SamplePlayer for an example. It sends the audio to both the DAC pin and Audio board simultaneously.

    Great. Thanks a lot for the prompt response and excellent support.

  23. #23
    Junior Member
    Join Date
    Feb 2016
    Posts
    13
    Sorry to resurrect this thread again but it seems like a good place to ask the question. I want to use the talkie library which outputs to the DAC pin. Can this be used as a sound source with the Audio Board/Audio Library? ie can you use the DAC pin as a line-in device? Or am I thinking about it wrong?

  24. #24
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,273
    The Talkie library does not use the general Audio library. From the source, it looks like it is made to run on various microprocessors. I imagine if you go through and recode it to use the Audio library, it would work as you want.

  25. #25
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,606
    Yeah, you could probably connect the DAC pin to the line in pin on the audio shield. You might need to use a couple resistors to reduce the voltage, or edit Talkie slightly to use the internal 1.2V reference for the DAC so it generates a smaller signal.

Tags for this Thread

Posting Permissions

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