From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a VI to buffer an array of waveforms

I'm reading an array of AI waveforms with AI Read. I need to add this array to a buffer of waveforms (Buffer consists of 2D array of waveforms, channel 0 in column 0, and the most recently acquired array of waveforms in Row N, the oldest in Row 0). I am trying to buffer 30 seconds of data, each waveform array consists of 1 second waveforms with 35,000 samples per waveform. I am using waveforms instead of a 2D array of doubles so I can store attributes as well. I got a version of this working with an uninitialized shift register and several method cases inside of the while loop. I don't have any problem adding elements, and I've moved the arrangement routines outside of the VI as a subVI (this VI takes the current
read point and basically rotates the 2D array in one dimension so the oldest data appears in row one, even though the write point may be the middle of the array). The biggest problem appears to be just writing the data to the "Buffer" indicator for passing information out of this Buffer VI. It can take as long as 8 seconds to complete the simple Read buffer method (this method only writes the values from the 2D array shift register on the left to an indicator). In the meantime the AI Buffered Read suffers a buffer overflow and tanks my application. Is there a better way to perform this whole buffer operation, or to just move the buffer data out of the VI? I'm currently using LabVIEW 7, I am initializing the shift register with a 2D array of sufficient size, and I've tried initializing the indicator as well, hoping that it was just the first Buffer Read that was causing problems.

Thanks,

Jason
0 Kudos
Message 1 of 2
(6,252 Views)
It sounds as if you have added a great deal of overhead (i.e. "rotating the 2D array", "buffering" new data to old) to the acquisition loop. As you have found, adding too much "non-acquisition" processing will eventually cause a Buffer Read Error depending upon the acquisiton data size and sample rate. One method, as you noted, is to initialize a data array and write to it (replace element NOT insert element) on the fly. So long as you do not try to manipulate/process the array, this should work. I have used this method to acquire 20M samples/sec on 400MHz class computers for a couple of years (you just need a lot of RAM). As you suggest, I think you need to move the "Buffering VI" out of the acquire loop. Dump all of the data into a single (pre-initialized) array a
nd sort it out after the acquisition. If you need to be sure that the data will never be lost if the VI aborts prior to saving that data, you could put in a Stream-to-disc function at regular intervals. Properly configured, the stream-to-disc routine will have less CPU overhead than repetative manipulating of large 2-D arrays. It appears that you are on the "right path" by considering moving the buffering out of the VI. I hope that I have providied some additional insight. Good luck.
0 Kudos
Message 2 of 2
(6,252 Views)