Difference between revisions of "THD Sweep Measurement"

Jump to navigation Jump to search
Line 268: Line 268:




== THD: Mathematical Formulas and Theory ==
= THD Formulas ==


=== Standard THD Definition ===
=== THD Percentage (DC1) ===
 
==== THD as Percentage ====
 
The most common definition of THD is the ratio of RMS harmonic content to RMS fundamental:


<math>
<math>
\text{THD\%} = \frac{\sqrt{\sum_{n=2}^{N} V_n^2}}{V_1} \times 100
\text{THD\%} = \frac{\sqrt{H_2^2 + H_3^2 + \cdots + H_9^2}}{H_1} \times 100
</math>
</math>


Where:
Where:
* <math>V_1</math> = RMS amplitude of fundamental (1st harmonic)
* <math>H_1</math> = Fundamental amplitude
* <math>V_n</math> = RMS amplitude of nth harmonic (n = 2, 3, 4, ...)
* <math>H_2, H_3, \ldots, H_9</math> = Harmonic amplitudes
* <math>N</math> = total number of harmonics analyzed
 
This represents the percentage of harmonic content relative to the fundamental.
 
==== Alternative Form (Total Distortion) ====
 
Some standards define THD as:
 
<math>
\text{THD} = \frac{\sqrt{\sum_{n=2}^{N} V_n^2}}{\sqrt{V_1^2 + \sum_{n=2}^{N} V_n^2}}
</math>
 
This normalizes to total RMS content (including fundamental). This is sometimes called '''THD+N''' (Total Harmonic Distortion + Noise).


===== Relationship: THD% vs THD =====
'''Example:''' If H1 = 1.0 V and harmonics RMS = 0.05 V, then THD% = 5%
 
<math>
\text{THD\%} = \frac{\text{THD}}{\sqrt{1 - \text{THD}^2}} \times 100
</math>
 
For small distortions (THD < 0.1): <math>\text{THD\%} \approx 100 \times \text{THD}</math>


---
---


=== THD in Decibels ===
=== THD in Decibels (DC2) ===
 
==== From Ratio ====


<math>
<math>
\text{THD}_{\text{dB}} = 20 \log_{10}\left(\frac{\sqrt{\sum_{n=2}^{N} V_n^2}}{V_1}\right)
\text{THD}_{\text{dB}} = 20 \log_{10}\left(\frac{\sqrt{H_2^2 + H_3^2 + \cdots + H_9^2}}{H_1}\right)
</math>
</math>


==== From Percentage ====
Or equivalently:


<math>
<math>
Line 321: Line 296:
</math>
</math>


===== Interpretation =====
'''Example:''' THD% = 5% → THD dB = -26 dB
 
* <math>\text{THD}_{\text{dB}} = -20 \text{ dB}</math> → <math>\text{THD\%} \approx 10\%</math>
* <math>\text{THD}_{\text{dB}} = -40 \text{ dB}</math> <math>\text{THD\%} \approx 1\%</math>
* <math>\text{THD}_{\text{dB}} = -60 \text{ dB}</math> → <math>\text{THD\%} \approx 0.1\%</math>
 
Every -20 dB represents a factor of 10 reduction in THD%.


---
---


=== Implementation in THD Sweep Measurement ===
=== Conversion Reference ===


==== Calculation Functions ====
{| class="wikitable"
 
|-
The application uses the following approach:
! THD % !! THD dB
 
|-
===== Python Implementation =====
| 1% || -40 dB
 
|-
<source lang="python">
| 3% || -30 dB
import math
|-
 
| 10% || -20 dB
def compute_thd_percent(fundamental_v, harmonics_v):
|-
    """
| 30% || -10 dB
    Calculate THD as percentage.
|-
 
| 100% || 0 dB
    Args:
|}
        fundamental_v: Fundamental amplitude (H1)
        harmonics_v: List of harmonic amplitudes [H2, H3, H4, ...]
 
    Returns:
        THD percentage (0-100+)
    """
    if not harmonics_v or not fundamental_v or fundamental_v == 0:
        return None
 
    rms_harmonics = math.sqrt(sum(h * h for h in harmonics_v))
    return (rms_harmonics / abs(fundamental_v)) * 100.0
 
 
def compute_thd_db(fundamental_v, harmonics_v):
    """
    Calculate THD in decibels.
 
    Args:
        fundamental_v: Fundamental amplitude (H1)
        harmonics_v: List of harmonic amplitudes [H2, H3, H4, ...]
 
    Returns:
        THD in dB (-200 to 0 dB)
    """
    if not harmonics_v or not fundamental_v or fundamental_v == 0:
        return None
 
    rms_harmonics = math.sqrt(sum(h * h for h in harmonics_v))
    ratio = rms_harmonics / abs(fundamental_v)
 
    return 20.0 * math.log10(ratio) if ratio > 0 else -200.0
</source>


===== Coherence Between DC1 and DC2 =====
'''Rule:''' Lower dB = better (more negative = less distortion)
 
The two DC inputs maintain mathematical coherence:
 
<math>
\text{THD}_{\text{dB}} = 20 \log_{10}\left(\frac{\text{THD\%}}{100}\right)
</math>
 
Example:
* If DC1 (%) = 5.5
* Then DC2 (dB) = 20 × log₁₀(5.5/100) = 20 × log₁₀(0.055) ≈ -25.18 dB


---
---


=== Measurement Configuration ===
=== Three DC Outputs ===
 
==== Harmonic Analysis ====
 
The application measures up to '''N = 9 harmonics''' by default:
 
* '''H1''' (Fundamental): ~1 kHz to ~20 kHz (sweep dependent)
* '''H2-H9''' (Harmonics): 2× to 9× fundamental frequency
 
For a 1 kHz fundamental:
* H1 = 1.000 kHz
* H2 = 2.000 kHz
* H3 = 3.000 kHz
* H4 = 4.000 kHz
* ... up to
* H9 = 9.000 kHz
 
==== Display Zones ====
 
Both Max and Harmonic markers use:
* '''Interpolation Type 1''' (X-axis): Linear interpolation for frequency precision
* '''Display Zone Type 4''' (FFT magnitude): Standard magnitude spectrum
 
This ensures:
* Frequency accuracy to ~1 Hz (depending on FFT resolution)
* Amplitude accuracy to ~0.1 dB
 
---
 
=== Physical Quantities Configuration ===
 
The three DC Simulated inputs are configured with specific physical quantities:


{| class="wikitable"
{| class="wikitable"
|-
|-
! DC Channel !! Physical Quantity !! Unit !! Formula !! Range
! Output !! Formula !! Range
|-
|-
| DC1 || Percentage || % || <math>\text{THD\%} = \frac{\sqrt{\sum V_n^2}}{V_1} \times 100</math> || 0 - 100%
| '''DC1 (THD %)''' || <math>\text{THD\%}</math> || 0 - 100%
|-
|-
| DC2 || Ratio || dB || <math>20 \log_{10}(\text{ratio})</math> || -200 to 0 dB
| '''DC2 (THD dB)''' || <math>20 \log_{10}(\text{ratio})</math> || -200 to 0 dB
|-
|-
| DC3 || Frequency || Hz || <math>f_{\text{max}}</math> (from Max marker) || 0 - 40000 Hz
| '''DC3 (Frequency)''' || <math>f_{\text{sweep}}</math> || 0 - 40000 Hz
|}
|}
The application queries '''GetSettingValues()''' to dynamically find the correct enum index for each physical quantity, ensuring compatibility across NVGate configurations.
---
=== THD Standards Reference ===
==== IEC 61000-3-2 (EMC - Harmonic Current) ====
For equipment <16A supply current, limits defined for harmonics up to 40th:
<math>
\text{Harmonic order } n: I_h \leq I_{\text{limit}}(n)
</math>
Common limits (Class A equipment):
* H3: 30% of I1
* H5: 10% of I1
* H7: 7% of I1
* H9: 3% of I1
==== Audio Industry Standards ====
* '''Professional Audio (AES)''': THD < 0.05% @ 1 kHz
* '''Hi-Fi''': THD < 0.1% @ 1 kHz, 20 Hz - 20 kHz
* '''Consumer Audio''': THD < 1% @ 1 kHz
* '''Basic Consumer''': THD < 5% @ 1 kHz
---
=== Measurement Uncertainty ===
The THD measurement uncertainty depends on:
* '''FFT Resolution''': <math>\Delta f = \frac{f_s}{N_{\text{FFT}}}</math>
* '''Windowing''': Choice of window function (Hann, Hamming, etc.)
* '''Interpolation''': Type 1 (X-axis) reduces frequency leakage
* '''Signal Stability''': Amplitude variation during sweep
For typical speaker measurements:
* Frequency uncertainty: ±2 Hz
* Amplitude uncertainty: ±0.5 dB
* THD uncertainty: ±2% (relative)
---
=== Examples ===
==== Example 1: Good Speaker (5% THD) ====
Given:
* H1 = 1.0 V (fundamental at 1 kHz)
* H2 = 0.05 V
* H3 = 0.02 V
* H4 = 0.01 V
* H5 = 0.005 V
Calculation:
<math>
\text{RMS}_{\text{harmonics}} = \sqrt{0.05^2 + 0.02^2 + 0.01^2 + 0.005^2}
= \sqrt{0.0025 + 0.0004 + 0.0001 + 0.000025}
= \sqrt{0.003025} \approx 0.055 \text{ V}
</math>
<math>
\text{THD\%} = \frac{0.055}{1.0} \times 100 = 5.5\%
</math>
<math>
\text{THD}_{\text{dB}} = 20 \log_{10}(0.055) \approx -25.18 \text{ dB}
</math>
'''Result:''' DC1 = 5.5% | DC2 = -25.18 dB
==== Example 2: Poor Speaker (20% THD) ====
Given:
* H1 = 1.0 V
* H2 = 0.15 V
* H3 = 0.08 V
* H4 = 0.05 V
* H5 = 0.03 V
<math>
\text{RMS}_{\text{harmonics}} = \sqrt{0.15^2 + 0.08^2 + 0.05^2 + 0.03^2}
\approx 0.18 \text{ V}
</math>
<math>
\text{THD\%} = 18\%
</math>
<math>
\text{THD}_{\text{dB}} = 20 \log_{10}(0.18) \approx -14.89 \text{ dB}
</math>
'''Result:''' DC1 = 18% | DC2 = -14.89 dB
---
=== References ===
* [https://en.wikipedia.org/wiki/Total_harmonic_distortion Wikipedia - THD]
* IEC 61000-3-2:2018 - Electromagnetic compatibility
* AES Recommended Practice for Measurements of Single-Channel and Stereo Analog Audio
* Typical Audio Specifications and Measurements - Analog Devices
---
'''Last Updated:''' 2026-04-15
'''Format:''' MediaWiki with LaTeX formulas

Navigation menu