rate of acquisition with DAQ board not equal to s.Rate

15 views (last 30 days)
John
John on 6 Jun 2017
Answered: Sid Jhaveri on 9 Jun 2017
I'm using the Data Acquisition Toolbox to create TTLs using outputSingleScan with a NI DAQ USB 6002. I want the single scan to be .05 seconds long (A rate of 20 scans per second).
d = daq.getDevices;
d(1);
s = daq.createSession('ni');
ch = addAnalogOutputChannel(s,'Dev2', 'ao0', 'Voltage');
s.Rate=1/.05;
outputSingleScan(s, 5);
When I run this code the output on my computer does not appear to have scans of .05 (50 milliseconds). They are more between 1 and 3 milliseconds.
I have also tried using s.DurationInSeconds and s.ScansQueued with S.Rate, but both give errors. How can I make the length of one outputSingleScan .05 seconds?

Answers (1)

Sid Jhaveri
Sid Jhaveri on 9 Jun 2017
"s.Rate" (where s is the session object) is usually used while doing continuous acquisition. Thus, I would suggest you the following:
1) Try sending data continuous using "startForeground" or "startBackground" function and check is that is giving you the sampling rate of 20 scans/second.
2) If you want to use "outputSingleScan" itself, then try giving an explicit pause after using it.

Community Treasure Hunt

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

Start Hunting!

Translated by