使用Python和NI-DAQ™mx執行資料擷取時出現錯誤-200279

更新 Jan 3, 2025

產品資訊

驅動程式

  • NI-DAQ™mx

程式語言

  • Python

問題敘述

連續進行資料擷取一定時間後出現如下錯誤-200279。
增加buffer  緩衝區只是延長了錯誤發生前的時間,並沒有解決錯誤。

The application is not able to keep up with the hardware acquisition.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos
Property: DAQmx_Read_Offset
Corresponding Value: 0

Task Name: _unnamedTask<0>

Status Code: -200279
 

解決方案

如果在與task.read()相同的迴圈中使用 Python 可視化工具(例如 matplotlib library),則可視化工具的處理會影響整個task.read()執行速率,從而導致緩衝區溢出。
降低擷取速率可能會解決問題,但當需要更高的擷取率時,它可能不是最佳解決方案。
比較好的方式是請將可視化過程放置在另一個迴圈中,以便資料擷取和可視化平行執行是防止硬體緩衝區溢出的推薦方法。