LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop runs once more once stopped?

 I recently posted a timeout question here, that was solved, but now I am running into another minor concern.

 

In the attached VI, in the Inner Loop, I get that my Input is SAV, which then causes the case to be true, and stops the VI.  My issue is that once that happens, for some reason, the Loop runs once more, the inner loop stays at 0 and I get something that is not what my scope sees.

 

When I highlight execution, I do not get this issue, I thought because of the timing, so I increased TimeDelay to 10 seconds, just to see, and it did the problem where Loop=Loop+1 and InnerLoop=0.

 

Any suggestions?

0 Kudos
Message 1 of 19
(4,729 Views)

I am not sure if i understand your issue.

However, the stop button in the outer loop is read *somewhen* during execution of the loops content. That means: the stop button is likely to be one of the first thing to be read/addressed in the loop iteration. That means that pressing stop most likely will be read in the NEXT iteration.

Is it possible that you are seeing this?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 19
(4,726 Views)

Is it possible that this idea is true for the inner loop, where it reads True, but then does not execute until the next loop?

 

I haven't been hitting the stop button, so I do not see how that could cause the extra loop.

0 Kudos
Message 3 of 19
(4,713 Views)

Norbert answered your question, but I'm going to state it another way (and demonstrate how you can get the behavior you seem to be expecting).

 

LabVIEW's principle of Data Flow means that in an "execution context" (and here, think of "everything inside the While loop"), anything not tied together by data flow (in particular, anything not on the Error line in your code) are candidates for "simultaneous execution".  Your loop has everything tied to the Error line (and hence strictly sequential) except the Stop button.  Hence the "main sequence" and the reading of the Stop button probably happen together.

 

     Suppose you press the Stop button -- you are probably somewhere in the middle of the loop, but the Stop button has already been read, and the "false" value put on its output line, so when you reach the end of the loop, you do not stop.  Now you enter the loop, read True for the Stop, execute "one more time", and stop.

 

     If you want the Stop to be read at the end of the loop (instead of at the beginning), put it inside a Sequence frame and run the Error line through it.  Until the Error line enters the Sequence, the Stop button will not be read.

 

Bob Schor

Message 4 of 19
(4,704 Views)

Thanks, that makes sesne.

 

Total beginner question: I am adding the flat sequence, but when I do, the stop hides behind it on the block diagram.  Is there a way to change that?

0 Kudos
Message 5 of 19
(4,682 Views)

Hi jmaslek,

 

move the button using the mouse into the sequence…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 19
(4,679 Views)

It just hides behind the sequence when I drop it in. 

0 Kudos
Message 7 of 19
(4,676 Views)

The stop terminal itself cannot be placed into a sub diagram.

Hint: The content of a sequence structure (each frame) is (each) called sub diagram (relative to the loop).

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 19
(4,665 Views)

Now I am a little lost.  @Bob_Schor mentioned that I need it inside a sequence with the error line, but if it cannot go inside one, how can I tell it to stop at the end of the loop?

0 Kudos
Message 9 of 19
(4,645 Views)

Additionally, this doesn't happen if I highlight execution.

0 Kudos
Message 10 of 19
(4,629 Views)