Hi everyone,
I am working on data processing with FFT. I have some doubts about fft size and adc data memory. Hopefully may get some bits of help, thanks.
I am designing a spectrum analyzer by reading analog from ADC and processed by Arduino with fft to convert time-domain signals to frequency domain signals. I have searched for many materials but still cannot solve my problems.
Let review what I understood (I am not sure is it correct, please correct me if I am wrong),
- Sampling frequency must larger than 2x signal frequency by Nyquist sampling theorem.
- High Sampling frequency would get a better resolution of the frequency bins.
- High Sampling frequency means need more memory to store sampling points of the signal.
- Sampling points(N) must be a power of 2 integers (N=64, 128, 256, etc).
- Numbers of frequency bins is the same as numbers of sampling points(N)
- The sampling frequency is fixed in the design
- FFT size is fixed in the design
Let talk about my problems. Since I may use arduino or FPGA as my data processor, so the highest sampling frequency is not a limitation for me. My FPGA can sample data with high-speed ADC up to 32MHz. Both FPGA and arduino would make me encounter some similar problems but I think it would easier to understand and discuss with Arduino.
Assume I am using constant 20kHz sampling frequency to sample Sinewave signal frequency in a range from 10Hz to 10kHz. The size of the fft is chosen to use 64.
Q1.
Is the fft process after captured the entire cycle of the signal?? or it is a continuous procedure to process each sample data at the time it received ??
/*SAMPLING*/
for(int i=0; i<SAMPLES; i++)
{
useconds_sampling = micros();
vReal[i] = analogRead(analogpin);
vImag[i] = 0;
while(micros() < (useconds_sampling + sampling_period_us)){
//wait...
}
}
/*FFT*/
FFT.Windowing(vReal, SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);
FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);
Q2.
When I sampling 10kHz signal with 20kHz, lt would only obtain 2 points per cycle in the 10kHz Sinewave signal.
How it would fit into a size of 64 fft? Is it process fft after captured 32 cycles of signal??
Q3.
When I sampling 10Hz signal with 20kHz, lt would obtain 2000 points per cycle in the 10Hz Sinewave signal.
How it would fit into a size of 64 fft? The size of fft is not enough for all points. A more extreme case with a sampling frequency 32MHz, total 3.2MHz data points are collected. How to fit the memory and the fft??
Q4. The numbers of sampling points must be the power of 2(N=64, 128, 256, etc). Is it true only in Arduino?? or also true in all data sampling??
Q5.
The number of samples is fixed, the Sampling frequency is fixed, fft size is fixed. How to process all difference frequencies ?? Why is it needed to be power of 2??
The complete code is referred to the follow website.
https://www.norwegiancreations.com/2019/03/arduino-fft-pt-2-improving-the-hardware-for-real-time-analysis/
Thank you for all of your help.