daq code storing data problem

1 次查看(过去 30 天)
mado
mado 2014-3-15
编辑: mado 2014-3-15
i wrote this code to acquire data from usb6008 and store it when i used just two channels or three and set s.duration =20 it enters a loop of reading and without end however i disconnect the daq
if true
% % Initialization
global Temperature global Irradiance global current global Vref global data
%%get connected devices d = daq.getDevices %create session s = daq.createSession('ni') s1= daq.createSession('ni') %add analog channel s.addAnalogInputChannel('ID',channel num, 'measurement type') s.addAnalogInputChannel('Dev1','ai0', 'Voltage')%irradiance % s.addAnalogInputChannel('Dev1','ai3', 'Voltage')%Temperature s.addAnalogInputChannel('Dev1','ai6', 'Voltage')%current s1.addAnalogOutputChannel('Dev1', 'ao0', 'Voltage') % set rate of scan 1000 scans/second , run for 30 seconds
s.Rate=100;
s.DurationInSeconds =20
%v.TerminalConfig = ' Differential';
v.TerminalConfig = ' SingleEnded';
%_____________________________
%aquire data and process
lh = s.addlistener('DataAvailable', @plotData);
%store data
h = s.addlistener('DataAvailable', @storedata);
% Analog Output
ao_value = 2.74;
s1.outputSingleScan(ao_value)
s.startBackground() s.wait()
delete (lh)
delete (h)
storing code
%
function storedata(src,event)
persistent tempData;
global data
if(isempty(tempData))
tempData = [];
end
plot(event.TimeStamps, event.Data)
tempData = [tempData;event.Data];
data = tempData
xlswrite('collect.xls', data);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Analog Input and Output 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by