06-05-2012 03:36 PM
I'm trying to create a a type of circular buffer on large-ish set of 2d data which are samples of voltage from a data acquisition board. The boards are Measurement Computing and a lot of the nice programming features built into DAQmx for NI boards aren't easily available to me.
I'm grabbing chunks of samples, 1000 per channel * 64 channels, every 100ms. I'm calling this a 'page'. For each page of samples I take a median for noise filtering and then I publish this median for multiple threads to use. I also want to be able to string together pages of samples as if it were one longer data acquisition, for up to 30 seconds. I'm doing it this way because the threads that are expecting their data every ~100ms can't release these AI boards for long periods of time to allow other threads to use them to perform long scans. The data coming back from my boards is a 2D array.
I have enough RAM available to pre-allocate the memory to hold all these pages and I've been playing with the In Place structures for awhile now and I haven't been able to land on the magical combination that will allow me to replace any page in the buffer. It's easy enough using the subarray option of the in Place to replace either the first page or the last page but it gets more complicated to do a page somewhere in the middle without having to resort to Case statements. I tried to do it with nested In Place structures but it seems as if the subarrays that get created in the lower levels already go out of scope by the time the top level gets it assigned and I just get jibberish on the output side. Does this make sense?
06-05-2012 04:20 PM
SmokeMonster wrote:I tried to do it with nested In Place structures but it seems as if the subarrays that get created in the lower levels already go out of scope by the time the top level gets it assigned and I just get jibberish on the output side. Does this make sense?
Sorry, but at least to me, this doesn't make sense. Can you post your code? I can't see how "out of scope" is a concept that applies here - LabVIEW keeps track of the memory for you and should never lose track of memory that's still in use.
I posted one approach to a 2D circular buffer; maybe it's of some use to you.
06-06-2012 07:54 AM
Try using queus to hold the data.
Much more efficient that any circular buffer I ever wrote (I tried).
Ben