01-29-2006 10:54 PM
01-29-2006 11:31 PM
Instead of using a scalar shift register and expanding it on the diagram to return the last several values, you could use an array shift register and initialize its size based on the input to the VI. Then you could just use the Replace Array Subset function to replace elements in the array as new elements come in.
As for the uninitialized shift register problem, that's easy...make the subVI reentrant. You can do this through VI Properties > Execution > Reentrant Execution. A reentrant VI maintains separate dataspaces for every instance of that VI in your hierarchy. So if your VI was reentrant, every subVI would maintain its own values in the uninitialized shift register. You can read more about Reentrant VIs in the LabVIEW Help.
Hope these answers made sense,
-D
01-29-2006 11:46 PM
As darren has already mentioned, making your moving avg sub VI re-entrant should solve your initialising shift register problem.
In my cache, i happened to find these two VI's for calculating moving average.
Hope it helps you
Regards
Dev
01-30-2006 01:18 PM
01-30-2006 04:03 PM - edited 01-30-2006 04:03 PM
Message Edited by Nickerbocker on 01-30-2006 04:04 PM
01-30-2006 06:37 PM
01-31-2006 01:14 PM
01-31-2006 02:16 PM
The atomic operations (delete/insert) MUST do the following:
Both operations involve an array resizing operation and data shuffling in memory.
How can LabVIEW be sure that the memory can be re-used? What if your code would delete one, but insert two at each iteration? It might well be that the LabVIEW compiler properly re-uses the memory in your particular case, but there are no guarantees. A five element array is peanuts. so it would probably be difficult to notice a difference.
You might want to run a benchmark of the different algoritms using a huge buffer. 😉
"First call?" is defined as followes in the online help:
First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
01-31-2006 06:03 PM
01-31-2006 07:16 PM