LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extra iteration after stopping while loop

Hi,
 
I'm writing a program that is designed to automate thermal measurements from a switch using thermocouples.  I'm conducting these temperature measurements inside a while loop, with a wait function set to a defined time.  I've noticed that when I stop the while loop, it has to finish its current iteration before it terminates.  While it's still in some initial test phases, the end result would likely be automatically taking temperatures every 30 minutes to an hour.  I was wondering if there was any way to circumvent this final iteration in the while loop so that someone would not be required to wait an extended period of time.
 
Thank You,
Mike
0 Kudos
Message 1 of 5
(3,660 Views)
The solution is to make sure that the switch isn't read until after the rest of the processing in the loop completes. One way to do it is put a single frame sequence structure around its terminal and then wire some signal that only becomes active after the data collection is complete (the error cluster works nicely) to the edge of the sequence.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,652 Views)
Typically, the part that takes the longest is the wait function. So you can create a data dependency from its output as in e.g. this image. Also wire the error cluster from your DAQ to the sequence frame as mike suggested, just in case your wait is too short.
 
 
 

Message Edited by altenbach on 08-24-2007 07:59 PM

0 Kudos
Message 3 of 5
(3,644 Views)
By your message subject "Extra Iteration after stopping while loop", I think Mike's and Altenbach's solutions will work for you, they guarantee that the stop button is read after the wait is finished.
 
But in your message, you say :
 
"I've noticed that when I stop the while loop, it has to finish its current iteration before it terminates.  While it's still in some initial test phases, the end result would likely be automatically taking temperatures every 30 minutes to an hour.  I was wondering if there was any way to circumvent this final iteration in the while loop so that someone would not be required to wait an extended period of time"
 
You don't mention the extra iteration, but talk about the current iteration.  This makes me think you want to stop the the program without it waiting the long before of time before the current iteration ends.  I think the attached diagram will do this as well as preventing an extra iteration from running.

Put a small wait statement inside that inner loop so it doesn't spin like crazy polling the clock.

Message Edited by Ravens Fan on 08-24-2007 11:16 PM

0 Kudos
Message 4 of 5
(3,641 Views)


@Ravens Fan wrote:
You don't mention the extra iteration, but talk about the current iteration. 

In this case it would be better to use the timeout case of an event structure for the DAQ, just set the timeout to your desired loop rate.

Place the stop and other operator events in a seperate event case, so it can override the timeout and execute immediately. See attached draft.

(If your acquisition has many steps and takes a long time, you should rewrite it as a state machine that can be interrupted between any of the steps.)

0 Kudos
Message 5 of 5
(3,623 Views)