Teensy 3.1 audio Volume not working in custom PCB

Status
Not open for further replies.

zachtos

Well-known member
Strange issue, my custom PCB will not change volume via normal software process in Wave Playback example. Just using the sample audioWavPlayback example, nothing fancy... Plays back fine, but the lineout to the amplifier circuit does not change intensity with the volume() command now.

sgtl5000_1.volume(0.1); //0 to 1, no effect, volume still remains full!!!!
sgtl5000_1.lineOutLevel(29); //13 to 31 - no real effect here, does get very distorted at low numbers, higher sounds the better but still full volume
sgtl5000_1.dacVolume(0.99); //this one does work, but I lose the ability to control mixer gains!!! What is going on? Also, this "loses resolution???"

Perhaps the gain on my amplifier circuit is too high? No idea what's going on or where to trouble shoot. It's not distorted though, so not sure why it would be gain...

(using most recent teensyduino and Arduino 1.06, windows 8.1, audio library 1.02)
 
Last edited:
Double check those extra capacitors, especially the one on pin 10 (VAG).

If you've got opamps and other circuitry, try disconnecting that stuff (or build another PCB without those parts) and test with the signals as they exist on the audio board, to at least narrow down where the problem is.
 
OK, thanks. Mixer does work and dacVolume, but not volume(). At least I know it's a hardware issue. I checked pin10, just using standard non electrolytic thin film SMD 0.1uF, tried adding another in parallel, no difference. Here is the schematic. Kind of stumped at this point why volume() does not work. (did not check gain calculations yet for amp input)

audio_circuit.jpg
 
This is as expected. From the documentation on volume (scroll down):
volume(level);

Set the headphone volume level. Range is 0 to 1.0, but 0.8 corresponds to the maximum undistorted output for a full scale signal. Usually 0.5 is a comfortable listening level. The line level outputs are not changed by this function.

and similarly for
lineOutLevel(both);

Adjust the line level output voltage range. The following settings are possible:

Code:
13: 3.16 Volts p-p
14: 2.98 Volts p-p
15: 2.83 Volts p-p
16: 2.67 Volts p-p
17: 2.53 Volts p-p
18: 2.39 Volts p-p
19: 2.26 Volts p-p
20: 2.14 Volts p-p
21: 2.02 Volts p-p
22: 1.91 Volts p-p
23: 1.80 Volts p-p
24: 1.71 Volts p-p
25: 1.62 Volts p-p
26: 1.53 Volts p-p
27: 1.44 Volts p-p
28: 1.37 Volts p-p
29: 1.29 Volts p-p  (default)
30: 1.22 Volts p-p
31: 1.16 Volts p-p

So - the SGTL5000 provides an analog control over the built-in headphone amplifier volume, and provides output level trimming for the line level output (to match an expected full-scale voltage). It does not provide analog volume control over the line-level outputs. So you have two options

1) control the volume in the digital domain, using dacVolume. This involves some loss of resolution, for example dacVolume(0.5) reduces resolution to 15 bits while dacVolume(0.125) reduces it to 13, and so on.
2) control the volume in the analog domain, with circuitry after the line outs. Options vary from an analog pot before your output buffer, to a VCA chip, to a digital pot controlled by the Teensy.

For the first option, again the documentation is helpful
dacVolume(both);

Normally output volume should be used with volume(), which changes the analog gain in the headphone amplifier. This function on the other hand controls digital attenuation before conversion to analog, which reduces resolution, but allows another fine control of output signal level. The ranges is 0 to 1.0, with the default (no digital attenuation) at 1.0.

dacVolume uses zero-crossing detect to avoid clicks, and ramping is handled by the chip so that a new volume may be set directly in a single call.
 
Last edited:
sgtl5000_1.dacVolume(0.99); //this one does work, but I lose the ability to control mixer gains!!!

If you could post a short, complete example demostrating loss of control of mixer gains when dacVolume is used, that would help with debugging.
 
So - the SGTL5000 provides an analog control over the built-in headphone amplifier volume, and provides output level trimming for the line level output (to match an expected full-scale voltage). It does not provide analog volume control over the line-level outputs. So you have two options

1) control the volume in the digital domain, using dacVolume. This involves some loss of resolution, for example dacVolume(0.5) reduces resolution to 15 bits while dacVolume(0.125) reduces it to 13, and so on.
2) control the volume in the analog domain, with circuitry after the line outs. Options vary from an analog pot before your output buffer, to a VCA chip, to a digital pot controlled by the Teensy.

For the first option, again the documentation is helpful

I was mistaken regarding mixer gains, those do work, but as you said, only dacVolume() works for line output volume control to the amplifier circuit.

Thank you for the help so far though! very close to this product release.

The dacVolume() and mixer gain control will work for my volume regulation needs then in this case. Line level control only distorts the sound if I add more gain, and it's all the way down already (depends on amplifier of course). Adding more circuitry (cost sensitive) is probably not an option. I could choose a different amplifier possibly if needed, but mixer gain seems to work well enough.

Any idea what the actual resolution loss is for dacVolume()??? 15 bit is fine (0.5 to 1.0 works for me very well).

Also assuming since dacVolume is handled in the SGTL5000 chip so should not affect my CPU load when mixing multiple wave files?
 
Hi all,

I have not connected any extra audio board and I'm using just DAC of teensy 3.2, kindly let me know how to adjust the DAC volume level of teensy 3.2.
 
I'm using just DAC of teensy 3.2, kindly let me know how to adjust the DAC volume level of teensy 3.2.

You can't adjust the volume directly in hardware, like you can with the SGTL5000. That's one of the many awesome features you get with a dedicated codec chip like SGTL5000, which simply aren't built into the on-chip DAC.

You can change from 1.2Vp-p to 3.3Vp-p levels with dac1.analogReference(EXTERNAL) and dac1.analogReference(INTERNAL).

If you need finer volume control, you will have to use a mixer in your design. Feed the final audio into one of the mixer inputs, and connect the mixer to the DAC. Then you can use the mixer gain(channel, level) function to change the volume.
 
Status
Not open for further replies.
Back
Top