Lowpass-RC-filter for MicIn: Code or resistor and capacitor?

Status
Not open for further replies.

AdaZus

Member
Hi everybody,
Does it make sense to solder a RC-filter between the microphone and MICIn (AudioAdaptorBoard)?
The idea is to lowpass all frequency less than ca. 350Hz, to give Teensy an as clean as possible sound to process. (Everything over ca. 400Hz is unused and should not disturb.)

Or is it obsolete because everything can made in code like demonstrated in my last post?

https://forum.pjrc.com/threads/53550-Biquad-filter-low-corner-frequency-test-sketch

I have already tried to add a RC-filter but it didn`t work. There are surely some influences with the already soldered components on AudioAdaptorBoard?!.

Can anyone give some help how to connect the AudioAdaptorBoard-MicIn with a RC-low pass filter and the microphone?
https://www.pjrc.com/store/teensy3_audio.html
https://en.wikipedia.org/wiki/RC_circuit

BR
 
Unless you're dealing with an extremely loud high pitch sound, I would implement this filtering on the software side. Usually the higher frequencies aren't huge signals, so best to just sample them and remove digitally.

For high pass filtering, where you might wish to filter out everything under 80 to 100 Hz, the trade-offs are different. Extreme low sounds & vibration tend to overwhelm microphones with huge signal output which leaves less dynamic range for the higher signals you want. Very low corner frequencies are also harder to implement in software.
 
Hi Paul,
Many thanks for your fast reply.
This day I have spent all to filters.
As described by you, I have implemented the lowpassfilter in code which works fine:


Code:
/*
https://www.pjrc.com/teensy/gui/index.html?info=AudioFilterBiquad
Biquad filters test with low corner frequency @ Teensy 3.6. 
Try out following sketch.
*/


//01 Notefreq1 after biquad1
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=105,240
AudioAmplifier           amp1;           //xy=262,224
AudioFilterBiquad        biquad1; //xy=444,223
AudioOutputI2S           i2s2;           //xy=695,161
AudioAnalyzePeak         peak1;          //xy=698,231
AudioAnalyzeNoteFrequency notefreq1;      //xy=706,305
AudioConnection          patchCord1(i2s1, 0, amp1, 0);
AudioConnection          patchCord2(amp1, biquad1);
AudioConnection          patchCord3(biquad1, 0, i2s2, 0);
AudioConnection          patchCord4(biquad1, 0, i2s2, 1);
AudioConnection          patchCord5(biquad1, peak1);
AudioConnection          patchCord6(biquad1, notefreq1);
AudioControlSGTL5000     sgtl5000_1;     //xy=362,332
// GUItool: end automatically generated code
//01 Notefreq1 after biquad1

/*
//02 Notefreq1 after amp1
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=105,240
AudioAmplifier           amp1;           //xy=262,224
AudioFilterBiquad        biquad1; //xy=444,223
AudioOutputI2S           i2s2;           //xy=695,161
AudioAnalyzePeak         peak1;          //xy=698,231
AudioAnalyzeNoteFrequency notefreq1;      //xy=706,305
AudioConnection          patchCord1(i2s1, 0, amp1, 0);
AudioConnection          patchCord2(amp1, biquad1);
AudioConnection          patchCord3(amp1, notefreq1);
AudioConnection          patchCord4(biquad1, 0, i2s2, 0);
AudioConnection          patchCord5(biquad1, 0, i2s2, 1);
AudioConnection          patchCord6(biquad1, peak1);
AudioControlSGTL5000     sgtl5000_1;     //xy=362,332
// GUItool: end automatically generated code
//02 Notefreq1 after amp1
*/



elapsedMillis msecs;


void setup() {

  Serial.begin(9600);
  
  AudioMemory(30);
  sgtl5000_1.enable();

  //Hearphone Out
  sgtl5000_1.volume(0.4);
  //Hearphone Out
  
  // MicIn
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC); 
  sgtl5000_1.micGain(50); // sgtl5000_1.micGain(30); original
  amp1.gain(0); //MicIn (i2s1) gain (again)
  //MicIn
  
  delay(1000);
  notefreq1.begin(.15);
}

      
void loop() {

    amp1.gain(0.9); // to ajusd MicIn(i2s1)-gain: Filters must have their input signals attenuated, so the signal does not exceed 1.0 (or 2 if measured peak to peak).
   
    // Filter 
    //File > Examples > Audio > Effects > Filter
    // Butterworth filter, 12 db/octave
    //biquad1.setLowpass(0, 400, 0.707);
   
    // Linkwitz-Riley filter, 48 dB/octave
     biquad1.setLowpass(0, 400, 1);
     biquad1.setLowpass(1, 400, 0.707);
     biquad1.setLowpass(2, 400, 1);
     biquad1.setLowpass(3, 400, 0.707);
     // Filter 
 


       
       if (msecs > 100) {
        
          // read back fundamental frequency
          if (notefreq1.available()  ) {
          int cpuusage = AudioProcessorUsageMax();
          float note1 = notefreq1.read();
          float prob1 = notefreq1.probability();
          Serial.printf("CPUusage1: %i | Note1: %3.2f | Probability1: %.2f\n", cpuusage, note1, prob1);
          }
          // read back fundamental frequency

          // Amplitude to serial monitor
          if (peak1.available() ) {//only Mono needed.
          msecs = 0;
          float leftNumber = peak1.readPeakToPeak();
          Serial.println(leftNumber); //left channel
          // Amplitude to serial monitor
          }
      }
 }



Secondly I have tried to create a discrete highpassfilter to reduce interferences of 50Hz.
I have tried out the schematics as follows.

Original:
https://www.dropbox.com/s/ygb2i4xa4oymyfl/01_Original_AudioBoard_MicIn.JPG?dl=0
https://www.pjrc.com/store/teensy3_audio.html
Capacitor of 1uF between Ground and MicIn
https://www.dropbox.com/s/mmbcc6hyqiszyvy/02_Capacitor_MicIn.JPG?dl=0
RC-highpassfilter
https://www.dropbox.com/s/4se6osazigaqibn/03_RC-Filter.JPG?dl=0
With capacitor between Ground an MicIn I have had the best results, but the disturbance source was still to loud. (As disturbance source I have used a halogen spotlight with dimmer and a long cable. The microphone cable during the test was situated directly over the dimmer. This because I wanted to create a hard electromagnetic environment for my project.)
What I have decide to do than, is to solder the microphone directly to the audioboard instead of using a microphone with cable. The flexibility in project of a cable is great, but more important at the moment is that my project works under any environment. For example on stages with high power spotlights.

But nevertheless, can you or any other give me a tip how to implement a Bass-Cut-Filter with discrete components to cut away all frequency below ca. 65Hz?

BR
 
Status
Not open for further replies.
Back
Top