I would like to use Matlab's data acquisition toolbox to continuously send data to a device (sort of like an outer loop that is always running) and collect data from a sensor for a pre-determined duration after some time (the data acquire part being the inner loop). The continuous output part is working but I;m having no luck with the input. Any help will be much appreciated.
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);