Difference between revisions of "THD Sweep Measurement"

From OROS Wiki
Jump to navigation Jump to search
Line 1: Line 1:
== Wiki : Système de Mesure de Balayage THD ==
== Wiki: THD Sweep Measurement System ==


Ce logiciel permet la mesure continue de la '''Distorsion Harmonique Totale (THD)''' pendant un balayage de fréquence (''sweep sine'') avec un système OROS.
This software allows for continuous measurement of '''Total Harmonic Distortion (THD)''' during a frequency sweep (sweep sine) with an OROS system.


=== 🚀 Installation & Lancement ===
=== 🚀 Installation & Launch ===


==== Utilisation de l'Exécutable (Recommandé) ====
==== Using the Executable (Recommended) ====
# Allez dans le dossier {{code|dist/}}.
# Go to the {{code|dist/}} folder.
# Lancez {{code|THD_Sweep_Measurement.exe}}.
# Launch {{code|THD_Sweep_Measurement.exe}}.
''Note : L'exécutable est autonome et contient toutes les dépendances.''
''Note: The executable is standalone and contains all dependencies.''


==== Utilisation des Sources Python ====
==== Using Python Sources ====
# Assurez-vous d'avoir Python 3.8+ (32 bits recommandé pour la compatibilité NVGate).
# Ensure you have Python 3.8+ (32-bit preferred for NVGate compatibility).
# Lancez le script via {{code|Lancer_THD.bat}} ou par ligne de commande : {{code|python thd_gui.py}}.
# Launch the script via {{code|Lancer_THD.bat}} or via command line: {{code|python thd_gui.py}}.


=== 🛠 Configuration NVGate Requise ===
=== 🛠 Required NVGate Configuration ===


Pour que le logiciel fonctionne correctement, votre projet NVGate doit être configuré comme suit :
For the software to function correctly, your NVGate project must be configured as follows:


# '''Analyseur FFT''' :
# '''FFT Analyzer''':
#* '''Fenêtre 1 (Window1)''' : Doit afficher la voie de réponse (Microphone).
#* '''Window 1 (Window1)''': Must display the response channel (Microphone).
#* '''Fenêtre 2 (Window2)''' : Doit afficher la voie de référence (Sweep Sine).
#* '''Window 2 (Window2)''': Must display the reference channel (Sweep Sine).
# '''Marqueurs''' :
# '''Markers''':
#* Le logiciel gère automatiquement un marqueur '''Max''' dans Window2 et un marqueur '''Harmonique''' dans Window1.
#* The software will automatically create and manage a '''Max''' marker in Window2 and a '''Harmonic''' marker in Window1.
# '''Entrées DC Simulées''' :
# '''Simulated DC Inputs''':
#* Activez les entrées DC simulées dans le Front-end.
#* Enable simulated DC inputs in the Front-end.
#* '''DC1''' recevra la valeur THD en '''%'''.
#* '''DC1''' will receive the THD value in '''%'''.
#* '''DC2''' recevra la valeur THD en '''dB'''.
#* '''DC2''' will receive the THD value in '''dB'''.


=== 📊 Détails Métrologiques ===
=== 📊 Metrological Details ===


==== Formule de Calcul ====
==== Calculation Formula ====
Le logiciel calcule la THD relative à la fondamentale ($THD_f$) selon la norme IEC 61000-4-7 :
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 de la fondamentale.
* '''H1''': Amplitude of the fundamental.
* '''H2 à H10''' : Amplitude des harmoniques (le logiciel suit les 9 premières par défaut).
* '''H2 to H10''': Amplitude of harmonics (the software tracks the first 9 harmonics by default).


==== Précision et Latence ====
==== Precision and Latency ====
* '''Mode Asynchrone''' : Pas de délai artificiel entre les cycles.
* '''Maximum Asynchronous Mode''': There is no artificial delay between measurement cycles.
* '''Latence''' : Une latence < 150ms est recommandée pour un sweep sine.
* '''Latency''': A total cycle time (Frequency Read -> Calculation -> DC Write) of < 150ms is recommended.
* '''Vitesse de balayage''' : '''4 octaves/min''' est un bon compromis précision/vitesse.
* '''Recommended Sweep Speed''': '''4 octaves/min'''. This ensures a good balance between measurement speed and tracking accuracy.
* '''Fenêtrage FFT''' : Utilisez une fenêtre de '''Hanning'''.
* '''FFT Windowing''': Use a '''Hanning''' window for the best frequency resolution during a sweep sine.


=== 💻 Développement et Compilation ===
=== 💻 Development and Compilation ===


==== Structure du Projet
==== 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.

Revision as of 11:11, 15 April 2026

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)

  1. Go to the Template:Code folder.
  2. Launch Template:Code.

Note: The executable is standalone and contains all dependencies.

Using Python Sources

  1. Ensure you have Python 3.8+ (32-bit preferred for NVGate compatibility).
  2. 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:

  1. FFT Analyzer:
    • Window 1 (Window1): Must display the response channel (Microphone).
    • Window 2 (Window2): Must display the reference channel (Sweep Sine).
  2. Markers:
    • The software will automatically create and manage a Max marker in Window2 and a Harmonic marker in Window1.
  3. 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.