LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming a conditional FOR loops' STOP button timing

Solved!
Go to solution

I have a conditional FOR loop with a STOP button, however, due to the data flow nature of LabVIEW, the stop button is being polled at some point prior to the end of the loop. Since a control has no input, I can't connect the last operation in a single iteration of the loop to trigger the polling of the STOP control, and I'd rather not use a flat sequence just for the stop button if I can avoid it. I've considered using an event structure, but I don't want to force the loop to wait for the stop button to be pressed, I simply want the loop to EXIT, *IF* the stop button is pressed...but I want the stop button to be polled at the END of the loop, so if the user presses the stop button at any point in the loop, at the end of that iteration, the loop will terminate....does that make sense? Currently, since the stop button is polled once at some arbitrary time durring the loop iteration, if the user presses the stop button after it is polled, the loop then has to execute an additional iteration, and I don't want that to happen.

 

...anyway, I guess I'm just looking for a more elegant way to implement this than having to use a flat sequence just for the stop button.

0 Kudos
Message 1 of 10
(3,220 Views)

Any chance you can post a code snippet so that we may see what you are trying to accomplish?

CLD | CTD
LabVIEW 2011 SP1 | TestStand 4.5
0 Kudos
Message 2 of 10
(3,216 Views)

The most elegant way will be a flat sequence structure where all of the code in the loop will execute in the first frame, and the stop button is read in the second frame.

0 Kudos
Message 3 of 10
(3,211 Views)

Clipboard01.png

0 Kudos
Message 4 of 10
(3,204 Views)

Nope.  The stop button can and probably will be read early in the loop iteration.  Only the boolean OR and feeding of that to the stop terminal will wait on the rest of the code.

0 Kudos
Message 5 of 10
(3,200 Views)
Solution
Accepted by topic author Ryan_G_EE

Sorry, but you are going to have to use a sequence structure.  That's why they are there.  They do have their purposes occasionally.  Here's how I would handle it.


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 6 of 10
(3,196 Views)
I guess I'm just looking for a more elegant way to implement this than having to use a flat sequence just for the stop button.

Wanna try Stacked Sequence Structure?

 

Or you can connect a wire to a flat sequence around stop button.

 

How much more elegant solution are you looking?

 

If dont wanna poll you can switch to event structure, but dont look elegant neither good technique.

 

Best Regards,

 

Luis A. Mata C.
Ing. Electrónico
Whatsapp: +58-414-1985579
BBM Pin: 2B83E99A
Thanks: Kudos
0 Kudos
Message 7 of 10
(3,192 Views)

Actually, my issue with the flat sequence was primarily a space contraint, but I just tried a stacked sequence and I think it will work better.

 

Thanks guys.

0 Kudos
Message 8 of 10
(3,188 Views)

No.  Don't use a stacked sequence.  It hides code.  You can see from Crossrulz's picture that the flat seqence won't take that much space.

0 Kudos
Message 9 of 10
(3,185 Views)

Oh yeah, I forgot about being able to use the error status as an entry tunnel to the flat sequence with a single frame. That should work. That's what I was looking for! Thanks!

0 Kudos
Message 10 of 10
(3,176 Views)