01-25-2014 11:27 PM
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.
01-27-2014 03:48 PM
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.
01-30-2014 01:53 PM
lvrat
So I haven't been able to discover another way of achieving this. Have you been able to?
01-30-2014 04:16 PM
Yes, there are many. many ways to do this. For starters, use a Local variable instead of a global:
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.
01-30-2014 04:59 PM
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