Hochschule Kempten      
Fakultät Elektrotechnik      
Elektronik       Fachgebiet Elektronik, Prof. Vollrath      

FFT (Fast Fourier Transformation)

02.12.2022 Joerg Vollrath

+    Share page with QR-code

Today we want to look at the FFT tab in EEBench.

User interface



Figure: FFT tab

The user interface shows the 'Run' button, 'Channel' selection for the magnitude list, a magnitude list and the display of the FFT of all selected channels.

FFT data (array betragdB) of active channels (array dataOSC2) plotting can be done by chart.js
For fft function dspFFT.js is used: Spectrum Analyzer.
For a class about data converters'Interface Electronics' a browser based FFT tool was realized, which can be used as starting point for SNR calculation and table creation.

Layout


The 'Run' button and channel selection list is placed on top of the page.
<table class="bx">
 <tr><td class="bo">
     <span id="fRun"  style="display:block" onclick="generateFFT()"><img src="ImagesS/Run.png" width="16"> Run  </span>
     <span id="fStop" style="display:none"  onclick="fOp('Stop')"><img src="ImagesS/Stop.png" width="16"> Stop </span> </td>
 </tr>
 <tr>
   <td class="bo">Channel   
      <select name="fftSrc" id="fftSrc" onclick="calcHarmonics()">
       <option value="1"> AWG1 </option>
       <option value="2"> C1 </option>
       <option value="3"> C2 </option>
       <option value="4"> C3 </option>
       <option value="5"> C4 </option>
	  </select>
   </td>
 </tr>
Only one list of SNR ratios for the active curve is shown, but FFTs for all curves are calculated and displayed.
From the example file FFT_Javascript_2017_Calibration.html the following functions were copied:
function nextPwrOf2(n)
function nutall(nPair)  { // Nutall window
function blackman(nPair) { // Blackman window
function hamming(nPair) { // Hamming window
function calcHarmonics() {  // List of harmonics
function generateFFT() {    // Calculate and display FFT 
After a review some code was updated for consistency of naming conventions.
The function calcHarmonics was extracted from generateFFT to be able to change the channel for the list of shown SNR ratios.

The ScatterPlot function was updated to ScatterPlotO to display consistent colors according to the oscilloscope.
Scaling of axis had to be changed, since now the x-axis is logarithmic and all curves have the same scaling.

Test of FFT function


A button with a function
function generateData() {
implemented at the oscilloscop tab was used to generated a base set of data which can then be analyzed with FFT and used for test.

Only active channels are displayed in the FFT window.
Correct values were checked with the harmonics list and the SNR ratio.

A live acquisition was then done with AWG1 at signal frequency = 2.00 kHz, amplitude 1 V and offset 1 V.
The FFT showed the expected signal level but a lot of bleeding of the signal.
The signal to noise ratio was very bad.
First try was to adjust the frequency and step size to get an integer number of periods during acquisition.
Former experience (FFT_Javascript_2017_Calibration.html, Sine signal and FFT playground) showed not optimum SNRs using windowing.
The limited precision (3) of the input fields of signal frequency at first limited step size resolution and was increased to 6.
function valueToUnit(val) {
..
    return (val*scale).toPrecision(6) + " " + mod;
}
For a 16-Bit DAC digital code generator a maximum SNR of -40 dB was achieved with the signal frequency of 2.3500 kHz.
This is far from the expected 16*6.02 dB = 96 dB.

A short experiment with Sine signal (5 amplitude) and FFT playground showed with a 256 FFT points and a signal length variation from 4.. .115 points the resulting frequency, signal magnitude and noise magnitude.

The signal amplitude has a maximum of 10.97 dB and noise magnitude goes down to -270 dB for period length of 4,8,16,32 and 64.
Effective number of bits is ENOB = (10.97 dB - (-270 dB) / 6 dB = 47.
(A 64 Bit floating point number has 1 sign bit, 11 exponent bis and 52 fraction bits.)

In between bleeding can be seen reducing the signal to noise margin. A non-integer number of periods causes a jump at the end of the FFT points.
For period length of 85 (-19 dB noise, 256/3), 51 (-15 dB, 256/5), 43 (-7.5, dB 256/6) and 37 (-2.7 dB, 256/7) the period nearly fits to the 256 points and bleeding and noise level is reduced.
For the remaining cases a signal to noise ratio less than 5 dB can be seen.

Windowing

Windowing can be used to estimate signal to noise ratio with non integer number of periods. The signal will be distributed to more bins (see next figure) and the signal to noise ratio improves.


Figure: Windowing an non integer number of periods for FFT

In FFT playground an offset of 0 and amplitude of 5 is used for the experiment.

CaseWindowFFT pointslengthsignal / dB total noise / dB Signal width (bins)adjusted noise
IdealNone12864 11 -289 1 -289
IdealBlackmann1286424.8 6-99
IdealHann128644.95 10-74
IdealHamming128645.64.3 10-74
IdealNutall128642.24.8 4-297
BleedingNone1285 8.5 101 10
BleedingBlackmann1285 1.5 5.57 -79
BleedingHann1285 4 6.310 -42
BleedingHamming1285 4.5 6.34 -22
BleedingNutall1285 1.6 5.67 -75
BleedingNone12885 8.5 10.31 10.3
BleedingBlackmann12885 1.8 6.47 -87
BleedingHann12885 3.6 6.710 -62
BleedingHamming12885 3.8 75 -40
BleedingNutall12885 1.9 6.46 -87
BleedingNone4k85 8.5 10.31 10.3
BleedingBlackmann4k85 1.9 5.27 -83
BleedingHann4k85 4.7 5.310 -47
BleedingHamming4k85 5.4 4.84 -27
BleedingNutall4k85 2 5.26 -79

( Kaiser window is not updating in FFT playground)
Windowing: Blackmann and Nutall are good, Hann und Hamming are bad. More FFT points give more noise.
What is limiting the maximum signal to noise ratio for windowing in the simulation? Windowing coefficients?

Now investigate around length 85:

NFFT128256 5121024 20484096
lengthSignal dBNoise dBSignal dBNoise dB Signal dBNoise dBSignal dBNoise dB Signal dBNoise dBSignal dBNoise dB
84 8.25 10.5 10.87 -7.21 10.78 -1.26 10.41 4.57 8.83 9.91 10.14 6.36
85 8.54 10.26 10.95 -19.39 10.94 -13.39 10.92 -7.39 10.83 -1.41 10.45 4.45
86 8.79 10.02 10.99 -13.52 10.97 -7.53 10.87 -1.55 10.48 4.34 8.87 9.8

Since for more FFT points the same period length has higher ratio the signal to noise ratio decreases??

Frequency: FFT points / 7 Signal dB Noise dB
4096/7 = 585 (585.1428) 10.97 -36.18
2048/7 = 293 (292.5714)10.97 -20.64
1024/7 = 146 (146.2857)10.96 -18.1
512/7 = 73 (73.1429)10.96 -18.1

More FFT points lead to better signal noise ratio for nearly fitting periods.

Source synchronous signal generation and sampling is required.

Up to EEBench_V05 the XADC sampling rate is 1 MSps and it is done 8 times for the channels giving fsample = 125kHz (8 us), the signal generator runs at 100 MHz and gives every 4th clk cycle (25 MHz, 40 ns) a new value.
256 samples are taken for FFT.
There is a factor of 25 between the sources.
There are 2 possible solutions:
1) The XADC sampling rate could be reduced to 25 MHz/32 =781.25 kHz (1.28 us * 8 = 10.24 us).
2) The AWG1 rate is reduced to 4 MHz (counter to 25) update in sineX pipe = "011000" .

Measurement XADC address change frequency at JA1 gives 8.32us/10ns = 832 cycles per sample.
Datasheet (7 Series FPGAs and Zynq-7000, All Programmable SoC, XADC Dual 12-Bit 1 MSPS, Analog-to-Digital Converter, User Guide, UG480 ) gives 104 clock cycles per conversion (Figure 5-1: Continous Sampling Mode). This gives 832 cycles per conversion.
Measurement of DA0 JB1 gives 250ns minimum pulse (25 cycles) with variable pipe of 24 in sineX.vhd.
DAC could be 13 cycles per sample: 13 * 64 = 832. Change variable pipe to 12.

Change in NEEBench.html, function genCmdAWG(), curveTyp == 1,
step = Math.trunc(1024*1024*1024/(1E8/4/frequency));
step = Math.trunc(30-bit for sine/(TclkfpgA/(pipe+1)/frequency));
step = Math.trunc(1024*1024*1024/(1E8/13/frequency));

Practical test showed for 3 periods with a step of 196608 = 3 * 64 * 1024 sometimes a FFT SNR = 1.07 dB - (-96.87) dB = 97.94 is ENOB = SNR/6 dB = 16 Bit.

Number of cyclesfrequency in kHzStep
31.40851196608 = 3 * 64 * 1024
115.16452 720896 = 11 * 64 * 1024
10147.419625 6619136 = 101 * 64 * 1024

Again precision 6 is for 101 cycles not enough. Precision of 8 is needed.
How can user friendly frequencies like 10, 20, 50, 100 kHz be used for FFT without bleeding?

Number of cyclesfrequency in kHzStep
41.878
115.16452
219.859
4320.188
10750.237


Summary



Open is the implementation for optimum sampling with poer of 2 number of FFT points at user friendly frequencies while using 100MHz FPGA frequency.
UART needs also fixed FPGA frequency.
Changing frequnecy can lead to clock domain interface.