Skip to main content
Senior III
Oct 23, 2026 3:18 PM UTC
Solved

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. 

mbarg.1
mbarg.1Best answer
Senior III
Oct 24, 2026 2:57 PM UTC

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

8 replies

Andrew Neil
Super User
Oct 23, 2026 4:57 PM UTC
  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
Oct 24, 2026 9:50 AM UTC

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
Oct 24, 2026 2:22 PM UTC

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
Oct 24, 2026 2:28 PM UTC

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
mbarg.1Best answer
Senior III
Oct 24, 2026 2:57 PM UTC

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
Oct 24, 2026 4:30 PM UTC

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...

mbarg.1
Senior III
Oct 29, 2026 9:43 AM UTC

 

Did any reply match your requirements ?

"If you feel a post has answered your question, please click ""Accept as Solution""."

Andrew Neil
Super User
Oct 29, 2026 10:37 AM UTC

"If you feel a post has answered your question, please click ""Accept as Solution""."

Although it’s now called “Best Answer” (a retrograde step, IMO).

 

​@STuser2 for full details, see:

 

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.