1
我想使用Matlab的數據採集工具箱將數據連續發送到設備(有點像外部循環一直運行),並從傳感器收集數據預定的持續時間過後(數據獲取部分是內部循環)。連續輸出部分正在工作,但我沒有輸入的運氣。任何幫助都感激不盡。帶連續輸出和不連續輸入的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);