THD Sweep Measurement
Jump to navigation
Jump to search
Wiki: THD Sweep Measurement System
This software allows for continuous measurement of Total Harmonic Distortion (THD) during a frequency sweep (sweep sine) with an OROS system.
π Installation & Launch
Using the Executable (Recommended)
- Go to the Template:Code folder.
- Launch Template:Code.
Note: The executable is standalone and contains all dependencies.
Using Python Sources
- Ensure you have Python 3.8+ (32-bit preferred for NVGate compatibility).
- Launch the script via Template:Code or via command line: Template:Code.
π Required NVGate Configuration
For the software to function correctly, your NVGate project must be configured as follows:
- FFT Analyzer:
- Window 1 (Window1): Must display the response channel (Microphone).
- Window 2 (Window2): Must display the reference channel (Sweep Sine).
- Markers:
- The software will automatically create and manage a Max marker in Window2 and a Harmonic marker in Window1.
- Simulated DC Inputs:
- Enable simulated DC inputs in the Front-end.
- DC1 will receive the THD value in %.
- DC2 will receive the THD value in dB.
π Metrological Details
Calculation Formula
The software calculates THD relative to the fundamental ($THD_f$) according to the IEC 61000-4-7 standard:
Β
- H1: Amplitude of the fundamental.
- H2 to H10: Amplitude of harmonics (the software tracks the first 9 harmonics by default).
Precision and Latency
- Maximum Asynchronous Mode: There is no artificial delay between measurement cycles.
- Latency: A total cycle time (Frequency Read -> Calculation -> DC Write) of < 150ms is recommended.
- Recommended Sweep Speed: 4 octaves/min. This ensures a good balance between measurement speed and tracking accuracy.
- FFT Windowing: Use a Hanning window for the best frequency resolution during a sweep sine.
π» Development and Compilation
Project Structure
| File | Role |
|---|---|
| thd_gui.py | Graphical user interface (Tkinter) |
| thd_sweep_measurement.py | Core calculation and NVGate communication |
| Toolkit NVdrive/ | pynvdrive library to control NVGate |
Recompiling the Executable
<syntaxhighlight lang="bash"> pyinstaller --onefile --windowed --name "THD_Sweep_Measurement" --add-data "Toolkit NVdrive;Toolkit NVdrive" thd_gui.py </syntaxhighlight>
β Troubleshooting
- "Error 4 bytes": Network buffer error handled automatically by a 20ms pause. Check local network load if it persists.
- THD at 0% or --: Ensure the signal is present in Window1 and the Max marker in Window2 detects a valid frequency (> 0 Hz).
- NVGate not connected: Verify that NVGate is running and the "NVDrive" option is enabled in settings.