Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Ford Creighton
Ford Creighton il 19 Mag 2014
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.

Categorie

Scopri di più su Data Acquisition Toolbox Supported Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by