Audio issues with Teensy 4.1 + Audio Board

Status
Not open for further replies.

JotaEfe13

Well-known member
I was working in an audio project in Teensy 3.6 with the Audio Board and I decided to migrate it to Teensy 4.1 and the rev. D Audio Board.
I don't know if it may be relevant, but I soldered a PSRAM chip and a Winbond 25Q256JVEIQ flash chip on the Teensy 4.1, and another 25Q256JVEIQ in the Audio Board.

After remapping my connections and updating my code, I am having some issues with the audio.

The first problem is noise when listening from the line inputs, but I have had no time to properly debug this one, so I it may be related to a ground loop of bad connections.

The second one is a high pitch noise when playing audio from the flash chip. I have detected that this problem was related with the ILI9341 display I have in my setup, as the noise disappears then I disconnect the ILI9341 from Teensy's pin 13(SCK). Is there any way to get rid of this noise, other than disconnecting the display, of course.

The last issue is the one that looks more intriguing to me. When I change de volume in the SGTL5000 I hear pops in the right channel, and this wasn't happening in the Teensy 3.6. I ended up removing my Teensy 4.1 from the breadboard (with the audio shield sandwitched) to discard any issue provoked by bad connections and reduced the code to the minimum and the issue persists. Every time I change the volume I hear a pop, louder as I increase the volume. I tried with different headphones and same result.
Here it is my sample code:

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

AudioOutputI2S           i2s1;           
AudioControlSGTL5000     sgtl5000_1;

void setup() {
  sgtl5000_1.enable();
}

void loop() {
  sgtl5000_1.volume(0.5);
  delay(1000);
  sgtl5000_1.volume(0.6);
  delay(1000);
  sgtl5000_1.volume(0.7);
  delay(1000);
  sgtl5000_1.volume(0.8);
  delay(1000);
  sgtl5000_1.volume(0.9);
  delay(1000);
  sgtl5000_1.volume(1.0);
  delay(1000);
}

Only when I remove the AudioOutputI2S object the pops disappear. Is there any known issue related to this, or may it be a problem with this specific Audio Board?

Thanks in advance.
 
Are you talking to the display (ie using SPI bus) when the high pitched noise is audible? Or could it be
the PWM for the LED backlight?

The pops will be a DC offset on the right hand channel I think. Are you sure its getting data - you've not
called AudioMemory so no blocks are being pushed to the DAC I think...
 
Are you talking to the display (ie using SPI bus) when the high pitched noise is audible? Or could it be
the PWM for the LED backlight?

No, I am not talking to the display. In fact I have tested this simple sketch that is doing nothing with the display really, and the sound is present.


Code:
#define VOL_HEADPHONES_PIN  A3

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SdFat.h>                    
#include <SerialFlash.h>
#include <Bounce.h> 
#include <ILI9341_t3.h>            

AudioPlaySerialflashRaw  playSfRaw1;   
AudioOutputI2S           i2s1;           
AudioConnection          patchCord1(playSfRaw1, 0, i2s1, 0);
AudioConnection          patchCord6(playSfRaw1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     

const int FlashChipSelect = 6;

// Audio shield rev D (Teensy 4.x)
const int FLASH_SCK_PIN = 13;
const int FLASH_MOSI_PIN = 11;

const int TFT_CS_PIN = 10;
const int TFT_RST_PIN = 255;  // 255 = unused, connect to 3.3V
const int TFT_DC_PIN = 9;
const int TFT_MOSI_PIN = 26; //11;
const int TFT_SCLK_PIN = 13;
const int TFT_MISO_PIN = 1; //12;

float volHeadphone = 0.5;

Bounce btnA = Bounce(4, 20);
Bounce btnB = Bounce(5, 20);
Bounce btnC = Bounce(24, 20);

ILI9341_t3 tft = ILI9341_t3(TFT_CS_PIN, TFT_DC_PIN, TFT_RST_PIN, TFT_MOSI_PIN, TFT_SCLK_PIN, TFT_MISO_PIN);

void setup() {
  AudioMemory(60);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  SPI.setSCK(FLASH_SCK_PIN);
  SPI.setMOSI(FLASH_MOSI_PIN);

  Serial.begin(9600);

  // wait up to 10 seconds for Arduino Serial Monitor
  unsigned long startMillis = millis();
  while (!Serial && (millis() - startMillis < 10000)) ;
  delay(100);

  if (!SerialFlash.begin(FlashChipSelect)) {
    Serial.println("Unable to access SPI Flash chip");
  }
  delay(1000);

  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(24, INPUT_PULLUP);
}

void loop() {
  btnA.update();
  btnB.update();
  btnCl.update();

  if (btnA.fallingEdge()) {
    playSfRaw1.play("A1L.RAW");
  } 

  if (btnB.fallingEdge()) {
    playSfRaw1.play("A2L.RAW");
  }

  if (btnC.fallingEdge()) {
    playSfRaw1.play("A3L.RAW");
  }
}

I was using pins 11 and 12, but I changed them to check if that was the problem, as they are used by the Audio Board too.

As for the backlight I tried removing the connection for this pin without success, but I don't know if that is a good way of checking it.

The pops will be a DC offset on the right hand channel I think. Are you sure its getting data - you've not
called AudioMemory so no blocks are being pushed to the DAC I think...

I removed the AudioMemory allocation in the sketch I posted as I was reducing my code iteratively to see if I could catch any error in it.

What sounds weird to me is that I am using the Teensy and the Audio Board directly, no more hardware. So how could I solve it in case this is the issue?


Thank you for your help.
 
For the popping are you sure the audio stream to the SGTL is getting all zeroes when you change volume? If so and the
RH channel is popping that's the chip itself, not a discontinuity in data. Not surprized it happens, am surprized it only
happens in one channel. I think some analog programmable VGA's are involved for the volume control.

If you want the best audio quality you do need a separate DAC with separate analog supply and differential outputs, all
on a nice quiet PCB well away from digital noise - The SGTL5000 is trying to do too many things and the Audio shield
doesn't have separate supply for analog and digital so its bound to leak some digital hash into the output.

Having the µSDcard socket on the Audio shield is going to inject lots of noise spikes into the supply alas. The SGTL5000
is a compromise for mobile phones etc where you cram as much as possible into a single chip.
 
Hi MarkT, thank you for your insights. Not sure how to check if is getting all zeroes, I'll have to check it.

I thought about creating my own audio circuit in a PCB, but frankly I wouldn't know where to start. I guess I could try learning how to create a proper design.
 
Or convert to SPDIF/toslink output. Then you have all digital up to a point with no electrical link.
 
I believe that, in the video introduction to this audio board, they said that the total for the volumes should equal 1. That i to say, that if you use 4 calls to volume, they should each be: .25 (.25 X 4 = 1).

I can't say for sure, but I think I saw that in the video found here: https://www.pjrc.com/teensy/td_libs_Audio.html. The video is labeled: "Teensy Audio Tutorial and Workshop".

Hope this helps.
 
Thank you for your reply Rob.
I think what you are refering to is gain values for sounds playing simultaneously. In this case what I am changing is the global volume, so there is no sum in gains.
 
Your unwanted audio issues remind me of a couple things. I was getting unwanted noise when no sound was playing, until I used the method:
Code:
  sgtl5000_1.adcHighPassFilterDisable();
after disabling that filter, I stopped getting a constant feedback after using certain effects when the sound was then idle. I don't know if it will help you, but I was very thankful to find someone mentioning it.

Also, I see a lot of old threads with people having frustration with older teensy boards when they would use an external SD card reader over SPI. When the teensy was reading sound files from SPI it would introduce noise into the audio stream. This seems to have troubled people for a while until later versions came out with an on-chip sd card slot. The only solution I ever saw for people having this problem was using a teensy with onboard sd, I never saw anyone mention resolving it by another method in the threads I was looking at when trying to solve my own issue (the one I ended up solving with the filter disable method from earlier). Your problem reminds me of what they were saying, that it's only introduced when the SPI line is active, they were able to do numerous other things without the audio feedback, except read over SPI from sd (and in your case, use the display over SPI).

I hope you're able to solve the issue!
 
Hi, Sandwich.

Indeed I am using the adcHighPassFilterDisable method in my current project. The reason it is not present in the sketch I posted is because I tried to reduce the code as much as I could to discard an error in my code as the cause of the issue. As for the SD card, the problem was present using both the internal reader and the audio board reader, so no luck with that.

Nevertheless, thank you very much for your insights.

Finally I ordered dedicated ADC and DAC boards, as suggested above, so I hope when they arrive and I can test them the noises I get disappear/decrease.
 
Hi

I am a complete newby to teensy's myself, so I dont know if this will help, but the teensy Bat Recorder project (using a 3.6 and audio shield) had problems with noise that were largely cured by using a separate 3.3V regulator for the audio and ttensy boards, rather than sharing the 3.3V line. If you use the same 3.3V for both it might be worth looking at.
 
Hi

I am a complete newby to teensy's myself, so I dont know if this will help, but the teensy Bat Recorder project (using a 3.6 and audio shield) had problems with noise that were largely cured by using a separate 3.3V regulator for the audio and ttensy boards, rather than sharing the 3.3V line. If you use the same 3.3V for both it might be worth looking at.

Looks interesting. I will have a look at it.

In fact I have followed that thread, as it is a very interesting project, but I might have missed that, or I read it in the past but I didn't remember it.

Thank you.
 
@JotaEfe13
Not sure if you have the display hooked up when your having this problem. I see a 'ILI9341_t3 tft = ILI9341_t3(T...'
If the display is hooked up then you must do 'tft.begin();' in setup() and also instantiate 'XPT2046_Touchscreen ts(T_CS, T_IRQ);' and corresponding ts.begin();
If they are hooked up, even if you don't use them they will be in a weird state until initiated with begin(). Ive had this issue many times and it took a while to figure out. I thought I posted somewhere about it but can't find it.
 
Status
Not open for further replies.
Back
Top