LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

indicator of a global variable

hello,
I created a VI which uses a global variable whose value is changed in different sub VIs.On my main panel i have put a simple indicator of the global variable. Unfortunatly when running the VI, the indicator doesn´t show the value of the global variable, although, when looking in the global variable´s panel, the value does change.
Any ideas ??
0 Kudos
Message 1 of 5
(3,477 Views)
Is the global variable in the main panel within some sort of loop that permits it to be refreshed?
Message 2 of 5
(3,477 Views)
The global variable is only in a "continue till stop" while-loop. In the same panel i have the SubVi that sets this global variable to different values.
My understanding of the global variable is that whenever changed, the value will change on all other panels (VIs) as well.
0 Kudos
Message 3 of 5
(3,477 Views)
But if your subVI is executing in some sort of loop, the indicator on your main VI will not be refreshed until the subVI finishes. Try putting the indicator in a different while loop than the one the subVI is in.
0 Kudos
Message 4 of 5
(3,477 Views)
The indicator is not the global: it's just an indicator wired to the global. The indicator only gets updated when the code wiring the global to it is run.
If the sub-VI which updates the global is in the same loop as the code which updates the global, the indicator only gets updated once per call to the sub-VI. Everything in the loop gets executed once per loop iteration. The loop will wait until everything within it (including sub-VIs) executes (and completes)before it continues to the next iteration.
If the global terminal is outside of the loop, only its initial value will be read. If the indicator terminal is outside the loop, only the final value gets read. They both need to be within the loop.
If you need to update the indicator multiple times per exec
ution of the sub-VI, you could put the global - indicator update in a separate loop, running in parallel with the loop calling the sub-VI. To make sure they run in parallel, neither loop should depend on an output from the other loop. They can share inputs, but an output from one cannot be the input to the other or they won't run in parallel: the loop getting the output from the first will wait unilt the first loop is done before executing. (That's the data-dependency model of LabView). The loops can read the same Stop button (if that's how you control the loop) if you use a local variable for Stop in one of the loops.
You could also use control references to update the calling VI indicator directly from the sub-VI.
Message 5 of 5
(3,477 Views)