LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looping an FFT data series

Hi there-  I'll make this as clear as possible so it's easy to understand.
 
I am using the DAQ assistant to import a signal into Labview. My goal is this - I want to perform an FFT on the first 2048 points of the data set. Now, without losing the orgininal 2048 points, I want to continue performing an FFT on the next sequence of 2048 points and continue in such a manner until the user decides he wants to stop . Ideally, the data should be stored in an array. Unfortunately, I am having a hard time getting a loop to do this. I can do it for the first 2048 points, but then after that my matrix refuses to get bigger and I am left with a 2048 point matrix. It doesn't really matter that I am using DAQ assistant, the signal generator in Labview would suffice as long as the heart of the program is there. Any suggestions?
 
Thanks a lot,
 
Cameron
0 Kudos
Message 1 of 6
(3,096 Views)
Cameron,

Are you using a shift register? On each iteration of the loop, add the new points to the array. This may be a place for a circular buffer. Pre-define an array big enough to hold all the data you expect to collect in one run (2048*N). Then use Replace Array Subset to replace the appropriate elements of the array. Keep pointers to the next available segment for writing and for the last segment analyzed in another shift register.

For large arrays the initialization and Replace Array Subset is much more efficient because LV does not need to reallocate memory as the array grows.

The Producer/consumer pattern may also be useful as it will allow the DAQ and the analysis to occur at different rates, if necessary.

Lynn
0 Kudos
Message 2 of 6
(3,089 Views)
If the first transform is of elements 0...2047, it is not entirely clear from your description if the next transforms should be elements (A) 1..2048, then 2..2049, .. etc.  or (B) 2048..4095, then 4096..6143, ...etc. 
 
If you want (A), use  "PtByPt" version of the fourier transform. You could probably just place it in a loop and feed it autoindexing elements of your data, one at a time, while having the sample lenght set to 2048.
 
If you want (B), reshape your data into a 2048x(N/2048) array and again autoindex it into a loop where you do the transform on each slice.
 
🙂
0 Kudos
Message 3 of 6
(3,082 Views)
Thanks a lot, but I don't think I am completely there yet. I am interested in siutation B you described. That is, I want to FFT the first 2048 points and then on the next loop FFT 2049-4096 points until the user so decides he is done. The problem is that I want to do this in real-time. Therefore, I do not have a matrix full of data points open to me that I can easily manipulate - it has to be done in a loop fashion.
 
Now that you know that I need situation B, I'll try again:
 
Let's say I have 4096 points in total (completely arbritrary). I want to FFT the first 2048 and then store them in a matrix. I then want to run through the loop again, acquire the next 2048 points, FFT those, and store the next 2048 points in a matrix that already includes the first 2048 points thereby expanding my final matrix to 4096 points. If there were more points, then the matrix would be even bigger. The issue that I am having is that once I FFT the first 2048 points, my for loop ends, even if I told it to keep going. I am certain the problem lies in how I am arranging to store the data in my arrays. What matrix trick am I missing? I do not really understand shift registers but maybe those have something to do with it.
 
Thanks so much for your time,
 
Cameron
0 Kudos
Message 4 of 6
(3,075 Views)
For help with shift registers go to Search the LabVIEW Help item on the menu, click Search when the page loads and then enter "shift register" into the search box. On my system the search resulted in 335 hits. Help is helpful.

If you still can't figure it out, post your attempt and someone will be able to offer suggestions.

Lynn
0 Kudos
Message 5 of 6
(3,070 Views)
OK, if your FOR loop runs only once, you most likely have an autoindexing input with only one element. Remember, the number of iteration is the smalles of [number wired to N, array size of any autoindexing input]. a FOR loop is not appropriate here, because we need to be able to terminate after a arbitrary number of iterations. Use a WHILE loop!.
 
If you generate the 2048 points in a loop, just wire them to the right border and autoindex out. at the end of the program, reshape the resulting 2D array to a 1D array with a lenght of the product of the original dimensions.
 
Attached is a simple example (LabVIEW 7.0)

Message Edited by altenbach on 06-06-2006 02:07 PM

0 Kudos
Message 6 of 6
(3,064 Views)