0
$\begingroup$

I'm using STPM32 for energy metering application.
I'm using STM32 micro-controller.
I wish to calculate up to 50-order harmonics. How should I proceed with this?

Current Plan:

  1. Store voltage, current and power in buffer. Buffer size is 1024. Data rate is 1000 Hz.
  2. Calculate FFT using Radix 2 algorithm

After this I'm drawing a blank. Can someone advice me how to proceed further.

$\endgroup$

1 Answer 1

1
$\begingroup$

AC fundamental frequency is 50/60Hz which puts the 50th harmonic at 2500/3000Hz. This means you need a sample rate in excess of 6 kHz. Let's pick 8 kHz, since it gives a healthy margin and is easily available (popular for audio/speech processing).

Your approach is unlikely to work: with an FFT length of 1024 you will have a frequency resolution of about 8Hz. That feels its too big.

I suggest the following approach

  1. Run a PLL to track the line frequency exactly.
  2. Generate complex local oscillators at all frequencies of interest
  3. Multiply with your input signal, calculate squared magnitude
  4. Run through a lowpass filter with whatever time constant you want to track the harmonics

If you implement the local oscillators using phasor rotations this can be done very efficiently and I'm guessing this will take less than 15 multiplies per sample per band.

The most expensive part here will probably be the arctan() of the PLL. But once the PLL is settled you only need to update this once per frame as the line voltage drifts only VERY slowly. This also implies that your phase error will be quite small and you approximate the transcendental function with it's Taylor series around $x=0$

That should fit easily on an STM32.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.