07-30-2015 12:48 PM
Hello. I have attached my Vi. I have a question about stopping a For Loop. On the "Test in progress" case I have 2 For Loops. I have a conditional termial that will stop my Vi but only after all the iterations of the For Loop have completed. I need this Vi to stop immediately, when the stop button is pressed. I realize it will probably still need to finish an itereation however, right now it waits until all iterations are done, before stopping. I am trying to do this with the same front panel pushbutton that stops the While loop. I have tried a local variable but it requires I change mechanical action and I would rather not do that, if at all possible. There were a lot of messages pertaining to this topic here on the forum however, I couldn't find one that suited my needs. Thank you for your time.
Solved! Go to Solution.
07-30-2015 12:58 PM
Your While Loop waits the For Loops to stop, so you can use local variables of your stop button to stop the for loops right away.
Cheers,
Jimmy
07-30-2015 01:02 PM
If you want to avoid the Local Variable, a standard way to do this is with Notifiers. Use the same construction that Jimmy has and then add a parallel while loop with an Event Structure that can throw the notifier when you hit the stop button.
Your architecture is a bit odd. You have the makings of a state machine that could be expanded to not use a for loop and be completely interruptible. Also, your flat sequence structure isn't doing anything for you.
07-30-2015 01:03 PM
@Jimmy.chretien wrote:
Your While Loop waits the For Loops to stop, so you can use local variables of your stop button to stop the for loops right away.
Cheers,
Jimmy
Thank you Sir for the reply. I tried the local variable before, the challenge is that I must then change the mechanical action of the stop switch.
07-30-2015 01:06 PM
@Taki1999 wrote:
If you want to avoid the Local Variable, a standard way to do this is with Notifiers. Use the same construction that Jimmy has and then add a parallel while loop with an Event Structure that can throw the notifier when you hit the stop button.
Your architecture is a bit odd. You have the makings of a state machine that could be expanded to not use a for loop and be completely interruptible. Also, your flat sequence structure isn't doing anything for you.
You have the makings of a state machine that could be expanded to not use a for loop and be completely interruptible I tried removing the For Loops but couldn't get it to do what I needed.
Also, your flat sequence structure isn't doing anything for you Yes Sir, I removed it yesterday. Sorry, I thought I sent my most current copy. Nothing else has changed other than the flat sequence removal.
Thank you
07-30-2015 01:14 PM - edited 07-30-2015 01:15 PM
@ceilingwalker wrote:
Thank you Sir for the reply. I tried the local variable before, the challenge is that I must then change the mechanical action of the stop switch.
Changing the action of the Stop button is easy and I do it a lot. It's a really easy way to make a local stop variable for multiple loops. Change the Stop button to "switching" mode and then write a False value to another local variable that runs after all loops have stopped.
This is your easiest solution.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-30-2015 01:17 PM
Here's a template for the alternate solution I was proposing. In this case, I illustrate with a while loop instead of a for loop.
07-30-2015 01:28 PM
The Latch on the boolean button is nice if you use an event structure, but you have none of that here, the easiest is to use Switch instead.
I'd go with Taki1999 suggestion but you need to quite redesign your code, if you're not going to develop a long term software and need something for a quick experiment, I'd go with the local variables.
07-30-2015 01:32 PM - edited 07-30-2015 01:41 PM
You'll still need a way to kill the event loop. You can use a user event for that.
Kill For loop and daq loop
Event loop:
07-30-2015 03:47 PM
@igagne wrote:
You'll still need a way to kill the event loop. You can use a user event for that.
Kill For loop and daq loop
Event loop:
Thank you for this. I have been trying to learn how to use events, as it seemed the better way to go for my entire project but I haven't figured out how to use them yet.