LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a control reference to work?

At my top level VI I have some simple button controls. I'd like to pass those controls to subVI so that the subVI can read and react to changes in the button states.

I tried using a control reference.

First I created a new subVI. Placed a refnum (control) on the front panel. I then inserted the type of boolean control that would be passed and wired it to the connection for the subVI. Then I tried to wire some dataflow in the subVI to read this control and ran into problems.

I created a property node to read the control, but the "Value" property appears to be the actual value of the refnum, not the value of the control itself? Is there a way to read the value of the control, or can I only read/modif
y its position, color, etc and not its actual value?
0 Kudos
Message 1 of 6
(2,683 Views)
You can certainly read the value of the control. I've attached a very simple VI that shows this.
0 Kudos
Message 2 of 6
(2,683 Views)
I think what you need to do is create a property node from the application control palette and wire the refnum control to that. Then the value property should be the value of the control. You need to be careful with boolean controls that have latching action, their value will be a variant.

I've whipped up a small example that may help you out.

Brian
0 Kudos
Message 3 of 6
(2,683 Views)
Hi, Thansk for the help. The variant is exactly what is causing the problem. If I try to pass a switch (as in your example) I can do it fine. If I try to pass a button I have problems. Is there any good documentation on how this variant stuff works -- I've wandered all over the manuals looking but no luck...

Thanks again
0 Kudos
Message 4 of 6
(2,683 Views)
This should show the problem I am having I think.

One of the references passes fine, the other complains about a "Wire class conflict"
Download All
0 Kudos
Message 5 of 6
(2,683 Views)
I'm not sure exactly how to deal with buttons that latch in this case. What you can do is set the button's Mechanical Action to "Switch When Pressed", then it will behave like a switch. In your code you can set it back to false when it goes true.

I've modified your example slighly to demonstrate my point.

Brian
Download All
0 Kudos
Message 6 of 6
(2,683 Views)