# Calculate Total Harmonic Distortion (THD)

#### Ala Eddine Bakkay

May 13, 2019
6
Good morning,
I have a distorted electical signal and i have it fundamental after filtering and i want to calculate the Total Harmonic Distortion (THD), so how can i do it ?

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
I would pull out my HP35665A DSA, and get it to compare the signals. Some digital oscilloscopes have FFT functionality and may be able to do this as well.

#### Nanren888

Nov 8, 2015
622
In what form do you have these signals?
Transient electrical signals?
Sampled in a computer?
.
Is the distortion severe? or subtle as it might be in an audio circuit?

#### Ala Eddine Bakkay

May 13, 2019
6
@Steve Thank you for your reply but i want a theoric algorithm

#### Ala Eddine Bakkay

May 13, 2019
6
I am using STPM34 module for measuring alternative current , the STPM34 calculates each few microseconds the instantaneous current which is distorted and calculate also the fundamental current by applying a filter, so i want to calculate THD with these two signals and find the existant harmonics and its values.

May 13, 2019
6

#### WHONOES

May 20, 2017
1,217
What sort of frequency are you dealing with?

#### Ala Eddine Bakkay

May 13, 2019
6
a 50-60 Hz signal

#### WHONOES

May 20, 2017
1,217
who It is generally done using a Fourier Transform (often quoted as a FFT which is a Fast Fourier Transform) so that is what you need to look up.
You will need to digitally sample the offending waveform and then apply the FFT to it which will then reveal all the harmonics associated with you waveform.
It sounds as though you are looking at mains voltage. If you are be very very careful. Industry best practice is to have another person, preferably competent in first aid, in the same room that you are conducting your investigation in who is aware of what you are doing and can come to your aid if you grab hold of something that you shouldn't.
There is of course the option of using the audio input of your computer and use an app that has been designed to recover the information you seek.
Another option is to use a twin T filter tuned to the voltage frequency on test. The idea is that the filter rejects the fundamental leaving just the harmonics form which you can calculate the overall distortion.

#### Ala Eddine Bakkay

May 13, 2019
6
who It is generally done using a Fourier Transform (often quoted as a FFT which is a Fast Fourier Transform) so that is what you need to look up.
You will need to digitally sample the offending waveform and then apply the FFT to it which will then reveal all the harmonics associated with you waveform.
It sounds as though you are looking at mains voltage. If you are be very very careful. Industry best practice is to have another person, preferably competent in first aid, in the same room that you are conducting your investigation in who is aware of what you are doing and can come to your aid if you grab hold of something that you shouldn't.
There is of course the option of using the audio input of your computer and use an app that has been designed to recover the information you seek.
Another option is to use a twin T filter tuned to the voltage frequency on test. The idea is that the filter rejects the fundamental leaving just the harmonics form which you can calculate the overall distortion.

@WHONOES Thank you very much for your clarifications

Replies
5
Views
128
Replies
5
Views
823
Replies
11
Views
5K
Replies
19
Views
7K
Replies
7
Views
3K