# Problem using arm_cfft_q15

Question asked by Pablo Cottens on Feb 27, 2018
Latest reply on Feb 27, 2018 by Pablo Cottens

Hello,

I am doing a project in which I am using the FFT to do some calculations for a determined signal. I get real data from the ADC and then process it with the FFT.

I noticed that the FFt give me an incorrect output, meaning that whenever I use the FFT to calculate magnitude, or RMS value, or anything I get incorrect values and the problem is not due to scaling since a DC signal give me an RMS value of 0.48 and a 60Hz sine wave that is 3.3V peak to peak gives me a result of 0.5. Because of that I decided to do the following:

- Take the raw data from the ADC and graph it (I got a pretty albeit noisy sign wave);

- Create a sine wave in real time and the perform the FFT

var = 0.0625 * arm_sin_f32(2 * PI * i / 128 + PI/2) + 0.0625;

arm_float_to_q15(&var, &buffer, 1);

I performed the float, q31 and q15 FFT and got the expected result for RMS value of the sine wave.

- I compared  both the runtime sinusoidal wave and the acquired wave from the ADC, both were very similar only the ADC sine wave was noisier.

- I decided to convert the data from the ADC to float and then do the float CFFT and the results were correct. I injected varying amplitude signals and all the time I got the correct output (after doing some scaling).

Has anyone faced this problem as well? Is this a bug or am I doing something wrong? Of course I gave the function a complex array, where the even indices were the raw ADC data and the odd indices were 0 (zero). Please help, I'd rather use the q15 version of the CFFT because then I don't have to spend time converting the entire buffer before processing

PS: The ADC buffer is filled by DMA @10kHz

Also, If I use the arm_rms_q15 function on the output of arm_cfft_q15 the result is ALWAYS zero.