10-06-2008 08:48 AM
Hello,
I have the attached code that is reading from a com port and filtering data into seperate arrays. I need to be able to access the stored data from from higher level VI's for data analysis. In the following code i am storing the data into one large global or into indvidual global, dependent on the boolean indicator values. When I call this VI the global values are not updated because to the calling VI as the loop does not stop. It seems that i need a VI on top of this one that makes incremental calls in order for the globals to be updated? I'm thinking i may be able to simply use an event structure based on serial events so that the loop will eventually break in order to update the globals?
I would also like to ask about most efficeint data storage. Would you recommend a more efficeint way of storing data and making it available to higher level VI's? I like the idea of using the globals to store the data rather than a higher level shift register but Im not sure it is the best way of going about it.
I would like some recommendations on how best organize this code for best performing operation.
Thanks for the comments
10-06-2008 09:48 AM - edited 10-06-2008 09:52 AM
You didn't include any of the subVIs or the global variable VIs, so it's difficult to tell if you are simply suffering from a race condition. I think you may want to look over Action Engines.
Also, you should avoid creating greedy loops.
10-06-2008 09:57 AM
I do not have LabVIEW installed on this PC, so I could not look at your VI.
However, you may not need to use Global Variables, as there are better alternatives.
The best approach is to have a main VI call sub-VIs and have the data directly from wires.
This may not always be applicable, especially in cases where there is acquisition happening at the same time as the data is being analyzed or processed. An approach would be to have a Producer / Consumer archetecture, where the sub-VIs would pass the data using a queue. Another approach would be to have Dynamic VI's (daemons) that collect data and make it immediately available by storing it into a Functional Global Variable or by using a queue.
And there are other scenarios available depending on how the overall process needs to take place. There are also ways to minimize the number of variables (controls) within Global Variable (or any of the alternatives) and that is to combine the data within clusters.
Food for thought...
R
10-06-2008 03:05 PM
10-07-2008 08:08 AM
What you want is a reference object. You pass a reference to the object around instead of the actual object. There are a variety of ways to do these in LabVIEW, but only two that I would recommend. You already know about one - LabVIEW 2 globals, AKA functional globals, shift register globals, or action engines. The other good option is single-element queues. Check out this post for more information on the subject. It has code examples and a complete writeup on the subject.
I, personally, prefer single-element queues because they fit my programming style better. They are a bit harder to use, but give better performance when you need it (large data). Try both and see what you like.
10-07-2008 09:16 AM