FFT Rounding error?

I computed this forward FFT using MS VC++ 6.0 and FFTW:

formatting link

I don't think the "tail" should flick up like that at the low-frequency end. Is this caused by a lack of floating-point precision?

TIA

Reply to
Andrew Holme
Loading thread data ...

It would be a lot easier to have an opinion if one knew the input data and what is displayed...?

Rune

Reply to
Rune Allnor

What are the two lowest frequencies calculated in that display?

This may be a result of having a non integer number of cycles at the lowest frequency computed.

Reply to
John Popelish

It's a prediction of frequency synthesizer phase noise, generated by simulation. FFT input is 1e6 samples of VCO control voltage. Graph is generated by calculating modulation index at each point in FFT output (NBFM approximation). Phase noise dominated by VCO rolls off at -20dB/decade outside loop bandwidth. Spur is 100 KHz reference frequency. Due to use of

3rd order loop filter, noise slope should be 40-20=20dB per decade inside loop bandwidth, and it is, except where that "tail" flicks up.

Does anyone recognise the effect?

TIA

Reply to
Andrew Holme

I'm not sure what you mean by the two lowest frequencies.

FFT input is 1e6 samples, sampled at 1 MHz. There are 1e6 output buckets, each 1 Hz wide. Bucket 0 is DC (not plotted) Bucket 1 is 1 Hz Bucket 2 is 2 Hz e.t.c The data is not repetitive, essentially a steady DC level with noise and 100 KHz ripple.

Reply to
Andrew Holme

So the line at the left side of the graph is really not information. the only information is in the points at 1 Hz,

2 Hz, etc. So 1Hz and 2Hz are the two lowest frequencies displayed by this graph.

What would you expect to find in this data if the original samples contained some 1.5 Hz energy?

Reply to
John Popelish

Does your data have a ramp in it?

1,2,3,4,5,6.... makes that sort of shape.
Reply to
MooseFET

Ah! I think you put your finger on it. I've just removed the DC, and the problem has gone. When you have an exactly integral number of cycles, the FFT shows a sharp reponse, and when you don't, it spills into adjacent buckets doesn't it? I think my DC bucket is spilling.

Thanks John.

Reply to
Andrew Holme

Phase noise? Is this the phase, not magnitude, as returned by the FFT?

This is a WAY to complicated an example to verify the FFT! To test the FFT, use one sinusoidal at a fraction of the sampling frequency, f = n/N*Fs, and see what happens.

You use FFTW. That library returns results in ways that some times are not at all obvious. Are you sure you unwrapped the results properly?

Rune

Reply to
Rune Allnor

Damn. The problem is back. It's not just DC. I think I need to make the

1e6 samples end on the same value they started at. Something like a Hanning window. I think the discontinuity is creating a response at 1 Hz. Does FFTW do windowing?
Reply to
Andrew Holme

I'm not exactly sure what your application of the FFT is for how ever, in one of my apps, I calculate a group, use only the middle results, shifted the original samples over and added to the samples and recalculated. You may want to look for "Continuous FFT" coding.

--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
 Click to see the full signature
Reply to
Jamie

What do you mean by "flick up"? The graph provided has no "flick up". What the heck are you blathering on about?

--
 JosephKK
 Gegen dummheit kampfen die Gotter Selbst, vergebens.  
 Click to see the full signature
Reply to
joseph2k

I'm not sure what is causing that, but it reminds me of the FFT graphs I get from LTspice.

BTW, what are you using to make that graph?

--
Ben Jackson AD7GD

http://www.ben.com/
Reply to
Ben Jackson

My C program outputs the data to a CSV file which I then paste into Microsoft Excel to plot the graph.

Reply to
Andrew Holme

My C++ program generates 1e6 samples of aperiodic data, sampled at Ts = 1 MHz i.e. duration = 1 second; and I want to analyse the frequency content. I'm using an FFT; but I'm getting a strong response in the FFT output at 1 Hz. This would be correct if the same 1e6 samples repeated, but they don't. Is there any way to reduce this effect, or is it a fundamental limitation of the FFT?

Reply to
Andrew Holme

This is probably just spectral leakage from the DC bin - my guess is that you are not applying an appropriate windowing function to the data prior to the FFT ?

Paul

Reply to
Paul Russell

Eliminating the DC component did not help. I am not using a windowing function at the moment. Can you suggest one? I don't mind sacrificing frequency resolution.

Reply to
Andrew Holme

As a rule of thumb you almost always need to use a windowing function prior to an FFT. There are plenty to choose from but the Hann or "Hanning" window is a good choice unless you have any very specific requirements which might dictate an alternate function.

Paul

Reply to
Paul Russell

Thanks, Paul. The Hann window works well. I still get a large response at

1 Hz, which I would expect; but there's no spillage into 2 Hz and above.
Reply to
Andrew Holme

Before you do any windowing, take out the DC and the trend. If the data has either, the windowing tends to make new problems. Chances are when you take out the DC and the trend, the problem will be much less without windows.

I've had good luck with 1.5 - cos(T) - 0.5*cos(2*T)

It depends a lot on what your data looks like and what you want to get out of it.

Reply to
MooseFET

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.