FFT query

I'm using a Microchip library FFT on a dsPIC witha time domain input, it all works splendidly and has done for some time.

However, re-visiting the code with a bit more time to think makes me wonder about the input waveform. I put this in to the Real buffer as it's digitised and clear the Imaginary buffer (actually the same buffer with alternating Re/Im) before kicking off the FFT. Is there something I could do with the Imag part of the buffer rather than just zero it to maybe improve resolution or something? On the output side I use both parts.

Likewise going the other way to generate a time domain waveform, I only use the real output, skipping the Imag parts, but use both parts for input.

Cheers

--
Clive
Reply to
Clive Arthur
Loading thread data ...

You can use the imaginary part to do another FFT at the same time or alternatively use a complex transform of half the length and a cunning twiddle factor to do a real to complex conjugate symmetric transform. There is a bit of pre/post processing to do to make this work.

See section 12.3 p617 in Numerical recipes.

formatting link

If the Microship library FFT is any good it ought to have something to do this sort of transform already. Beware that some versions need a complex array that is one longer than the nominal 2^N.

--
Regards, 
Martin Brown
Reply to
Martin Brown

Yes. You can compute the FFT of a real number in half the time. IIRC Numerical Recipes talks about how. (NR is a pretty good numerical methods book with some reasonably OK but not great code attached.)

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC / Hobbs ElectroOptics 
Optics, Electro-optics, Photonics, Analog Electronics 
Briarcliff Manor NY 10510 

http://electrooptical.net 
http://hobbs-eo.com
Reply to
Phil Hobbs

Thanks! (And to Phil Hobbs) that's very useful.

Cheers

--
Clive
Reply to
Clive Arthur

Bought the book, it arrived today. So much to learn, so little time!

Cheers

--
Clive
Reply to
Clive Arthur

NR is mostly pretty good (a lot more reliable than DIY numerical algorithms) but they are slightly simplistic in places and were originally translated out of the FORTRAN so be a little careful.

C array bases index from 0 and FORTRAN from 1

This has the effect of disguising some things like BITREV indexing.

You might find that FFTW has something that will do what you want more or less off the peg and for any sane length of transform not just 2^N. The learning curve for it is a bit steep but there are examples and on the right compiler it is pretty much as fast as anything out there.

Another reasonable resource (though a bit dated now) is TI's:

formatting link

Be sure to test the thing carefully after coding it.

--
Regards, 
Martin Brown
Reply to
Martin Brown

Half the time because for real data streams the fft always has conjugate pairs for the imaginary side. So you only have to calculate half the bins and the other half are automatically the conjugate pairs

Reply to
bulegoge

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.