フィルターのクリア

How can I change the buffer size on NI-Daq device, using session-based interface ?

7 ビュー (過去 30 日間)
Marthe Curtit
Marthe Curtit 2014 年 4 月 1 日
編集済み: Walter Roberson 2019 年 7 月 8 日
Hello, I'm using the session-based interface to acquire datas from an NI-USB Daq-device. I'm processing datas during acquisition, using a listener. I would like to change the length of the events, recieved during acquisition. In this exemple, would it be possible to change the size of event.data, recieved in the function plotData ?
s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod1', 'ai0', 'Voltage');
lh = addlistener(s,'DataAvailable', @plotData);
function plotData(src,event)
plot(event.TimeStamps, event.Data)
end
Thank you,

回答 (1 件)

Shyam Sangaraju
Shyam Sangaraju 2014 年 7 月 24 日
編集済み: Walter Roberson 2019 年 7 月 8 日
You can use “getdata” function to acquire data of specific size. Following sample code demonstrates how to use “getdata” function:
>> ai = analoginput('nidaq','Dev1')
>> addchannel(ai,0);
>> set(ai,'SamplesAcquiredFcnCount',4)
>> set(ai,'SamplesAcquiredFcn',@mydaqcallback);
Where @mydaqcallback consists of the following code:
function mydaqcallback(obj, event)
% number of data samples to acquire
data = getdata(obj,obj.SamplesAcquiredFcnCount);
% you can execute your logic here.
Where ‘obj’ is an analog input object.
‘obj. SamplesAcquiredFcnCount’ is number of samples to extract.
‘data’ is m-by-n array, where m is the number of samples extracted and n is the number of channels contained by obj.

カテゴリ

Help Center および File ExchangeSimultaneous and Synchronized Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by