LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The function that can keep old value

I remember that LabView has a function that will keep an old value for a specified time period but I couldn't fild it. It works like this, if I set the time period for 5 minutes, then it will always keep the value that happened 5 minutes ago and keeps on updating it. This way, I can easily compare the current value and the value 5 minutes ago. Without it, I will have to build a big array to keep all the values even though most of them I don't need. Anyone can tell me where this function is?

 

Thanks and best regards,

 

Guangde

0 Kudos
Message 1 of 21
(6,095 Views)

You probably need to keep an array of all history data for five minutes in a FIFO buffer. You can implement this as an action engine.

 

 

How fast does your loop run (=how big is the history)? If it only runs once per minute, you could expand a shift register to show 5 terminals and tap into the last one. This method is only appropriate for very shallow histories.

0 Kudos
Message 2 of 21
(6,087 Views)

Thank you for responding to my question. My program updates every second. Also, the time period is not a fixed number, user should be able to set it. So it may be 5 minutes or 50 minutes. The array method is little difficult. I remember somewhere I encountered this function in LabView but I just couldn't find it right now.

 

Guangde

0 Kudos
Message 3 of 21
(6,068 Views)

Are you sure this was a function that is/was part of the LabVIEW palette or could it be something written by somebody else.  If your application updates every second and you want data from 5 minutes ago, you're looking at an array of only 5x60=300 elements.  Alternatively, you could implement a counter in your main application loop to only allow the latest data point to be written to a variable or indicator every x number of iterations.  See the attached image where the loop will only update the indicator 'Data' every 300 iterations...

 

 

Message Edited by Jimmbo on 11-03-2008 02:58 PM
-Hook 'Em
0 Kudos
Message 4 of 21
(6,055 Views)

Thank you for responding to my question. I don't remember where I encountered this function even though I thought it's from LabView pallete. But if I couldn't find it and people don't know it, then It may be somewhere else. The way you mentioned in your graph will not work as I wanted because it will not keep the 5 minutes ago's value all the time. If I have to make this function myself, I think I have to use an arry to save the data. Please let me know if you get any advice.

 

Guangde

0 Kudos
Message 5 of 21
(6,040 Views)

You can also use the queue functions to implement a FIFO (First In First Out) buffer.

 

Set the size of the queue depending on the max time interval for which you want to retain the value and the rate of update. For example, if you want to compare values before 5 minutes and you are updating the value every second set the size of the queue to 5 * 60 = 300 elements.

 

After you acquire the first 300 points (the points for the last 5 minutes), you can dequeue an element (this was the point acquired 5 minues back) and then an enqueue the latest acquired point. The first point is removed from the queue and the latest point is added at the end of the queue. The advantage of using a queue is that you do not have to shift the array elements around. The dequeue/enqueue functions should help you implement this rather easily.

Message 6 of 21
(6,006 Views)
The attached example illustartes the use of queues for implementing a FIFO buffer.
0 Kudos
Message 7 of 21
(5,998 Views)

Thank you for your response and the example. I have a few questions regarding the issue:

1. What will be the advantages and disadvantages of using the queue method compare with an array?

2. I want to make it into a subVI then it will be convenient to use in the future. But I don't know whether it's going to work with either methods because the initialization involved.

 

Can you give some advices.

 

Best regards,

 

Guangde

0 Kudos
Message 8 of 21
(5,984 Views)

Guangde

 

Any function that always keeps and updates the value 5 minutes ago must store a lot of points in memory....whether this is in an array, waveform, FIFO, etc...

 

Pacific's Idea of a queue would work just fine, but when I first read your post, the 'get waveform subset.vi' came to mind. I had used this in the past to grab values at specific time periods.  Is this what you were looking for? With some clever coding, it could get values from 5, 10, x minutes ago, as long as your sampling rate is constant.

 

If not, then I would use FIFO's as Pacific suggested.

 

 

Message Edited by Rob_K on 11-04-2008 11:55 AM
Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 9 of 21
(5,924 Views)

If you were to use an array, the following steps have to be performed when you want to replace an old point with a new point:

(1) Index first array element.

(2) Copy the remaining N-1 array elements to a new array.

(3) Insert the new point at the end of this new array.

Hence two arrays are required to replace the old point with a new point.

 

With the queue functions you do not need to use two memory blocks. The dequeue/enqueue functions can be used instead. LabVIEW will take care of all the memory management. My guess is that this would be a lot faster than using arrays.

0 Kudos
Message 10 of 21
(5,920 Views)