LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating Historical Rate of Change From Continuous Real-Time Input

Hi everyone,

 

I'm trying to create a Sub-VI that will calculate the change in a value collected in a real-time over the last 10 minutes.

 

The way my main VI is running now, a new value is calcuated once every second from data streamed via DAQ @ 1ks/s. Since everything is in a giant while loop, the data is constantly being written over my the next wave of data being read. I was wondering what is a good approach to "remember" what the value was 10 minutes prior so that I can compare it to the current value once every minute. I know shift registers can be used to pass information between iterations of a while loop, but we're talking about hundreds of thousands of iterations here. I don't know if there's some way to conditionally read/write to something outside the while loop as the program is running.

 

Basically what I need to do is have a program that monitors a value calculated in real time. This program also needs to be able to know how much this value has changed over the last 10 minutes once every minute (the rate of change over last 10 mins). The way that I've done it is to rewrite an array at the top of every minute with the new value until it reaches 10 values, and then it just starts back to 0 index writing over the values. This way I always have a snapshot of the values, once per minute, for the last 10 mins. However to "retain" this array for the other 59 seconds of every minute when I am not writing a new value to it, I just have it constantly rewriting the same array to itself repeatedly, and I believe this may be causing my program to develop a memory leak and throwing a buffer overflow error after a few minutes.

 

Is there some more effective way of approaching this problem? Also do you think that this is the reason behind my buffer overflow error? My main VI was running slowly, but without errors, before I added this subVI so that's why I'm suspecting this is the problem.

 

I have attached my subVI. I know it's kind of a giant mess and difficult to decipher, so please let me know if you need clarity on anything.

 

Thanks!

0 Kudos
Message 1 of 2
(2,975 Views)

Hello, 

 

First I want to make sure I understand everything thouroughly. Within a while loop in your main VI, you take a reading of stiffness. This reading is passed into your subVI where it undergoes some math operations in your formula node. This math operation should ideally return how the current reading is different than a previous reading (from 10 minutes prior). It also calculates percent change and moving average. If I am understanding this incorrectly let me know.

 

I would like to suggest first that you keep in mind LabVIEW is a data flow language, not a procedural language like most text-based programming. You may already be aware of this, but I got the feeling from looking at your code that you're approaching this as if you were doing some text-based programming. Below are a couple resources on data flow. I think they will give you a good perspecive for improving some characteristics of your subVI. 

 

http://www.ni.com/newsletter/51770/en/

http://www.ni.com/getting-started/labview-basics/dataflow

 

Back to an effective way to monitor the value change over 10 minutes, you're on the right track with using arrays, but I think you could take a simpler approach.

 

Data gathered at once per second for 10 minutes would provide 600 samples. I recommend something along the lines of setting up two arrays. One array (Array1) is your current run of 600 samples, the other (Array2) is the previous run of 600 samples. You fill one, then fill the other, and alternate back and forth. Each time you are taking (Array1Value[n] - Array2Value[n]). The values in the same positions of the different arrays are 10 minutes apart. This would provide the difference between those two values and you could store these values in another array to determine percent change and moving average.

 

I hope this helps!

 

-Will

 

 

 

 

0 Kudos
Message 2 of 2
(2,934 Views)