daq code storing data problem

1 view (last 30 days)
mado
mado on 15 Mar 2014
Edited: mado on 15 Mar 2014
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);

Answers (0)

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by