LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to abort indefinitely waiting task pragmatically

Solved!
Go to solution
Highlighted

I am acquiring analogue data when a trigger event occurs.  The event may take a while to happen, or the user may want to exit the program with no event having been received.  This is a one shot event, and will be costly if it is missed. I would like to set the timeout on the data acquisition task to -1, i.e. wait indefinitely.  But, if no event occurs and the user wants to exit, how to end the task which is waiting indefinitely for a trigger that is not going to come?

 

Thanks

 

 

 

0 Kudos
Message 1 of 6
(680 Views)

You could set a short timeout and put the DAQmx read in a loop.  In the event the read times out, you can repeat the loop.  If it doesn't timeout OR the user hits the stop button, then end the loop.

0 Kudos
Message 2 of 6
(667 Views)

I considered this, but dont think it is suitable, because the event may be missed if the previous timeout happens just before the trigger event.  Note I am interested in the data preceeding and after the event, hence the reference trigger and pre-samples.  If insufficient presamples have been acquired the event will be ignored.

0 Kudos
Message 3 of 6
(662 Views)
Solution
Accepted by topic author M7

You'll have to try it to be sure, but I think it will work.  Once you've executed the DAQmx Start Task which would be before the loop, the task should be armed and ready to go.  The samples should be sitting in the buffer waiting for you to read them whenever the DAQmx Read gets around to reading them.

0 Kudos
Message 4 of 6
(658 Views)

I will test this.

0 Kudos
Message 5 of 6
(655 Views)

Yes, this does work. The presample data is not affected by looping the acquisition task.

 

Thanks.

0 Kudos
Message 6 of 6
(642 Views)