Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Embedded maths Algorithms math , +
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 Smile | :)
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.
Posted 24-Feb-12 2:20am
Indivara33.1K
Edited 31-Mar-12 20:47pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Cannot you simply count events, based on a known property of the waveform (for instance crossing a given level)?
  Permalink  
Comments
Indivara at 24-Feb-12 20:14pm
   
Like zero-crossings? That doesn't work because the level isn't constant, the entire thing shifts up and down, an sometimes there may not even be a recognizable pulse. The peak levels also vary with time.
Indivara at 24-Feb-12 20:17pm
   
OK, you may be on to something after all. Maybe I can use the average signal and count how many times the peaks vary from it. Let me think about it while waiting for more answers...
CPallini at 25-Feb-12 9:26am
   
Yes, in order to measure frequency, at least in principle, the signal must be periodic, and you could exploit its periodicity.
Indivara at 26-Feb-12 7:50am
   
I forgot to mention that the signal is more or less periodic, and ultimately I'm calculating the average frequency. I'll update the question.
 
backspace backspace... I didn't forget, the question already said periodic signal... though the comment above is a more precise description.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 1 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100