LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you pass data from a running sub VI to a higher level VI?

If I have a sub VI running in my main VI can I pass the data from the running sub VI to the front panel of the main while the sub VI is running. I know after the sub VI is finished I can get the data but I would like to get it while it is running and display it on the front panel.
0 Kudos
Message 1 of 9
(2,999 Views)
You can use queues to pass the data without data dependency. Whether it will do what you want depends on program structure details, specifically whether the producer and consumer of the data are running in independent loops. Global variables and property nodes can also be used, but each has significant disadvantages.

From a program architecture point of view, it often is advantageous to use a state machine. The user interface is usually in one independent loop, often with an event structure, while the processing and data acquisition or external communications are in other loops.

Lynn
0 Kudos
Message 2 of 9
(2,991 Views)
Yes you can. There are actually several ways to do it. One way would be to use datasockets and have the subVI publish the data and the main VI subscribe to it.

A more common way would be to use control references through VI server. If you create a reference to a control and pass that reference to the subVI, you can wire it to a property node and change the value property of the main VI.

I hope that this helps,
Bob Young
0 Kudos
Message 3 of 9
(2,989 Views)
Yes, pass references of the front panel controls to the subvi and use
property or invoke nodes to effect the change.


0 Kudos
Message 4 of 9
(2,988 Views)
I appreciate the help with this however I am not quite underatanding the solutions. Does any one have an example I can look at? I am experimenting and cannot figure out the keystrokes. Thanks for the help so far.
0 Kudos
Message 5 of 9
(2,982 Views)
someone posted a similar question the other day.................

the example in there with control references may be able to help you understand 🙂

http://forums.ni.com/ni/board/message?board.id=170&message.id=113762
0 Kudos
Message 6 of 9
(2,968 Views)
Michael - Thank you for the help. That example helped me to get what I wanted working. Now I am just trying to understand the concept. I am not sure why to get my boolean indicator working on my main VI front panel I had to wire the reference as a control into the sub VI. That just is not making any sense to me. One other thing I have is that to get this to work it was a few steps which is fine for one or two indicators from a sub VI to a main. However in my real program I have many indicators that I want to send their status to the main VI. Is there a better way to do that than with references and property nodes. Using that method would just make me put my sub VI block diagram in my main VI and use local variables. I think it would be less work just not as "pretty" looking. Any other suggestions/examples for many indicators being boolean, numeric, and string types? Thanks for the help so far.
0 Kudos
Message 7 of 9
(2,955 Views)
I'm afraid my skills with control references are no more than looking at that example. I just remembered seeing that thread a few days before and brought it to your attention!

Hold tight and one of the pros will be able to help you out 😄
0 Kudos
Message 8 of 9
(2,948 Views)
If you only want to display the data, you can use a subpanel and place the subVI in it. This will solve all your problems.
If you do want to use the data, you can use any of the methods described here, as well as global variables, which are probably the fastest to implement, but have problems of their own.
The reason you need to pass the reference as a control is because the reference, similar to a pointer, is like the "address" of the variable (or control, in this case) whereas the terminal only holds its value (for example, T or F for a boolean).
To transfer the references to many controls, you can give the subVI the reference to main VI itself and then use the property Front Panel>>[Controls] to get an array of references to all the controls on the front panel of the main VI. You will need to search that array to find the controls you're looking for. If you have unique names for controls, you can simply go over all the elements (using a for loop) and read the "label.text" property. Keep in mind that controls in a tab control don't appear in this list.
You can also get only the references you want in the main VI, build them into an array, and pass that array into the subVI.
Hope this helps.

Message Edited by tst on 04-03-2005 11:04 AM


___________________
Try to take over the world!
0 Kudos
Message 9 of 9
(2,940 Views)