From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-18-2023 05:07 PM - edited 04-18-2023 05:10 PM
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!
Solved! Go to Solution.
04-18-2023 06:06 PM
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.
04-18-2023 06:14 PM
Using a global variable is possible but not a good idea. See Read and Write Main VI Control/Indicator Value from a SubVI instead.
04-19-2023 03:49 AM - edited 04-19-2023 03:50 AM