Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Wrong Amplitude After FFT Calculation!

Status
Not open for further replies.

karanbanthia

Junior Member level 1
Joined
Jan 7, 2010
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
pune
Activity points
1,412
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;
  VectorWindow(numofsamples,&storedreading[0].real,&storedreading[0].real,&windowcoeff[0]);
  FFTComplexIP (log2n, &storedreading[0], (fractcomplex *) __builtin_psvoffset(&twiddleFactors[0]), (int) __builtin_psvpage(&twiddleFactors[0]));
  BitReverseComplex (log2n, &storedreading[0]);
  SquareMagnitudeCplx(numofsamples, &storedreading[0], &storedreading[0].real);
  peak = VectorMax((numofsamples/2), &storedreading[0].real, &peakFrequencyBin);
  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
Joined
Mar 21, 2007
Messages
132
Helped
28
Reputation
56
Reaction score
12
Trophy points
1,298
Activity points
1,973
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
Joined
Jan 7, 2010
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
pune
Activity points
1,412
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top