Start DAQ Continuous Sampling after discrete samples
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Holden
el 9 de Sept. de 2024
Movida: Walter Roberson
el 30 de Oct. de 2024 a las 22:47
0 comentarios
Ver también
Categorías
Más información sobre Periodic Waveform Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!