Skip to main content
Senior III
October 23, 2026
Question

Sine signal frequency measurement without input capture

I have a hardware where i need to measure the input signal of the AC mains signal 50Hz, the problem is the hardware does not have provision for input capture. Is it possible to measure? I also several other tasks running like RS485, 13 channels ADC measurement etc, the input signal is given to ADC channel. 

6 replies

Andrew Neil
Super User
October 23, 2026
  1. read a free-running timer at your measurement point on the waveform (eg, zero crossing);
  2. read again at the next measurement point.

Difference between the readings gives you the time between readings - whence the frequency.

You could trigger this on an interrupt...

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.
mbarg.1
Senior III
October 24, 2026

If the input signal is connected to ADC, use digtized waveform to measure frequency - get max and min, compute zero crossing, count number of samples between zero crossing, and you have a half period, average on many measurements, compute freq …

OK ?

STuser2Author
Senior III
October 24, 2026

At present my implementation is i am triggering the ADC at every 10KHz with DMA enabled once the number of samples are received, in the receive call back i calculate the RMS of the samples. So, as per your suggestion i can check those samples get the maximum and minimum values, i need to have logic for zero crossing. Is my understanding correct? 

TDK
October 24, 2026

It would be more accurate to do an FFT of the data to determine frequency rather than just a zero-crossing. Otherwise, yes.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mbarg.1
Senior III
October 24, 2026

Zero = min + (max - min) / 2 = ((2 * min - min) + max) / 2 = (min + max) / 2 - not a real logic, just some math 

unless you have huge non linear loads causing waveform distortions.

​@TDK : yes FFT is more accurate providing you have large number of samples and good math engine - it depends from what STuser2 is looking for - computational burden is several orders of magnitude greater

MM..1
Super User
October 24, 2026

All is based on hav many instruction you can waste for this. Based on range frequency can arrive use DMA buffer size , if memory isnt prblem use bugger and chcek max values on half and full complet etc. simply two max values distance on sine is perfect frequency value...