Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I get values into a vi from a subvi while the subvi is still running within the vi?

1,483 views
Skip to first unread message

zkajan

unread,
Jun 19, 2001, 11:41:46 AM6/19/01
to
Hello
This is my problem. I have a subvi that runs an experiment. At
different point in the experiment different instruments are on or off
and I have a boolean array display this info. It is updated at
various points of the experiment via a local variable. That works
fine. Here is the problem though. I run that subvi from a main vi
program (that runs it several times for several experiment cycles). I
would like to pass the status of that array onto the mainvi to display
there too. The problem is that the array in the main vi is not
updated until the subvi is done running and thus displays only the
array status at end of experiment (instead of changing as the status
changes within the subvi). I tried using a global variable to write
to it in the subvi every time there is an update, and read from it in
the mainvi, but that doesn't work, it still displays just the status
at the end of the subvi execution. Does anyone know how to make this
work, or if there is a workaround this? Thanks.

Shan Pin Koh

unread,
Jun 19, 2001, 12:04:29 PM6/19/01
to
I am going to guess that you have some form of loop - FOR or WHILE
inside your subVI. This loop is what is controlling your experiment
and such.

From what I know, you're right about the main vi not getting updated.
The subVI can only return values when it is done running. (It would be
nice if you could use pointers here...)

However, there are two ways to make this work:

First, you might want to bring the FOR or WHILE loop to the main VI
calling the subVI. Thus, the subVI only runs once and will return its
proper value to the main VI.

Second option is to have two consecutively running WHILE loops. One
calls the subVI as you are doing now. The second takes values from the
GLOBAL variables and displaying it on the screen. This method is not
elegant but it works. (also consider adding some delay or wait time so
you don't end up using all processor time updating the screen.)

Hope that helps.

Shan Pin Koh

Franz Josef Ahlers

unread,
Jun 20, 2001, 2:19:32 AM6/20/01
to zkajan
If you have LabVIEW 6i, you can update indicators of a calling VI from
a SubVI, while the subVI is running.

In your case you need
1) an indicator on the main VI panel to display the boolean array
2) to pass a reference to that indicator to the subvi when you call it
3) to use this reference in the subVI, connect a property node to it and
write the values to be displayed to the 'value' property of this node

If you don't have version 6, you can write the values to be displayed to
a global and display this global in the main VI from within a while loop
which must run in the main VI in parallel to the running subVI.
It's more complicated, since you need a mechanism to gracefully shut
down the while loop after subVI finishes. You could do this with
another global control boolean which is not displayed but just connected
to the repeat terminal of the while loop. Don't forget to put a 'Wait' of,
say, 50...100 msec in that while loop.


-Franz

zkajan schrieb:

--
Franz Josef Ahlers
Section Semiconductor Devices
Physikalisch-Technische Bundesanstalt
Bundesallee 100
D-38116 Braunschweig
phone: (+49) 531 592 2410
fax: (+49) 531 592 2405


zkajan

unread,
Jun 20, 2001, 1:30:32 PM6/20/01
to
Thanks EricE
That is exactly the kind of stuff I meant. I haven't had a chance to
make it part of my program, but looking at what you did it doens't
seem that hard (once I understood that it could be done that way).
Thanks man
0 new messages