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 Center および File ExchangeAnalog Data Acquisition についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by