03-30-2011 10:07 PM - edited 03-30-2011 10:12 PM
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
Solved! Go to Solution.
03-30-2011 10:19 PM
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.
03-30-2011 10:27 PM
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.
03-30-2011 10:34 PM
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.
03-30-2011 10:41 PM
I will test this.
03-30-2011 11:54 PM
Yes, this does work. The presample data is not affected by looping the acquisition task.
Thanks.