Hi I tested arm_rfft_fast_f32 function from CMSIS-DSP 1.4.4 with generated 50hz sine wave at 1000Hz sample rate using 1024 samples, but i get peek value at 102, not 51 which i should get 1000/1024 ~0,97 * 51 = 50Hz:
uint16_t i;
float32_t khz10[1024];
float32_t maxvalue;
uint32_t maxindex;
//float32_t output2[1024];
arm_rfft_fast_instance_f32 S;
arm_rfft_fast_init_f32(&S, 1024);
printf("Input=[");
for(i=0; i<1024; i++){
khz10[i] = 1.2f*arm_sin_f32(2*3.1415926f*50*i/1000)+1;
printf("%f,",khz10[i]);
}
printf("]\r\n");
arm_rfft_fast_f32(&S, khz10,khz10,0);
arm_abs_f32(khz10, khz10, 1024);
arm_max_f32(khz10+1, 1023, &maxvalue, &maxindex);
printf("Max:[%ld]:%f Output=[",maxindex,maxvalue);
I later tested this function with real data from adc and I can only get 1/4 of frequency spectrum
not about 1/2 as I expected. Can anyone could me explain this ?
Horrible and thorny!
If these are the real and imaginary parts of the real FFT function output, then the problem existed even before my suggested modifications. As you can see in the code used to generate these two graphs, the modified portions are not there anymore. I know you can easily understand what I am trying to point out now, that there is a spurious output at bin 460 right after arm_rfft_fast_f32 returned. It's now more difficult to troubleshoot this problem but we still have options to try.
Again I would suggest a simple modification to your program and we will observe its effect in the output of arm_rfft_fast_f32. I want to temporarily modify the sampling rate to 800, later on you can restore your preferred sampling rate. I've shown the block containing the line and the modification
khz10[i] = 1.2f*arm_sin_f32(2*3.1415926f*50*i/800)+1;
Be careful that you enter 800, not 8000. You will do this in the latest code (where I separated the real and imaginary parts) I posted. Again plot khz10 and output2, the range is 0 to 511.