From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to Update a Global Variable Continuously while a subVI runs persistently?

Solved!
Go to solution

Hi all,

 

Fundamental Beginner question:

 

Is it possible to update a global variable continuously while a subVI runs once, continuously, in parallel?

 

I am trying to pass a value from the mainVI to the subVI, while the subVI is running, allowing the user to change the value from the mainVI in real time.

 

In this current version, the global variable is only updated once, before the subVI starts to execute. Once the subVI starts executing, the while loop doesn't run, and the global variable is not updated by front panel control.

 

Attached is a screenshot showing the concept.

 

If this is fundamentally impossible and breaks the "dataflow" of labview, how can I update a value within the subVI, from the mainVI, while the subVI is running persistently?

 

Thanks for any feedback!

 

CaptainKruncy_0-1681855280200.png

 

0 Kudos
Message 1 of 4
(674 Views)
Solution
Accepted by topic author CaptainKruncy

Your code is executing exactly as it is written. All code within your case statement must complete before it will exit the case. If your power meter subVI runs continuously that means you will not exit the case statement. Your while loop reading the control will execute once if the initial value of the control is FALSE. If it is TRUE, it will exit as soon as it becomes false. Once the while loop exits you are stuck in the case waiting for your power meter subVI to complete.

 

More fundamentally you should not be using globals to pass data. There are much better mechanisms such as queues, notifiers or channel wires. Also, your while loop will consume all of the CPU since it will run as fast as possible given no delay or other means for the scheduler to allow other code to run.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 4
(652 Views)
Solution
Accepted by topic author CaptainKruncy

Using a global variable is possible but not a good idea. See Read and Write Main VI Control/Indicator Value from a SubVI instead.

0 Kudos
Message 3 of 4
(647 Views)

EDIT: ignore.

 

 

0 Kudos
Message 4 of 4
(607 Views)