LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ending "wait until next ms multiple" timed loops instantly

Within the main while loop of my program, I have a loop controlled with a "wait until next ms multiple" timer function. When I hit the stop button to end the program, it waits until the next multiple How can I instantly end the program, without waiting to perform that task again?  Is there another timer feature that would work better? This loop writes data to a URL every 60 seconds. Also, what kind of loop should I use that runs the whole time the program is going, no matter what?
Thanks.
 
0 Kudos
Message 1 of 5
(3,663 Views)
An iteration cannot end until everything in it has completed.
 
There are plenty of alternatives.
  1. Use a faster loop (e.g. 1000ms) and divide the iteration couter by 60. Whenever the remaider is zero, write your data (wride code is in case 0 of a case structure, while the default case does nothing.
  2. Use an event structure and set the timeout to 60 seconds. Place your special code in the timeout case. In all other events, you need to recalculate the remaining timeout. For example, if an event occurs after 20 seconds, you need to reset the timeout to 40 seconds, etc. Keep the timeout value in a shift register.
  3. ...


Message Edited by altenbach on 04-18-2008 02:21 PM
Message 2 of 5
(3,654 Views)

altenbach wrote:
Place your special code in the timeout case. In all other events, you need to recalculate the remaining timeout. For example, if an event occurs after 20 seconds, you need to reset the timeout to 40 seconds, etc. Keep the timeout value in a shift register.

Here's an old example: RegulateTimeoutEvent1.vi
 
The VI reacts immediately to any other events (e.g. the switch). Notice that all other events force a recalculation of the timeout value such that the interval between timeout events remains constant.
 
0 Kudos
Message 3 of 5
(3,641 Views)
There are a couple other ways to accomplish this:

  1. OpenG has a Wait ms function that allows you to pass in an Occurrence reference. It will wait until the specified number of ms has elapsed or the occurrence is fired. Note that this isn't a Wait until next ms multiple function.
  2. Use a Timed Loop. This might be overkill for your application, but Timed Loops allow among other things the ability to abort the loop immediately when it's waiting for the next iteration to start.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 5
(3,611 Views)
thanks for the help!
0 Kudos
Message 5 of 5
(3,561 Views)