9,371
edits
| Line 1: | Line 1: | ||
== Wiki : | == 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 & | === 🚀 Installation & Launch === | ||
==== | ==== Using the Executable (Recommended) ==== | ||
# | # Go to the {{code|dist/}} folder. | ||
# | # Launch {{code|THD_Sweep_Measurement.exe}}. | ||
''Note : | ''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 {{code|Lancer_THD.bat}} or via command line: {{code|python thd_gui.py}}. | ||
=== 🛠 Configuration | === 🛠 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''' | #* '''DC1''' will receive the THD value in '''%'''. | ||
#* '''DC2''' | #* '''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: | |||
<math>THD_{\%} = \frac{\sqrt{\sum_{n=2}^{10} H_n^2}}{H_1} \times 100</math> | <math>THD_{\%} = \frac{\sqrt{\sum_{n=2}^{10} H_n^2}}{H_1} \times 100</math> | ||
* '''H1''' : Amplitude | * '''H1''': Amplitude of the fundamental. | ||
* '''H2 | * '''H2 to H10''': Amplitude of harmonics (the software tracks the first 9 harmonics by default). | ||
==== | ==== Precision and Latency ==== | ||
* '''Mode | * '''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 === | ||
==== Structure | ==== Project Structure ==== | ||
{| class="wikitable" | |||
! 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. | |||