Professional Documents
Culture Documents
Control System
Submitted to:
Mr. Usman
Submitted by:
Junaid Mukhtar
2012-MC-139
Lab Session 1
Introduction of MATLAB and its application in control
system design and analysis.
MATLAB:
MATLAB (matrix laboratory) is a numerical computing environment
and fourth-generation programming language. Developed by MathWorks,
MATLAB allows matrix manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces, and interfacing with
programs written in other languages, including C, C++, Java, and Fortran.
Although MATLAB is intended primarily for numerical computing, an
optional toolbox uses the MuPAD symbolic engine, allowing access to symbolic
computing capabilities. An additional package, Simulink, adds graphical
multidomain simulation and Model-Based Design fordynamic and embedded
systems.
Application of Matlab:
Mathematical operations
Vector
Matrices and Matrix operations
Solving systems of linear equations
Plotting
Curve fitting, Interpolation
Solving Ordinary Differential Equations
Three Steps:
There are three major steps which are followed in Control System design.
SISO Systems:
SISO means "single input single output" systems e.g. dc motor speed
control. In which we give step input voltage to motor and resulting speed control
of dc motor rotor.
MIMO Systems:
MIMO means" multiple input multiple outputs" systems e.g. jet transport
air craft. All standard model representations are supported, including;
Transfer function
State Space Model
Zeros, poles and gains etc.
Step Response
Impulsive Response
Bode diagram
Nyquist Plot
Lab Session 2
To illustrate control system characteristics with the help of
MATLAB by introducing a control to speed Techo-generator
system.
DC Motor:
The DC motor is a power actuator device that delivers energy to a load, as
shown in Figure2.18 (a); a sketch of a DC motor is shown in Figure2.18 (b). The
DC motor converts direct current (DC) electrical energy in to rotational mechanical
energy. A major fraction of the torque generated in the rotor (armature) of the motor
is available to drive an external load.
The transfer function of the DC motor will be developed for a linear
approximation to an actual motor, and second order effects, such as hysteresis
and the voltage drop across the brushes, will be neglected. The input voltage
may be applied to the field or armature terminals. The air gap flux of the motor
is proportional to the field current, provided the field is unsaturated, so that
As,
The block diagram model of the field controlled DC motor is shown in Figure2.19.
Alternatively, the transfer function may be written in terms of the time constants of the
motor as,
Where,
and,
, and
Where
is a function of the permeability of the magnetic material. The armature current
is related to the input voltage applied to the armature by
Where
is the back electromotive force voltage proportional to the motor speed.
Therefore, we have
Where
the transform of the angular speed and the armature is current is,
Output:
Transfer function:
-1
--------2 s + 1.5
ans = 0.6650
Output:
Transfer function:
1
---------2 s + 808.5
Comments:
As we can see from the graph that in closed loop system the response meet with
x-axis but in open loop system the response meet with x-axis after a little bit of
time. It takes more time to touch real axis for open loop system as compared to
closed loop system.
Open loop system response is quicker than the system response of closed loop
system.
Lab Session 3
To determine the performance of a second order system
& adjust the systems performance with the variation of
parameter.
For which the transient output, as obtained from the Laplace transform is,
Where,
, and
overall performance. Infect, for second order systems, the damping ratio is the
only factor determining the value of the percent overshoot to a step input. As it
turns out, the damping ratio can be estimated from the response of a system to a
step input
Over-damped ( > 1): The system returns (exponentially decays) to
equilibrium without oscillating. Larger values of the damping ratio return
to equilibrium more slowly.
Critically damped ( = 1): The system returns to equilibrium as quickly as
possible without oscillating. This is often desired for the damping of
systems such as doors.
Under-damped (0 < < 1): The system oscillates (at reduced frequency
compared to the un-damped case) with the amplitude gradually
decreasing to zero.
Un-damped ( = 0): The system oscillates at its natural resonant
frequency ( ).
Graph:
Assignment:
clc
t=[0:0.1:12];
a=0.5:0.5:3;
for(i=1:length(a))
sys(i)=tf([a(i)*a(i)],[1 2*0.4 a(i)*a(i)]);
end ltiview
%import system sys in ltiview
% or
[y1,T1]=step(sys(1),t);[y2,T2]=step(sys(2),t);
[y3,T3]=step(sys(3),t);[y4,T4]=step(sys(4),t);
[y5,T5]=step(sys(5),t);
%
plot(T1 ,y1 ,T2,y2,T3,y3,T4,y4,T5,y5);
xlabel('\omega_n t'), ylabel('y(t)')
title('\omega_n t=0.5, 1.0, 1.5. 2.0, 2.5'), grid
Comments:
As we can see from the first graph by decreasing the damping ratio () the over
shoot is less.
From second graph, it is clear that by increasing the value of natural frequency ( ) the
response is quicker but over shoot is increase.so varying value of wn and zeta both effect
the system response.so these two are the important factor which effect P.O,Tr,Ts.
Perameters of system is totally dependent of these two variables.(wn,zeta)
Lab Session 4
To determine the steady state error of a mobile robot steering
control.
Output:
Assignment:
clc
syms s d1 d2
;
a=input('enter numinator:')
b=input('enter denumerator:')
M=d2*s^2+d1*s+1
m1=diff(M,s)
m2=diff(m1,s)
m3=diff(m2,s)
m4=diff(m3,s)
%%%%% putting s=0 in M and its derrivatives
m0=limit(M,s,0)
m10=limit(m1,s,0)
m20=limit(m2,s,0)
m30=limit(m3,s,0)
m40=limit(m4,s,0)
%%%%% finding M2 and M4..................
M2=(-(m0*m20)/2)+((m10*m10)/1)-((m20*m0)/2)
M4=((m20*m20)/(4))
D=tf(a,b);
%%D=((1)/(114))*s^3+((11.4)/(114))*s^2+((14)/(114))*s+1
d1=diff(D,s)
d2=diff(d1,s)
d3=diff(d2,s)
d4=diff(d3,s)
%%%%% putting s=0 in D and its derrivatives
d0=limit(D,s,0)
d10=limit(d1,s,0)
d20=limit(d2,s,0)
d30=limit(d3,s,0)
d40=limit(d4,s,0)
%%%%% finding D2 and D4..................
D2=(-(d0*d20)/2)+((d10*d10)/1)-((d20*d0)/2)
D4= -2*(d10*d30/6)+((d20*d20)/(4))
f=D2-M2
g=D4-M4
%%%%%% calculating d1 and d2 from (f and g)equation
[d1,d2]=solve(f,g)
d1=sym2poly(abs(d1(1)))
d2=sym2poly(abs(d2(1)))
den11=1+d1*s+d2*s^2
p=sym2poly(den11);
num=1;
den=p;
X=sym2poly(D)
disp('orignal transfer')
sys1=tf(num,X)
disp('approximate 2nd order system')
sys=tf(num,p)
t=0:.01:4;
[y,t]=step(sys1,t);
plot(t,y);
hold on
[y1,t1]=step(sys,t);
plot(t1,y1);
Output:
if r==1
P=P_2;
Q=Q_2;
end
for i=3:(r+1)
if i>3
P=del(i-1)*[1 zeros(1,(i-2))]+conv([1 0 0],P_1)+[0 gam(i-1)*P_2];
else
P=del(i-1)*[1 zeros(1,(i-2))]+[0 gam(i-1)*P_2];
end
Q=conv([1 0 0],Q_1)+[0 gam(i-1)*Q_2];
P_1=P_2;P_2=P;
Q_1=Q_2;Q_2=Q;
end
[P,Q]=tfdata(tf(P,Q)+D_fact,'v');
P=P.*(abs(P)>1e-6);
Q=Q.*(abs(Q)>1e-6);
RouthApprox=tf(P,Q)+D_fact;
t=0:.001:2;
[y,t]=step(G,t);
plot(t,y);
hold on
[y1,t1]=step(R,t);
plot(t1,y1);
Output:
Comment:
In the graph of robot the green line is required response but the blue line is actual
response.
The difference between these responses is due to steady state error. So with
approximation we cant get exact the required system response but we just get a
system response near to original required response .This method give us easy
way to analyze the system with a simple approximate system transfer function.
Lab Session 5
Stability analysis of feedback system using MATLAB and also
to draw the ROUTH array.
Stability:
A stable system is a dynamic system with a bounded response to a bounded input.
Absolute stability:
We can say that a closed loop feedback system is either stable or it is not stable.
This type of stable/not stable characterization is referred to as absolute stability. A
system possessing absolute stability is called a stable system the label of absolute is
dropped.
Relative stability:
A closed loop system is stable; we can further characterize the degree of stability.
This is referred to as relative stability.
Where,
And so on. The algorithm for calculating the entries in the array can be followed on
a determinant basis or by using the form of the equation for
.
The Routh-Hurwitz criterion states that the number of roots of q(s) with positive
real parts is equal to the number of changes in sign of the first column of the Routh
array. This criterion requires that there be no changes in sign in the first column for a
stable system. This requirement is both necessary and sufficient.
Output:
ans =
10.5000
Assignment:
K=[0:0.5:20]; for i=1:length(K) q=[1 2 4
K(i)]; p(:,i)=roots(q); end
plot(real(p),imag(p),'x'), grid xlabel('Real
axis'), ylabel('Imaginary axis');
m=zeros(l,l/2);
[cols,rows]=size(m);
for i=1:rows
m(1,i)=D(1,(2*i)-1);
m(2,i)=D(1,(2*i));
end
else
m=zeros(l,(l+1)/2);
[cols,rows]=size(m);
for i=1:rows
m(1,i)=D(1,(2*i)-1);
end
for i=1:((l-1)/2)
m(2,i)=D(1,(2*i));
end
end
for j=3:cols
if m(j-1,1)==0
m(j-1,1)=0.001;
end
for i=1:rows-1
m(j,i)=(-1/m(j-1,1))*det([m(j-2,1) m(j-2,i+1);m(j-1,1) m(j-1,i+1)]);
end
end
disp('--------The Routh-Hurwitz array is:--------'),m
Temp=sign(m);a=0;
for j=1:cols
a=a+Temp(j,1);
end
if a==cols
disp('
----> System is Stable <----')
else
disp('
----> System is Unstable <----')
end
output:
Comments:
Routh-Hurwitz table is an effective way to see whether the system is stable or not.
It also helps us in determining the auxiliary roots of the system and rout locus of
the system.
With this we can also find the point where rout locus cut the imaginary axis.
With this we can analyze the system status that weather the system is stable or
unstable before implementing it. We can also find the asymptotic center and also
we can find poles location of our system. We can also find break away and break
in points from the graph.
Lab Session 6
Obtaining a Root Locus plot & Design of Parameter of K for an Electrohydraulic Servo Mechanism using MATLAB Root
locus analysis:
The root locus is the path of the roots of the characteristic equation traced
out in the s-plane as a system parameter varies from zero to infinity.
And
Where, k=0,1,2,
The simple second order system considered in the previous chapters is
shown in Figure. The characteristic equation representing this system is
Or,
The locus of the roots as the gain K is varied is found by requiring that
The gain K may be varied from zero to an in finitely large positive value. For a
second order system, the roots are,
Comments:
Rout locus defines a path with which the root of a system moves by changing the
value of k.
Due to attraction of zero the root locus differ from their asymptotes.
Using sisotool we added two zeros to the system and got the desired desired the
stable
step response alonge with desired P.O%,Tr,Ts .
It is also helpful to us for getting response for many inputs, just like ramp input
parabolic input.
Lab session 7
PID Controller Design
In this lab session, we will consider the following unity feedback system:
The output of a PID controller, equal to the control input to the plant, in the time-domain is as follows:
First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above. The
variable ( ) represents the tracking error, the difference between the desired input value ( ) and the actual output ( ).
This error signal ( ) will be sent to the PID controller, and the controller computes both the derivative and the integral
of this error signal. The control signal ( ) to the plant is equal to the proportional gain (
error.This control signal ( ) is sent to the plant, and the new output ( ) is obtained. The new output ( ) is then fed back
and compared to the reference to find the new error signal ( ). The controller takes this new error signal and computes
its derivative and its integral again, ad infinitum.
The transfer function of a PID controller is found by taking the Laplace transform of Eq.(1).
= Proportional gain
= Integral gain
= Derivative gain
We can define a PID controller in MATLAB using the transfer function directly, for example:
we may use MATLAB's pid controller object to generate an equivalent continuous-time controller as follows:
C = pid(Kp,Ki,Kd)
C =
Kp + Ki * --- + Kd * s
with Kp = 1, Ki = 1, Kd = 1
) will have the effect of reducing the rise time and will reduce but never eliminate
) will have the effect of eliminating the steady-state error for a constant
or step input, but it may make the transient response slower. A derivative control (
the stability of the system, reducing the overshoot, and improving the transient response.
The effects of each of controller parameters,
, and
CL RESPONSE
RISE TIME
OVERSHOOT
SETTLING TIME
S-S ERROR
Kp
Decrease
Increase
Small Change
Decrease
Ki
Decrease
Increase
Increase
Eliminate
Kd
Small Change
Decrease
Decrease
No Change
, and
fact, changing one of these variables can change the effect of the other two. For this reason, the table should only be
used as a reference when you are determining the values for
and
Example Problem
Suppose we have a simple mass, spring, and damper problem.
Let
M = 2 kg
b = 5 N s/m
k = 25 N/m
F = 4 N
then becomes
and
contributes to obtain
Minimum overshoot
No steady-state error
Comment:
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to a unit step input. This
corresponds to the steady-state error of 0.95, quite large indeed. Furthermore, the rise time is about one second, and
the settling time is about 3.5 seconds. Let's design a controller that will reduce the rise time, reduce the settling time,
and eliminate the steady-state error.
Proportional Control
From the table shown above, we see that the proportional controller (Kp) reduces the rise time, increases the overshoot,
and reduces the steady-state error.
The closed-loop transfer function of the above system with a proportional controller is:
Kp = 300;
C = pid(Kp)
T = feedback(C*P,1)
t = 0:0.05:5;
step(T,t)
C = Kp = 300
P-only controller.
T =
300
----------------
Comment:
The above plot shows that the proportional controller reduced both the rise time and the steady-state error, increased
the overshoot, and decreased the settling time by small amount.
Proportional-Derivative Control
Now, let's take a look at a PD control. From the table shown above, we see that the derivative controller (Kd) reduces
both the overshoot and the settling time. The closed-loop transfer function of the given system with a PD controller is:
X(s) /F(s) = (Kd*s+Kp) / 2s^2+(5+Kd)s+(25+Kp)
Let
Kp = 300;
Kd = 20;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
20 s + 300
-----------------
2 s^2 + 25 s + 325
equal 20
Comment:
This plot shows that the derivative controller reduced both the overshoot and the settling time, and had a small effect
on the rise time and the steady-state error.
Proportional-Integral Control
Before going into a PID control, let's take a look at a PI control. From the table, we see that an integral controller (Ki)
decreases the rise time, increases both the overshoot and the settling time, and eliminates the steady-state error. For
the given system, the closed-loop transfer function with a PI control is:
X(s) /F(s) = (Kp*s+Ki) / s^3+ 5s^2+(25+Kp)s+Ki
Let's reduce the
Kp = 30;
Ki = 70;
C = pid(Kp,Ki)
T = feedback(C*P,1)
t = 0:0.05:5;
step(T,t)
equal 70.
T =
30 s + 70
------------------------
s^3 + 5 s^2 + 55 s + 70
Comment:
We have reduced the proportional gain (Kp) because the integral controller also reduces the rise time and increases
the overshoot as the proportional controller does (double effect). The above response shows that the integral controller
eliminated the steady-state error.
Proportional-Integral-Derivative Control
Now, let's take a look at a PID controller. The closed-loop transfer function of the given system with a PID controller is:
= 350,
= 300, and
confirm, enter the following commands to an m-file and run it in the command window. You should get the following
step response.
Kp = 350;
Ki = 300;
Kd = 50;
C = pid(Kp,Ki,Kd)
T = feedback(C*P,1);
t = 0:0.01:2;
step(T,t)
Comment:
After several trial and error runs, the gains
= 350,
= 300, and
Now, we have obtained a closed-loop system with no overshoot, fast rise time, and no steady-state error.
Which is our desired response.
2.
3.
4.
5.
Adjust each of Kp, Ki, and Kd until you obtain a desired overall response. You can always refer to the table shown
in this "PID Tutorial" page to find out which controller controls what characteristics.
Lastly, please keep in mind that you do not need to implement all three controllers (proportional, derivative, and integral)
into a single system, if not necessary. For example, if a PI controller gives a good enough response (like the above
example), then you don't need to implement a derivative controller on the system. Keep the controller as simple as
possible.