THD Sweep Measurement

From OROS Wiki
Revision as of 11:08, 15 April 2026 by Lmagimel (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. 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.

    1. 🚀 Installation & Launch
      1. 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.*
      1. Using Python Sources

1. Ensure you have Python 3.8+ (32-bit preferred for NVGate compatibility). 2. Launch the script via `Lancer_THD.bat` or via command line: `python thd_gui.py`.

---

    1. 🛠 Required NVGate Configuration

For the software to function correctly, your NVGate project must be configured as follows:

1. **FFT Analyzer**:

   *   **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**.

---

    1. 📊 Metrological Details
      1. Calculation Formula

The software calculates THD relative to the fundamental ($THD_f$) according to the IEC 61000-4-7 standard:

$$THD_{\%} = \frac{\sqrt{\sum_{n=2}^{10} H_n^2}}{H_1} \times 100$$

  • **H1**: Amplitude of the fundamental.
  • **H2 to H10**: Amplitude of harmonics (the software tracks the first 9 harmonics by default).
      1. Precision and Latency
  • 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.

---

    1. 💻 Development and Compilation
      1. 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.
      1. 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 ```

---

    1. ❓ 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.