Altera_Forum
Honored Contributor
13 years agoFFT IP - correct magnitude calculation
Hi guys,
I try to use the FFT IP Core in Burst Mode with 4096 points (single output engine), .Input and Twiddle factors are 12 bit. The input signal comes directly from the ADC with a sample rate of 25kHz. The input sample stream is windowed with a hanning function. The signal then goes to the sink_real input. The sink_imag input is hard wired to zero value. The output of the IP core (source_real and source_imag) is used to calculate the spectrum magnitude by the formula magnitude=sqrt(source_real^2+source_imag^2). I use the Altera sqrt megafunction for the calculations. I skip the remainder of the sqrt megafunction because I have no idea, yet, how to calculate this to my final result. I think, maybe, I don't need that for my purposes. . . Anyway, so far so good, everything works until this stage. I am able to see a nice spectogram in Signal Tap. However, here is my problem: I just don't get the magnitude working as i expect it to be. I know, that there is this scaling factor output out of the fft core which determines the shifts in a full scale output. But please forget this scaling factor for a moment. If I adjust the input signals amplitude in that way, that the scaling factor of the FFT core is not changing, I would expect the magnitude of the spectrum to change within a certain margin. But this does not happen. I can clearly see the change of the amplitude of my input signal on an off the shelf oscilloscope but there is no notable change in the magnitude of the the spectrum. Okay, now, I take the scaling factor from the fft into account. If i adjust the external signal in a way, that the fft core switches the scaling factor and I do not shift my source_real and source_imag signal into the according direction, I see a significant difference in the calculated magnitude. If I calculate a full_scale value for the source_real and source_imag signals, then the calculated magnitude will not change at all over the whole input range of my input signal. It seems as if there is something like an AGC (automatic gain control) working that keeps my magnitude on a constant level, no matther what the amplitude of the input signal is. I really wonder, what I can do to calculate a ,magnitude that follows the inputs amplitude. As i said, the frequency recognition of the fft core works perfectly. If I shift the input freuency, I see this change in my signal tap spectrum analyzer, but the changes in magnitude are just not working as expected. Maybe the information I gave here is a little bit confusing but maybe there is somebody out there who may have some hints I can look into in order to get my magnitude calculation correct. I'm also able to supply Signal Tap screenshots or whatever is needed in order to help me with this issue. Regards, Maik