03-11-2010 10:14 AM
Hi all,
My loop iterates approx every 0.06s and now i've been asked to add to the program a function which will sample the most recent 3s of data and return the max/min value for two of the signals. I can think of a programmatically clumsy way to do this with shift registers- take the max/min for each iteration, save-repeat-compare until you have enough iterations to fill 3s of time. But I can't help but think there has to be a cleaner(better?) way to do this.
Any help?
Thanks
Solved! Go to Solution.
03-11-2010 10:28 AM
Hi there,
Try looking into a circular buffer.
http://zone.ni.com/devzone/cda/tut/p/id/7188
Once you've determined how often you're putting entries into the buffer, you'll know exactly how big of an array to grab and do the Min/Max on.
Another option is to use a circular array.
http://decibel.ni.com/content/docs/DOC-3414
I would set this up to function a little like a Functional Global or an Action Engine. The subVI would then be used in your DAQ loop to "stack" new data. And then called in another loop or part of your code to be read every three seconds.
03-11-2010 01:34 PM
Thanks Patrick, it looks like thats going to work.