07-26-2011 03:07 PM
I have a VI which gets data from the device every 2 seconds with the loop. After that this data goes to the TXT file - 2 columns (time and value from the device).
It works fine. But I need to add next thing. I need to get mean of last 30 points and mean of previous 31-90 points and compare them. If the difference is small then I need to exit the loop. I think there is 2 ways: get last 90 points from the file to array each 2 seconds and analyse it, but I don't know how to get last data from the growing file.
Second - is to put the upcoming data to the file and to the array at the same time. But I don't know how to keep the size of array equal to 90 points (I need to delete first value, move 89 values to the beginning, and put on 90th place new data).
Any suggestions on how to do it?
07-26-2011 04:19 PM
The later versions of LV have a limited size queue which might work for you. Set the queue size to 90. The Queue Status function lets you get all the dat in the queue at once.
Lynn
07-26-2011 05:34 PM
@paly4 wrote:
I have a VI which gets data from the device every 2 seconds with the loop. After that this data goes to the TXT file - 2 columns (time and value from the device).
It works fine. But I need to add next thing. I need to get mean of last 30 points and mean of previous 31-90 points and compare them. If the difference is small then I need to exit the loop. I think there is 2 ways: get last 90 points from the file to array each 2 seconds and analyse it, but I don't know how to get last data from the growing file.
Second - is to put the upcoming data to the file and to the array at the same time. But I don't know how to keep the size of array equal to 90 points (I need to delete first value, move 89 values to the beginning, and put on 90th place new data).
Any suggestions on how to do it?
You say the file is growing? Does it continue to add new data past 90 points? If so, it would be easier to store the last 90 measurements/data points to an array and process it from there. Take a look at the two VIs attached. Maybe this will help.