LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to share references?

Hi all,
 
In short I have a main VI that was a boolean that the user can toggle in the main VI.
I pass a reference to this boolean to a sub VI that is displayed simultaneously on screen. I would like the user to have the ability to toggle the value of the boolean from either VI. How do I get the reference to be updatable by either VI. My application is on a single machine so I was hoping to get away from having to declare a network variable.
 
Anywho, any ideas out there?
0 Kudos
Message 1 of 16
(3,045 Views)

Hi punkmonkey,

it sounds like you have only one application with many subvis, so you need no network variable. If you pass the reference to a subvi then you got it. With this reference you can change the value of your boolean button. Where is the problem?

Mike

0 Kudos
Message 2 of 16
(3,041 Views)
Attached is an example.
In the main VI there is a reference to a boolean button that gets passed to the sub VI.
The Sub VI has a button that I stuff the value to from the reference. I want to be able to Click either the button in the sub VI or the button in the main VI and get th value to change. I've only gotten it to work in a one way manner or some crazy flickering between the states. I guess I would like it to work like a databound variable.
Download All
0 Kudos
Message 3 of 16
(3,026 Views)

Hi punkmonkey,

ok it is not that easy i think first, but you can use Queues to build a communication between both vi´s. I´ve attached your changed vi´s and hope it helps.

Mike

Download All
0 Kudos
Message 4 of 16
(3,002 Views)
Thanx,
It definately works like I want but it is way busy.
0 Kudos
Message 5 of 16
(2,988 Views)

Hi punkmonkey,

yes you are right, it is bigger than a thought first, but with the solution you have no polling. You send the event only if the state change.

Mike

0 Kudos
Message 6 of 16
(2,983 Views)

I figured out a simpler way. Not sure if there will be a race condition, but it appears to be doing what I want. The key is handling the value change events.

 

Thanx for you help though.

 

Download All
0 Kudos
Message 7 of 16
(2,950 Views)

Hi punkmonkey,

you should use a "wait" or a "wait until next..." in you subvi´s top while loop, because the cpu usage is very high without it. i guess 5 or 10 ms are enough and your code run all the same.

Mike

0 Kudos
Message 8 of 16
(2,947 Views)


punkmonkey wrote:
I figured out a simpler way.
No! 😄 This is overly complicated.
  1. Use one loop per VI. You can use the timeout event to read the value property at regular intervals.
  2. Never use the "stop" primitive, just wire the correct boolean to the loop condition.
0 Kudos
Message 9 of 16
(2,924 Views)

I'm lost. Could you modify the attached examples to explain.

I can't seem to get the timeout event to fire.

Thanx.

0 Kudos
Message 10 of 16
(2,907 Views)