User:DukeEgr93/DAQ
Jump to navigation
Jump to search
Channel Checker
% Clear out workspace
clear
% Clear out DAQ objects
delete(daqfind)
% Create Analog Output Object
AO = analogoutput('nidaq', 'Dev1');
% Change sample rate
set(AO, 'SampleRate', 500);
% View Analog Output Object
AO
% Add channels to Analog Output Object
addchannel(AO, [0])
% Create Analog Input Object
AI = analoginput('nidaq', 'Dev1')
% Add channels to Analog Input Object
addchannel(AI, [0 1 2 3 4 5 6 7])
% Write values to output channels
putsample(AO, [5])
pause
putsample(AO, [0])
% Use loop to set several different voltages
for k=1:300
% Calculate voltages for each channel
Vout0 = 2.5+2.5*sin(2*pi*k/100);
% Put voltages to each output channel
putsample(AO, [Vout0])
% Read voltages from all input channels
Voltages(k,:) = getsample(AI);
pause(0.02)
end
% Plot voltages versus index
plot(Voltages)
% Turn all outputs off
putsample(AO, [0])