I want to calculate power supply THD (Total Harmonics Distrotion) using microcontroller.

My current sampling rate is 5000 samples per second to measure other parameters.

I have followed some formulas like using FFT but it is not showing results near by to industrial meters.

If anyone have some methodology or way to find please suggest.

Thanks in advance


  • \$\begingroup\$ If your power supply is AC, then you must reveal the FREQUENCY. If your power supply is DC, then it makes no sense to measure THD (or any other AC measurement, either). Your question cannot be answered without clarification of exactly what is the nature of your power supply. \$\endgroup\$ Aug 8, 2016 at 4:35
  • \$\begingroup\$ Thanks for response @RichardCrowley My Power supply is AC. My frequency of power supply is 50Hz according to Asian Standareds. \$\endgroup\$ Aug 8, 2016 at 6:29
  • \$\begingroup\$ In some Three phase Energy meters they are doing with microcontroller \$\endgroup\$ Aug 8, 2016 at 6:36

1 Answer 1


Power supplies are not usefully characterized by THD. THD stands for Total Harmonic Distortion, and DC (the desired power supply output) has no harmonics.

The closest thing to THD is pk-pk ripple, or perhaps noise (over a specified bandwidth). In neither case is an FFT a useful tool. In the case of ripple, a scope is the preferred tool, and for noise performance an RMS voltmeter works just fine.

  • \$\begingroup\$ THD is sometimes given instead of power factor on the input, but I don't see any reference to DC in the question. \$\endgroup\$
    – Daniel
    Aug 8, 2016 at 5:00
  • \$\begingroup\$ THD is normally an audio specification, and there are expensive instruments to measure it. It is done by comparing a "perfect" sine wave put into an amplifier and comparing it's sine wave output to the reference waveform. \$\endgroup\$
    – user105652
    Aug 8, 2016 at 5:18
  • \$\begingroup\$ Hey Thanks for replies guys but I want to calculate Harmonics in microcontroller not to observe in Oscilloscope \$\endgroup\$ Aug 8, 2016 at 6:31
  • \$\begingroup\$ Also I won't be having "Perfect" sinewave at input any how thanks \$\endgroup\$ Aug 8, 2016 at 6:32
  • \$\begingroup\$ In Three phase energy meters they are doing without this stuffs. I wanted to get for single phase and three phase as well \$\endgroup\$ Aug 8, 2016 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.