Data acquisition read "all" does not work properly
이전 댓글 표시
I use a National Instruments USB-6009 daq box for a long time now. For a new project I use Matlab R2025b instead of previous versions. In a loop I want to use the read function with the "all" option but no data is stored. If I interspere calls with a span of 1 everything works. Why? Here my code:
%% Prepare data acquisition
dq = daq('ni');
% Add a channel to the data acquisition object
Channel = addinput(dq, 'Dev1', 1:4, 'Voltage');
for i = 1 : 4
Channel(i).Range = [-10, 10];
Channel(i).TerminalConfig = 'SingleEnded';
end
dq.Rate = 250;
%% data acquisition loop
Results = zeros(5000, 5); Start = 0;
dq.flush;
start(dq, 'Duration', seconds(20));
while dq.Running
pause(0.2);
Span = dq.NumScansAvailable;
if Span == 0
Span = 1;
else
Span = "all";
end
[data, TimeStamps] = read(dq, Span, "OutputFormat", "Matrix");
% Store the acquired data in the Results array
if ~isempty(data)
Results(Start + 1 : Start + size(data, 1), :) = [TimeStamps, data];
Start = Start + size(data, 1);
end
end
% Stop the data acquisition
stop(dq);
Results = Results(1 : Start, :);
I have all updates installed for Matlab R2025b, the current version of the Data Acquisition Toolbox Support Package for National Instruments NI-DAQmx Devices and the appropriate NI-DAQmx driver. The code works but I do not understand why no data is retrieved with a permanent Span setting to "all".
Greetings Andreas
댓글 수: 2
dpb
1분 전
I presume you have verified that prior release still functions as before?
Is the problem that
Span = dq.NumScansAvailable;
is now never returning anything but "0" or that the "all" case never returns any data or does it also work if there is a single scan returned first? Does a single scan reset the NumScansAvailable value to zero?
Andreas Sprenger
대략 4시간 전
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!