LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting actual data from running subVI

I want to display changing data from a running subVI continously on the frontpanel of the main VI and use this data to create signals for digital output (with the same change of value). How can i do this. The implemented indicators only show the result when the subVI has finished!
0 Kudos
Message 1 of 4
(4,061 Views)
There are two options here, Global variables and VI server.

Using global variables, the values of interest are written to a global variable in the sub-vi during every loop. this way, the values can be read "simultaneously" in the main program. Try keeping this "one vi Read" and "one vi-Write" approach to avoid race conditions.

Using the VI server is more complicated and involves getting a reference to the sub-vi within the main VI. This reference can then be used to get the value of certain controls and indicators from the front panel of the running sub-vi. You need to know the name of the indicators and controls you wish to read (or write).

I reckon the global variable is easier, but can anyone say which is "better"?

Shane

Ps there are of c
ourse other ways of doing this but I don`t even want to start discussing writing files or looping IP packets.....
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 4
(4,061 Views)
That's the way data flow works..See this related question and answer:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000006C840000&USEARCHCONTEXT_CATEGORY_0=_49_%24_6_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0

If you want to get data from the sub-vi you must make it run in parallell with the code updating the front panel of the VI, you can do that by calling the sub-vi outside the loop that is updating the front panel or you can run the VI using an invoke node as described in the Q&A referred to above...

Now - to get access to the data you need to share it using some sort of global or que, the best option is to use what is called a "functional global". Check out the following description of suc
h globals:

http://zone.ni.com/devzone/conceptd.nsf/webmain/82E60E34E609C22A862569F8007E3F4A?opendocument
0 Kudos
Message 3 of 4
(4,061 Views)
"for displaying data from subVI"
If your main VI is not so complicated I think you just save your subVI as "show front panel when called" and you can do it under vi properties. But in some cases like if your main VI is quite complicated and you want to display the data from the loop or from array or whatever, we can use the data socket connection and we do not need to write the code for the data socket, we can just bind at the front panel. But before you run the program, you may need to run the data socket server and if you do not want to run the data socket server each time you run this vi, you can look at the labview example� how to run the data socket server from the VI.� what I posted last few days.
Under
>data operation
>>data socket connection
Take
a look at the labview data socket examples.
"for use the data from the subVI to create signal"
Do the same concept use datasocket.
Hope it is useful.
Saw Naing Aye.
0 Kudos
Message 4 of 4
(4,061 Views)