How can I calculate THD using only the first harmonic? How can I implement in C code DFT voltage formula in order to calculate THD?
Asked
Active
Viewed 143 times
0
-
does the waveform only have one harmonic? – Apr 26 '21 at 10:45
-
I have a PCB that is connected to the power grid by using AC/AC adapter. My number of samples is 512 (since the microcontroller tact frequency of 25.6 kHz divided by 50 Hz gives 512). I am using the Code Composer studio for this project and from the view...>graph I can watch the power grid's sinusoidal voltage signal with an amplitude of around 20 V. – Јелена Продановић Apr 26 '21 at 11:03
-
That's too low a sampling rate and too low samples to reconstruct enough information – Apr 26 '21 at 11:07
1 Answers
4
You can't. It's not possible.
The T in THD is for "total", and the whole point of giving a THD instead of just the power of the first harmonic relative to the fundamental is exactly that most nonlinear systems have behaviour that's complicated enough so that you can't know how much power is in the other harmonics (and to how much total power that sums up) from just the first harmonic.

Marcus Müller
- 88,280
- 5
- 131
- 237
-
Thank you for your answer, but is there some other way to calculate the THD by using the first harmonic and some other value (or in other words, what should that ''other value'' be)? – Јелена Продановић Apr 26 '21 at 11:06
-
1The only other value that would help you would be *all other harmonics*. Calculating THD is pretty easy, I don't understand why you're trying to make this complicated by relying on individual harmonics instead of just their sum power! – Marcus Müller Apr 26 '21 at 11:09
-
The problem is that I know the formula for calculating the THD, but I don't know how to write a code in C to determine the sum power of all other harmonics (or to be more precise, I would like to know how to write the code for getting values of the harmonics (since it is obvious that by knowing the values of the harmonic it is easy to determine their sum power), so if somebody could help me with that part I will be able to write the rest of the needed code. :) – Јелена Продановић Apr 26 '21 at 11:34
-
A quick Google yielded this: https://duino4projects.com/power-quality-meter-pq-monitor-using-arduino/amp/ – Kartman Apr 26 '21 at 12:20
-
I've also found this https://www.nayuki.io/page/how-to-implement-the-discrete-fourier-transform but I still don't understand how to determine just the amplitude of the first harmonic (after determinating the real and imaginary parts), since they get outreal[k] = sumreal and outimag[k] = sumimag; but didn't explain how they used that info to determine the amplitude. – Јелена Продановић Apr 27 '21 at 15:27
-
What is "the first harmonic"? The second harmonic is the first one to appear in distortion. It is zero if the waveform is symmetrical even if there is severe clipping distortion. The frequency response reduces the Total harmonic distortion so the Total of all harmonics should be measured. – Audioguru Feb 24 '22 at 22:01