AnsweredAssumed Answered

FFT problem on stm32427- solved

Question asked by SAIDHI REDDY SAREDDY on Apr 20, 2017

I have done fft computation but I got strange results.Please let me know if i did any mistake.

why I am getting the following strange results?

 

// ADC
#define ADC_RAW_LENGTH 512

// FFT
//#define FFT_SAMPLES 2048
#define FFT_SIZE ADC_RAW_LENGTH/2

 

UINT16 ui16ADCRaw[ADC_RAW_LENGTH],ui16ADCCnt = 0,ui16Flag = 0, ui16CalibrateMaxValue = 0;
FLOAT32 fl32ADCRaw[ADC_RAW_LENGTH], fl32FFTOut[FFT_SIZE], fl32FFTMaxValue = 0;
UINT32 ui32FFTMaxIndex = 0;

arm_cfft_radix4_instance_f32 FFT_InitStruc;
arm_cfft_instance_f32 FFT_InitStruc_dsp;
arm_status status = ARM_MATH_ARGUMENT_ERROR; // default failure

 

//input data collection with timer interrupt from adc
void TIM2_IRQHandler(void)
{
UINT16 ui16ADC_Value = 0 ;
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

 

ui16ADC_Value = ADC_GetConversionValue(ADC1) ;
if((ui16ADCCnt < ADC_RAW_LENGTH) && (ui16ADC_Value > 500) )
{
if((ui16CalibrateMaxValue < ui16ADC_Value) ) {
ui16CalibrateMaxValue = ui16ADC_Value;
}
fl32ADCRaw[ui16ADCCnt] = (FLOAT32)ui16ADC_Value;
ui16ADCCnt++;
fl32ADCRaw[ui16ADCCnt] = 0.0;
ui16ADCCnt++;
}
}


// FFT calculation
status = arm_cfft_radix4_init_f32(&FFT_InitStruc,FFT_SIZE,0,1);

 

arm_cfft_radix4_f32(&FFT_InitStruc, fl32ADCRaw);

 

arm_cmplx_mag_f32(fl32ADCRaw,fl32FFTOut,FFT_SIZE);

 

arm_max_f32(fl32FFTOut, FFT_SIZE, &fl32FFTMaxValue, &ui32FFTMaxIndex);

 


// input sample data fl32ADCRaw
503
0
507
0
516
0
514
0
524
0
530
0
532
0
537
0
....

 

//arm_cfft_radix4_f32 function fl32ADCRaw
388595
0
0
0
-1186
1163
-1087
0
4.66130239e+011
-4.66130239e+011
-1186
-1163
4.66130239e+011
4.66130239e+011
-4.66130239e+011
4.66130239e+011
0
0
-4.66130239e+011
-4.66130239e+011
0
0
0
0
nan (0x7fffff)
nan (0x7fffff)
0
0
nan (0x7fffff)
nan (0x7fffff)
nan (0x7fffff)
nan (0x7fffff)
2.48002616e+012

 

//arm_cmplx_mag_f32 function fl32FFTOut data
5.66332883e+011
5.68833212e+011
1.86279645e+018
7.30765853e+011
1.86279645e+018
1.86279645e+018
0
1.86279645e+018
0
0
0
0
0
0
0
1.16413673e+013
0
1.67605685e+012
6.25887412e+011
inf
1.60195215e+012
inf
inf
0
inf
0
0
0
0
0
0
inf
0
inf
inf
inf
inf
inf
inf
0
inf
0

Outcomes