Error Code -200479 When Running a Data Acquisition Program

Updated Oct 8, 2018

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I am using the DAQmx Start Task.vi and DAQmx Read.vi or DAQmx Write.vi functions to acquire or generate data. When I run my program, I receive the following error message: Error -200479 Specified operation cannot be performed while the task is running

Solution

This particular error occurs when a task's state is set to Running when it is already in the Running state. There are three common scenarios where this error may show up:
  1. Referencing the same task twice, and attempting to start both before stopping one of them.
  2. Placing a DAQmx Start Task.vi inside a while loop without stopping the previous instance of the task.
  3. Placing a DAQmx Read.vi or a DAQmx Write.vi before a DAQmx Start Task.vi and setting Autostart to False.
You can avoid this error by starting and clearing the task outside of the While loop, and ensuring that the DAQmx Read.vi is not called before the DAQmx Start.vi, as in the example below.



If a DAQmx Start Task.vi is placed inside a While loop without stopping or clearing the task, on every successive iteration of the While loop the task will attempt to start a task that is already Running. In order to avoid this, make sure that you stop or clear the task before it is restarted using the DAQmx Stop Task.vi or DAQmx Clear Task.vi. Typically, starting and stopping the task outside of the While loop will avoid this error and improve driver performance as there are less state transitions taking place. 

Additional Information

Understanding the source of this error involves understanding the NI-DAQmx Task State Model. NI-DAQmx uses the Task State Model to improve ease of use and speed up driver performance. The Task State Model consists of five states: UnverifiedVerifiedReservedCommitted, and Running. For more information about the Task State Model refer to the Related Links.

When a task begins to perform an operation, the task transitions to the Running state. You can explicitly perform this transition by invoking the DAQmx Start Task.vi, however, starting a task does not necessarily begin acquiring samples or generating data. It is important to note that if a DAQmx Read.vi or DAQmx Write.vi is called, it will automatically start the task and transition the task into the Running state. If the DAQmx Start Task.vi is called after either one of these functions, it will be trying to start a task that is already in the Running state. In order to avoid this error, ensure that the DAQmx Start Task.vi is not called after your task has begun acquiring or generating data.

WAS THIS ARTICLE HELPFUL?

Not Helpful