Is there a possible method to reduce time latency in DAQ data acquisition in GUIDE app designer?

조회 수: 2 (최근 30일)
We are trying to acquire data in loops using the current DAQ syntax for data acquisiton while using the GUIDE app designer. However, when looping data acquisition there is latency in the collection. I understand that there is no way of completely reducing this latency to zero, but is there any common practice to help reduce this to a reasonable ammount? Also, this DAQ acquisition has already been tried in the new app designer, but there is even more latency that occurs in that format due to background operations. Here is a copy of the code we are using:
function daqAcquisiton()
d=daq("ni");
d.flush
trialNum=20; % User edits
lagtime=zeros(trialNum,1);
for i=1:trialNum
tic
AvailableDevice = daqlist;
d=daq("ni");
d.Rate=2000;
Ch1=addinput(d,AvailableDevice.DeviceID,'ai10','Voltage'); % Input config options here
d.ScansAvailableFcnCount = 14000;
d.ScansAvailableFcn = @(obj,evt)plotMyData(i);
start(d,'Duration',seconds(7))
pause(8)
%d.flush
lagtime(i) = toc;
disp(lagtime(i))
d.flush
end
end

답변 (1개)

Amal Raj
Amal Raj 2024년 4월 16일 9:41
Hi,
Reducing latency in MATLAB DAQ loops involves optimizing both software and hardware configurations. Key strategies include minimizing operations within the loop, such as moving device and channel configuration outside the loop to avoid repeated initialization. Utilizing continuous instead of repeated acquisition can significantly reduce overhead by avoiding the start-stop cycle for each trial. Adjusting data transfer settings, like `ScansAvailableFcnCount`, to accumulate more data before transfer can improve efficiency. It's crucial to avoid unnecessary commands like `daq` and `daqlist` inside the loop and to preallocate resources to reduce dynamic memory allocation. Optimizing callback functions for performance and considering hardware configurations for optimal data transfer can also help. Implementing these strategies, like configuring DAQ sessions before the loop and using efficient timing control, can significantly reduce latency, leading to more efficient and faster data acquisition systems in MATLAB.
function daqAcquisitionOptimized()
d = daq("ni");
AvailableDevice = daqlist;
d.Rate = 2000;
addinput(d, AvailableDevice.DeviceID, 'ai10', 'Voltage');
d.ScansAvailableFcnCount = 14000;
d.ScansAvailableFcn = @(obj, evt) plotMyData(evt);
trialNum = 20; % User edits
lagtime = zeros(trialNum, 1);
for i = 1:trialNum
tic;
start(d, 'Duration', seconds(7));
wait(d); % Consider using wait instead of pause for precise timing
lagtime(i) = toc;
disp(lagtime(i));
end
d.flush;
end

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by