Jump to content
  • 0

FFT / iFFT / RS - Basys3


donwazonesko

Question

Hello, 

A while ago i've managed to receive data from XADC using my board Basys3 and now i need to use FFT, iFFT and proceed the output from these to via RS to my computer. Could you please show me examples of FFT / iFFT and RS connection? I've been trying to find something online, but there is nothing as simple as that.

 

Best Regards,

Michael

Link to comment
Share on other sites

Recommended Posts

Hi,

if you aren't required to do it on the FPGA, you'll save yourselves a lot of implementation and debugging effort if you do the FFT offline.

An Octave script for the job can be found here. It's basically this

        b = b .* blackmanharris(numel(b));
        
        % calculate spectrum
        mag = abs(fft(b.')) .^ 2;
        
        f_Hz = fd_freqbase(numel(mag)) * rAdc_Hz;    
        
        % === keep only positive frequencies ===
        mask = (f_Hz >= 0) & (f_Hz < rAdc_Hz / 2);
        mag = mag(mask);
        f_Hz = f_Hz(mask);

        % === convert to dB ===
        mag = 10*log10(mag/max(mag)+eps);
		h = plot(f_Hz/1e3, mag); %set(h, 'lineWidth', 2);
        xlabel('f/kHz'); ylabel('dB');

  with those two functions

function fb = fd_freqbase(n)
    fb = 0:(n - 1);
    fb = fb + floor(n / 2);
    fb = mod(fb, n);
    fb = fb - floor(n / 2);
    
    fb = fb / n; % now [0..0.5[, [-0.5..0[
end

function win = blackmanharris(n)
    a0 = 0.35875;
    a1 = 0.48829;
    a2 = 0.14128;
    a3 = 0.01168;
    N = n-1;
    n = [0:N]';
    win = a0 - a1.*cos(2.*pi.*n./N) + a2.*cos(4.*pi.*n./N) - a3.*cos(6.*pi.*n./N);
end

There's many ways to skin a cat... this one has regulatory approval ?

This is just about postprocessing. You still need to transfer the data e.g. via a UART. I'd recommend 16 bit binary format. ASCII or hex will be very slow in comparison.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...