08-17-2012 09:13 PM
i don't know how to make while loop stop at a fixed time. Usually. while loop stops when we enter stop button or mistakes have been made. now i wanna while loop stop at a fixed time, 20ms,40ms,and so on. how can i realise that. thank u!
Solved! Go to Solution.
08-17-2012 09:26 PM
Use the Tick Count function. Get the current tick count when you start the loop. Add your time (20 ms) to the start value creating a "stop time." On each iteration read Tick Count again and compare the current value to the "stop time" value. If greater, then stop, otherwise continue.
Note that on a desktop operating system you will see some jitter when trying to use loop times as small as 20 ms. You may need to go to a real time system or something hardware timed to get any precision or stability at those time scales.
Lynn
08-17-2012 11:21 PM - edited 08-17-2012 11:31 PM
wire the stop with a true constant, this will execute the loop once and wire a cntrl to the wait (ms)
maybe this is not what you want, not realizing you may want code to continuosly run for a certain time allocated...
08-18-2012 08:54 PM
thank u so much!
08-18-2012 08:54 PM
thank u!