AnsweredAssumed Answered

Fast Fourier Transform - FFT - CFFT - arm_cfft

Question asked by RMS-69 on Aug 9, 2017
Latest reply on Aug 10, 2017 by RMS-69

Hi,

 

I try to use the fft code provided in the arm library. For the moment i only generate a sinus to test these codes but i already have an issue. Here is the code that i use to generate the sin :

 

int freqHz = 100;
int fsanpling = 4000;
float32_t result[512];

 

for(int j=0;j<256;j++){
result[j]=sin(2*3.1415*freqHz*j*1/fsampling);}

 

Then i apply the fft :

 

  arm_cfft_radix2_instance_f32 S[1];
  arm_cfft_radix2_init_f32(S,256,0,1);
  arm_cfft_radix2_f32(S,result);

 

The problem is that when i plot (with excel or Matlab) the output of the fft, i get the first spike at f=200Hz instead of 100Hz. And this for differents values of fsampling (Always over 2*fmax). However when i process the fft on Matlab with the sinus values obtained above (with the first code), the output is fine and i get the spike at the right position. So i guess the problem comes from the way i use the fft or configurate it. I tried with the radix4 and get the same problem.

 

If anybody has already used these codes, thanks in advance for your help

 

Aurelien

Outcomes