Jigglypuff
Member
Hello! Hobbyist here slowly going crazy to figure this out... I'm running out of ideas and wanted to post this in hopes of getting some additional thoughts on this as I'm not sure how else to best move forward. Pardon any mis-wordings below -- EE and software is not my primary background.
Objective 1: Upcycle an old CB, desktop microphone so it is usable on PCs via USB. (I know you can buy desktop mics but where's the fun in that? Despite the frustration this has been a wonderful learning experience, and I am incredibly amazed by the Teensy community!)
- Bought some Teensy 4.0s and RevD Audio Shields.
- Made some edits to the usb_desc.c and usb_desc.h for custom names and to make it such that only the Mic input will show up as a USB device.
- Generated code using the Audio System Design Tool. Pretty much just to set micgain and a highpass filter. Code is at the end.
- Added some code for push-to-talk, debounce, and turn on an LED. It has been commented out during debugging.
- I have been able to get this working perfectly.
Objective 2: Due to space constraints, I could not fit the stock Audio Shield without chopping it up. Cue me designing a custom shield.
- For some reason I thought using the QFN20 version of the SGTL5000 chip was the best option. I based the electrical circuit based on the PJRC documentation. Since many features weren't needed for my application (SD card, line out, line in, headphone) I did not include them.
- Attached to this post is my electrical circuit with some annotations that may help explain what's going on. The SGTL5000 section -- I tried to copy the power and mic circuit exactly from here https://www.pjrc.com/store/teensy3_audio.html
- Used the same code from Objective 1.
- I have not been able to get any response with my custom shield.
Debugging: I've done some common sense debugging and am at a loss for what to do next. Below is a mostly chronological list of steps I've done already. Any further pointers?
- Quintuple checked the soldering of the QFN20 chip, even under microscope. I believe soldering is ok.
- Used a multimeter to check input voltage to the SGTL5000. 3.3V VDDIO and VDDA is ok, 1.8V VDDD is ok. I believe the SGTL5000 is getting power.
- Used a multimeter to check MICBIAS. I am seeing a fluctuating ~0.070V to ~0.200V with a multimeter. I am not seeing any voltage with an oscilloscope. I believe there is an issue with the MICBIAS output.
- Checked for obvious shorts or voltage where it shouldn't be. I do not believe there are any shorts.
- Removed the Mic-related capacitors and rechecked voltages. Still the same MICBIAS observation.
- O'scoped all the clock signals. Compared all signals to the OEM Audio Shield and the frequency is spot on. I believe the SGTL5000 is getting the correct clock signals.
- O'scoped the SDA and SCL lines. I haven't decoded the message, but I do see a blip in the signal upon Teensy bootup. I believe the SGTL5000 is getting bootup commands.
- O'scoped the TX and RX lines with no signal. I believe the SGTL5000 is not outputting any data. For reference, I scoped the stock Audio Shield and was able to clearly see activity on the TX line.
- Removed the SGTL5000 and replaced it with another one. Checked the soldering many times again.
- Using a multimeter, all input voltages are still ok.
- When rechecking MICBIAS, it was reading ~2.8V for a few minutes, and then it went back to ~0.070V to ~0.200V.
Objective 1: Upcycle an old CB, desktop microphone so it is usable on PCs via USB. (I know you can buy desktop mics but where's the fun in that? Despite the frustration this has been a wonderful learning experience, and I am incredibly amazed by the Teensy community!)
- Bought some Teensy 4.0s and RevD Audio Shields.
- Made some edits to the usb_desc.c and usb_desc.h for custom names and to make it such that only the Mic input will show up as a USB device.
- Generated code using the Audio System Design Tool. Pretty much just to set micgain and a highpass filter. Code is at the end.
- Added some code for push-to-talk, debounce, and turn on an LED. It has been commented out during debugging.
- I have been able to get this working perfectly.
Objective 2: Due to space constraints, I could not fit the stock Audio Shield without chopping it up. Cue me designing a custom shield.
- For some reason I thought using the QFN20 version of the SGTL5000 chip was the best option. I based the electrical circuit based on the PJRC documentation. Since many features weren't needed for my application (SD card, line out, line in, headphone) I did not include them.
- Attached to this post is my electrical circuit with some annotations that may help explain what's going on. The SGTL5000 section -- I tried to copy the power and mic circuit exactly from here https://www.pjrc.com/store/teensy3_audio.html
- Used the same code from Objective 1.
- I have not been able to get any response with my custom shield.
Debugging: I've done some common sense debugging and am at a loss for what to do next. Below is a mostly chronological list of steps I've done already. Any further pointers?
- Quintuple checked the soldering of the QFN20 chip, even under microscope. I believe soldering is ok.
- Used a multimeter to check input voltage to the SGTL5000. 3.3V VDDIO and VDDA is ok, 1.8V VDDD is ok. I believe the SGTL5000 is getting power.
- Used a multimeter to check MICBIAS. I am seeing a fluctuating ~0.070V to ~0.200V with a multimeter. I am not seeing any voltage with an oscilloscope. I believe there is an issue with the MICBIAS output.
- Checked for obvious shorts or voltage where it shouldn't be. I do not believe there are any shorts.
- Removed the Mic-related capacitors and rechecked voltages. Still the same MICBIAS observation.
- O'scoped all the clock signals. Compared all signals to the OEM Audio Shield and the frequency is spot on. I believe the SGTL5000 is getting the correct clock signals.
- O'scoped the SDA and SCL lines. I haven't decoded the message, but I do see a blip in the signal upon Teensy bootup. I believe the SGTL5000 is getting bootup commands.
- O'scoped the TX and RX lines with no signal. I believe the SGTL5000 is not outputting any data. For reference, I scoped the stock Audio Shield and was able to clearly see activity on the TX line.
- Removed the SGTL5000 and replaced it with another one. Checked the soldering many times again.
- Using a multimeter, all input voltages are still ok.
- When rechecking MICBIAS, it was reading ~2.8V for a few minutes, and then it went back to ~0.070V to ~0.200V.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
//**********************************************************************************//
// With highpass filter
AudioInputI2S i2s1; //xy=239.09091186523438,217.09091186523438
AudioAmplifier amp1; //xy=339.66669845581055,264.6666889190674
AudioFilterBiquad biquad1; //xy=508,266
AudioOutputUSB usb1; //xy=749.091064453125,273.0910186767578
AudioConnection patchCord1(i2s1, amp1);
AudioConnection patchCord2(amp1, biquad1);
AudioConnection patchCord3(biquad1, 0, usb1, 0);
AudioConnection patchCord4(biquad1, 0, usb1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=382.0909118652344,567.0909214019775
//**********************************************************************************//
float gainValue = 1; //Max gain = 1
float gainStep = 0.1; //Gain increment during ramps
bool talk = false; //Talk yes or no?
int talk1 = LOW; //Talk switch sample 1
int talk2 = LOW; //Talk switch sample 2
int talk3 = LOW; //Talk switch sample 3
const int talkPin = 12; //The number of the Talk switch pin
const int talkLED = 6; //The number of the LED control pin
void setup() {
pinMode(LED_BUILTIN, OUTPUT); //DIAG. Use internal LED for diagnostics for now
pinMode(talkPin, INPUT); //Set talkPin and digital input
pinMode(talkLED, OUTPUT); //Set talkOutput and digital output
Serial.begin(9600); //DIAG. For diagnostics
AudioMemory(12); //12 seems to work well.
sgtl5000_1.enable();
sgtl5000_1.volume(1);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(24); //Set 36 as the base
amp1.gain(1); //Initialize mic off
biquad1.setHighpass(0, 60, 0.7071); //Highpass filter at 125Hz, first stage
//biquad1.setHighpass(1, 125, 0.7071); //Highpass filter at 125Hz, second stage
Serial.println("On"); //DIAG
talk = true; //Initialize off
digitalWrite(LED_BUILTIN, HIGH); //Initialize off
digitalWrite(talkLED, HIGH); //Initialize off
delay(1000);
}
void loop() {
// //Update 3-sample history every loop
// talk3 = talk2;
// talk2 = talk1;
// talk1 = digitalRead(talkPin);
//
// //Debounce -- if 3 consecutive samples, then chnage Talk state
// if (talk3 == HIGH && talk2 == HIGH && talk1 == HIGH){
// talk = false;
// }
// if (talk3 == LOW && talk2 == LOW && talk1 == LOW){
// talk = true;
// }
//
// //TODO Analog input as mic gain adjuster
//
// if (talk == true){ //If talk = on, start ramping gain to 1
// if (gainValue < 1){
// gainValue = gainValue + gainStep; //Ramp gain to avoid pops
// Serial.println(gainValue); //DIAG
// amp1.gain(gainValue);
// }
// if (gainValue >= 1){ //Do the following once ramp is complete and fully on
// amp1.gain(1); //Make sure gain is at max 1 in case of overshoot/rounding error
// gainValue = 1;
//// delay(5000); //Remove!!
//// talk = false; //Remove!!
// digitalWrite(talkLED, LOW); //Turn external LED off
// digitalWrite(LED_BUILTIN, LOW); //DIAG
// Serial.println("Off"); //DIAG
// }
// }
//
// if (talk == false){ //If talk = off, start ramping gain to 0
// if (gainValue > 0){
// gainValue = gainValue - gainStep; //Ramp gain to avoid pops
// Serial.println(gainValue); //DIAG
// amp1.gain(gainValue);
// }
// if (gainValue <= 0){ //Do the following once ramp is complete and fully off
// amp1.gain(0); //Make sure gain is at muted 0 in case of overshoot/rounding error
// gainValue = 0;
//// delay(5000); //Remove!!
//// talk = true; //Remove!!
// digitalWrite(talkLED, HIGH); //Turn external LED on
// digitalWrite(LED_BUILTIN, HIGH); //DIAG
// Serial.println("On"); //DIAG
// }
// }
delay(5); //5 msec loops
}