audioboard REV d voume pin 15

snowsh

Well-known member
Teensy 4.1
Audio board Rev D

I am designing a board with option to add the rev D audioboard, however I am pin limited.

I dont need the SD card or the memory expansion, so I have omited those connections.

Code:
SD Card	        10, 11, 12, 13	  MOSI, MISO, SCK (other SPI chips)
Memory Chip	6, 11, 12, 13	  MOSI, MISO, SCK (other SPI chips)
Is that OK?

I need to use Serial 3 for other things, no way round this. Can I setup the volume pin on a different pin (not pin 15),if so where is this defined?
Code:
Volume Pot	        15 (A1)	          -
 
Teensy 4.1
Audio board Rev D

I am designing a board with option to add the rev D audioboard, however I am pin limited.

I dont need the SD card or the memory expansion, so I have omited those connections.

Is that OK?
Yes.

I need to use Serial 3 for other things, no way round this. Can I setup the volume pin on a different pin (not pin 15),if so where is this defined?

If you don't want to use the 3 pins on the audio board to connect a potentiometer, just don't connect pin 15. If you do want to use the pins on the audio board, just connect some other pin to the pin 15 slot on the audio board. As I understand it, the audio board just has some capacitors, and such to make using a potentiometer smoother. But those capacitors might interfere with other uses of pin 15 if you don't do an analogRead on pin 15.
 
Yes.



If you don't want to use the 3 pins on the audio board to connect a potentiometer, just don't connect pin 15. If you do want to use the pins on the audio board, just connect some other pin to the pin 15 slot on the audio board. As I understand it, the audio board just has some capacitors, and such to make using a potentiometer smoother. But those capacitors might interfere with other uses of pin 15 if you don't do an analogRead on pin 15.

im thinking the pin 15 connection to the teensy being analogue, is going to allow the teensy to digitally set the volume. Before I wade into the library, I thought I would ask. I doubt I want to use any volume functionality like this, but best to find out while I am designing the PCB
 
im thinking the pin 15 connection to the teensy being analogue, is going to allow the teensy to digitally set the volume. Before I wade into the library, I thought I would ask. I doubt I want to use any volume functionality like this, but best to find out while I am designing the PCB

Well looking at the schematic:
https://www.pjrc.com/store/teensy3_audio.html
schematic_audio3.png

pin 15 goes past a cap into a pot then via a solder bridge (default to GND) to the "ADDR" line (pin 31) on the sgtl500. Looking at the datasheet, https://www.digikey.fr/htmldatasheets/production/3406126/0/0/1/SGTL5000-Datasheet.pdf there is a schematic example where pin 31 is just tied to GND.... I am confused as to how this functions as a volume control line...

Desc of pin 31:

31 CTRL_ADR0_CS Digital I2C Mode: I2C Address
Select 0; SPI Mode: SPI
Chip Select
 
The volume control and ADDR are two completely different circuits, they just happen to be drawn next to each other since they both connect to 3.3V.

The volume control simply feeds an analog input on pin 15 as you would expect. One side of the pot is tied to 3.3V and the other is tied to ground. The cap to ground is presumable there to help filter noise off the line.

The address jumper function simply uses the solder pads to tie the ADDR line either to 3.3V or ground. By default a trace connects ADDR to ground.

As Michael mentioned, just be aware that there is a 0.1uF cap on pin 15 if you repurpose that pin for something else while the Audio adapter is installed. The cap could always be removed if you aren't using that functionality
 
I am confused as to how this functions as a volume control line...

By itself (if you solder a thumbwheel pot), it doesn't. It's just an analog input.

To implement volume control, software needs to repeatedly read the analog input and adjust the volume by configuring the DAC chip or scaling the signal in software. Several of the examples have this sort of code.
 
Paul, I think I see, so the volume change is achived by changing the AGND in some way? Im a bit lost in the analogue side, much more of a programmer but keen to know more about how this works.....
 
Paul, I think I see, so the volume change is achived by changing the AGND in some way? Im a bit lost in the analogue side, much more of a programmer but keen to know more about how this works.....

The Audio library controls the volume in software.
The Analog input is just read to see where it should be set using the software.
 
Paul, I think I see, so the volume change is achived by changing the AGND in some way? Im a bit lost in the analogue side, much more of a programmer but keen to know more about how this works.....

@snowsh:

In this particular case, the two ends of the potentiometer are wired to GND & 3.3VDC. So, as the potentiometer shaft is turned, the voltage on the wiper varies from 0VDC (when the wiper is at the GND end) to 3.3VDC (when the wiper is at the 3.3VDC end). If the wiper is connected to an analog input pin (say, PIN 15) & you call the analogRead(15) function, the return from that function call will be a value between 0 (when the wiper is at the GND end, so that the voltage provided to & thus measured at that pin is 0VDC) & 1023 (when the wiper is at the 3.3VDC end, so that the voltage provided to & thus measured at that pin is 3.3VDC). When the wiper is in the middle of the pot, the return from that function call will be approximately 512, corresponding roughly to a voltage of 1.65VDC provided to & thus measured at that pin. See <this> reference for an explanation of how the analogRead() function can be used.

I hope these few examples of input voltage vs. returned value from the analogRead() function help to clarify how the analog inputs work. From there, you write code that then takes that value returned from the analogRead() function & translates it into how you want to manage the volume on the SGTL5000 audio chip. For example, if you want 3.3VDC to represent full volume, & 0VDC to represent full silence, one possible way to implement this is as follows:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>

// GUItool: begin automatically generated code
AudioSynthWaveformSine   sine1;          //xy=203,233
AudioOutputI2S           i2s1;           //xy=441,233
AudioConnection          patchCord1(sine1, 0, i2s1, 0);
AudioConnection          patchCord2(sine1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=452,162
// GUItool: end automatically generated code

elapsedMillis msec;
int new_volume_input;
int previous_volume_input;

void setup(void) {
  Serial.begin(9600);

  AudioMemory(4);
  previous_volume_input = 0.0;

  sine1.amplitude(1.0);
  sine1.frequency(440);

  sgtl5000_1.enable();
  sgtl5000_1.volume(0.0f);     // set the main volume to fully off

  Serial.println("setup done");
}

void loop(void) {
  if (msec > 100) { // check/change the volume every tenth of a second
    // read the input from the potentiometer
    new_volume_input = analogRead(15);

    // see if the volume input value changed
    if (new_volume_input != previous_volume_input)
    {
      // if so, then save off the new value
      previous_volume_input = new_volume_input;

      // actually set the new volume
      sgtl5000_1.volume((float)(new_volume_input) / 1024.0f);     // set the main volume to the new setting

      // and print the new settings
      Serial.print("Volume input: ");
      Serial.println(new_volume_input);

      Serial.print("Volume level: ");
      Serial.println(new_volume_input);
    }

    msec = 0;
  }
}

Hopefully, this all helps to clarify how to implement volume control on the SGTL5000 audio chip using the analog input from a potentiometer. If not, please feel free to ask more questions !!

Mark J Culross
KD5RXT
 
AHA! got it. I was thinking the volume was set by the SGTL5000, but I see now the Audioboard is just holding a pot and connecting the wiper back to the t4.1 for processing..... How did I not see that! That has been doing my nut.
 
Back
Top