Hi, guys,
I have some questions and problems about using the FFT-LIB:
*********1. **********
I tried a list of procedures to invoke this fft-lib, and compared the results to what MATLAB produced, so, they were much different.
I convinced that, MATLAB would not wrong, .....neither would this lib, so, it's me,......please help me to point out my blind spot. I guess my misusing of IQ-format.
I attached the entire example file (where using F2812 simulator) and the error screen-snapshot included.
Also, the code snippet is as follows:
By the way, I have tried the input signal shifted left by 16-bit, but still no correct result. And I have verified that function fft.mag works fine - it needs L16 shifted-data.
#include "sgen.h"
#include "fft.h"
#include "iqmathlib.h"
/* Create an instance of Signal generator module */
SGENTI_1 sgen = SGENTI_1_DEFAULTS; // single channel, tbl look-up, interpolation
/* Create an Instance of FFT module */
#define N 128
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");
long ipcb[N+2];
long mag[N/2+1];
RFFT32 fft=RFFT32_128P_DEFAULTS;
/* Define window Co-efficient Array and place the
.constant section in ROM memory */
const long win[N/2]=HAMMING128;
/* Create an instance of FFTRACQ module */
RFFT32_ACQ acq=FFTRACQ_DEFAULTS;
extern const long samples[4096];
long i=0, xn=0;
void main_test(void){
/* Signal Generator module initialisation */
sgen.offset=0;
sgen.gain=0x7fff; /* gain=1 in Q15 */
sgen.freq=10000; /* freq = (Required Freq/Max Freq)*2^15 *///?
/* = (931/3051.7)*2^15 = 10000 *///?
sgen.step_max=10000; /* Max Freq= (step_max * sampling freq)/65536 */
/* Max Freq = (10000*20k)/65536 = 3051.7 */
/* Initialize acquisition module */
acq.buffptr=ipcb;
acq.tempptr=ipcb;
acq.size=N;
acq.count=N;
acq.acqflag=1;
/* Initialize FFT module */
fft.ipcbptr=ipcb;
fft.tfptr=ipcb;
fft.magptr=mag;
fft.winptr=(long *)win;
fft.init(&fft);
while (1){
#if 1
sgen.calc(&sgen);
xn=sgen.out;
#else
if (i>=128) i=0;
xn=samples[i++];
#endif
acq.input=xn; // ((unsigned long)xn)<<16;
acq.update(&acq);
if (acq.acqflag==0){ // If the samples are acquired
fft.calc(&fft);
fft.split(&fft);
fft.mag(&fft);
acq.acqflag=1; // Enable the next acquisition
}
}
}
*********2. **********
Are there ways to modify the fft-lib to support 8-point to 64-point samples? And does this fft-lib support zero-padding condition? Any concerns?
*********3. **********
The manual says that the CFFT would zero the imaginary part of input data, what if I want to fft against on the same data consecutively, that is,
first fft on a real-signal data and a complex freq-domain signal result was obtained, and then, fft on the result again?
As I know, on the outer perspective, the difference between this CFFT and this RFFT is how they treat the input data, e.g., CFFT: real | imag | real | imag |...; RFFT: real | real | ..;
CFFT remains manipulating on the real only?
The manual also says 2 additional data would stuff on the 1st index and the middle position of the FFT buffer(ipcb), but I only found that magnitude buffer did, ipcb didn't?
*********4. **********
As I know, there are memory-allocated restrictions on FFT-lib, why are these restrictions?(although, not important...)
I list some:
"Exactly X" alignment of the ipcb buffer.
Some must be in the NVRAM.
All are in the same mem blocks area?
*********5. **********
As I know, IQmath tries to keep the MSB at most, it only supports Q1 to Q30. How if I have an entire-bit effective data, all the 32-bit are possible, what format can I use?
Q31 or Q0?
If Q1 to Q30 within, are used, at the very beginning, 1 bit would already be discarded?
How can I manipulate the entire various calculation process by only using Q format and use one-time IQ-to-float at last, is it possible?
The RFFT use Q15 for input, FFT on it in Q31, magnitude on it in Q30..........so how do I treat my original data and it's succeeding format?
For example, if some function of the lib needs Q15 for input, but I have a variable being 32-bit effective, e.g., what I have to convert to from this value -2000000001 or this value -21?
Thanks a lot for your help.
Ken.