ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DO WHILE LOOP

Hello community,

 

I have a question about a DO WHILE loop. I use the While loop frequently, but now I'm in need of a DO WHILe loop. I want it to run once, then wait for a user input that decides whether to run it again or procede. I'm running a meassurement that ocassionally fails, so I want the opertunity to rerun it bevore I move on to the next step.

I'm sure there is a simple solution, I just don't see it.

 

Thank you in advance,

 

Florian

Windows XP Professional, Labview 9
0 Kudos
Message 1 of 4
(7,956 Views)

Based on your requirements, I suggest you to use a state machine. You will find plenty of information on this on this forum, the ni web page. You also have a template with your LV installation.

 

Felix 

Message 2 of 4
(7,950 Views)

Hi Florian,

attached you´ll find two screenshots/VI snippets of examples, currently I don´t have access to a LV 7.1 installation, but these two are very simple  to reprogram.

1. Acquire the data and thenWiat for the user input. On "Measure again?" you run the loop a second time, on Measurement ok, you leave the outer loop and give your data to wherever you need it.

2. Version1_twoWhileLoops.png

 

 

The smarter way, if you have to wait for a USER reaction, is to use a Event structure for acquiring and stopping the main loop.

 

Version2_EventBased.png

 

 

Hope that helps.

 

Stefan K.

Message 3 of 4
(7,940 Views)

Florian,

 

The "while loop" that comes with LabVIEW actually is a "do while loop" since it will defenetly execute atleast once.

 

Or to say that the "while loop" are actually "do while loops" in LabVIEW.

 

What you need is some thing like a state machine or events like others mentioned

 

Guru

Regards
Guru (CLA)
Message 4 of 4
(7,929 Views)