このコンテンツは設定された言語で表示できません。

このコンテンツは表示可能な別の言語で表示されています。 お使いのブラウザに翻訳機能がある場合はご利用ください。

DAQmx Read Error -200278 During Finite Acquisitions in LabVIEW

Updated Jan 11, 2023

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

When running an Analog Input task to acquire Finite Samples using DAQmx with support for LabVIEW, I receive the following error at DAQmx Read: 

Error -200278: Attempted to read a sample beyond the final sample acquired. The acquisition has stopped, therefore the sample specified by the combination of position and offset will never be available. Specify a position and offset which selects a sample up to, but not beyond, the final sample acquired. The final sample acquired can be determined by querying the total samples acquired after an acquisition has stopped.

Why do I see this error and how can it be resolved?

Solution

This error occurs when DAQmx Read attempts to return data after the DAQ device has stopped acquiring data. 

One common occurrence of this error is when DAQmx Read is used inside of a while loop while the task is configured for finite acquisition. When the Sample Mode property of DAQmx Timing is set to Finite Samples, the DAQ device will acquire data for a number of samples, at which point it will stop acquiring data and throw error -200278 if DAQmx Read is called again.

Note: If you do not explicitly configure the Sample Mode property for DAQmx Timing, the default value is Finite Samples. If you desire Continuous Samples, remember to explicitly configure this property appropriately.

There are several potential solutions below to resolve Error -200278 in your DAQmx application outlined below:

Solution 1: Remove the While Loop

If you are performing a finite acquisition, most likely a while loop is unnecessary, as you are only acquiring a single array of samples across a finite period. In this case, the easiest solution is to just remove the while loop, as in the example code below:
 

Solution 2: Configure DAQmx to Acquire Continuously

If a while loop is needed, another solution is to configure the task to acquire Continuous Samples instead of Finite Samples. When this option is selected, the DAQ device will continue acquiring data until the task is explicitly stopped.
 

Solution 3: Restart Acquisition in a While Loop

If you do need to use Finite Samples and you need to use a while loop, the task will need to be restarted to continue acquiring data after the first read is complete. This can be accomplished by starting and stopping the task inside of the loop as in the example code below:
 


Note: In order to improve performance, you should manually move the DAQmx task to the Commit State before entering the while loop, as is shown in the example above.  You can read more about the Commit State and other DAQmx Task States at NI-DAQmx Help: Task State Model .

Solution 4:  Use Is Task Done? in While Loop

In some cases, you may be interested in acquiring a subset of the complete finite acquisition before the acquisition is complete.  In this case, you can manually specify a number of samples that is lower than the total number of samples being acquired.  

In the example below, the DAQmx Read property Status»Available Samples Per Channel is used to determine how many samples are currently in the DAQmx buffer and make a read request for the number of samples available in the buffer at that moment.  

After DAQmx Read is called, the DAQmx Is Task Done? function is used to identify whether the finite acquisition is complete.