Forum Discussion
Matlab FFT Vs. DSP Builder FFT
I'v posted a thread in this section, maybe I was wrong, please check it at the following link
http://www.alteraforum.com/forum/showthread.php?t=1654&highlight=dsp+fft (http://www.alteraforum.com/forum/showthread.php?t=1654&highlight=dsp+fft) THANKS!14 Replies
- Altera_Forum
Honored Contributor
I just commented on your other post. Check it out.
- Altera_Forum
Honored Contributor
I will continue here the thread.
Thanks wronghorizon, but I've just checked these threads but I really cannot learn too much from them...:( Also because I found some incompatibility between the System Versions... I've tried to make my scheme more clear... maybe now somebody can be helpful to me. I will explain first my scheme and then my problems. It's fondamentally divided in 3 parts: 1) Matlab FFT power spectrum output using only the proper block "Matlab FFT Spectrum" 2) Matlab FFT power spectrum output using simpler matlab blocks, I made this to understand how to work with the Megacore output.... and to compare the Megacore output to somethin similar 3) Megacore FFT power spectrum The first output is obviously perfect!!:D The second output is not 0 on the frequencies not excaited...this because I haven't implemented the Hanning windowing I think ...but this is not a problem , anyway the plot show the right peak. The third output has some problem: It's seem to be shifted and it's not really accurate like the matlab one,some times the spectrum is not specular also..... Can you give me some suggestion???? THANKS http://img385.imageshack.us/img385/6451/fftimgqe1.jpg - Altera_Forum
Honored Contributor
Hi,
Just a basic question and thought... are you doing fft or PSD(power spectrm density). I haven't done simulink for years but it seems you are doing (fft) in (1) but possibly a sort of spectrum density on (2,3). I have used an old altera fft core(not DSPBuilder-based) and it was producing fft. compare the matlab functions fft & periodogram. These are two different things. fft doesn't use any windowing, periodogram does... Kaz - Altera_Forum
Honored Contributor
Hi Kaz, thanks for your reply,
I'm doing an FFT and I choose to display the power spectrum to have an understandable output to compare. I understood what you are saying. (1) Calculate the power spectrum using the periodogram with Hann windowing (2),(3) doesn't I've used the classic method: Sign --> FFT --> ( |RE|^2 + |Imm|^2 )/FFT_length --> frequency plot The problem is in the 3d plot as I've sayed before. - Altera_Forum
Honored Contributor
Hi,
Let us do things the easy way. I assume you want to compare your core fft output with matlab fft. This should be very easy, I suggest you consider the following: 1) ignore plot(2) altogether. 2) your sine input: you need to scale it to 12 bits then round it and input it to Matlab fft. and you need to convert these decimal values to 2's complement(12 bits) for the core(unless it uses a different scheme). 3) all what is left is compare output(should be almost bit-accurate apart from rounding effect) for both real and imaginary components. Make sure you read core output when it is ready. Remember core fft is block based and is only ready after some time. Also remember to round up matlab fft output. you better compare data directly instead of the spectrum at this stage. Your data must be identical and that tells it all. for step (2) to scale the sine wave from(-1 to +1) into 12 bit signed you need this: data = round((2^11-1)*sine_data/max(sine_data)); this to input to matlab fft for core fft you need decimal to 2's complement conversion of data... You can use the function dec2bin() but after some trick as the function doesn't accept signed values, you can convert them to equivalent unsigned first then enter them in dec2bin(). Most importantly, the frequency grid(fft resolution) should be same in both cases. hope this helps kaz - Altera_Forum
Honored Contributor
Be sure to pay attention to the sink_ready signal when you are using Altera's FFT core: the signal indicates when the core is ready to take on input. You are seeing the shift because you are not paying attention to this signal and are sending in data when the core isn't ready.
- Altera_Forum
Honored Contributor
@Wronghorizon: OK! Thank you!!!! I will check it!
@Kaz: I'm trying also in your way. I'm trying to find the proper simulink blocks to do that. - Altera_Forum
Honored Contributor
The sink_ready is up after 2 clock steps so I've delayed the input signal of 2 to send the input at the right time but the output is not shifted back...
I've tried also various time delay but the result is only to loose samples on the FFT first window.... - Altera_Forum
Honored Contributor
What version of DSP Builder are you using? I have a FFT/IFFT (Streaming architecture) Unity gain design (built using 8.0SP1) posted somewhere in this forum. That might help you out some...
- Altera_Forum
Honored Contributor
I have the DSP BUilder 7.2.
Do you know if I can update it easily? Or I need a new license?