FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP

Help with altera FFT

Altera_Forum
Honored Contributor II
7,557 Views

hello; 

 

what i want to do is to get spectrum of an sinusoidal signal using the altera fft core i have generated a v8 fft with the following setting: 

fft point : 64 (to start with) 

architecture : brust 

data width : 16 

twidle width : 16 

i am including the matlab files in the attachment .. the input is a 64 point 2`compliment form. 

in the compare.m file i am doing three fft,,2 matlab fft and 1 altera core fft  

 

what i cant figure out is why the magnitude of the second and the the third power spectrum has bigger amplitude than the first fft at the signal fundmental frequency ? 

and why are those two are not so clean like the first one ? 

 

please have a look .. thanks to anyone who replies.
0 Kudos
56 Replies
Altera_Forum
Honored Contributor II
508 Views

So you are just multiplying the input data with some constants before passing it to the FFT. What are the values in the ROM? And how large is the ROM? I guess the ROM size should be depenent on the FFT size?

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

you are correct, each input data is multiplied by a constant. this value depends on which input sample you are working with. the values in the ROM are the FFT window which you select. you can read about them here: 

 

http://en.wikipedia.org/wiki/window_function 

 

you can generate FFT windows with MATLAB or Octave (I think) which is free. i can generate a window and paste it here if you'd like. the length of the ROM is indeed equal to the length of the FFT. 

 

you should do some reading on FFT windows to see which trade-offs you are willing to deal with. basically it comes down to dynamic range vs spectral resolution.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

I'll do some reading on it. Given the following problem that I have... 

 

I have an audio wave file that changes around 1000Hz going into the FFT (configured as streaming 256 points.) At the output of the FFT, I check for the amplitude in the bin for 1000Hz. My problem is that when I play the SAME audio file over and over again, most of the time I will get a large amplitude in that bin for 1000Hz (which is correct), but once in a while, I get a very low amplitude in that bin. 

 

...should I use dynamic range or spectral resolution? 

Can you please generate the window for me and tell me how to do it in Octave? Yes, Octave is GNU free software and is 100% compatible with Matlab.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

i was looking at the images you posted and thought that it looked like a windowing issue. your last post sounds a little different. 

 

are you displaying the magnitude spectrum in linear or log? if its linear then small variations in amplitude of the sinusoid will look like significant variations in the frequency domain.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

I'm displaying it in linear. But I really don't care too much about the display; I was just using that to visualize the numbers that I was getting. What I want to do is to check whether there is a 1000Hz in the input sample. So I just constantly read the value that is in the FFT output bin for 1000Hz. If the value is greater than a certain threshold, I say that there is a 1000Hz in the sample. I play this same audio file over and over again, and most of the time, the value is greater than the threshold, but as I said, once in a while, it is much lower than the threshold. 

 

The only difference that I can think of is that I play this same audio file at a different time in the FFT input cycle, and that is why I thought that your suggestion of a windowing problem might be the solution.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

does your wave file sweep frequencies or is a constant tone? 

 

maybe an FFT is overkill if you're just trying to detect presence of a 1 kHz tone. 

 

 

is it possible that some of your FFT input data is silence until the wave file actually plays? that would explain why the amplitude varies below your threshold.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

 

--- Quote Start ---  

is it possible that some of your FFT input data is silence until the wave file actually plays? that would explain why the amplitude varies below your threshold. 

--- Quote End ---  

 

 

Well yes. I can't start the FFT and the wave file at the same time. I have to start the FFT first, and so the FFT is reading silence input before I play the wave file. If I can't do this then what am I supposed to do?
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

i would say that could affect the amplitude of your tones. one solution is a kind of squelch circuit that turns the FFT on/off based on an amplitude threshold in the time domain.

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

So the FFT should be turned on only at the first sound signal? 

What if the FFT input is not silence but some other random sound?
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

attached is a basic block diagram of a windowed FFT.

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

Thanks for the block diagram. Can you please tell me how to generate the numbers for the LUT?

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

if you have MATLAB you can type "help window" to get a listing of the window functions and learn their usage. for example: 

 

my_window = hann(window_length); 

 

it doesn't look like Octave has hann, but you can see which windows are supported here: 

 

http://octave.sourceforge.net/doc/funref_signal.html 

 

i attached a 256-point Hann window coefficient list.
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

Did you try the vector wave form simulation or only the matlab simulation???????????

0 Kudos
Altera_Forum
Honored Contributor II
508 Views

can someone tell me please what is that function :  

 

??? Undefined command/function 'Sfftmodel'. 

 

Error in ==> create_fft_model at 45 

[roc,ioc,eoc] = Sfftmodel(rin,iin,N,THROUGHPUT,ARCH,DATA_PREC,TWIDDLE_PREC,INVERSE); ??? 

 

that is the function that altera creat for the fft , but matlab dont know that function...
0 Kudos
Altera_Forum
Honored Contributor II
508 Views

there is a dll and mex file in $QUARTUS_ROOTDIR\ip\altera\fft\lib which you'll need

0 Kudos
Reply