Showing results for 
Search instead for 
Did you mean: 

Timing a while loop

HI everyone,


I am writing a program involving nested loops. This program is going to be called by another program eventually. This program is supposed to wait for user input (via voice), execute the selected case, and then repeat that with different user input until a given time interval is up. I am having problems making the while loop time properly. I can't use the stop function because it will quit the higher calling program, which is not acceptable for This project. Right now, I have a case structure an event structure inside a while loop, and the event structure is wired to the conditional stop in the while loop. If This is not wired like that, then the inner loop can't repeat itself and get new user input. But I can't figure out a way to quit the while loop without the conditional stop. Does anyone have any ideas about how This can be done, or suggestions as to other structures I could use (instead of a while loop)? I tried a timing loop, but I couldn't get it to work properly.



0 Kudos
Message 1 of 5
I am having a hard time visualizing your description of your program.  Why don't you post your actual VI so we can see what you are talking about?
0 Kudos
Message 2 of 5

I don't know right now if I can post my code, I signed an IP and non-disclosure agreement. I will check with my supervisor tomorrow and see if I can post it.

0 Kudos
Message 3 of 5

You should be able to post a generic example of what it is you are trying to do.  Your description talks about an inner while loop but doesn't say what that while loop is inside of.


I don't understand in what way you want to stop a while loop and why you can't use the stop terminal of the loop.  Are you actually trying to stop the loop before it's iteration is finished?


If the code inside of your while loop is so complex that it is really multiple steps, (Get voice, execute, wait, repeat, ......) perhaps you should break up the code into multiple steps and turn your architecture into a state machine.

0 Kudos
Message 4 of 5

Hello mz1,


Could you make a simple VI to demonstrate the structure of your current VI? This would make it easier to understand exactly what you are trying to do.

Vivek Nath
National Instruments
Applications Engineer

Machine Vision
0 Kudos
Message 5 of 5