Home
Support
在連續擷取資料時為什麼會需要設定Number of Samples to Read?
在連續擷取資料時為什麼會需要設定Number of Samples to Read?
主要軟體:
主要軟體版本: 1.0
6.1
2011
5.0
1.2
8.6.1
1.1
8.1.2
8.1
2.8.1
2.0.1
14.0
3.2.2
3.0
1.2.0
1.6
1.0.164
1.0.1
主要軟體修正版本: N/A
次要軟體: SignalExpress>>Development System
問題: 在連續擷取資料時為什麼會需要設定Number of Samples to Read?
解答: 在利用DAQmx實現擷取時,所擷取的訊號在到達使用的軟體前(如LabVIEW, SignalExpress, C-code…等)會通過兩道傳輸的步驟:
1.資料會從DAQ裝置中傳遞到電腦的記憶體中(RAM)。此處的RAM的大小是有限的,稱做buffer,是為了傳輸過程所使用的。
2.接著資料會從buffer中被讀取,並傳輸到軟體的記憶體中。當DAQmx Read VI的參數number of samples被設定時,其實是在要求此段傳輸的大小。
當你設定DAQmx Timing VI時,Samples per Channel所給定的數值會根據Sample Mode設定的不同會有不同的效果。
如果是設定為Finite Samples,Samples per Channel會是task結束前實際擷取進來的資料量。
如果是設定為Continuous Samples,Samples per Channel會用來決定buffer的大小。
在設定DAQmx Read VI時會去設定第二段傳輸的部分,也就是從buffer傳到軟體記憶體中。此VI其中一個參數設定Number of Samples per Channel中,當sample mode設定為continuous時,該參數會去設定每次從buffer讀取進來的資料量。

在Signal Express中,此參數位於Configuration的Step Setup為Samples to Read。
需要注意的是,DAQmx Read VI會等到設定的大小擷取至buffer後才會去取用回軟體的記憶體中再去做後續處理。因此,若是sample rate設定的不夠高,不足以在設定的timeout內讀到足夠的量,該VI即會產生timeout的錯誤。為了避免這樣的狀況,可以增加timeout或是減少Number of Samples per Channel。
在LabVIEW中,不給定Number of Samples per Channel時即為預設值 -1,當Number of Samples per Channel設定為 -1時,DAQmx Read VI會讀入buffer所有的資料。如果buffer內沒有任何資料,DAQmx Read VI 會回傳empty array。
相關連結: KnowledgeBase 2V3FK03J : Samples Per Channel Input of -1 On the DAQmx Read VIKnowledgeBase 27R8Q3YF: How Is the Actual Scan Rate Determined When I Specify the Scan Rate for My Data Acquisition?
附加檔案:
報告日期: 03/30/2009
最後更新: 03/04/2015
文件偏號: 4VTI04BQ
Other Support Options
Ask the NI Community
Collaborate with other users in our discussion forums
Request Support from an Engineer
A valid service agreement may be required, and support options vary by country.