# [SOLVED]Wrong Amplitude After FFT Calculation!

Status
Not open for further replies.

#### karanbanthia

##### Junior Member level 1
Hello all,
I am not able to get the correct amplitude of input signal from DFT. My sampling frequency is 128Hz and I am take 128 Samples and computing 128-point FFT. I also have a simulated sine wave generator which I am using as input. When I vary the input frequency, FFT detects the frequency correctly till 64Hz (i.e. Fs/2) but it gives different amplitude values for different frequencies even though I am not changing the amplitude, why is this so??
I am using Blackman window and following is a part of my main code where I am calculating frequency and amplitude. I am using MPLAB C30 compiler and DSP library.

Code:
while(1)
{
if(startcalc==1)
{
testpin = 1;
FFTComplexIP (log2n, &storedreading[0], (fractcomplex *) __builtin_psvoffset(&twiddleFactors[0]), (int) __builtin_psvpage(&twiddleFactors[0]));
peaksqrt = _Q15sqrt(peak);
utoa(txt,(unsigned int)(peaksqrt),10);
cmd(0x80);                    // Move to 1st Row, 1st Column
send_string(txt);          // Sends string to LCD for display
itoa(txt,peakFrequencyBin,10);
cmd(0xc0);                    // Move to 2nd ROw, 1st Column
send_string(txt);
testpin = 0;
startcalc=0;
TMR3 = 0x0000;
SR = 0x0000;         // Set CPU Priority to 0
}
else;
}

#### Fahmy

##### Full Member level 2
Can yo try the flat-top window , it shall give you a better amplitude accuracy according to the attached application note .

#### Attachments

• fft_windowing.pdf
307.1 KB · Views: 9

#### karanbanthia

##### Junior Member level 1
I tried flat-top as well as rectangular window too... nothing seems to help me out!
What might be the reason that I am getting variable amplitude at different frequencies even though my amplitude is constant?

Status
Not open for further replies.