Teensy 3.1 DAC audio output

Status
Not open for further replies.

andyclymer

New member
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
 
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.
 
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.
 
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.
 
Hi I'm trying to get that to work. How Exactly do I wire the audio output without the audio shield?
 
Last edited:
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.
 
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).
 
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.
 
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.
 
quick question, can i use external reference for the DAC? i am using 3v external ref for the ADC inputs already.
 
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
 
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)
 
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.

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.
 
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?
 
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.
 
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?
 
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 ?
 
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.
 
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.
 
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?
 
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.
 
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.
 
Status
Not open for further replies.
Back
Top