12-22-2015 11:07 AM
I'm wondering if there is a good way, or even anyway to stop a while loop without waiting for its next iteration. Lets say you have a timer in the loop so it iterates once evey 10 seconds, then you have to wait 10 seconds for it to stop after a stop button is pressed which could be a problem.
Thanks!
Solved! Go to Solution.
12-22-2015 11:14 AM
Rather than put a 10s wait, make the wait much shorter, but only perform your action after 10s has elapsed. There is an 'elapsed time' express VI, or you can create your own Timer FGV.
12-22-2015 11:24 AM
There are lots of ways to do this, but it depends, a bit, on the current architecture or Design Pattern you are using. Since you have shown us none of your code, we can't do more than say "Yes, it is possible, and not that difficult ...". For more specific suggestions, post your code (as a VI or Snippet, so we can execute it and test out our suggestions to be sure they function correctly).
Bob Schor
12-22-2015 11:42 AM
Sorry I didn't post code, here is a very simple example of what is happening. I took out the insurment controls but as you can see, the longer the ramp time, the longer the loop runs, thus it takes longer until it shuts off.
Thanks for assisting!
12-22-2015 11:52 AM
One easy way would be to use the timeout event of an event structure and an event case for the stop button. Pressing stop will break the current timeout wait, even if it is infinite.
12-22-2015 12:19 PM
I've been looking at event structures in the labview help because I've never really used one. I can't figure out the correct way to wire it up
12-22-2015 12:21 PM
I guess it's just a stop button inside the timeout case wired to stop the loop but im not sure what else i have to do
12-22-2015 12:38 PM
12-22-2015 12:45 PM
So is this what the final solution should look like, it seems to work?
12-22-2015 12:45 PM
oops