input range for usb6008 daq and pid controller
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!