01-28-2013 04:25 PM
I have the following problem:
In my main loop, i have a signal processing SubVI that generates results only after a few iterations. For example, the loop iterates 1000x and, during the runtime, this SubVI produces 16 numbers (can vary) that need to be stored in a array.
I have found the solution in attachment, but i fear this isnt a good solution. Is there an alternative?
Thanks!
01-28-2013 04:29 PM
That is a rather simple example of what is known as an action engine or LabVIEW 2 Style Global. Generally an action engine will support more options of what you can do with the data and use an ENUM to select the operation. There are other ways that you can pass data in your application such as queues, notifiers or user events. The basic action engine is a viable solution as well.
01-28-2013 04:39 PM - edited 01-28-2013 04:51 PM
Mark_Yedinak, is something like that. The idea is the VI produce an output (and execute subsequent VI's) only when the result is ready.
Is there a more efficient solution?
Where i can find alternative examples?
Thanks!
01-28-2013 04:58 PM
Take a look at the producer/consumer examples. Your acquisition loop would be the producer and the consumer would get the period data and do whatever processing you need.
01-28-2013 06:02 PM
While you created a simple LV2 style global, there are several issues (that don't really mattter if you only generate 16 elements, but could be useful in the future).
Appending an element to the front of the array is significantly more expensive than appending an element to the back, you might want to swap the inputs.
The code is relatively disfunctional, because it is initialized on first call and you can only ever add elements, never reset the array for re-use, etc. until the program is restarted.
You did not really explain how this is used? Is it (1) only read out after all elements are in it or is the (2) array monitored asynchronously from a second loop? In the case of (1), you should place the shift register in the main loop instead of a subVI (or inline the subVI). You could also use a queue instead.