LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

General questions about wait function within a sub-loop

Hello,

 

I had a general question about the "wait" function. If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait? I know there is probably a super easy solution, but I can not figure it out. I have been using an "elapsed time" function to solve this problem.

0 Kudos
Message 1 of 12
(954 Views)

I would not recommend using loops within loops. Use a state machine instead. You can place the wait function inside a certain case with the state machine.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 12
(928 Views)

@Dfturner42 wrote:

Hello,

 

I had a general question about the "wait" function. If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait? I know there is probably a super easy solution, but I can not figure it out. I have been using an "elapsed time" function to solve this problem.


You can't. You're using the wrong design. What are you trying to do? 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 12
(916 Views)

@Dfturner42 wrote:

I have been using an "elapsed time" function to solve this problem.


You can use that to "wait for" (check if time is passed) a time (aka polling), but not to "wait" (stall execution).

 

Structures (well, more accurately structure frames) will wait until everything executing in it is done. Always...

Message 4 of 12
(904 Views)

@Dfturner42 wrote:

If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait?


Remember the Three Laws of Data Flow.  The Second Law says a structure runs until everything inside it has run.  So the Wait in the sub-loop means that the sub-loop "waits" as instructed.  Anything that contains this sub-loop also has to wait, as it is also obeying the same Second Law, and cannot exit until its inner loop (with the Wait function) finishes.

 

Note that any other structure that does not "depend" on the inner "Loop With a Wait" is free to run (in parallel) as a result of the Third Law, but that's another lesson.

 

Bob Schor

Message 5 of 12
(877 Views)

@Bob_Schor wrote:

@Dfturner42 wrote:

If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait?


Remember the Three Laws of Data Flow.  The Second Law says a structure runs until everything inside it has run. 


Sorry, but no!

 

It's nitpicky, but formally not correct. A structure frame runs until everything inside it has run!

 

Spoiler

Flat sequences are structures too...

Sequence Flow.png
Message 6 of 12
(839 Views)

Until I read the Spoiler, I didn't realize the subtlety of your "nitpicking".  You are, of course, correct, though I (personally) view Frame Sequences as "sequential structures" (Frames) (my bad!), and something to be avoided (except for FPGA code).

 

Bob Schor

0 Kudos
Message 7 of 12
(826 Views)

@Bob_Schor wrote:

Until I read the Spoiler, I didn't realize the subtlety of your "nitpicking".  You are, of course, correct, though I (personally) view Frame Sequences as "sequential structures" (Frames) (my bad!), and something to be avoided (except for FPGA code).

 

Bob Schor


I agree, but they're still structures!

 

In general there's very little you can say about anything in LabVIEW without any reservation.

Message 8 of 12
(813 Views)

If you see a Flat sequence as an array of structures it still holds. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 12
(808 Views)

@Yamaeda wrote:

If you see a Flat sequence as an array of structures it still holds. 🙂


Sure.

 

To be fair, even in LV's class structure a flat sequence isn't a structure (or even a node, until you ask for nodes, and they are still returned in an array of nodes 😲).

 

The norm is to consider a flat sequence as a (single) structure.

Message 10 of 12
(782 Views)