LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop/ abort execution in case when the task inside while loop can not be completed

I am using Count digital events example from LabVew. This VI is using DAQmx Read vi. If I press Stop button before this DAQ gets required amount of samples VI does not stop. I tried to change amount of samples on a fly with stop button but it did not work either.
Please help.
0 Kudos
Message 1 of 3
(2,842 Views)
This is directly related to the way LV handle the data. Your question is similar to "How can I stop a For-Next loop before completion ?". The answer is : No way, except changing the loop for a while loop (ie: change the algorithm) or stop the whole vi.
Attached is an example of stopping an infinite running loop. It uses a parallel loop, with a Stop node (see how to handle the stop button in order to reset it to false at the next vi run).

If you only want to stop the DAQ, whithout halting everything else, the solution is trickier : you will have to run your DAQ loop in a dynamically loaded vi, then use the vi server functions to halt the vi if the run period is excessive. But that is worth another discussion...

Give some feedback !..

CC
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 3
(2,842 Views)
Thanks, Charly. Problem is, that even your method did not work for me in al cases. I am using "Count digital events Buffered Ext. Clk" example in LV 7.1 under examples,DAQmx, counter. If DAQmx Read (Counter 1D...) does not receive specified amount of sample clock edges, it look like nothing else in that loop executes. I made it work, changing amount of samples to -1, what make DAQ happy with what it got already.
May be it has something to do with tha particular DAQmx.vi ?
Thanks again.
Aleks
0 Kudos
Message 3 of 3
(2,842 Views)