04-23-2013 01:27 PM
Hello,
I'm building a LabView program with LabView 2011 to control an experiment. The overall program is contained in a stacked sequence and this sequence is held inside a main while loop. This main while loop is controlled by a Stop button, to which a local variable is associated, and in my intentions the stop buttons and the local variable associated to it were meant to stop the program at different possible points during the execution.
Now the way the program is built the stop button of course never actually stops the execution of the program, because given that the main while loop contains all the program, the stop button, which is at the first iteration in the false status, will never change its status to "true" before the first iteration, that is the overall program, is completed. So I'm aware of the reason why I'm not able to stop my program, but I don't know how to correct this. I've read that queues, events or notifiers could solve my problem, but I have no idea of how to use them.
Can somebody please help me with this?
Many thanks
Solved! Go to Solution.
04-23-2013 01:41 PM
This is one of the main reasons not to use seqeunce structures. I think a State Machine is what you really want. That way you can stop the program at any point.
04-23-2013 01:50 PM
There is not enough information to troubleshoot the problem or give advice.
You say there is a "main while loop". are there also others?
One problem with stacked sequences is the fact that they cannot be easily escaped. That's why everybody uses a state machine architecture instead. Overall, your code descriptions tells me that it's probably not architected well.
Can you show us some of the code?
04-23-2013 01:55 PM
Many thanks for the very quick answer. I'm having a look at what a state machine is.
I attach my overall code if it can help.
04-23-2013 02:14 PM
The first issues is that your "abort" terminal gets read right when the while loop starts so when the value changes to something else, it will only get registered at the next iteration of the while loop. You need to ensure that these local variables only get read as the last step in the loop.
It is also a really bad idea to trap an event structure in the middle of a long sequence. most likely it cannot react most of the time.
04-25-2013 10:51 AM
Many thanks for the two answers. Building the code as a State machine solved the issue. Thanks again.