FFT Scope
SinksThe FFTScope block is a real-time frequency spectrum analyzer that performs the Fast Fourier Transform (FFT) on incoming simulation signals. It functions as a sink block, accepting one or more input signal connections and displaying their overlaid, color-coded magnitude or phase spectra directly on the canvas.
Control engineers and signal processing specialists use this block to identify dominant resonant modes, evaluate harmonic distortion in non-linear loops, verify digital filter stopband rejection, and inspect phase alignment across frequency bins.
Mathematical Model
For a discrete-time signal sequence conditioned by a tapering window over buffer length :
The discrete frequency corresponding to bin is , where is the simulation sample rate. Depending on displayMode, the spectral values are computed as:
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | signal |
Signal | number | Required |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
title |
Title | text | Frequency Spectrum |
|
displayMode |
Display Mode | select | db |
|
analysisMode |
Analysis Mode | select | window |
|
fftSize |
FFT Window Size | select | 1024 |
Number of samples used per FFT computation. |
windowFunction |
Window Function | select | hann |
Reduces spectral leakage. |
maxFrequency |
Max Frequency (Hz, 0 = auto) | number | 0 |
Set to 0 to auto-scale based on the Nyquist frequency. |
peakHold |
Peak Hold | boolean | false |
Maintains the maximum value reached across all spectra. |
showLegend |
Show Legend | boolean | true |
|
showGrid |
Show Grid | boolean | true |
Usage Examples
Example 1: Harmonic Distortion in Saturated Feedback Loops
Measuring harmonic content generated by an amplifier with saturation non-linearities. Wiring the saturated output to FFTScope in "db" mode with fftSize = "1024" and windowFunction = "blackman". The spectrum displays the primary excitation peak at 50 Hz alongside third (150 Hz) and fifth (250 Hz) harmonic spurs at dB and dB below fundamental.
Example 2: Digital Filter Passband and Attenuation Verification
Verifying stopband attenuation of a DigitalFilter lowpass block fed by broadband white noise. Connecting both raw noise and filtered output to the multi-input port with displayMode = "db" and peakHold = true. The comparative spectra confirm a flat response up to the 100 Hz cutoff followed by steep dB/decade roll-off.
Remarks & Best Practices
- Nyquist-Shannon Sampling Boundary: The maximum observable frequency is limited to half the simulation sample rate (). Frequencies exceeding this limit will alias into lower frequency bins.
- Window Trade-Offs: The Hann window offers optimal trade-off between main-lobe width and side-lobe suppression for continuous oscillations; use Blackman for high dynamic range and Rectangular for transient impulses.
- Resolution Scaling: Frequency bin resolution improves with larger buffer sizes (); use
"full"analysis mode post-simulation for ultra-fine sub-Hertz spectral line extraction. - Buffer Initialization: If the simulation has stepped fewer times than
fftSize, the input buffer is zero-padded to allow immediate spectral estimation.
Related Components
- uPlotDisplay: Multi-channel time-series oscilloscope for time-domain waveform analysis.
- DigitalFilter: Configurable IIR/FIR filter block for band-limiting signals.
- SignalGenerator: Multi-waveform signal source for frequency-domain stimulus.
- NumericDisplay: Real-time scalar readout for instantaneous signal magnitudes.