LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop a while loop...

Hi All,
          very new to labview, working on a collage project and have a question.... I have setup a small while loop with a RNG simulating an input, the value goes through a few simple calculation steps and then into a waveform chart which displays on the front panel. I have a 1000ms delay also, my question is........when i hit the stop button the chart continues to be updated!! Why does it not stop? I looked at an example vi which my version of labview (8.5) has,  Generate Random Signal vi but this also keeps generating the signal when the stop button is pressed..
 
Thanks.
0 Kudos
Message 1 of 17
(3,604 Views)

Hi sparrowro...,

could it be that the code inside your loop is not jet ready? The loop stops first, if all code has been executed.

Mike

0 Kudos
Message 2 of 17
(3,600 Views)

Hai,

you can stop a while loop by sending a true constant to it. see the attached image.

Message 3 of 17
(3,599 Views)
Hi,
it would be helpful if you could post your code

Best regards
Kabanga
0 Kudos
Message 4 of 17
(3,594 Views)
Hi sparrow,

GenerateRandomSignal.vi stops as soon as Stop is clicked - atleast on my installation...

Could you attach your vi?

Btw. Have you tried these courses?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 17
(3,591 Views)

Hi all,

Attached is scan of the loop I am trying to stop..

Thanks.

0 Kudos
Message 6 of 17
(3,536 Views)
Just "Print to HTML" directly from LabVIEW and post the .png files....I can't make that pdf out...
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 7 of 17
(3,531 Views)
Your loop has to finish it's iteration before it scans the stop button. If your loop takes 3 days to execute, it'll run for 3 days before it stops.
 
p.s. Generate Random Signal vi stops just fine for me.


Message Edited by Broken Arrow on 04-24-2008 12:21 PM
Richard






0 Kudos
Message 8 of 17
(3,512 Views)


Broken Arrow wrote:
Your loop has to finish it's iteration before it scans the stop button. If your loop takes 3 days to execute, it'll run for 3 days before it stops.

Three to Six days is probably a better estimate. 😮
 
Words like "before" and "after" are very dangerous when applied to a dataflow program. Unless there is a data depedency, reading the stop button can happen at any time during the execution of the while loop. If it is just a stop button wired directly, it probably will get read very early into the current iteration.
 
Have a look at the following code (shown during execution highlighting). As you can see by the green data dot on the stop terminal, the button has already been read, while the wait is still waiting. For an even better demonstration, run the same code normally and press the stop button after about 1 second. The button will reset back to false (latch action) after 9 seconds at the beginning of the second iteration, at which time it will take another 10 seconds for the program to finish. The total execution time will be 20 seconds unless you press the button before program start or within the first nanosecond or so. 😄
 



Message Edited by altenbach on 04-24-2008 10:52 AM
0 Kudos
Message 9 of 17
(3,493 Views)

altenbach,

Gotcha! You used the word "after" and "before" in your own words describing how the data flows! Smiley Very Happy But all kidding aside, you are correct. The Stop button is indeed scanned. I should have said the stop button's action isn't reacted upon until....

Richard






0 Kudos
Message 10 of 17
(3,462 Views)