LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass realtime data from a sub vi to a calling vi?

I'm trying to pass some data from a called (sub) vi to the calling vi,
while the sub vi is running. I've tried passing to a global, but the
calling vi doesn't show the results until the sub vi has completed
execution. I understand why this is happening, I'd like a method, if
one exists, to work around it.

Thanks!

Bill
0 Kudos
Message 1 of 12
(4,432 Views)
In LabView 6.x, a VI can read globals set by sub-VIs while those sub-VIs are still running. If you're not seeing the global update until the sub-VI stops, it may be due to the structure of your program.
Are you sure the sub-VI updates the global before it ends?
Are you sure the calling VI isn't structured to force it to wait for the sub-VI to end before updating the global?
Pay close attention to the dataflow and any structures (like loops or cases) in your VIs.
0 Kudos
Message 2 of 12
(4,434 Views)
As Al mentioned the structure of the sub-VI could be such that the data is not transfered to the global until it completes.

You question indicates that you understand this.

If you have data that is continually being collected by teh sub-VI and you want to get at this data while the sub-VI is running, you may want to look into "queues".

In 6.1 they are polymorphic so they now rival the speed of functional globals are are straight forward to use. You push the data into the pipe in the sub-VI and it bubbles out the other end in the main.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 12
(4,433 Views)
Depending on what you want to do, there are several ways to do it. As mentioned above, using a global should work.

You could also pass a control reference to the subvi and use property nodes on the reference in the subvi to change values.

You can also use queues or notifiers, pass their references to the subvi, and you can add things to the queue or generate notifications in the subvi, and receive them in the main vi.

You could make it network aware and use tcp/ip to communicate between the two.
0 Kudos
Message 4 of 12
(4,433 Views)
This is exactly what I am trying to do also - although unsuccessfully.

I have a VI that calls a sub-VI. The sub-VI updates a progress meter in a while loop. I pass the progress meter back to the main VI, but it never updates until the sub-VI is done.

I tried to tie a global variable to the logic that calculated the progress in the sub-VI, then I tied an indicator in the main VI to the same global variable. It still only updated when it was finished.

Any help would be appreciated.
0 Kudos
Message 5 of 12
(4,413 Views)
Hello –

As mentioned above, queues will probably be the solution to your problem. Take a look at the example program attached.

Hope this helps.

SVences
Applications Engineer
National Instruments
0 Kudos
Message 6 of 12
(4,403 Views)
Yes, that did help. I have never used queues in labview before, so I was trying to make it as simple as possible with globals. The example you included was definitely simple enough that it only took a couple of hours to implement it into my code 🙂

Thanks
0 Kudos
Message 7 of 12
(4,397 Views)
I am attempting to do a similar thing: continuously read data from a subVI. You mentioned that the global should work.  I wasn't able to get it to work.  Here is a simple program I created to help me understand the process.  Please tell me what is wrong with it.

Nathan
0 Kudos
Message 8 of 12
(4,075 Views)
here's the attachment
0 Kudos
Message 9 of 12
(4,074 Views)

You've done several things incorrectly. First, the subVI has a while loop that terminates with a front panel Boolean. Since you don't make the front panel of the subVI visible, the subVI just runs with no way to stop it. When you call a subVI, execution passes to the subVI and the calling VI is paused. Since the subVI has no way to stop and return to the main, the while loop in the main is not running and reading the global variable. If you were to drag the subVI outside the while loop, then you would see the global update. You still would need to make the subVI visible in order to be able to press it's stop button. Of course, with the subVI visible, it's front panel is showing the value getting updated and there's no reason to have a global in the main anyway.

If you want to have a subVI remain hidden, you can't use a while loop with a front panel control that's needed to stop it. Well, you can but that gets kind of complicated. If you do have a subVI and want to update an indictor with a global, the reading of the globabl should be done in a separate while loop. To keep the update in the same loop, don't use a global. You can create a reference to a front panel indicator and pass that to the subVI. The subVI writes to the value property. Here's a real simple example of that in 7.0.

Message 10 of 12
(4,063 Views)