LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT Wrong?

Solved!
Go to solution

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,

0 Kudos
Message 1 of 14
(4,213 Views)

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?

0 Kudos
Message 2 of 14
(4,204 Views)

Thanks for your reply altenbach,

 

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....

0 Kudos
Message 3 of 14
(4,197 Views)

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.

0 Kudos
Message 4 of 14
(4,191 Views)

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

 

For more information, have a look at figure 25 here.

 

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,185 Views)

 


@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?

0 Kudos
Message 6 of 14
(4,179 Views)

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).

0 Kudos
Message 7 of 14
(4,172 Views)

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.... 🙂

0 Kudos
Message 8 of 14
(4,170 Views)
Solution
Accepted by topic author simply_me

 


@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,151 Views)

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?

 

Thanks again for your help,

 

 

Download All
0 Kudos
Message 10 of 14
(4,147 Views)