Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx: How to restart a task after an error occurs

I'm using a 6602 board in continuous two-edge separation mode.
 
Whenever an error occurs, I can't figure out how to recover and make the task usable again.
 
For example, when this occurs:
 
    Error: Two consecutive active edges of the input signal occurred without a counter timebase edge.
 
I have tried a number of steps to then recover and continue with the app.  I always get this when next accessing the task:
 
    Error: Task name specified conflicts with an existing task name.
 
 
After the first error, I have tried a couple of techniques for recovery.  Currently, my code tries
 
    DAQmxResetDevice ("Dev1");
 
followed by
 
   DAQmxCreateTask("MyTaskName", ptask);
 
 
 
Previously, I had tried this sequence with the same result
 
    DAQmxStopTask(taskHandle);
    DAQmxClearTask(taskHandle);
    DAQmxCreateTask("MyTaskName", ptask);
 
 
Finally, I have tried to not stop, clear or reset the task, but just go on reading from the task after the  error.
I get 'Task specified is invalid or does not exist'.
 
 
So, my question is, what is the correct sequence of API calls to correctly recover from an error when using mx?
 
Also, I'm not interested in fixing the first error, I know how to do that.  My concern is the more general issue of recovering from an arbitrary error.
 
 
 
Thanks
 
 
 
0 Kudos
Message 1 of 3
(4,170 Views)
Well I think we figured this one out.  When an error occurred in the Read task, we would go into error recovery.  First we would issue a Stop Task and then a Clear Task.  The problem was the stop task was failing and sending us somewhere else in the code because a new error occurred.  We were never actually getting to Clear Task.  Now we ignore the error when stopping and just go to Clear and it seems to work perfectly.
0 Kudos
Message 2 of 3
(4,142 Views)

You got it, I had this problem in the past with reading in a loop and dealing with filtering out timeout errors.  After an error occurs you need always to deal with it (even if it is as simple as filtering the error).  I usually put an error handling subroutine which uses a case structure to handle any errors which occur in the acquisition loop.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 3
(4,109 Views)