我想使用 Matlab 的数据采集工具箱连续向设备发送数据(有点像一直在运行的外循环),并在一段时间后从传感器收集预定持续时间的数据(数据采集部分是内循环)。连续输出部分正在工作,但我对输入没有运气。任何帮助都感激不尽。
Fs=10000; % Sampling Frequency
timetoacquire=10; % Acquisition time
ss=daq.createSession('ni');
ss.Rate=Fs;
ss.DurationInSeconds=timetoacquire;
ss.addAnalogOutputChannel('Dev1',0,'Voltage');%Voltage to run pump
ss.addAnalogInputChannel('Dev1',1,'Voltage'); %Voltage from AnalogInputChannel
load VoltageOld;
load TimeOld;
timevect=linspace(min(TimeOld),max(TimeOld),Fs*max(TimeOld));
voltagevect=pchip(TimeOld,VoltageOld,timevect)';%Output Voltage Waveform
lh = ss.addlistener('DataRequired', ...
@(src,event) src.queueOutputData(voltagevect));
ss.IsContinuous=true;
ss.queueOutputData(voltagevect);
ss.startBackground();
llh = ss.addlistener('DataAvailable', @plotData);
ss.queueOutputData(voltagevect);
[Voltagedata,timeStamps,triggerTime] = ss.startForeground;
% ss.stop();
% delete(lh);