# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## FFT Wrong?

Hello,

I've built a vi that does the FFT of a signal (~200,000 entries in a 1-D array), while it is running, I'm not sure it's outputting the correct answer (or at least it doesn't make sense to me).

I'm trying to find the frequency distribution. The signal was acquired at ~200Hz. A screenshot of the output and the vi are attached.

Any thoughts? I really need some help with this.

Thank you,

Message 1 of 14
(4,121 Views)

## Re: FFT Wrong?

You need to calculate the increment df from dt and set the two x-axes accordingly. Currently, things are done in units of the array index.

Since you are not saying in what way you think the result is wrong, the above is my first guess. Please clarify if aything else seems off. 😉

Also note that you are throwing away the imaginary part of the transform. is that as intended?

Message 2 of 14
(4,112 Views)

## Re: FFT Wrong?

what do you mean by "increment df from dt..."? df/dt would be 1/0.005, correct (dt=1 sec/200 samples=0.005)?

Well, to my understanding, in general, an FFT should return frequency values and spike around a center frequency, and the result I get doesnt show any spikes....

Message 3 of 14
(4,105 Views)

## Re: FFT Wrong?

I forgot to answer the last part, it's not intended to discard the imaginary part, but I don't think that there is an imaginary part to this signal. The signal is position tracking along the horizontal axis of a laser for stability measurements.

Message 4 of 14
(4,099 Views)

## Re: FFT Wrong?

dt is 1/200. df is 1/(N dt).

There are two conventions on how to display the transform: (1) DC centered or (2) Niquist centered. You are expecting (1) but LabVIEW gives you (2) by default.

Newer LabVIEW versions have a "shift?" input to the FFT, wire a TRUE and you'll get (1) 😄

(for older versions: Nothing a little array rotation cannot fix. :))

Message 5 of 14
(4,093 Views)

## Re: FFT Wrong?

@simply_me wrote:

The signal is position tracking along the horizontal axis of a laser for stability measurements.

Why wound that cause the imaginary part to be zero? That is very unlikely. Why don't you split the signal into RE and IM parts and graph both?

Without the IM part, you lose all phase information. Are you looking for a power spectrum instead, for example?

Message 6 of 14
(4,087 Views)

## Re: FFT Wrong?

Thanks again, it already looks much better. Only one problem is left-- both the horizontal and vertical axis scales (the horizontal should be frequency), Any idea on how to change it?

The link doesn't show how to handle such issue (of index instead of time domain).

Message 7 of 14
(4,080 Views)

## Re: FFT Wrong?

You are right about the Im part. I'm trying to follow the link you've provided me with to change the vi.

Sure, power spectrum would help too, but I rather take it one bridge at a time.... 🙂

Message 8 of 14
(4,078 Views)
Solution
Accepted by topic author simply_me

## Re: FFT Wrong?

@simply_me wrote:

Only one problem is left-- both the horizontal and vertical axis scales (the horizontal should be frequency), Any idea on how to change it?

The link doesn't show how to handle such issue (of index instead of time domain).

you need to set the increment of the x-axis to reflect the proper units.

For the time domain graph, set it to 1/200 and for the frequency domain to the derived value as described above.

You can set the axis increment in many ways:

• Manually via the graph properties (right-click...properties)
• Via a property node of the graph (X-scale.multiplier)
• Via bundling as shown in the quoted figure 25.

Message 9 of 14
(4,059 Views)

## Re: FFT Wrong?

I didn't manage to change the scales as you suggested, but I think I managed to perform the FFT. Please review the attached files, do you think it is correct?