Difference between revisions of "THD Sweep Measurement"

From OROS Wiki
Jump to navigation Jump to search
(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.

Revision as of 11:10, 15 April 2026

Wiki : SystĂšme de Mesure de Balayage THD

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 & Lancement

Utilisation de l'Exécutable (Recommandé)

  1. Allez dans le dossier Template:Code.
  2. Lancez Template:Code.

Note : L'exĂ©cutable est autonome et contient toutes les dĂ©pendances.

Utilisation des Sources Python

  1. Assurez-vous d'avoir Python 3.8+ (32 bits recommandé pour la compatibilité NVGate).
  2. Lancez le script via Template:Code ou par ligne de commande : Template:Code.

🛠 Configuration NVGate Requise

Pour que le logiciel fonctionne correctement, votre projet NVGate doit ĂȘtre configurĂ© comme suit :

  1. 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).
  2. Marqueurs :
    • Le logiciel gĂšre automatiquement un marqueur Max dans Window2 et un marqueur Harmonique dans Window1.
  3. 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.

📊 DĂ©tails MĂ©trologiques

Formule de Calcul

Le logiciel calcule la THD relative Ă  la fondamentale ($THD_f$) selon la norme IEC 61000-4-7 :

  • H1 : Amplitude de la fondamentale.
  • H2 Ă  H10 : Amplitude des harmoniques (le logiciel suit les 9 premiĂšres par dĂ©faut).

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.

đŸ’» DĂ©veloppement et Compilation

==== Structure du Projet