fft source for the SX is at ftp://ftp.scenix.com/apps/sine&fft.zip and Tony Nixon's SX to PIC asm menomic converter is at http://210.8.30.173/parapic.zip It needs the .lst file as well as the .src file to function correctly, so compile the parallax file first with SPASM /L ftp://ftp.scenix.com/tools/SASM.exe then press the start button, click on a Parallax.src file, watch the progress indicator on the form, and voila, you have a PIC.asm file. Any errors are listed in the new .asm file Or just read the source (SX instructions aren't that different; kind of like the 8080 vs. the Z80) James Newton, webmaster http://get.to/techref (hint: you can add your own private info to the techref) mailto:jamesnewton@geocities.com 1-619-652-0593 phoneĘ -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Erik Reikes Sent: Monday, August 30, 1999 1:45 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Cheat-cheap FFT: 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