Skip to main content
Visitor II
September 27, 2025
Question

Measuring Total Harmonic Distortion (THD) in Voltage with STM32F4

  • September 27, 2025
  • 2 replies
  • 390 views

Hello everione!

I’m working on a project where I need to measure the total harmonic distortion (THD) of voltage and visualize its harmonics. The fundamental frequency is 50Hz. I’m relatively new to STM32, and I’d appreciate any guidance on libraries or tools I could use for this task, or if there are any similar projects that could serve as a starting point. I appreciate any suggestions or resources you can share, thanks.

2 replies

AScha.3
Super User
September 27, 2025

Hi,

Afaik DFT is used for something like this, or FFT and then adding the harmonics.

You can write it yourself, or search on GitHub for DFT or FFT, or use the cmsis math library.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
October 2, 2025

Surely, the only thing that would be specific to STM32 would be the use of the ADC to collect the measurements?

Check out the Cube Firmware pack for examples - including ADC ...
https://www.st.com/en/embedded-software/stm32cubef4.html

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.