Showing results for 
Search instead for 
Did you mean: 

timed loops in sequence.

Sorry if this question is too noobish, but I'm having lots of trouble doing something I thought would be simple. I want to create loops that run successively, and are timed. The first loop will not run until a button is pressed. Once pressed one loop will run for a set time, then a second loop will run for a different time. A third loop will run for another set time. After this all happens the button can be pressed to start all over again. What i've done so far is create a flat sequence structure, and put each loop in successive frames. Inside the first I have a case structure which the start button sets to true. When true it runs the first loop. I don't know how to make that loop run for the time I want it to after the button is pressed. I've been messing with all the timing and wait functions, but I'm only confused more now. Any help would be great. Thanks.
0 Kudos
Message 1 of 5
All of the timing functions output a millisecond counter value. This vaule will be the same across all of the functions.

So when you hit your start button, you need to grab the current ms timer value using the 'Tick Count' function. Put this function inside the first frame, but outside the loop and wire the value into the loop. Then inside your loop, monitor the tick count from the 'Wait' or 'Wait until next ms Multiple' function. Subtract that value from the original value to get elapsed time. Use something like the 'Greater than or Equal to' function to compare the elasped time to the time you want to run the loop and connect its output to the loops stop terminal.

Do this in each loop and you should have what you need.

You can probably even get rid of the sequence structure if you just wire some value from one loop to the next. Even if you don't pass that value into the loop, wiring to the edge will prevent the loop from starting until the previous has stopped and put a value on that wire. This is Dataflow.


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 5
Here is an alternative approach.

0 Kudos
Message 3 of 5
Well, I'm lazy so I made an example with only 2 successive loops (LabVIEW 7.0). Extend as needed ;).

(Of course if you have LabVIEW 7.1, you can use the "timed loop". I has error cluster so can easily be chained via dataflow.)
0 Kudos
Message 4 of 5
Thanks for all the help! I think I've got the basic idea down now.
0 Kudos
Message 5 of 5