Skip to content

Commit

Permalink
Further updates to SSB doc page
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthPagadarai committed Nov 14, 2024
1 parent b9fe7f7 commit 4b098b9
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions doc/spectral_analysis_ssb.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ As before, we will follow the three-stage workflow shown below.
We will first generate the waveform to be analyzed, compute its FFT, and calculate various performance metrics by running spectral analysis. Please refer to the [leakage and spectral-analysis example](https://github.com/analogdevicesinc/genalyzer/blob/main/bindings/python/examples/gn_doc_spectral_analysis2.py) Python script to follow the discussion on this page.

## Leakage
```{eval-rst}
.. mermaid::
graph LR;
A[Generate/Import Waveform] --> B[Compute FFT];
B -->C1[Configure Spectral Analysis];
subgraph SA[Spectral Analysis]
C1[Configure] -->C2[Run];
end
style SA fill:#ffffff
style A fill:#9fa4fc
style B fill:#9fa4fc
```
In the [leakage and spectral-analysis example](https://github.com/analogdevicesinc/genalyzer/blob/main/bindings/python/examples/gn_doc_spectral_analysis2.py) Python script, we generate the complex-sinusoidal waveform as follows:
```{code-block} python
# signal configuration
Expand All @@ -40,16 +56,14 @@ A time-domain plot of the complex-sinusoidal tone is shown below for reference.
Time-domain plot of a ``375 KHz`` complex sinusoidal tone sampled at ``4 MSPS``.
```
As shown in this plot, the snapshot of the signal is aperiodic and data is sampled over an incomplete period at the end of the data record. This discontinuity causes _leakage_ resulting in a smearing effect that spreads the energy of a tone over a wider frequency range, with the appearance of frequency components that are not present in the original signal. This is readily seen in the FFT plot of the complex-sinusoidal tone shown below.
As shown in this plot, the snapshot of the signal is aperiodic and data is sampled over an incomplete period at the end. This discontinuity causes _leakage_ resulting in a smearing effect that spreads the energy of a tone over a wider frequency range, with the appearance of frequency components that are not present in the original signal. This is readily seen in the FFT plot of the complex-sinusoidal tone shown below.
```{figure} figures/fft2.png
FFT plot of a ``375 KHz`` complex sinusoidal tone sampled at ``4 MSPS``.
```

### Windowing To Reduce Leakage
Note that in the FFT plot shown previously, the FFT of the time-domain waveform was computed as is with the underlying assumption that the waveform is periodic. In practice, since this assumption is generally invalid and the snapshot of a wavform contain incomplete periods rendering the signal aperiodic, a window function is applied to overcome leakage. A window function shapes the time-domain waveform such that the first and last samples are exactly zero, and the samples in between are multiplied according to a mathematical function that is symmetric around the center and tapers off away from the center. Thus, by applying a window function, an aperiodic waveform is forced to be periodic. When computing the FFT of a waveform to which a window function has been applied, a weighting factor must also be taken into account so that the correct FFT signal amplitude level is recovered after the windowing. Genalyzer takes this effect into account.

In the [leakage and spectral-analysis example](https://github.com/analogdevicesinc/genalyzer/blob/main/bindings/python/examples/gn_doc_spectral_analysis2.py) Python script, we used Blackman-Harris window as follows:
Note that in the FFT plot shown previously, the FFT of the time-domain waveform was computed as is with the underlying assumption that the waveform is periodic. In practice, this assumption is generally invalid and the snapshot of a wavform contains incomplete periods rendering the signal aperiodic. Consequently, a window function is applied to overcome leakage. In the [leakage and spectral-analysis example](https://github.com/analogdevicesinc/genalyzer/blob/main/bindings/python/examples/gn_doc_spectral_analysis2.py) Python script, we used Blackman-Harris window as shown in the snippet below:
```{code-block} python
# signal configuration
npts = 30000 # number of points in the signal
Expand Down Expand Up @@ -79,8 +93,28 @@ qwfq = gn.quantize(awfq, fsr, qres, qnoise, code_fmt)
# compute FFT
fft_cplx = gn.fft(qwfi, qwfq, qres, navg, nfft, window, code_fmt)
```
The FFT plot of the tone where Blackman-Harris window has been applied prior to computing the FFT is shown below for reference.
```{figure} figures/fft.png

A window function shapes the time-domain waveform such that the first and last samples are exactly zero, and the samples in between are multiplied according to a mathematical function that is symmetric around the center and tapers off away from the center. Thus, an aperiodic waveform is forced to be periodic. As a result, the FFT plot below shows that leakage has been minimized and a sharp peak where the tone is expected is seen clearly.
```{figure} figures/fft3.png
FFT plot of a ``375 KHz`` complex sinusoidal tone sampled at ``4 MSPS``.
```
```{note}
When computing the FFT of a waveform to which a window function has been applied, a weighting factor must also be taken into account so that the correct FFT signal amplitude level is recovered after the windowing. Genalyzer takes this effect into account.
```

## Configuring Single Side Bins
```{eval-rst}
.. mermaid::
graph LR;
A[Generate/Import Waveform] --> B[Compute FFT];
B -->C1[Configure Spectral Analysis];
subgraph SA[Spectral Analysis]
C1[Configure] -->C2[Run];
end
style C1 fill:#9fa4fc
style SA fill:#ffffff
```

0 comments on commit 4b098b9

Please sign in to comment.