input range for usb6008 daq and pid controller
조회 수: 2 (최근 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에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!