Difference between revisions of "THD Sweep Measurement"

Jump to navigation Jump to search
no edit summary
(Created page with "# 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 `dist/` folder. 2. Launch `THD_Sweep_Measurement.exe`. *Note: The executable is standalone and contains all dependencies.* ### Using Python Sources 1. Ensure you have Python 3.8+ (32-bit preferred for NVGat...")
 
Line 1: Line 1:
# Wiki: THD Sweep Measurement System
== Wiki : Système de Mesure de Balayage THD ==


This software allows for continuous measurement of **Total Harmonic Distortion (THD)** during a frequency sweep (sweep sine) with an OROS 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.


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


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


### Using Python Sources
==== Utilisation des Sources Python ====
1. Ensure you have Python 3.8+ (32-bit preferred for NVGate compatibility).
# Assurez-vous d'avoir Python 3.8+ (32 bits recommandé pour la compatibilité NVGate).
2. Launch the script via `Lancer_THD.bat` or via command line: `python thd_gui.py`.
# Lancez le script via {{code|Lancer_THD.bat}} ou par ligne de commande : {{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''' :
#* '''Fenêtre 1 (Window1)''' : Doit afficher la voie de réponse (Microphone).
#* '''Fenêtre 2 (Window2)''' : Doit afficher la voie de référence (Sweep Sine).
# '''Marqueurs''' :
#* Le logiciel gère automatiquement un marqueur '''Max''' dans Window2 et un marqueur '''Harmonique''' dans Window1.
# '''Entrées DC Simulées''' :
#* Activez les entrées DC simulées dans le Front-end.
#* '''DC1''' recevra la valeur THD en '''%'''.
#* '''DC2''' recevra la valeur THD en '''dB'''.


1.  **FFT Analyzer**:
=== 📊 Détails Métrologiques ===
    *  **Window 2 (Window2)**: Must display the reference channel (Sweep Sine).
    *  **Window 1 (Window1)**: Must display the response channel (Microphone).
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**.


---
==== Formule de Calcul ====
Le logiciel calcule la THD relative à la fondamentale ($THD_f$) selon la norme IEC 61000-4-7 :


## 📊 Metrological Details
<math>THD_{\%} = \frac{\sqrt{\sum_{n=2}^{10} H_n^2}}{H_1} \times 100</math>


### Calculation Formula
* '''H1''' : Amplitude de la fondamentale.
The software calculates THD relative to the fundamental ($THD_f$) according to the IEC 61000-4-7 standard:
* '''H2 à H10''' : Amplitude des harmoniques (le logiciel suit les 9 premières par défaut).


$$THD_{\%} = \frac{\sqrt{\sum_{n=2}^{10} H_n^2}}{H_1} \times 100$$
==== Précision et Latence ====
* '''Mode Asynchrone''' : Pas de délai artificiel entre les cycles.
* '''Latence''' : Une latence < 150ms est recommandée pour un sweep sine.
* '''Vitesse de balayage''' : '''4 octaves/min''' est un bon compromis précision/vitesse.
* '''Fenêtrage FFT''' : Utilisez une fenêtre de '''Hanning'''.


*  **H1**: Amplitude of the fundamental.
=== 💻 Développement et Compilation ===
*  **H2 to H10**: Amplitude of harmonics (the software tracks the first 9 harmonics by default).


### Precision and Latency
==== Structure du Projet
*  The software operates in **"Maximum Asynchronous"** mode. There is no artificial delay between measurement cycles.
*  **Latency**: The time displayed in the logs corresponds to the total time of one cycle (Frequency Read -> Calculation -> DC Write). For a sweep sine, latency < 150ms is recommended.
*  **Recommended Sweep Speed**: **4 octaves/min**. This is a good balance between measurement speed and tracking accuracy.
*  **FFT Windowing**: Use a **Hanning** window. It provides the best frequency resolution for a sweep sine, ensuring clear separation between the fundamental and its harmonics.
 
---
 
## 💻 Development and Compilation
 
### Project Structure
*  `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
If you modify the source code, you can generate a new `.exe` with the command:
```bash
pyinstaller --onefile --windowed --name "THD_Sweep_Measurement" --add-data "Toolkit NVdrive;Toolkit NVdrive" thd_gui.py
```
 
---
 
## ❓ Troubleshooting
 
*  **"Error 4 bytes"**: This network buffer error is handled automatically by a 20ms pause. If it persists, check your local network load.
*  **THD at 0% or --**: Ensure the signal is present in Window1 and that the Max marker in Window2 detects a valid frequency (> 0 Hz).
*  **NVGate not connected**: Verify that NVGate is running and that the "NVDrive" option is enabled in NVGate settings.

Navigation menu