# How do I calculate THD?

I want to calculate the total harmonic distortion of the signal using this graph and formula.

The formula is taken from this page: Calculating harmonic distortion

First Question: So my problem is to find the rms value of each frequency component. I know the magnitude of each frequency component from this graph, but how can I convert this magnitude to rms value?

Second Question: If I want to calculate an approximate THD value, how many harmonics should I calculate up to?

Third Question: I'm calculating it manually, but does Proteus have a practical feature for this? Or is there a specific application for THD calculation?

• I've settled on ten frequencies as more than enough to be defensible in audio. But that choice is arbitrary. Apr 24 at 14:40

So my problem is to find the rms value of each frequency component. I know the magnitude of each frequency component from this graph, but how can I convert this magnitude to rms value?

Remember the Fourier expansion. It gives you all sinewave components that form the original signal. So the magnitudes you see on your FOURIER ANALYSIS graph are the magnitudes of each sinewave component. To get the RMS, just divide the magnitude by the square root of two, 1.414.

If I want to calculate an approximate THD value, how many harmonics should I calculate up to?

I'm calculating it manually, but does Proteus have a practical feature for this? Or is there a specific application for THD calculation?

This answers your last two questions: You don't need to use a number of sinewaves' peaks. You can, but there's no standard way to choose the number of harmonics for THD calculation. Of course, after a certain index of harmonic the THD measurement will not change much, but that depends on the frequency content or the original signal itself, and also your accuracy requirement. So it's up to you i.e. you can start with up to 10th harmonic and calculate the THD, then up to 11th to see if it changes much, etc.

2. Calculating the V1, RMS of the fundamental, should not be a problem either because you can calculate it by hand. The peak is $$\V_{1pk}=(4/\pi) \ V_p\$$ and its RMS is $$\V_1=(2\sqrt2/\pi) \ V_p\$$, where $$\V_p\$$ is the peak of your original square wave signal.