41
Lab Report Control System Submitted to: Mr. Usman Submitted by: Junaid Mukhtar 2012-MC-139

Control System Lab Report

Embed Size (px)

DESCRIPTION

It contain all performances of control system lab,which were verified on Matlab .

Citation preview

Page 1: Control System Lab Report

Lab Report

Control System

Submitted to:

Mr. Usman

Submitted by:

Junaid Mukhtar

2012-MC-139

Page 2: Control System Lab Report

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

Compiling MATLAB and Toolboxes: MATLAB Compiler supports the full MATLAB language and most MATLAB

toolboxes, with some exceptions. For details on compliable features and products.

Page 3: Control System Lab Report

Control System Toolbox:

Control System Toolbox™ provides industry-standard algorithms and

apps for systematically analyzing, designing, and tuning linear control systems.

You can specify your system as a transfer function, state-space, pole-zero-gain,

or frequency-response model. Apps and functions, such as step response plot

and Bode plot, let you visualize system behavior in time domain and frequency

domain. You can tune compensator parameters using automatic PID controller

tuning, Bode loop shaping, root locus method, LQR/LQG design, and other

interactive and automated techniques.

Three Steps:

There are three major steps which are followed in Control System design.

(1) Building Models:

In building models there are two systems

SISO system

MIMO system

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.

Page 4: Control System Lab Report

Control System Toolbox provides commands for:

Performing arithmetic on linear models

Building complex block diagrams by connecting simple models in

series, parallel, or feedback

Discretizing continuous-time models

Computing low-order approximations of high-order models

Consider a block diagram:

(2) Analyzing Models:

We can analyze the model by LTIview (Linear time invariant) and

GUI (Graphical user interface). In which we can analyze the model

behavior by plotting different graphs e.g.

Step Response

Impulsive Response

Bode diagram

Nyquist Plot

Page 5: Control System Lab Report

By comparing the time and frequency responses of several linear models

at once we can analyze the system behavior for different parameters.

(3) Designing Compensator:

How we build compensators using functions from the Control System Toolbox.

We can build SISO system by

Roots locus method

Bode diagram (compensator)

Pole placement technique (for MIMO)

Controller design can be validated by verifying rise time, overshoot, settling time,

gain and phase margins, and other requirements.

Page 6: Control System Lab Report

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

The torque developed by the motor is assumed to be related linearly to

and the armature current as follows:

Page 7: Control System Lab Report

Then we have, in Laplace transform notation,

Where = is a constant armature current, and is defined as the motor constant. The

field current is related to the field voltage as,

The motor torque is equal to the torque delivered to the load. This relation may be

expressed as,

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

Page 8: Control System Lab Report

Armature controlled DC motor:

The armature controlled DC motor uses the armature current as the control

variable. The stator field can be established by a field coil and current or a permanent

magnet. When a constant field current is established in a field coil, the motor torque is

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,

Page 9: Control System Lab Report

Open loop control of DC motor:

Ra=1; Km=10; J=2; f=0.5; Kb=0.1; b=0.5; num1=[1];

den1=[J,b];

sys1=tf(num1,den1);

num2=[Km*Kb/Ra]; den2=[1];

sys2=tf(num2,den2)

sys_o=feedback(sys1 ,sys2);

sys_o=-sys_o

[yo,T]=step(sys_o);

plot(T,yo) title('Open-Loop Disturbance Step Response') xlabel('Time (s)'),ylabel('\omega_o'), grid yo(length(T))

Output:

Transfer function:

-1

---------

2 s + 1.5

ans = -

0.6650

Page 10: Control System Lab Report

Closed loop control of DC motor

(Techogenerator system):

clc; clear all; Ra=1; Km=10; J=2; f=0.5; Kb=0.1; b=0.5; Kt=8; for(i=1:10); Ka=i; num1=[1]; den1=[J,b]; sys1=tf(num1,den1); num2=[((Ka*Km*Kt*Ka)+(Ka*Km*Kt*Kb))/(Ra*Ka)]; den2=[1]; sys2=tf(num2,den2); sys=feedback(sys1 ,sys2); step(sys); hold on; end

Output:

Transfer function:

1

----------

2 s + 808.5

Page 11: Control System Lab Report

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.

Page 12: Control System Lab Report

Lab Session 3

To determine the performance of a second order system

& adjust the system’s performance with the variation of

parameter.

Second Order System:

Let us consider a single loop second order system and determine its

response to a unit step input. A closed loop feedback control system is shown in

Figure. The closed loop system is,

With a unit step input, we obtain,

For which the transient output, as obtained from the Laplace transform is,

Where, , and ,

Damping ratio (ζ):

The damping ratio plays a fundamental role in closed loop system

performance. As seen in the design formulas for settling time, percent overshoot,

peak time, and rise time, the damping ratio is a key factor in determining the

Page 13: Control System Lab Report

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 ( ).

Part 1: Effect of Damping ratio “Zeta” on system

performance

clc t=[0:0.1:12];num=[1]; zeta=0.3:0.1:1.2; zeta(9)=2;

for(i=1:9) sys(i)=tf(1,[1 2*zeta(i)1]); end

[y1,T1]=step(sys(1),t);

[y2,T]=step(sys(2),t);

[y3,T3]=step(sys(3),t);[y4,T4]=step(sys(4),t); [y5,T5]=step(sys(5),t);[y6,T6]=step(sys(6),t); [y7,T7]=step(sys(7),t);[y8,T8]=step(sys(8),t); [y9,T9]=step(sys(9),t)

plot(T1 ,y1 ,T2,y2,T3,y3,T4,y4,T5,y5,T6,y6,T7,y7,T8,y8,T9,y9); xlabel('\omega_n t'), ylabel('y(t)')

legend('underdamped:zeta<1','overdamped:zeta>1','criticallydamped:zeta=0','un

damped:zeta=1 ')

Graph:

Page 14: Control System Lab Report

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

Page 15: Control System Lab Report

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)

Page 16: Control System Lab Report

Lab Session 4

To determine the steady state error of a mobile robot steering

control.

Page 17: Control System Lab Report

Part 1: Steady state response to a triangular wave input (kind of

ramp input)

clc; K1=1; K2=2; K=1; a=1/10; numg=[K1*K K*K2]; deng=[a 1 0]; sysg=tf(numg,deng); [sys]=feedback(sysg, [1 ]); t=[0:0.1:8.2]'; v1=[0:0.1:2]; v2=[2:-0.1:-2]; v3=[-2:0.1:0]; u=[v1 v2 v3]; [y,T]=lsim(sys,u,t); plot(T,y,t,u,'-'), xlabel('Time (s)'), ylabel('\theta (rad)'), grid

Output:

Page 18: Control System Lab Report

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

Page 19: Control System Lab Report

plot(t1,y1);

Output:

Page 20: Control System Lab Report

Assignment: (General code) function RouthApprox=Routh_Approximation(G,r) Function RouthApprox=Routh_Approximation(G,r)

% it Computes the r-th order Routh Approximation of a given n-th order % transfer function G, with 1<=r<=n.

clc; G=tf([3 1 2 4],[1 3 4 8 5 4]) r=3; R=Routh_Approximation(G,r)

% system Approximation if mod(n,2) A=[den1(1:2:end);den1(2:2:end)]; B=[num1(1:2:end);num1(2:2:end)]; else A=[den1(1:2:end);den1(2:2:end) 0]; B=[num1(1:2:end);num1(2:2:end) 0]; end gam(r)=0;del=gam; gam(1)=A(1,1)/A(2,1); if gam(1)<=0 disp('System Unstable. Routh Approximation does not exist'); RouthApprox=0; return end for i=3:r+1

for j=1:(size(A,2)-1) A(i,j)=A(i-2,j+1)-gam(i-2)*A(i-1,j+1); end gam(i-1)=A(i-1,1)/A(i,1); if gam(i-1)<=0 disp('System Unstable. Routh Approximation does not exist'); RouthApprox=0; return end end

del(1)=B(1,1)/A(2,1); for i=3:r+1 for j=1:(size(A,2)-1) B(i,j)=B(i-2,j+1)-del(i-2)*A(i-1,j+1); end del(i-1)=B(i-1,1)/A(i,1); end

P_1=0; P_2=del(1);

Q_1=1; Q_2=[1 gam(1)];

Page 21: Control System Lab Report

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:

Page 22: Control System Lab Report

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.

Page 23: Control System Lab Report

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.

Routh-Hurwitz Stability criterion:

The Routh-Hurwitz criterion is a necessary and sufficient criterion for the stability

of linear systems. The method was originally developed in terms of determinants, but

we shall use the more convenient array formulation.

The Routh-Hurwitz criterion is based on ordering the coefficients of the

characteristic equation,

In to an array or schedule as follows

Further rows of the schedule are then completed as,

Page 24: Control System Lab Report

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.

Part 1: Finding system’s stability:

clc; k=0:0.5:20; check=0; for i=1:length(k) q=[1 2 5 k(i)]; p=roots(q); re=real(p); for j=1:3 if re(j)>0 check=1; end end if check==1 break end end k(i)

Output:

ans =

10.5000

Page 25: Control System Lab Report

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');

Assignment: (General code)

clc;

disp(' ')

D=input('Input coefficients of characteristic equation');

l=length (D);

disp(' ')

disp('--------------------')

disp('poles of characteristic equation :')

roots(D)

---- Bulding array--------

if mod(l,2)==0

Page 26: Control System Lab Report

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

Page 27: Control System Lab Report

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.

Page 28: Control System Lab Report

Lab Session 6

Obtaining a Root Locus plot & Design of Parameter of K for an Electro-

hydraulic 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.

Therefore it is necessary that,

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

Page 29: Control System Lab Report

The gain K may be varied from zero to an in finitely large positive value. For a

second order system, the roots are,

Page 30: Control System Lab Report

Procedure of finding of Rout Locus:

Program:

p=[1 1];

q=[2 5 5 0]; sys=tf(p,q); sisotool(sys)

Page 31: Control System Lab Report

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.

Page 32: Control System Lab Report

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 ( ) times the magnitude of the

error plus the integral gain ( ) times the integral of the error plus the derivative gain ( ) times the derivative of the

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:

Page 33: Control System Lab Report

C = pid(Kp,Ki,Kd)

C =

1

Kp + Ki * --- + Kd * s

s

with Kp = 1, Ki = 1, Kd = 1

Continuous-time PID controller in parallel form.

Automatic PID Tuning

MATLAB provides tools for automatically choosing optimal PID gains which makes the trial and error process described

above unnecessary. You can access the tuning algorithm directly using pidtune or through a nice graphical user

interface (GUI) using pidtool.

The MATLAB automated tuning algorithm chooses PID gains to balance performance (response time, bandwidth) and

robustness (stability margins). By default the algorthm designs for a 60 degree phase margin.

Let's explore these automated tools by first generating a proportional controller for the mass-spring-damper system by

entering the following commands:

The Characteristics of P, I, and D Controllers

A proportional controller ( ) will have the effect of reducing the rise time and will reduce but never eliminate

the steady-state error. An integral control ( ) 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 ( ) will have the effect of increasing

the stability of the system, reducing the overshoot, and improving the transient response.

The effects of each of controller parameters, , , and on a closed-loop system are summarized in the table

.

Page 34: Control System Lab Report

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

Note that these correlations may not be exactly accurate, because , , and are dependent on each other. In

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.

The modeling equation of this system is

Taking the Laplace transform of the modeling equation, we get

The transfer function between the displacement and the input then becomes

Let

M = 2 kg

b = 5 N s/m

k = 25 N/m

F = 4 N

Plug these values into the above transfer function

X(s) / F(s) = 1 / 2s^2+5s+25

Page 35: Control System Lab Report

The goal of this problem is to show you how each of , and contributes to obtain

Fast rise time

Minimum overshoot

No steady-state error

Open-Loop Step Response

Let's first view the open-loop step response. Create a new m-file and run the following code:

s = tf('s');

P = 1/(2*s^2 + 5*s + 25);

step(P)

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:

Page 36: Control System Lab Report

X(s) /F(s) = Kp / 2s^2+5s+(25+Kp)

Let the proportional gain ( ) equal 300 and change the m-file to the following:

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

----------------

2 s^2 + 5*s + 325

Continuous-time transfer function.

Page 37: Control System Lab Report

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 equal 300 as before and let equal 20

Kp = 300;

Kd = 20;

C = pid(Kp,0,Kd)

T = feedback(C*P,1)

t = 0:0.01:2;

step(T,t)

T =

20 s + 300

-----------------

2 s^2 + 25 s + 325

Page 38: Control System Lab Report

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 to 30, and let equal 70.

Kp = 30;

Ki = 70;

C = pid(Kp,Ki)

T = feedback(C*P,1)

t = 0:0.05:5;

step(T,t)

Page 39: Control System Lab Report

Continuous-time PI controller in parallel form.

T =

30 s + 70

------------------------

s^3 + 5 s^2 + 55 s + 70

Continuous-time transfer function.

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:

Page 40: Control System Lab Report

After several trial and error runs, the gains = 350, = 300, and = 50 provided the desired response. To

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)

Continuous-time PID controller in parallel form.

Comment:

After several trial and error runs, the gains = 350, = 300, and = 50 provided the desired response.

Now, we have obtained a closed-loop system with no overshoot, fast rise time, and no steady-state error.

Which is our desired response.

Page 41: Control System Lab Report

General Tips for Designing a PID Controller

When you are designing a PID controller for a given system, follow the steps shown below to obtain a desired response.

1. Obtain an open-loop response and determine what needs to be improved

2. Add a proportional control to improve the rise time

3. Add a derivative control to improve the overshoot

4. Add an integral control to eliminate the steady-state error

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.