LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop button in the while loop

Hi, everyone
 
I have a while loop which has to stop on the completion of the measurement (say a 1000 iterations of data acquisition and GPIB control of the instrument) or when the stop button is pressed. Most of the time it works but sometimes the stop button is ignored by the program and I have to wait all 1000 iterations. (no changes in the code at all).
What I have to do to make sure labview reads the stop button input?
 
Cheers
0 Kudos
Message 1 of 9
(3,619 Views)
you have a race competition problem:
you have a loop with 1000 iterations, and a stop button , all in the while loop.
the question is which is reached first? the inner loop or the stop? well, you cant know in advance! (thats in a sense the beauty of LV).
 
what you need to do is put the inner loop with the 1000 iterations in a true-false case, which is powered by the same stop button: if stop then dont pass trough the 1000 inner iterations.
does that answers?
 
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 9
(3,612 Views)

hi there

hm, just a guess: make sure the "mechanical action" (right click on the button to see options) is not set to "switch until released". or post some code.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 3 of 9
(3,602 Views)
Thanks Gabi1 for a good suggestion. I thought there would be a more elegant way to do it, but probably I have to use assembler if I want it to be perfect. Smiley Happy Thanks again.
0 Kudos
Message 4 of 9
(3,566 Views)


@wsm wrote:
I thought there would be a more elegant way to do it, but probably I have to use assembler if I want it to be perfect. Smiley Happy Thanks again.


the way i see LV is perfect.

send the code we might have nice solutions for you 🙂

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 5 of 9
(3,541 Views)
We really need to see your code to identify the problem.
 
Make sure the stop button terminal is in the innermost loop, make sure the loop is set to "stop if true" and make sure that you take the logical OR of the stop button and end of experiment and wire the result to the termination condition.
 
Most problems can be avoided if you don't use local variables and use a latch action for the stop button.
 
Message 6 of 9
(3,539 Views)
Thanks guys case loop does the job.
0 Kudos
Message 7 of 9
(3,513 Views)
What's a "case loop"?
0 Kudos
Message 8 of 9
(3,505 Views)

he probably means that in the main loop, he has a case structure wired to the "stop" button. in this case he has his 1000 read iterations.

but it is probably not the best, nor most elegant solution. too bad no code is posted, we cant show how beautifull is LV when properly programmed ( as you teach me every time again and again on this forum Altenbach:) ). of course, any comparison with assembler is not really objective...

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Message 9 of 9
(3,493 Views)