필터 지우기
필터 지우기

How do I periodically acquire data from a NI USB DAQ with a high sample rate?

조회 수: 2 (최근 30일)
Kilian
Kilian 2014년 1월 22일
답변: Ford Creighton 2014년 5월 19일
Hello
I am using an NI USB-6216 DAQ card with Matlab 2012b on Windows 7 32-bit. I am trying to sample data for 5ms at a sample rate of 100kHz periodically every 50ms, but I can't work out how to do it. Is this possible or is the latency between the the DAQ card and the PC too slow? Running a single acquisition seems to take up to 100ms, but I think running the acquisition continuously and periodically grabbing the data as required should be much faster.
I've been using the following code for a single acquisition and it works fine, but is quite slow:
ai = analoginput('nidaq','Dev2');
set(ai,'InputType','SingleEnded')
addchannel(ai,1);
ai.SampleRate = 100000;
ai.SamplesPerTrigger = 500;
%ai
tic
start(ai)
[data,time] = getdata(ai);
toc
I really appreciate any help with this.
Thanks

답변 (1개)

Ford Creighton
Ford Creighton 2014년 5월 19일
You'll need to use "addlistener" and then create a function that is called by the listener. In addition, you'll need to notify the listener when to run. Use "NotifyWhen..." (there are several notification options). Do a search for MATLAB listeners and it should point you in the right direction.

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by