LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Below I have a sample vi.  I want to be able to show a sub vi whenever Torque 2 is used and then again when Torque 1 is used.  The goal is for the user to know whenever a new torque value is used.  So, everytime a different torque value is  used and sub vi pops up to where the program pauses execution and when the sub vi open the user has to press ok in order for the program to continue executing.  I also enclosed the sub vi that I wanted to open every time a different torque value is used.
0 Kudos
Message 1 of 35
(3,850 Views)
Use an event structure.  Create an event case for Torque1 value change, then press the green Plus sign at the upper left and add the Torque2 value change to the same event.  Then inside the event case, put your subvi.  Each time either boolean is changed, the subvi will execute.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 35
(3,824 Views)
I tried that but when I put an event structure inside of my while loop, it only runs the event structure and the rest of my program doesn't get executed. 
0 Kudos
Message 3 of 35
(3,819 Views)
You need to learn how to use event structures.  Look for examples on them.  They wait until some event happens, then they execute the code inside that event case.  Meanwhile, the rest of your vi should go on executing.  Post your code with the event structure so we can look at your mistake.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 35
(3,811 Views)

Tbob's suggestion should work, but if you want other code to run concurrently with the event structure it needs to be in a separate thread (loop) or you need to set the timeout to something other than -1 (indefinite timeout).

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 35
(3,799 Views)
I'm not really sure how event structures work.  I placed on inside of my while loop, but it only executes the first loop.  I assuming it executes the first time and then it waits for the torque or position value to change to execute the next time.  Do I have to put my whole vi in a event structure or can I just leave it in the while loop,  Is there a setting or property on the event structure that allows the vi to keep executing even though no value has changed?
0 Kudos
Message 6 of 35
(3,796 Views)
Yes...  Use what falkpl mentioned, and wire something other than -1 to the timeout of the event structure.  If timeout is infinite (-1), then the event structure hangs, waiting for input, thus causing your loop to hang.  If there is a specified timout time, then it waits that long, then runs the timout event, which enables your loop to iterate.

I would however, follow falkpl's advice and use two threads.  One for your event structure, and one for the rest.
Message 7 of 35
(3,791 Views)
I added a constant to the event structure so that it proceeds until a value change, but it doesn't recognize the boolean value change, do I have to route the boolean into the event structure too?
0 Kudos
Message 8 of 35
(3,781 Views)
 
0 Kudos
Message 9 of 35
(3,776 Views)
It would be easier for all of us if you would post your code, or the part you are having a problem with.  If the boolean change is not setting off the event, you probably are just wiring a value into the boolean variable, or into a value property node.  To cause the event to be fired programatically, you need to wire a value into the Value(signaling) property node.  The value property is for manually clicking on a boolean with the mouse.  The value(signaling) property is for programatically causing a value change event.
 

Message Edited by tbob on 08-16-2005 10:25 AM

- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 35
(3,653 Views)