OK, so I really suck at math so I'm going to ask this here. Spent most of today Googling without much luck...
The question is, what algorithm would you use to calculate the frequency of a periodic signal? The signal in question is not a clean sine wave, but a noisy pulse from a sensor.
My current plan is to use a fast Fourier Transform to single out the largest frequency component, but it looks a bit daunting to implement, and the hardware I'm using is a 16 bit micro-controller with 8K of memory - it may not be up to that level of processing.
Another plan is to low-pass filter (digital filter, also done by software, to remove noise) and count the peaks, throwing out spurious ones that get through.
Does this make sense or am I completely off? Any better methods?
(Free/open source code would be nice too, but I can do the programming myself)
Update
I discovered that the Fourier method does indeed work, but only checked the theory using Excel. I bet nobody knows Excel can do that :)
link[
^]
The highest peak is the fundamental frequency, that I want to measure, but the waveform shown is not the real thing (not allowed to reveal that)
However, I'm inclined to go ahead with Carlo's method of counting level-crossings (after applying some kind of smoothing ). Updates will be posted if it goes as planned.
Update 2
I finally implemented the level-crossing method, using a
moving average[
^] to filter out noise first. A few more tweaks were needed to remove spurious peaks too.