LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I show a sub vi whenever a boolean value changes

Hello,
 
Show the event case you wish to execute on the boolean value change, right click on the event structure and choose "Edit Events Handled by This Case...", choose your boolean under Event Sources (under the Controls tree entry), choose Value Change under Events, and then click the OK button.  Doing this in a loop will cause that event case to execute whenever you change the value of the boolean.  Now, if you have other code in the loop which will execute after the event structure, you will not see the results of your subsequent value changes until that code completes and your loop actually proceeds to the next iteration.  Further, if you have code within an event case that takes significant execution time, AND you'd like to actually queue subsequent value changes WHILE that event case code is executing, then you'll need to uncheck the "Lock front panel until the event case for this event completes" checkbox.  This tells LabVIEW to capture events even while an event case is executing; they will be queued internally and their event cases will be executed in the order the events occurred.
 
I hope this helps!  Repost if you are still having trouble!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
Message 11 of 35
(1,320 Views)
I've added the event structure in my while loop and everytime my program go through the loop, the event structure executes. Is there a way that you can put some type of if statment in the event structure.  Because I would like for the sub vi to open only when the value of torque or position changes from its previous value.  But they way that I have it set up now, is that the sub vi opens every time there is a value, but I only want it to pop up whenever there is a value change.  Is there a way to do that through the event structure?
0 Kudos
Message 12 of 35
(1,202 Views)
You're certainly not using the value change event if your subVI is executing continuously. Which event are you using and where in the event structure is your subVI? It's really pretty simple. Right click on the event structure and select Add Event Case. In the event sources, select the control and in the Events window, select Value Change. Click the OK button. The subVI you want to execute when the value changes should be placed in the event you just created. It would really help if you posted your VI so that someone could see exactly what you're doing wrong.
0 Kudos
Message 13 of 35
(1,198 Views)
The VI is posted in the first reply of this thread.  I already added the event structure inside of my loop and I put the sub vi inside of the event structure and when I execute the vi it opens my sub vi everytime it sees a value in the boolean, but I only want the sub vi to open whenever the value changes
0 Kudos
Message 14 of 35
(1,199 Views)

What type of boolean button are you using?  I think that latched buttons have to be read from inside the event structure to unlatch and be recognized, but I dont have LV in front of me to test this.  This is knid of unique to the latching mechanism and not so with other kind in event structures.  So inside of the boolean value change event wire the control to a case structure and plave the event handle code inside of the true case.  Try to keep any code in your event structure shors so the system responce time stays quick as well.  Long events should be handeled in a worker thread, see the event producer/consumer event design pattern for more on this .  Good luck

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 15 of 35
(1,198 Views)
It is not a button, it is a indicator coinnected to true or false constants.  Whenever the indicator changes value I want the sub vi to open
0 Kudos
Message 16 of 35
(1,197 Views)
The VI you posted DOES NOT have an event structure. Post the VI that you've modified.
0 Kudos
Message 17 of 35
(1,185 Views)
Now I understand. You don't want to use an event structure at all. Just put the subVI inside a case statement and wire the case selector to the same source as the indicator. Put the subVI in the True case.
0 Kudos
Message 18 of 35
(1,182 Views)
The sample below contains the vi with the event structure in it.  It also shows the sub vi inside of the breaker box along with the property nodes for value signaling
0 Kudos
Message 19 of 35
(1,178 Views)
0 Kudos
Message 20 of 35
(1,176 Views)