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 Data Acquisition에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by