LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping while loop problem

Hello, I have a vi that is working perfectly except when I want to stop the loop using the stop button.
I have attached the vi so anyone is free to try....
Thanks in advance!!!
______________
KowdTek
LabVIEW 2009

One Step At A Time, Maybe Two...
0 Kudos
Message 1 of 4
(2,668 Views)
Having a stop button is senseless the way you've written the VI. It will automatically stop when you get to the last frame of your sequence structure and the stop button will be ignored until then because a sequence structure ALWAYS executes every frame. If you want the ability to stop early, you need to remove the sequence structure and use a different architecture. A state machine would be ideal. Look at the shipping examples and the different design patterns (File>New...).
0 Kudos
Message 2 of 4
(2,665 Views)
Thanks!!!
______________
KowdTek
LabVIEW 2009

One Step At A Time, Maybe Two...
0 Kudos
Message 3 of 4
(2,657 Views)

Some extra observations on your coding style:

  • Most likely, the stop button will get read while the sequence is still executing, giving a high chance that the conditional terminal receives a FALSE after the first iteration (race condition). THe stop terminal belongs in the last frame in a sequence like that.
  • Avoiding the seiquence and use a state machine will be much better as Dennis already mentioned.
  • Of course you use the stop primitive, which aborts the VI before the conditional terminal even gets a chance to act.
  • You should really never use a STOP primitive except in emergencies. Once the VI has competed all its code, it will stop naturally.
  • Your tight inner loop needs a wait statement (see also this link).
  • The small sequence frame on the left has no purpose. It does not enforce any specific execution order and none is needed anyway.
0 Kudos
Message 4 of 4
(2,634 Views)