LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deactivating a boolean (latch action) in subvi possible?

I have a sub VI that handles some events in the main UI of an application. One event that I handle in the sub VI is a value change of a boolean (in an event structure).  Since this variable is not set to mechanical action=switch, then it is impossible to create a local variable in the main.vi or refrence it in the sub Vi.  (The button won't deactivate/depress unless the value is read).  The event structure in the sub VI works fine, I can read the value from the terminal inside, but LV doesn't recognize this as a "read" and the button gets stuck.  Any options?  Do I just need to set the mechanical action to "switch---" instead and then manually set the boolean to 0 every time after it has been read?

 

Rob
0 Kudos
Message 1 of 4
(3,352 Views)

Hi robdevyogi,

 

Have you tried setting up a project and using a global variable to reference this control? Another idea would be to use the Boolean control to operate a case statement that could run code depending on which state the Boolean is in. For this implementation though, you would need the switch to be in "switched" mode rather than "latched". 

 

I have a attached a sample VI.

 

Thanks,

Andrew McLennan
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,308 Views)

Hi Andrew,

 

Using global reference of the boolean: Do you mean I should use the reference to set the variable back to false (so that button depresses)? I wouldn't be able to read anything from it other than false I presume.

 

I wasn't able to open the VI since I'm still on 8.5.1, sorry for not stating that. Could you resend?

 

They way I'm working around it is to have an event structure in the main.vi and one in the sub VI.  The one in the main VI has a case structure where I placed the terminal (in a value change event).  This assures that the mechanical state is reset after clicking on it.  But the event tasks are performed in the sub VI where the second event structure is located.  It works, but I wish I didn't have to put any code in the main VI since the reason for putting it in the sub VI is to make the code as simplified and easy to understand as possible.

Rob
0 Kudos
Message 3 of 4
(3,297 Views)

Hi robdevyogi,

 

I've attached the VI to this post. I did come across the following whilst looking at property nodes.

 

"Data value of this control. If this is a Boolean value configured with a latching mechanical action, this property always returns an error. Due to race conditions that can occur when you have a Boolean value with latching mechanical action, you cannot programmatically read Boolean values that are set with a latching mechanical action"

 

So I wonder if that explains the difficulty you are having with this. Could you possibly send me your code so that I can review it?

 

Many thanks,

Andrew McLennan
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,271 Views)