input range for usb6008 daq and pid controller

1 view (last 30 days)
mado
mado on 25 Mar 2014
Edited: mado on 25 Mar 2014
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

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!