input range for usb6008 daq and pid controller

조회 수: 1 (최근 30일)
mado
mado 2014년 3월 25일
편집: mado 2014년 3월 25일
i used this code to acquire data but the maximum input voltage that the card could read was 10.4 volt on a3 however it is differential that is ranging from+20to -20 according to datasheet
also i want to use pid controller to output control signal u is this code correct? % ai = analoginput('nidaq', 'Dev1'); %Create an analog output object AO = analogoutput('nidaq','dev1'); addchannel(ai,0:3);
%Add hardware channels to analog output object
chans = addchannel(AO,0);
% Set the SampleRate
set(AO,'SampleRate',100)
for ii = 1:40 %loop for aqcisition
start(ai)
[data,time,abstime,events] = getdata(ai);
plot(data);
fismat = readfis('CVfinalsm55') getfis(fismat);
Vref=evalfis([46;700 ],fismat); %Calculating the error
for i=1:3
read=getsample(ai)
Vmeasured=read(:,4)
e(i)= Vmeasured-Vref
end
IE=sum(e); %Integral of Error
KP=20; KI =10; u=(KP*e+KI*IE) %pid
for i=1:length(u)
t = timer('TimerFcn', ' putsample(AO,u(i))',...
'StartDelay',0);
start(t)
end
end
end

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by