Solution
You should use the DAQmx Start Task node and the DAQmx Stop Task node when you use the DAQmx Write node or the DAQmx Read node repeatedly.
For example, when using the DAQmx Read node with the Autostart property set to
True, the DAQmx Read node will start the acquisition task and stop the task once the last sample is acquired. If you use the DAQmx Read node in a loop, the measurement or generation starts and stops in each iteration of the loop due. To avoid this you can explicitly tell it to start and stop with the DAQmx Start Task node and the DAQmx Stop Task node.
Explicitly starting the task prior to the loop and stopping the task after the execution of the loop significantly improves performance. This is due to the task state of the DAQmx Task. Starting a task before a loop ensures that the task is in the running state, which can help reduce execution time if used before a loop. Stopping a task after the loop will allow the task to remain in the running state within the loop and not return to a previous task state after being stopped. For more information on task states and the DAQmx Task State Model, see the related link below.
For a demonstration of this concept, you can run a test that benchmarks the performance difference as in the example
Figure 1 below, which allows you to perform a single-point acquisition on a DAQ device using two methods:
- Explicitly starting and stopping the task with the DAQmx Start Task node and DAQmx Stop Task node outside of the loop.
- Implicitly starting and stopping the task inside the loop.
Figure 1. NXG Performance Example
Open the Start Task and Stop Task VIs project and run the Start and Stop Compare VI. Select to either use the Start and Stop nodes or not using the Boolean Control on the Front Panel. Run the VI in both modes. When you press the Stop button, the Calculate Frequency VI calculates the rate of the acquisition. You should see a significant increase in the acquisition rate when using the DAQmx Start Task node and the DAQmx Stop Task node.