At 03:43 PM 9/18/99 -0300, you wrote: >I'm looking for a simple FFT routine for audio analisis (spectrum) that >runs on >low end PICs like the 16x84. >The device have an ADC, and I need to separate the audio in 10, 7 or >even 5 bands, >to display it on a LCD screen or fluorescent tube, along with the signal >intensity. >I've seen a program that do 128 bands, and generates video, but it's too >much for me... >My application doesn't need to be very accurate, so any simple approach >would work. If you only need a feed points in the spectrum (< 10), you can get by with a direct DFT without the fancy FFT logic. You will need: 1. Table of 8-bit sines and cosines incremental frequencies (can store in EEROM). 2. 8 x 8 multiply routine (available from MicroChip app note). 3. A 16-bit add routine (ditto). 4. Directly compute the coefficients via a(k) = sum(0,n-1) {x(k) * sin(2 pi k/n) } b(k) = sum(0,n-1) {x(k) * cos(2 pi k/n) } 5. You compute the power at each frequency by p(k) = a(k)*a(k) + b(k)*b(k) 6. If you want the rms power, you'll also need a sqrt routine. The simplest method (albeit a slow one) is the Newton method s(i+1;k) = { s(i;k)*s(i;k) + p(k) }/{ 2*s(i;k) } Note that this also requires a 8-bit into 16-bit division algorithm. This is an interesting little problem that keeps coming up in microprocessor applications. Perhaps the low accuracy and reliance on a arithmetic library explains why such a routine is not commonly available. Another approach would be to switch a more microprocessor friendly analysis, such as use of z-transforms instead of Fourier transforms. PS. I'm writing the above from memory, so that might be a couple of details in error. Also, I haven't worried about scaling, since I assume this is unimportant in the application. ================================================================ Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral@lcfltd.com Least Cost Formulations, Ltd. URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239 Fax: 757-467-2947 "Vere scire est per causae scire" ================================================================