LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

accessing panel controls/indicators from a sub-vi

I am confused about how to access controls and indicators in my main vi from a sub-vi. I have a very specific need which I can present as a simple example of what I want to do:
 
I am using GPIB to control instrumentation. I am using the VISA ibsta indicator on my panels (a row of LED-style indicators labeled to represent the different handshake lines on GPIB; it's typedef'd in VISA).  The ibsta indicator resides on my main vi's control panel where the user can see it when the program runs. I have several sub-vi's that send commands over GPIB, and the main vi also sends command over GPIB.
 
What I want to do is be able to update the ibsta indicator (in 'real time') from not only the main vi, but from the sub-vi's that make GPIB calls. I therefore created a refnum for the ibsta and pass it to all my sub-vi's as an input to them. I *thought* (this is where I get confused) that by setting the property: value for the passed-in ibsta reference I could set the ibsta in the main vi and therefore the LEDs on the user-visible main control panel. It doesn't work.
 
I tried setting the 'synchronous' flag but it makes no difference.
 
I'm sure this is something very fundamental; but what am I missing?
 
I want the LEDs to indicate the real-time update of the GPIB bus state as the processes (sub-vi's) run, but the indicator only gets updated when each sub-vi returns control to the main vi, where I explicitly update the indicator. I'm missing a lot of ibsta updates since some of the sub-vi's contain loops that perform GPIB activity, and they take a long time to run; I had hoped to see flickering lights during those time periods, not a static display of the old GPIB state...
 
Any help (of course) would be much appreciated!
 
As an aside, if I create a reference from a control/indicator and use property:value to set/get the value (as versus a direct assigment), is that any different than creating a local variable and using the local var to set/get the value (aside from have some flow-of-control ability due to the property's use of the error-in/error-out paradigm)?
 
 
0 Kudos
Message 1 of 7
(3,322 Views)
The key is in your statement:

"... want the LEDs to indicate the real-time update of the GPIB bus state as the processes (sub-vi's) run, but the indicator only gets updated when each sub-vi returns control to the main vi,..."

The Main VI is waiting while the subVI runs. This is normal LV dataflow. To get the effect you want, the subVI needs to be running in parallel to the main VI. It can be in a while loop and controlled via queues or can be called via invoke nodes. Perhaps other ways also. In any case you need to plan carefully how the subVI is called, how parameters are passed, how it is stopped, and so on to make sure that both parts of the program do what you want.

Lynn
0 Kudos
Message 2 of 7
(3,306 Views)

Thanks for the help, Lynn.

I fully understand that the Main VI waits until the subVI finishes given the way I invoke the subVI (merely putting it on the Main VI diagram in the normal flow of things).

But are you telling me that the data structures (controls/indicators) in the Main VI are not available to the subVI? I would think that the controls/indicators would be implemented as subroutines (to animate them and change their values) and that those subroutines in a main VI would be global in the sense that subVIs could also access them.

I don't want to interact with the Main VI in the sense that it needs to execute code in response to changing conditions in the subVI. But it seems to me that the subVI should be able to call service routines and access data structures in the Main VI even while the Main VI is waiting for the subVI to complete... in much the same way as a subVI can call other subVIs that the Main VI calls also...

If you are correct, I don't understand how controls/indicators are implemented in Labview. (By the way, this is NOT a CVI question).

Gary

0 Kudos
Message 3 of 7
(3,288 Views)
Hi Gary,

It seems like you might want to use global variables.
Global variables created in a project allows you to update the variable anywhere in the project.

But you might run into issues of race conditions

Van
Van L
NI Applications Engineer
0 Kudos
Message 4 of 7
(3,284 Views)

My understanding of the implementation of global variables is that they exist on a special front panel that ISN'T visible. So if the sole purpose of my use of globals is to have a boolean indicator that I can flash on and off to indicate activity inside the loop in a subVI, and I want that indicator to be visible on the mainVIs front panel, the global doesn't appear to help...

I tried creating a reference to the indicator and giving that to the vi; the vi got the property:value from the reference and changes it. But the indicator on the mainVI front panel doesn't change; the update to the visual part of the indicator only occurs when the subVI exits.

There *must* be a way that a subVI can change indicators on the panel of a mainVI *without* the mainVI having to run in parallel....

0 Kudos
Message 5 of 7
(3,276 Views)

Hello Gary

Creating a reference is what i wanted to recommend you. This should work. I attach a zip file with a simple main VI and a subVI . The boolen control changes its value every half second. Does this work on your computer?

Greetings,

shb

0 Kudos
Message 6 of 7
(3,270 Views)

Not only does it work on my machine, but MY code works on my machine... after I fixed the STUPID blunders. Geez, you'd think after doing this a quarter century I wouldn't still step in the same potholes.

Thanks... my implementation using references was architecturally correct. My syntax screwups prevented my knowing that. Your confirmation that references are the thing to use made me go back and actually think about what I was looking at. Anyone know how to run 'lint' on G code?!

 

PROBLEM SOLVED.

0 Kudos
Message 7 of 7
(3,249 Views)