Start DAQ Continuous Sampling after discrete samples
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello All,
I am using a DAQ USB6003, and have written some code that waits for a signal using the "read" command, and once it gets the signal (trigger), I then want to start continuous background sampling. The code looks like this
% Description
% Code to start collecting data from distal load cell on rising edge
% Clear Workspace
close all;
clearvars;
clc;
figNum = 1;
%% Program Parameters
%% Add DAQ Device and Channels
% Device
d1 = daq("ni"); % initiate object
%%
deviceID = 'dev1';
%%%%%%%%%%%%%%%%%%%%%%%%%% INPUT CHANNELS %%%%%%%%%%%%%%%%%%%%%%%%%%%
distForceID = 'ai0'; % analog channel for SPEED from Aruino
distForceCh1 = addinput(d1,deviceID,distForceID,'voltage');
%% Loop and Wait for Signal to Start Sampling
start = false;
priorData = [];
cnt = 1;
while ( start ~= true )
[scanData,timeStamp,~] = read(d1,"OutputFormat","Matrix"); % read single scan
priorData(cnt) = scanData;
if (scanData > 1)
start = true;
end
cnt = cnt + 1;
end
%% Start Data Sampling
% Start Data Sampling
start(d1,"Continuous"); % start analog channels
disp('Start');
sampling = true; % boolean that sampling is running
cnt = 1; % initialize for logging Zaber position
timerStart= tic; % start of timer for when position is logged
stop(d1); % end analog recording
disp('Stop');
However, when it gets to the line for continuous sampling, I get the following error:
Unable to use a value of type daq.interfaces.DataAcquisition as an index.
When I eliminate the while loop with the discrete sampling, I do not get the error. Any ideas how do resolve this? I didn't see much online regarding this error
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Periodic Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!