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 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by