04-30-2010 11:50 AM
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?
04-30-2010 11:59 AM
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.
04-30-2010 12:06 PM
04-30-2010 12:40 PM
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!
04-30-2010 01:01 PM
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.
05-03-2010 03:18 AM
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.
05-03-2010 07:53 AM
05-03-2010 11:27 AM
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:
05-03-2010 12:53 PM - edited 05-03-2010 01:03 PM
yup....I missed initialization side........