LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Break out of Timer at Stop event

Hello,

 

I have a producer/consumer architecture. In the consumer loop I have a elapse timer which runs within a while loop as shown in the attachment. My quesiton is how to break the elapse timer when stop button is pressed? The way I have done is by using a global for stop and then have the Elapse Time loop stop if stop is pressed. Are there any other way to perform this and avoid globals? I have looked into events but the timer needs to be in consumer loop within the state machine.

Are there any drawbacks of using Elapsed Time express VI for example overhead, momory usage, polling etc?

 

Thanks.

*************************************************
CLD
*************************************************
0 Kudos
Message 1 of 5
(2,716 Views)

lvrat,

 

The LabVIEW Express VIs do typically have extra overhead associated to their actual use, so may not be the preferred way to go.  I am not aware of any previous cases where this approach was taken.  I will take a closer look later to see if there's another way to consider.

 

 

Wayne T. | Application Engineer | National Instruments
0 Kudos
Message 2 of 5
(2,657 Views)

lvrat

 

So I haven't been able to discover another way of achieving this.  Have you been able to?

Wayne T. | Application Engineer | National Instruments
0 Kudos
Message 3 of 5
(2,624 Views)

Yes, there are many. many ways to do this. For starters, use a Local variable instead of a global:

 

Capture.PNG

This isn't the best way to pass data between loops, but it's quick and it works. Try reading up on queues or user events.

0 Kudos
Message 4 of 5
(2,613 Views)

Get rid of the inner while loop in the consumer. Make the consumer a state machine. One state (case) checks the Elapsed Time. If Time has Elapsed is False, then exit the case but make the next state the same state (and case). Thus this state will be entered and exited repeatedly until the Time has Elapsed but opportunities to check for Stop occur on each iteration.  If the Stop was pressed in the Producer, use a notifier or queue to transfer the command to the consumer. On each iteration of the consumer state machine the queue/notifier is checked for the Stop command. If it is not present the next state in the shift register is used. If it is present, go to  the Halt state.  The timeout on the Dequeue/Wait for Notifier defines the maximum time before entering the next state.

 

Lynn

0 Kudos
Message 5 of 5
(2,605 Views)