Hi Sven, It is interesting how the minds of people on this list often think alike! A few years ago, before I had studied Fourier analysis, I had a very similar idea to what you propose here. I got interesting results but I found some problems with it at the time and pretty much came to the conclusion that it wasn't quite working. I think if I were to go back and look at it again now, I would find many problems with it. The method you describe works if you want to find the fundamental (i.e., the period of the composite signal, which is NOT necessarily the period of any sine wave component of it). It also might work in some special cases (where a the appropriate number of peaks and troughs appear in the signal). However, some quick examples will quickly show that there are flaws in the method: Take a square wave for example. It displays no peaks and valleys, only steps,and yet it is composed of many sine wave harmonics. The same is true for a triangle wave,and for many other cases. It is true that some ripple will remain in a square wave or triangle wave if some ofhte upper harmonics are cut off,but this will effectively be removed by the quantized nature of the sampling. I have not yet learned FFT, DFT, or any of the digital transform methods. The basic idea, as I understand it (from doing the paper/pencil versions of the continuous time transforms),is to run a bunch of correlation integrals (i.e., multiply the input waveform by various frequency sine and cosine waves and average over a period of the input. If the result is non-zero,the there is some content at that frequency,and it is proportional to the result). If the input is non-periodic,you should be able to make some approximation based on the highest and lowest freq. components that you want to search for. There are ways to simplify this and make it more amenable to calculation,and that's where the FFT source code comes in. So, I guess the answer is to take a look at the source code mentioned by others,in addition to maybe taking a look at a textbook regarding signals and systems. I am taking a course in that right now,but unfortunately,I do not have my textbook yet. >From work that I have done on how optical scanners deal with sine wave patterns, my hunch is that FFT probably uses a discrete averaging technique and looks for cases where the averaging process produces a minimum in the signal amplitude,which would correspond to the "notch filter" effect of the averaging window. When this happens,the window width is the same as the period of one of the frequency components. Sean At 09:52 PM 8/30/99 +0200, you wrote: >Hello everyone out there , > >Is it my turn now? I have been on this list for a few months; find it very interesting, and have learnt a lot. I also hope I have added a few cents worth... > >Competence is very high amongst contribituors, and I guess the following issue can be solved - or already have been solved by a few of you: A suggestion for approoach would be appreciated: > >I would like to measure the frequency of signals in the 1 -- 20 Hz range, not using a DSP or anything other that the already engaged PIC 16C711. It uses a timer interrupt routine, that is it idles most of the time, but every millisecond it jumps out of the loop and polls the AD RES. The A/D is of course picking up the low freq. "AC" (actually 0 -- 5V) to be measured. > >My idea was to see on each sample if the previous sample was smaller. If so, the voltage is ascending. When descending (implementing 3 bits of noice reducing "backlash") I have found a point in time when the peak was found. Correspondingly, I find the "valley". The idŽa is based on a counter that is stepped up every ms, and is used to measure the time between peaks and valleys. In other words, if there are 100 counts between a valley and a peak, we have ¸ wavelength being 100 ms long. 5Hz - right ? > >I have 20 registers. If the frequency is 1.5 -- 2.5 Hz, I add one to the "2 Hz register". If the frequency is 18.5 -- 19.5 Hz, I call it 19Hz. After a few seconds of measurement, I should have a handfull of values in the registers, to correspond to the frequency components of the signal. > >This should work for pretty and clear sinewaves. But these signals are actually noisy with - for instance - long "flats" to consider, when finding a correct point in time. Actually the signal can be considered a random pink noice. > >The signal is in other words a bit complex for finding frequency components in a FFT-type fashion. If it is 5 Hz with a dent in it, it is maybe 80 % 5 Hz, 15 % 15 Hz . . so to speak. This is not imortant in detail. I would like to know that the base is 5 Hz. > >Now to the problem. It doesn't __ work. Am I too optimistic ? Should I realize that a PC or a DSP of some quick sort is needed for this? Am I better off "zero cross-detecting" at 2.5 Volts? > >So - the question is - has anyone been walking this path before ? Am I on the right track ? > >Sven > | | Sean Breheny | Amateur Radio Callsign: KA3YXM | Electrical Engineering Student \--------------=---------------- Save lives, please look at http://www.all.org Personal page: http://www.people.cornell.edu/pages/shb7 mailto:shb7@cornell.edu ICQ #: 3329174