piclist 1999\08\30\164317a >
www.piclist.com/techref/index.htm?key=
BY : Erik Reikes email (remove spam text)

At 09:52 PM 8/30/99 +0200, you wrote:
>Hello everyone out there ,
>
>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.

The problem with this approach is that you are only getting the main low
frequency out of your signal and not any lower amplitude higher frequency
stuff on top of it.

My advice to you would be to lower your sampling rate from 1kHz to
something around 50Hz (40Hz nyquist number with some margin)  and actually
do the FFT calculation.  I'ts been a while since I've actually done this
(since college as a matter of fact), but you should be able to pull off the
FFT algorithm in a PIC with your 8 bit input values, especially at this
slow update rate.

You might be able to filter the signal somehow if you are only interested
in fundmental frequency... maybe an integration or something?

Good luck!

-E

<4.1.19990830133609.009b17d0@xsilogy.com>