LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event loop and one main while loop

Dear all,

 

I have create two independant while loop. One while loop is for my main program and another loop has the event sequence.

 

Right now, to stop the two while loop, i have to create 2 stop button and click on both of them.

 

Is there any way in which i only need to create one stop button to stop both loops?

 

Can anyone show me any example to do this?

0 Kudos
Message 1 of 9
(5,128 Views)

Its called a local variable.  Right click on the stop button and select Create - Local Variable.  Use the original stop in one loop and the local in the other loop.  When using boolean local variables, the boolean mechanical action cannot be a latched type.  The normal stop button is a latched type.  You will have to right click on the front panel stop button and select mechanical action - switched when pressed (or released).  This is allow a local variable to work.  However, when you click the stop button, it will stay "on" until you click it again.  That means the when you run your program the second time, the Stop button will be on instead of off.  You can fix that by creating another local variable and writing a False constant to it at the end of your program.  This will turn the button off so you will be ready to run the program again.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 9
(5,115 Views)
Here is a recent discussion on this. Smiley Happy
Richard






0 Kudos
Message 3 of 9
(5,105 Views)

Dear Sir,

 

Just some queries. Can the local variable created work in event sequence? Suppose if i have a stop button (value change) in an event sequence  in  while loop and i create a local variable for this stop button.

 

If i pass this local variable and wire it to stop another independant while loop, will it still work?

 

Thanks!

0 Kudos
Message 4 of 9
(5,082 Views)

Instead of asking if it will work, why don't you try it?  Write code as you described and run it.  It it doesn't work as you expected, then post your vi and ask questions.  The proper way to learn is by trying.

 

- tbob

Inventor of the WORM Global
Message 5 of 9
(5,072 Views)

If you are going to use an event for the stop button (change value) then you can use the "new value" of your stop button and wire it directly on your loop conditional terminal to stop your event loop - and then you don't need to create a local variable of the stop button because you can use your stop button control directly wired to the other loop conditional terminal to stop the other while loop.

 

  

0 Kudos
Message 6 of 9
(5,032 Views)
check attached  VI
Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 7 of 9
(5,013 Views)

Sorry Anil, your vi is not quite right.  If you run it, press the stop button, you can notice that the stop button is still on.  It would be better to turn it off at the end of the program.  Also there is no need to write a true to the stop buttons value property since it already is true.  Lastly, you should put the stop button itself inside the event case that acts on the stop value change.  Here is a vi that addresses these issues:

 

 

locals.png.png

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 9
(4,988 Views)

yup....I missed initialization side........

 

 

Message Edited by Anil Reddy on 05-03-2010 01:03 PM
Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 9 of 9
(4,976 Views)