LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to immediately abort a timed loop

Solved!
Go to solution

@apok wrote:

would this work instananeously? rather that waiting for a 10ms iteration loop to read a "stop" as suggested by altenbach.


Yes, your actual solution should involve an Event Structure. I was commending altenbach's use of the Stop Timed Structure VI, not his use of a polling loop for the stop button. 😉

 

Also, I would programmatically set the Timed Loop name...that way you know both the loop and the Stop Timed Structure VI are always using the same name:

 

abort-timed-loop.png

0 Kudos
Message 11 of 13
(618 Views)

i have to say it is very nice to see members inputting their ideas and having a peer group evaluation to come up with an efficient code. i don't have that luxury here at work as i am the only one using LabVIEW. I look forward to good criticism and pats to keep me encouraged....  Smiley Happy

Message 12 of 13
(611 Views)

@apok wrote:
would this work immediately, whether from user input or dynamic event? rather that waiting for a 10ms iteration loop to read a "stop" as suggested by altenbach.

In the time it took you to ask this question, you could have written a small program to test it yourself and remove all doubt. 😄

 

I made the polling loop to keep it as simple as possible (some users, e.g. LabVIEW base prior to LV2012 have no event structure!). Since the delay is localized to the second loop, it only limits how often the button is read, and not how long it would take to shut down the timed loop.

Notice that a probably more critical question is what's in the timed loop. If you have slow code there, it might not be able to stop immediately. Place a 10000s wait in the timed loop and see. 😄

 

In any case, everything takes a finite amount of time, even with an event structure there will be more than zero clock ticks until the loop stops. 😄

Message 13 of 13
(601 Views)