FFT Spectrum and Error Analysis
GX-TXT DEV112 P011-bis
Compute the FFT spectrum of a two-tone signal and compare the fundamental, harmonics and quality indicators over samples or intervals.
Enable and select the module
Open Configuration → Modules → Analysis & Services. Select FFT Spectrum & Error Analysis (analysis.fft_spectrum). Check that Health shows Available. With CORE / OFF press Enable module. The tested version is 2.3.0 in GX-TXT P011-bis. Open Analysis and enable Run / recalculate now to include the module in the current run.

Generate and acquire the teaching signal
- Open Sessions → Session → New Session… → Generate Session…. In GX-TXT Numerical Examples → Signals choose FFT Example (
fft_example1.0.0). Leave Standalone Session, choose the name and press Generate Session. The lab createsraw/fft_example.csvwith 1024 samples at 1024 Hz. The synthetic signal adds a 50 Hz tone with amplitude 1 and a 120 Hz tone with amplitude 0.4. - In Acquisition choose the generic CSV module. Add
raw/fft_example.csv, useguida.fft.misurafor the Dataset ID andtimeseries.tableas the contract. Check the columnstime_sandsignaland use Import into Current Session. - In Dataset select and enable
guida.fft.misura. In Variables, assign Unitsand Semantic roleelapsed_timetotime_s. Assign1to the columnsignal. Save and confirm the save. Check in Preview that the source contains 1024 rows.


Choose Dataset, time and signal
In Dataset sources assign guida.fft.misura to the role primary. The row is mandatory and its Remove is disabled. Use Independent (uniform sample axis, e.g. time) primary.time_s and Signal variable / channel to analyse primary.signal. The menu of each field shows auto and the fields of the source. Assign the two roles according to the meaning of the column. auto delegates the resolution to the module. Choose the time axis in seconds explicitly if you want to check the peaks in Hz. The axis must increase with a uniform step and the chosen values must be finite.
Data selection (optional X/time interval) accepts a saved X selection for the same source. None uses the available record. In temporal_set leave this selection at None and use any Parent Selection in the set definition.

To save a test interval, plot time_s and signal of the source with Scientific Dataset Plot. In Plots select that plot, use Data / Variants → Select data…, choose the series and Draw area in graph. Draw a rectangle between about 0.20 and 0.70 s that covers the height of the curve. Press Save Selection and close the dialog. In the FFT choose sel_001 in Data selection and run full_record. In the test the interval contains 512 samples, from about 0.2002 to 0.6992 s.

Process all samples, one block or a Temporal Set
- Analysis mode
full_record, the default, transforms the whole source or the chosen interval.fixed_blocktakes a single block.temporal_setpublishes an independent spectrum for each member of the set. Each member uses its own frequency grid. Separate regions stay distinct.- FFT length (fixed block; Auto = full record)
autogoes withfull_record. Forfixed_blockchoose the number of samples explicitly among 16384, 32768, 65536, 131072, 262144, 524288 or 1048576. The length must fit within the usable samples. Infixed_block,autocauses a run error.- Block position
startstarts from the first sample,centercenters the block in the selected record and is the default,explicituses Explicit block start sample. Enter a zero-based index, initially 0. The last sample of the block must fall inside the record or the selection.- Temporal Set
- In
temporal_setreplaceNonewith a Window Set or Segment Set of the same source and the same time variable. The mode requires at least one effective member and at least eight finite samples per member. The FFT button does not create the set.
For the temporal test, enable the source in Dataset → Temporal Sets… → New Window Set…. Set Label to Quattro finestre FFT, Temporal variable to time_s, Parent Selection to None, Basis to Samples, Window size and Step to 256 and Partial window to Drop. Press Save. With Duration, size and step are expressed in the selected Duration unit . Include includes the last incomplete block if there is one. In Analysis choose temporal_set and the saved set. Four 256-sample windows at 1024 Hz give four spectra with a frequency step of 4 Hz.

The original lab has fewer samples than the minimum block. For a fixed_blocktest, start from the Generator CSV (ZIP) and download extend_fft_example.py (ZIP). Run the command below. The resulting file repeats the Generator waveform 20 times, keeping the 1024 Hz grid. Import it as guida.fft.estesa and assign the same units.
python3 extend_fft_example.py fft_example.csv fft_example_20s.csv
Choose fixed_block, length 16384, and try start, center and explicit with index 1024. On 20,480 samples the report gives 0–16,383, 2048–18,431 and 1024–17,407 respectively. The frequency step is 0.0625 Hz.
In P011-bis, when you move from a Dataset with a Temporal Set selected to another source, the field can show None and the Run can still reject the old set as incompatible. Go back to the previous source, choose None explicitly and then select the new one. The block computation succeeded after this step.

Set the window, fundamental and quality measures
- Control
- FFT window
- Choices and effect
rectangularweights the samples uniformly and uses a narrow lobe.hann, the default, tapers the ends of the block.hamminguses a weighting with residual ends.blackman_harrisattenuates the side lobes more strongly.flat_topfavors the amplitude estimate over a wider lobe. The report gives the window and the estimate used.
- Control
- Pre-FFT detrend
- Choices and effect
nonekeeps the signal,meansubtracts the mean and is the default,linearsubtracts the estimated linear trend before windowing.
- Control
- Fundamental frequency
- Choices and effect
auto_peak, the default, searches for the reference peak. Withexplicitenter in Explicit fundamental [Hz] the expected frequency within the domain. The field is empty by default and becomes required inexplicit. In the lab use 50 Hz.
- Control
- Harmonics to track for THD (2..K)
- Choices and effect
- Maximum order number K, initially 10. The module searches for multiples starting from the second within the usable FFT range. Changing K can change the THD.
- Control
- SFDR spur search
- Choices and effect
all_nonfundamental, the default, also counts the harmonics among the admitted spurs.nonharmonic_onlyremoves the regions of the tracked harmonics from the search. The 120 Hz tone of the lab is distinct from the multiples of 50 Hz.
- Control
- Guard bins excluded around each tracked line
- Choices and effect
- Number of guard bins around each line. Start from 2. It changes the width of the neighborhood used or excluded in the measurements. One bin is fs/N Hz.

Run and read the spectrum, metadata and report
- In Analysis configure
full_record,hannand the lab bindings. In Run reread the plan and start the analysis. Completion is indicated by the message Selective analysis completed. After an error, check the date and origin of the output, because a previous Dataset may still be visible. - In Dataset select
guida.fft.misura.spectrum, contractspectrum.table. Preview identifies the result. Use Open Dataset → Canonical table to readfrequency_Hz,amplitudeandmagnitude_dBc. In Metadata readanalysis.statistical_results. Technical details shows the payload identity and the provenance. Intemporal_setopen instead each variant.spectrum.tset_001.win_…. - In Results open
fft_report.txtfor steps, sampling frequency, resolved fundamental and results. The report gives a 1 Hz step on the 1024-sample record. The lines at 50 and 120 Hz are the two expected tones. THD uses the tracked harmonics, SFDR uses the largest admitted spur and SINAD includes the power remaining after the declared exclusions. The effective number of bits estimated from SINAD uses the ideal full-scale quantizer convention.
This module publishes a numerical spectrum and a report. In the test the panel Plots did not add an automatic plot. To display them, use the separate module Scientific Dataset Plot with the source guida.fft.misura.spectrum. In Scientific dataset 2D → Series… choose frequency_Hz for X and amplitude for Y, save the series and start the module. In Plots select Scientific dataset 2D. The two peaks match the components of the Generator.


