A few questions regarding FFTs and performance

Status
Not open for further replies.
What a lucky coincidence that we are all working on more or less the same project :D very nice!

That sound like a simple enough setup CorBee for generating tones. I will see if I can throw together something similiar to it. Also thanks for the tip about using AudioSynthWaveformSineHires! I didn't even see it there. Looking at the code, the regular sine synth uses a lookup table and some interpolation while the hires version caculates the sin based on the taylor series expansion. So yeah absolutly now wonder it gives better results!

Ah would be nice if the problems I was having would be because of the two different power supplies as well. I will look into it!
 
Code:
Teensy 3V3  -----2K2---2K2---Pre-amp/Mic 3V3[INDENT]        |       | 
[/INDENT]
              10µF  10µF
              |       |
             GND     GND

It is thus a simple RC lowpass filter.

see here for more info:
http://www.sengpielaudio.com/Rechner-RCglied.htm

What is your 5 to 6V power supply? Is it clean or a switching PS? If yes, you should filter it extensively or use a different power supply.

Have fun with the Teensy!

Frank
 
Last edited:
Formatted as code it might do.
Also the frequency response of the mic can be found in the SPU0410LR5H-QB datasheet. According to WMXZs test the frequency response of the ADC in the SGTL5000 is fairly linear until 60kHz at 192kHz sampling rate before slowy falling off. Of course the frequency response of the mic amp is not known. Its not HiFi, but overall I'd say its fairly resonable.
My power supply is a cheap lab power supply. I can't immagine it being very good. I think I will try to power everything from the teensy at 3.3V as you suggested. This way I will skip the external power supply and can later power everything through one battery.
The curcuit you discribe in the post above, is it for transforming power (3.3V -> 5V) or is it for smoothing out edges in the 3.3V power of the teensy?
 
@frank: Screenshot from 2018-06-17 22-09-12.png

Updated my schematic for the transistor preamp using the RC decoupling

Cor
 
Hi frank,

I hadnt answered your earlier question it seems:
"What is your 5 to 6V power supply? Is it clean or a switching PS? If yes, you should filter it extensively or use a different power supply."

The 5-6V power supply I was refering to my analog detector thats working on a set of batteries. Thats why my schematic shows a resistor-dividor R1/R2 to bring down the 5-6V to max 3.6V for the MEMS micro. But in my current setup I am powering everything directly from the teensy. Thats - after reading loads of mails on this forum - probably the main source of the noise I get when connecting my preamp. This evening when returning from work I will see if I can create the double RC filter on the 3.3V powerline from the teensy towards the preamp.
Hopefully that will remove a lot of noise to get things working easier. In my tests yesterday I could not even hear my ultrasonic sweep at all when connecting the pre-amp using the 3.3V from teensy. When I used the battery-setup i had a clear signal.

Cor
 
Hi Frank

Ive tested the setup as you suggested, using 2k2 and 10uF however attenuated the power towards the preamp it looks too much. The signal became rather weak. Ive switched then to 220 ohm and 10uF, tested also with 100uF. Both worked but adding a 2nd identical RC-filter stage again attenuated the signal. Ive also tried using the VIN signal instead of the 3v3. The VIN in my case came from a USB-batterypack (so 5V), both worked fine with the 5V giving clearly more signal. There was still some background "hiss/white noise" but that was also there when I had nothing connected. I was using the MIC_IN with the preamp. Tomorrow I will build a separate preamp board based on what I have tested today (I was now using the inner modular guts of one of my analog detectors).

cheers
Cor

PS. I also found out that using the GND from the location on the audioboard where a volume-potentiometer can be added is NOT wise. That injected a lot of noise again. Might be due to the fact that I have the preamp and the RC on a breadboard
 
Last edited:
Hi,

made some more experiments with the ultrasound MEMS microphone SPU0410LR5H-QB and the mentioned ELV microphone preamp:

- I used the original schematics of the preamp, but changed the Opamp from TL072 to TL972
- used 680 ohms for impedance of the MEMS mic
- I believe that the gain of the preamp is something around 40dB, but I am not sure, because I used 3.3 Volts as Vdd instead of 5 Volts (original schematics)
- used 47µF choke to filter Teensy 3.3V before feeding it to the preamp
- used the original Teensy ADC bias schematics (bias at 0.6 Volts) at the output of the preamp before feeding to the Teensy ADC pin
--> https://www.pjrc.com/teensy/gui/img/adccircuit.png

--> I analysed the recordings with Audacity and measured:

- the maximum signal before clipping, which was 0.06 at the Audacity scale (whatever that scale means)
- the noise, which was about 0.0004

So I get 0.06 (max signal) divided by 0.0004 (noise), which is 150, equivalent to 44dB SNR (Signal-to-noise-ratio --> 20 * log(150))

I am not sure whether that is good or bad or exactly what I can expect with a simple setup like this (hopefully I did the math right ;-)).

When I tweaked the preamp for even higher gain (52dB), the signals were louder, but the SNR got worse, because the noise seemed to rise faster than the wanted signals. Also the Teensy ADC started to clip even with quite low signals.

Have fun with the Teensy,

Frank
 
Hi Frank,

You could use the 5V from VIN (if your board runs on USBpower) to see if that changes the effectivity of the preamp. I have no idea yet how "effective" my transistorbased preamp is. Do you use screened cables etc for the connections between preamp-teensy microphone-teensy ?

Cor
 
Thanks for the suggestion!

But as I wrote, more gain does not mean more SNR, but less. And potentially using the 5V from the USB means even more noise coming in.

Here is my setup (from right to left):
* preamp PCB with ultrasound mic PCB soldered from underside
* PCB with Vdd filtering (47µF choke on the underside) & biasing circuit
* Teensy 3.6
* RTC backup Lithium battery

the GND wire is not used, because the shielded cable already has AGND connection
--> I use analog GND == AGND to connect preamp and mic, NOT GND


microSoundRecorder ultrasound preamp DD4WH 2018_06_20.jpg
microSoundRecorder ultrasound preamp backsides DD4WH 2018_06_20.JPG
 
Hi Frank,

Thanks for sharing pictures of the hardware, ill try to do that also today after I have finalized soldering the preamp.

I know its the signal/noise ratio that counts, if that improves you can always make it "louder" without much issues. You are using AGND, this is however not mentioned as a connected part of the audio-shield (https://www.pjrc.com/store/teensy3_audio_pins.png). I wonder if it will work in the same fashion. Ill try that later today.

Cor
 
- used 680 ohms for impedance of the MEMS mic
The MEMS output impedance is 400 Ohm, so I would put the input resistor much higher or take it out to not to 'short' the microphone (there is no line transmission effect, where matching is required)
- I believe that the gain of the preamp is something around 40dB, but I am not sure, because I used 3.3 Volts as Vdd instead of 5 Volts (original schematics)
The gain depends only on the 10k/1k resistors and as the TL927 works above 2.7 V there should be no impact of Vdd
So I get 0.06 (max signal) divided by 0.0004 (noise), which is 150, equivalent to 44dB SNR (Signal-to-noise-ratio --> 20 * log(150))
I am not sure whether that is good or bad or exactly what I can expect with a simple setup like this (hopefully I did the math right ;-)).
the math is right, and the Micro docu gives SNR 63 dB(A), so ignoring the A weighting, the 44 dB would be somewhat worse.
But in order to compare one should keep in mind that the A weighting emphasizes the best human hearing (-10 dB point 200 Hz to 20 kHz), and assuming your sampled bandwidth would be 5 times higher than you could increase your SNR by 7 dB to have 51dB SNR // 20 kHz. Also the A weighting suppresses LF (e.g. 50 Hz) signals by 30 dB, so that would give you some other dBs. So maybe the SNR you are measuring is not so bad at all.
 
Hi Walter,

thanks for the clarification and the info on Vdd, input resistor and dB (A) measurements! Thats very helpful! I will take out the input resistor, your comment solves that long-standing question for me.

I found some comparison figures of SNR plus preamp for similar field recorders (one open source and one commercial type):

https://www.openacousticdevices.info/audio

So, 44dB seems to compete very well with those two figures (44.2dB and 48.7dB), although we have to take care, because I did not use a calibrated sound source, just my key ring was producing ultrasound . . . :). (but the clipping point was very clearly and sharply visible at 0.06)
 
@CorBee:

I do not know exactly, but I think you should also use the AGND when using the audio board.

One thing I thought about was the follwoing: You have the preamp already in the audio board, so you should need much less gain before the audio board. When I tested my mic + preamp setup, I used the audio board (just passthru-sketch). I had the micGain on the audio shield set to 10dB only! Higher settings lead to clipping.

You have a maximum possible setting of 63dB for mic gain, as far as I remember. So it could be possible that you can use the mic with the audio board without using an external preamp!

For that purpose you would have to take extreme care of power supply filtering for the microphone and for that the filtering mentioned above with the 2k2 resistors and caps would be suitable, I think. Attach an additional choke at the 3.3V input from the Teensy and it could possibly work withoout a preamp, if you set your codec gain (micGain) to 50 or 60dB.
 
@Frank

I tried using both the SPU and an electret (PRIMO EM258, seens as a replacement for the panasonic WM61-A) directly on the MIC input of the audioboard. The signal was very weak and the range completely incomparable with what I am used to with my analog detector. I tend to hear common pipistrel bats at 15 meters easily. Thats why I am trying to improve the signal/noise ratio using a preamp. Also the preamp was designed specifically for ultrasound. At the first stage the emitter RC combo (4k7 and 10uF) was added to have more gain at higher frequencies than at audio frequencies.
Currently my mic_gain setting is 20 when using the preamp
 
Hi

Here is my current setup:

-preamp is on the right
-on the top is the microphone (connected with a 4 wire shielded cable)
-teensy and audioboard on the bottom (blue = GND, red=VIN, yellow is MIC)

On the left my normal analog batdetector (excluding wires/potentiometers etc)

Luckily I can now start programming things a bit and hopefully tomorrow I can build the shield for a TFT that I will use also.

Ive done a bit of testing again, one thing I am still confused about is that the noise I hear also shows up when I shortcut MIC and GND (directly at the audioboard). That clearly shows its coming directly from the board. In fact when I remove all the stuff and only have teensy and audioboard connected the same noise is there. Is that also the case with you ?

regards
Cor
P.S. Ive done some more tests. The background noise seems to be related to the sample rate, when I set that at 96K its far more quiet than at 192K


IMG_20180620_213915815a.jpg
 
P.S. Ive done some more tests. The background noise seems to be related to the sample rate, when I set that at 96K its far more quiet than at 192K

What is your F_CPU?
the noise floor is definitely depending also on the inherent jitter, when you generate the I2S signals.
 
And to further clarify, I am using this code to set the clocks for the samplerate (its by Frank B), if I understand things well this selects 219 for the multiplier and 802 for the divider at a F_PLL of 180M and 192k ?? Am I right ? Reading up on the forum on this I see that the multiplier should be as low as possible. So should I tweak these numbers and if so ... how ?

Edit: reading additional threads on the forum it looks I could use Mult 3 and DIV 11 with F_CPU 180M to achieve 191.76 kpbs .... is it that simple ?

Code:
// set samplerate code by Frank Boesing 
void setI2SFreq(int freq) {
  typedef struct {
    uint8_t mult;
    uint16_t div;
  } tmclk;

  const int numfreqs = 14;
  const int samplefreqs[numfreqs] = { 8000, 11025, 16000, 22050, 32000, 44100, (int)44117.64706 , 48000, 88200, (int)44117.64706 * 2, 96000, 176400, (int)44117.64706 * 4, 192000};

#if (F_PLL==16000000)
  const tmclk clkArr[numfreqs] = {{16, 125}, {148, 839}, {32, 125}, {145, 411}, {64, 125}, {151, 214}, {12, 17}, {96, 125}, {151, 107}, {24, 17}, {192, 125}, {127, 45}, {48, 17}, {255, 83} };
#elif (F_PLL==72000000)
  const tmclk clkArr[numfreqs] = {{32, 1125}, {49, 1250}, {64, 1125}, {49, 625}, {128, 1125}, {98, 625}, {8, 51}, {64, 375}, {196, 625}, {16, 51}, {128, 375}, {249, 397}, {32, 51}, {185, 271} };
#elif (F_PLL==96000000)
  const tmclk clkArr[numfreqs] = {{8, 375}, {73, 2483}, {16, 375}, {147, 2500}, {32, 375}, {147, 1250}, {2, 17}, {16, 125}, {147, 625}, {4, 17}, {32, 125}, {151, 321}, {8, 17}, {64, 125} };
#elif (F_PLL==120000000)
  const tmclk clkArr[numfreqs] = {{32, 1875}, {89, 3784}, {64, 1875}, {147, 3125}, {128, 1875}, {205, 2179}, {8, 85}, {64, 625}, {89, 473}, {16, 85}, {128, 625}, {178, 473}, {32, 85}, {145, 354} };
#elif (F_PLL==144000000)
  const tmclk clkArr[numfreqs] = {{16, 1125}, {49, 2500}, {32, 1125}, {49, 1250}, {64, 1125}, {49, 625}, {4, 51}, {32, 375}, {98, 625}, {8, 51}, {64, 375}, {196, 625}, {16, 51}, {128, 375} };
#elif (F_PLL==168000000)
  const tmclk clkArr[numfreqs] = {{32, 2625}, {21, 1250}, {64, 2625}, {21, 625}, {128, 2625}, {42, 625}, {8, 119}, {64, 875}, {84, 625}, {16, 119}, {128, 875}, {168, 625}, {32, 119}, {189, 646} };
#elif (F_PLL==180000000)
  const tmclk clkArr[numfreqs] = {{46, 4043}, {49, 3125}, {73, 3208}, {98, 3125}, {183, 4021}, {196, 3125}, {16, 255}, {128, 1875}, {107, 853}, {32, 255}, {219, 1604}, {214, 853}, {64, 255}, {219, 802} };
#elif (F_PLL==192000000)
  const tmclk clkArr[numfreqs] = {{4, 375}, {37, 2517}, {8, 375}, {73, 2483}, {16, 375}, {147, 2500}, {1, 17}, {8, 125}, {147, 1250}, {2, 17}, {16, 125}, {147, 625}, {4, 17}, {32, 125} };
#elif (F_PLL==216000000)
  const tmclk clkArr[numfreqs] = {{32, 3375}, {49, 3750}, {64, 3375}, {49, 1875}, {128, 3375}, {98, 1875}, {8, 153}, {64, 1125}, {196, 1875}, {16, 153}, {128, 1125}, {226, 1081}, {32, 153}, {147, 646} };
#elif (F_PLL==240000000)
  const tmclk clkArr[numfreqs] = {{16, 1875}, {29, 2466}, {32, 1875}, {89, 3784}, {64, 1875}, {147, 3125}, {4, 85}, {32, 625}, {205, 2179}, {8, 85}, {64, 625}, {89, 473}, {16, 85}, {128, 625} };
#endif

  for (int f = 0; f < numfreqs; f++) {
    if ( freq == samplefreqs[f] ) {
      while (I2S0_MCR & I2S_MCR_DUF) ;
      I2S0_MDR = I2S_MDR_FRACT((clkArr[f].mult - 1)) | I2S_MDR_DIVIDE((clkArr[f].div - 1));
      return;
    }
  }
}
 
Last edited:
And to further clarify, I am using this code to set the clocks for the samplerate (its by Frank B), if I understand things well this selects 219 for the multiplier and 802 for the divider at a F_PLL of 180M and 192k ?? Am I right ? Reading up on the forum on this I see that the multiplier should be as low as possible. So should I tweak these numbers and if so ... how ?

If you are flexible with sampling you could use
F_CPU= 180MHz and Mult=1, Div=2 to get 175.78 kHz

if you only record (no processing)
you could use
F_CPU= 49 or 96 MHz and MULT=2 , Div=2 to get 187.5 kHz

if heavy processing
F_CPU=240 MHz and MULT=2, DIV=5 to get also 187.5 kHz

I used Matlab
round(240000000*1./(1:10)/2/4/64)
round(240000000*2./(1:10)/2/4/64)
to obtain the proper DIV value for MULT=1 or 2 respectively
 
Hi,

My aim is to have a good advanced batdetector. So I will be processing also quite a bit (FFT), I will try the settings you are recommending for F_CPU 180. I guess I only need to change the last entry in the
line
"elif (F_PLL==180000000)
const tmclk clkArr[numfreqs] = {{46, 4043}, {49, 3125}, {73, 3208}, {98, 3125}, {183, 4021}, {196, 3125}, {16, 255}, {128, 1875}, {107, 853}, {32, 255}, {219, 1604}, {214, 853}, {64, 255}, {219, 802} };"


So 219, 802 would become 1,2.

Thanks for the advice, I will report back on the noiselevel
 
Just tested using the 1,2 setting at 180M F_CPU to achieve around 176k SR. Unfortunately this had no effect on the noise-level, oddly enough when connecting the micro(I first tested with MIC_GND connected) the signal is a lot weaker than expected.
 
Just tested using the 1,2 setting at 180M F_CPU to achieve around 176k SR. Unfortunately this had no effect on the noise-level, oddly enough when connecting the micro(I first tested with MIC_GND connected) the signal is a lot weaker than expected.
Are you using the circuit shown un post #29?
either it shows wrong resistors or it can not work.
The first collector resistor is with 100 k far too high, putting that to 4.7 k I get a 20 dB gain.
Otherwise I do not have the hardware, so cannot help more on why signal is weaker.

Edit: I had also to increase the emitter capacitor to 1u to get a high pass cutoff down to 1 kHz or 0.1u for 10 kHz Highpass
 
Last edited:
Hi,
The
I am using the basic for the schematic from #29, but a few things are different. To remove ripple from the powersupply I use a 220 resistor followed by a 100uF cap between VCC/GND. The schematic is tried/tested by many people. Be aware that I am feeding it with 5V(from Vin) and the gain increases with higher frequencies due to the setup with a capacitor/resistor pair at the emitter of the 1st transistor. The 100k is together with the 39k used to set a base voltage. I am not the designer of the schematic it comes from http://bertrik.sikken.nl/bat/ne612het.htm

I have good results with this in my analog detector and it also works fine with the teensy, but the background noise is what I still want to reduce further
 
Hi,
I am using the basic for the schematic from #29, but a few things are different. To remove ripple from the powersupply I use a 220 resistor followed by a 100uF cap between VCC/GND. The schematic is tried/tested by many people. Be aware that I am feeding it with 5V(from Vin) and the gain increases with higher frequencies due to the setup with a capacitor/resistor pair at the emitter of the 1st transistor. The 100k is together with the 39k used to set a base voltage. I am not the designer of the schematic it comes from http://bertrik.sikken.nl/bat/ne612het.htm

I have good results with this in my analog detector and it also works fine with the teensy, but the background noise is what I still want to reduce further

I hope you can see that the schematic in #29 is not equivalent to the schematic of the link
(I only talk about the active part that constitute the preamp, not the filtering of the supply, or the load of the micro)
that the part shown in the two pictures
ne612hetpreamp.gif
Screenshot from 2018-06-17 22-09-12_cut.png
therefore my question.
Simulating the second schematic, does nor generate any output (due to the high value of R7)

Edit If you refereeing to the heterodyne circuit, R5 is given as 15 k and not 100 k
 
Hi

Very well seen, that R7 should not be 100k, I had made this schematic too fast to share ... sorry.

Forgot to check the values. I am BTW using 10k instead of 15k for R7 according to the design on the bottom of the page. As stated its very effective. Ive just managed to add the TFT to the prototype. I hope this evening allows me to hear some bats with the contraption ;)

Can you share the results of the simulation you made ?
 
Status
Not open for further replies.
Back
Top