%Lab3b.m %analog input test % analogin reads voltage across an LED faster %(by grabbing N samples at a specified rate) % than it is being updated by analog out (putdata) in the %output loop, which has a command to slow it to one iteration % every 25th of a second. % % You need to fill in the gaps as indicated by comments.... % clear; delete(daqfind); ai = analoginput('nidaq','Dev2'); addchannel(ai, 1, 'ain'); ai.ain.InputRange = [-5,5]; ActualInRate = setverify(ai, 'SampleRate', 100) set(ai, 'TriggerType', 'Manual'); % just for fun set(ai, 'SamplesPerTrigger',110); %room on either side? ai % tell us about it ao = analogoutput('nidaq','Dev1'); addchannel(ao, 0:1); start(ai); % ready, steady... disp('triggering in two seconds...'); pause(2); trigger(ai); %go! for k = 1:25 % now ai is off and running %%%%%%%%%%%% % your code for the voltage-generation loop here %%%%%%%%%%%% end % this loop should take 1.0 sec. wait(ai,2.0); %%%%%%%%%%%% % need a getdata command here %%%%%%%%%%%% plot(LEDData); delete(daqfind);