Continue to Site

# AC Frequency measurement using STM32/ADC

#### 0xbadcaffe

##### Newbie
Hi All
Not sure if this is the right thread.
Doing a new design.
Trying to figure out if STM32H7 with its internal ADCs is capable for the problem or should I use an FPGA.

The problem is:
I need to measure the frequency and amplitude of 12 AC input signals.
The frequency is 400hz and sampling must be at 2Khz.
The ADC resultion can be 12bit.
Is it possible using the STM32H7? perhaps with DMA?

Thanks

#### KlausST

##### Super Moderator
Staff member
Hi,

You are posting in the "power" thread, but the problem has nothing to do with power.
Indeed it's not clear what the priblem is:
* software, algorithm?
* hardware?
* matgematics?

If you know the frequency is 400Hz, why do you need to measure it? So I guess there is a "range". -> You need to tell us.
What's the input waveform?

I personally don't recommend to do frequency measurement with ADC. Doing it with a digital capture unit is way more simple and still rather accurate.

What's the range of amplitude?
What resolution, accuracy, precision do you expect for freq and ampl?
What is the expected output data rate for freq and ampl?

Klaus

#### FvM

##### Super Moderator
Staff member
I'd split the question.
1. Can we sample ADC continuously at 2 kHz with STM32H7 - yes
2. Requirements for signal pre-processing - e.g. anti-aliasing filters
3. Motivation for frequency measurement through ADC measurement and possibe methods

Can be useful if the input is a complex mixture of multiple signals and noise. All-digital-PLL (generating a reference sine with NCO) is a popular method.

#### 0xbadcaffe

##### Newbie
Hi
You are right there is no "problem", I'm trying to figure out whether I can use the STM32H7 with the given use case.
I guess the problem can be classified as "how to measure the input voltage from 12 AC inputs."

The input waveform is sinusoidal.
The input voltage will be lowered from high voltage to fit the MCUs voltage levels.
We need a 7% accuracy on the voltage (amplitude) and 5% on the frequency.
We must use the internal ADC in the STM32H7.

#### mtwieg

##### Advanced Member level 6
When you say "sampling must be at 2Khz" are you referring to the sampling rate of the ADC? If so, then yes a STM32H7 can definitely do that easily. An Arduino could probably do it easily.

But I wonder if you actually meant you want to update the measured frequency every 500us, or with 500us latency. That is a completely different story...