ADmoney wrote:OK well I've decided to write my own FFT ... something like Q10.5 ...
I was hoping someone could share some insight into converting floating point to fixed point in C ... assuming we use a 256 point FFT, with each sample occupying 16 bits ...
Have you seen the tips for fixed-point FFTs at http://en.wikibooks.org/wiki/Embedded_S ... Point_Unit
It appears to be almost exactly what you are looking for.
The ATMEGA32 has 2 KBytes of SRAM, which may be enough for a 256 byte FFT.
(It also has 32 KBytes of program flash, which seems more than adequate for this application).
I've heard that some Atmel AVRs have slightly more RAM.
For a 256 real point FFT, many people calculate 512 output values (2 values each at 256 distinct frequencies), but the 2 values in frequency bin 5 are always identical to the 2 values in frequency bin 256 - 5.
I've heard that it is possible to calculate only the 256 output values (2 values at each of 128 distinct frequencies) for a given 256 real input values.
Skipping the calculation of those "redundant" values may allow you to use less time and RAM.
If you are really only interested in few of those 256 bins, using the Goertzel algorithm at any 8 frequencies of your choosing may be faster than a 256 point FFT. http://en.wikipedia.org/wiki/Goertzel_algorithm
I agree with stevech: the Atmel168 has only 1 KByte of RAM, and I'm not sure that is enough for a 256 point FFT. (Its 16 KByte of program memory can't be used for rapidly changing data).
I'm not sure 16 bit resolution will be enough. Have you calculated what number you expect the FFT to give in the "DC" ("0 Hz") bin when given a flatline constant at the maximum expected level?
Many DSPs do internal calculations at 24 bit resolution (fixed point) for a reason, even though that at first glance seems overkill when they are connected to "CD quality" 16 bit ADCs and DACs.