FFT query

C

Clive Arthur

Guest
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
 
On 04/08/2019 12:09, Clive Arthur wrote:
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.

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.

http://apps.nrbook.com/empanel/index.html#

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.

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
 
On 8/4/19 7:09 AM, Clive Arthur wrote:
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

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
 
On 04/08/2019 12:18, Martin Brown wrote:
On 04/08/2019 12:09, Clive Arthur wrote:
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.

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.

http://apps.nrbook.com/empanel/index.html#

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.

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.

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

Cheers
--
Clive
 
On 04/08/2019 12:18, Martin Brown wrote:

<snip>

See section 12.3 p617 in Numerical recipes.

http://apps.nrbook.com/empanel/index.html#

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

Cheers
--
Clive
 
On 07/08/2019 23:46, Clive Arthur wrote:
On 04/08/2019 12:18, Martin Brown wrote:

snip

See section 12.3 p617 in Numerical recipes.

http://apps.nrbook.com/empanel/index.html#


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

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:
http://www.ti.com/lit/an/spra291/spra291.pdf

Be sure to test the thing carefully after coding it.

--
Regards,
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
 

Welcome to EDABoard.com

Sponsor

Back
Top