LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Exit While Loop with Timing Delay?

Solved!
Go to solution
Solution
Accepted by topic author Jeffrey_Zola

multiple pressings adds to the queue and it is still working on the extra "start test" in the queue, plus by pressing the "stop" ...you've stopped the producer loop. Add a "flush queue"...it should work or you can "enqueue at opposite end".

 

abort notifier_BD.png

0 Kudos
Message 11 of 15
(2,027 Views)

Yes.  Experimented with the "Flush Queue" myself! 😉

 

I have read in these forums about "Producer/Consumer" structures. I guess I'm now building one! If I understand the full operation correctly:

 

1. Pressing START causes the event structure in the producer loop to put a "start test" on the queue.

2. The state of the CASE in the consumer loop transitions from "initialize" to "start test" when the "start test" is taken off the queue. The "start test" case includes all of the work of the VI.

3. Pressing STOP flushes the queue (now!) and puts a "stop" on it, sends the abort notification, and stops the producer loop.

4. The abort notification ends execution of the "start test" case. The next execution of the Consumer Loop takes the "Stop" off the stack and transitions the CASE to the "stop" case, whose sole function in life is to flip the boolean input to the consumer's conditional terminal.

 

 

Jeffrey Zola
0 Kudos
Message 12 of 15
(2,016 Views)

I now have this running in an acceptable state using the producer/consumer architecture that apok posted as a guide, and also taking johnsold's suggestions into account. I'm actually pretty happy with the way it has turned out. 😉

 

The Producer Loop is essentially the same as apok's diagram with the "Flush Queue." The Consumer Loop is customized based on my needs. I kept the three states, although I really do not need an initialize state. Only difference is that I have to push the START button to begin data collection. The data collection state includes three "blocks" that iteratively execute in sequence:

 

    1. For Loop through the nine channels of data collection using a PXI switch module as a multiplexer and a PXI DMM module.
    2. Update on-screen graphs so someone who walks by the machine can see what it's doing.
    3. A While Loop operating every 500ms that checks the current timestamp vs a calculated time the next data collection should start. Each execution of this loop looks for the STOP signal. If the STOP signal is not received when the time comes to start the next collection, the loop passes execution to the next iteration of the For Loop. The STOP signal is only detected after the on-screen graphs are updated for each data collection. If the signal is sent while the channels are being polled, it waits until the first execution of this delay loop, then terminates the consumer.

 

For reference, the program is used to periodically collect the temperature of nine locations in a system using nine 4-wire RTDs. The RTDs are wired to a pair of 50-pin terminal blocks that connected to a PXI-2530 that is in 4-wire MUX mode. The temperature is being measured by a PXI-4071 DMM with its terminals wired to the common pins of the terminal block.

 

Jeffrey Zola
0 Kudos
Message 13 of 15
(1,993 Views)

good to hear it helped...if you want to directly goto "start test", click on the enum that is "initialized" on the outside loop and make it "start test". As soon as you run the program, your test will begin. Also, you can delete the front panel control "start test." and delete the "event case" in the structure for that action.abort notifier ver8.5_BD.png

0 Kudos
Message 14 of 15
(1,987 Views)

Yes, Indeed. Simple enough to omit the Inititalized state. Not a terrible nuisance to keep it though. There's only been one tome when I've looked at the screen asking myself why the thing isn't collecting data to realize I hadn't pressed "Start". So far, anyway. 😄

 

And I hadn't "lost" anything except a few minutes time.

 

Thanks again!

Jeff

Jeffrey Zola
0 Kudos
Message 15 of 15
(1,962 Views)