Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Kilian
Kilian le 22 Jan 2014
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

Réponses (1)

Ford Creighton
Ford Creighton le 19 Mai 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.

Catégories

En savoir plus sur Data Acquisition Toolbox Supported Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by