LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT doesn't work

Hmm that sounds rather complicated, but I will have a try at the weekend...

I also figured out that I have had a mistake in my program. For the FFT I needed to build a waveform and therefore the timestep dt was neccessary. I have used the constant time interval between the frames, out of the reciprocal value from fps. But now I have seen that the time interval between the frames isn't constant! I have figured out how to associate the right time values with the corresponding intensity values and to plot these two arrays in an x-y-graph!
But now I can't create a waveform to use the FFT eventually, like my above attached VI shows. A direct connection from my two array cluster to the  dynamic data signal input is also not possible! Maybe you can help me with this one and then I can work further in the weekend!

Thanks so much for your effort...
0 Kudos
Message 11 of 16
(1,105 Views)
Standard FFT algorithms are based on the assumption that all the samples are equally spaced (known as uniform sampling) in time. If you feed non-uniformly sampled data to the FFT (or Spectral Measurements.VI), you will not get accurate results.

The waveform datatype has one value of dt and it is associated with every interval between adjacent samples in the Y array. You cannot force non-uniformly sampled data into a waveform without losing some information. You could create an array of points. Each point is a cluster of two values, X and Y. In your case X would be the time of the frame and Y would be the mean intensity value for the frame. Build an array of these clusters of points. Some graphs and perhaps some analysis routines can use arrays of points. The FFT caution above still applies, however.

I have not used it but a resample VI exists. I am not sure if it could generate uniform samples from a set of non-uniformly points. Otherwise you would need to interpolate your data and generate a uniformly sampled set to use with the FFT routines. I don't know how easy or difficult this is because it may be dependent on the nature of your data. If your data has sharp edges, interpolation may not reproduce these features well.

Lynn
0 Kudos
Message 12 of 16
(1,102 Views)
Hi,

this resample VI exists but it doesn't work, because therefore I would also need a waveform! But I can't create a waveform with out constant time steps...
0 Kudos
Message 13 of 16
(1,081 Views)
Then you will need to create your own interpolation and resample code. If your data is fairly smooth a simple linear interpolation between adjacent points might be good enough. Otherwise you will need to find an interpolating function which behaves similarly to your data and use that.

For the linear interpolation over two adjacent points you can calculate the formula ahead and do not need to fit a straight line separately. Let your data points be (ya,ta) and (yb,tb) and the uniformly sampled time variable be ti = T0 +i*dt. Solving the equation of a straight line for the data points finds the slope and intercept. Using these values to find the interpolated yi(ti) gives:

yi(ti) = ((yb-ya)*(T0+i*dt) + ya*tb - yb*ta)/(tb - ta). This can probably be rearranged for more efficient calculation.

Use this when ta < ti < tb. If ti = ta, then yi = ya. If ti > tb, then set ta <- tb and tb <- time of next data point (tc).

This will produce a set of points with dt = constant so that the standard spectral analysis VIs will work. You can use the Build Waveform to convert the array Y and dt to the waveform datatype. I think you will have the best performance if dt is chosen so that at least one ti occurs between each pair of actual data points. Choosing dt to be very small will make the Y array larger and may appear to improve frequency resolution, but remember that the information in the actual data points in the only information you really have.

Lynn
0 Kudos
Message 14 of 16
(1,071 Views)
Hi,

thanks very much, I have fixed most of my problems with your help! The only thing I couldn't get working was the design pattern, but I don't have much time left so I won't waste more time with that! But what I still need is to record the rectangle information from the IMAQ Light Meter.VI I have used in the measurement! There must be somehow a way to write it in any file or better in the header of the AVI file I have recorded with my program....

thx
0 Kudos
Message 15 of 16
(1,030 Views)
I do not have any of the IMAQ or Vision stuff so I am not sure what is in the rectangle or how to save it. If you do not get a response here soon, create a new thread with the rectangle question. People who may know about that may not have looked at a thread with "FFT" in the title.

Lynn
0 Kudos
Message 16 of 16
(1,021 Views)