Long story short... After a couple of weeks of failures using a nRF52 and Arduino IDE trying to measure a 10us to 800us varying length "non-periodic" radar signal from a nerf/bow chronograph...I decided to buy a Teensy 4.0 and the Teensy Audio Adapter...and got it working on the first try! (only at 2 Khz period so far)
I used the Teensy Example -> Audio > Analysis -> FFT example code. I added rudimentary "dominant frequency" to the results, but I wonder, if there is already another Teensy FFT example out here that has some sort of an averaged dominant frequency? Also, I would like to change the 44100Hz sampling rate to maximum and also the ADC sampling rate to maximum. I think I need to dig into the Teensy Arduino libraries support files (h, cpp) to change those, but wondering what are the maximum FFT sampling rate frequency and sampling bin size settings the CPU and the ADC that still provide stability?
The example code works fine with the Audio Adapter, but would like to use the Teensy 4 pins directly eventually. So far I slightly modified an old beta code I found here posted by Paul...that uses FFT without FFT-Window. Based on my tests in Audacity with an actual radar signal I recorded, a "rectangular" FFT window would work the best and at 4096 samples. For the fastest period of signal length I expect, 10us. So, I would need an ADC setting that is able to sample at 2.5 x 100 Khz = 250 Khz rate.
I read this and watched the video as well: https://forum.pjrc.com/index.php?threads/need-help-understanding-fft-bins.56820/
Signal example:
I used the Teensy Example -> Audio > Analysis -> FFT example code. I added rudimentary "dominant frequency" to the results, but I wonder, if there is already another Teensy FFT example out here that has some sort of an averaged dominant frequency? Also, I would like to change the 44100Hz sampling rate to maximum and also the ADC sampling rate to maximum. I think I need to dig into the Teensy Arduino libraries support files (h, cpp) to change those, but wondering what are the maximum FFT sampling rate frequency and sampling bin size settings the CPU and the ADC that still provide stability?
The example code works fine with the Audio Adapter, but would like to use the Teensy 4 pins directly eventually. So far I slightly modified an old beta code I found here posted by Paul...that uses FFT without FFT-Window. Based on my tests in Audacity with an actual radar signal I recorded, a "rectangular" FFT window would work the best and at 4096 samples. For the fastest period of signal length I expect, 10us. So, I would need an ADC setting that is able to sample at 2.5 x 100 Khz = 250 Khz rate.
I read this and watched the video as well: https://forum.pjrc.com/index.php?threads/need-help-understanding-fft-bins.56820/
Signal example:
Code:
//teensy 4.0 gives you FFT of an audio signal on analog pin A2/ pin 16
//This will work without the audio shield present, but I2S output
//(or any other I/O object that causes the library to update) is currently required.
//Future versions will remove this requirement
#include <Audio.h>
// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=197,73
AudioAnalyzeFFT1024 fft1024_1; //xy=361,47
AudioOutputI2S i2s1; //xy=378,99
AudioConnection patchCord1(adc1, 0, i2s1, 0);
AudioConnection patchCord2(adc1, 0, i2s1, 1);
AudioConnection patchCord3(adc1, fft1024_1);
AudioControlSGTL5000 sgtl5000_1; //xy=265,161
// GUItool: end automatically generated code
void setup() {
AudioMemory(30);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
while (!Serial) ; // wait for Arduino Serial Monitor
//Serial.println("FFT test");
}
void loop() {
float domfreq;
float n;
float majorpeak=0;
if (fft1024_1.available()) {
for (int i=0; i < 60; i++) { // print the first 60 bins to 2580 Hz from a max of 22Khz.
n = (fft1024_1.read(i));
if (n >= 0.01) {
if (n > majorpeak) {
majorpeak= n;
domfreq = (i*43.0664);
}
Serial.print(n); Serial.print("<");Serial.print(i*43.0664); Serial.print("Hz ");
} else {
Serial.print(" - ");
}
}
Serial.print(domfreq,2), Serial.println("Hz |");majorpeak=0;domfreq=0;
}
}