From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop a program

Solved!
Go to solution

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

 

 

0 Kudos
Message 1 of 6
(3,049 Views)
Solution
Accepted by topic author minni

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(3,045 Views)

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?

0 Kudos
Message 3 of 6
(3,042 Views)

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.

0 Kudos
Message 4 of 6
(3,035 Views)

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.

0 Kudos
Message 5 of 6
(3,028 Views)

Many thanks for the two answers. Building the code as a State machine solved the issue. Thanks again.

0 Kudos
Message 6 of 6
(2,962 Views)