On Wed, 7 Aug 2002, Leandro wrote: > Hi Scott , Claudio & list. > > First, thanks for answer. > > Scott , what we need is a 8 bar spectrum analizer, speed is not a real > problem (for > now) but the problem is that floating point requires, let's say 16 real & > 16 imaginary > array, each of 32 bit, this and the cosine calculation, kills the ram > memory even using > a 16F876. Okay. > > Claudio, you are right, that was my though too, the problem is the cosine > that CCS does it by calculation and eats about 60 memory positions, > that and the array is too much for the poor pic :) > so I found a routine that does 16 bit Integer FFT and uses a Cosine table, > this routine works even great that the floating point one, excelent results > in Borland C, but porting to pic present 2 problems. > > It requires 16 x 16 int mutliply (intermediate 32 bit result), when the CCS > cannot handle 32 bit integer (at least the one i have, doesn't), but it was > solved doing some shifting, and worked great, no problem with that right now. > > The other problem (when I'm stuck right now) was the Cosine table, it 's > too big, 1024 points, and due to the indirect addressing limitations of > the pic (8 bit pointer) i can't use more than 256 element table, also > the table has a strange, and exagerate amount of data. Take a look at: http://www.dattalo.com/technical/software/pic/picsine.html > > I tried to cut the data to 256 element's but don't work, I'm not a math guru > at all, and the inisdes of the fft are still a mystery for me :), however I'm > beginning to understand a bit, but not enough to solve the cosine table > by myself :(( > one of the things that i don't understand why is the line > "Sinewave[j+N_WAVE/4]" > testing another sine/cosine table (below), replaced this > by i_sin(j+NWAVE/4) and the result is any kind of crap. > so tried replacing for i_sin(j) and the one with the minus ahead > replaced by i_cos(j) and it works partially but not really good, have > a lot of random noise in the background with this approach. > > I'm lost, that's why i decide to look for another fft in the mean time > or perhaps another cosine table that gives me no such errors. > but without the fully understanding of the function itself it's very > difficult to me to simply figure it out by myself. > > can you give me some suggestion?, approach?, a way to... :) or > any ideas?. If you need *only* 8 frequency banks then an FFT is really a waste of time in my opinion. The difference between an FFT with 8 banks and 8 discrete filters is minimal. Furthermore, for the PIC architecture, the incurred overhead of an FFT computation will rapdily consume the minimal savings that an FFT will provide. Recall that an FFT is an efficient way of computing the DFT (discrete Fourier Transform). The DFT is the dot product between your signal and the complex exponential exp(j*omega*t). In other words, for one frequency, omega_1, you create a vector of equal-spaced samples of exp(j*omega_1*k/N). This vector, or array if you prefer, is multiplied element-by-element by the samples of your input signal. You may wish to experiment with DFT's nd verify that they produce the same result as FFT's. One other problem with FFT's is that the frequency bins are equally spaced. I doubt that this what you really want for your application. At least with a DFT you can select which 8 frequencies you wish to filter. You may also wish to take a look at: http://www.dattalo.com/technical/theory/dtmf.html Where a theoretical technique is presented for decoding DTMF signals using square waves instead of sine waves. For DTMF, there are 8 frequencies like in your case. However, the midpoints of these frequencies are not harmonically related. Scott -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.