Calculating THD

Post general discussions on using our drivers to write your own software here
Post Reply
elousv
Newbie
Posts: 0
Joined: Tue Jan 31, 2012 8:56 pm

Calculating THD

Post by elousv » Thu May 31, 2012 4:40 pm

I have a 3204A in my system with a custom GUI so I am having to re-create functions that are embedded in PicoScope6. I found some open source at FFTW.org. It seems to be working, but I need help in interpreting the results and manipulating the numbers so they can entered into a THD equation. Here are the steps:
1) Take pico reading
2) Send to FFT function
3) Divide by sample size
4) Caculate magnitude by summing the squares
5) Find fundamental
6) Find harmonics
7) Calculate THD
For testing I am feeding the Function Generator output direct to Scope A. I am using 1kHz 2V PtoP a 32768 size, 100kS/s, 10us sample interval. I can find the fundamental f0 at about bin 327 and the harmonics f1-f4. If I use the PicoScope6 software and use the THD measurement function with this same setup I get .2% for a sine and about 12% for a triangle so this is what I am trying to duplicate. I am not doing anything else to the data right now like windowing. Here is my data:
For sine:
f0 = 177975
f1 = 0.7765
f2 = 1.90922
f3 = 2.45012
f4 = 1.5336
For Triangle:
f0 = 116626
f1 = 1.997
f2 = 2000.58
f3 = 0.4469
f4 = 143.754
I can see that the 3rd harmonic for triangle will have the most impact on the THD calculation at 2000 as opposed to 2 for a sine, but when I try to plug those into an equation for THD using sum of the powers of the harmonics divided by the power of the fundamental it does not work out no matter what I have tried as far as multiplying or squaring or square rooting. So I am either missing a step or am not using the numbers above correctly. Any help appreciated.

Martyn
Site Admin
Site Admin
Posts: 3226
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Calculating THD

Post by Martyn » Fri Jun 15, 2012 2:04 pm

You have
using sum of the powers of the harmonics divided by the power of the fundamental
should it be
using sum of the powers of the harmonics divided by the power of the "fundamental plus the harmonics"
Martyn
Technical Support Manager

Post Reply