Sei sulla pagina 1di 144

LABORATORY MANUAL

CONTROL SYSTEMS
(EEE 325)
ENGR. NASEER ALI BAJWA

Department of Electrical Engineering


COMSATS Institute of Information Technology
Lahore Campus
0
LIST OF EXPERIMENTS
LAB 1. MATLAB REVIEW FOR CONTROL SYSTEMS 1

1.1 Matlab Variables 1


1.2 Plotting in Matlab 6
1.3 Polynomials in Matlab 6
1.4 Laplace Transform 10
1.5 Scripts, Functions and Flow Control 13

LAB 2. MATHEMATICAL MODELING OF PHYSICAL SYSTEMS 21

2.1 Modeling a Translational Mechanical System 22


2.2 Modeling an Electrical System 26
2.3 Modeling an Electronic System 28

LAB 3. SIMULATION OF LTI SYSTEMS 31

3.1 The Block Diagrams 33


3.2 Simulation in Matlab 38
3.3 Design and Simulation in Simulink 43

LAB 4. PERFORMANCE PARAMETERS OF A CONTROL SYSTEM 49

4.1 Time Domain Specifications 49


4.2 Review Examples 52

LAB 5. DC MOTOR CHARACTERISTICS 61

5.1 Modeling of Armature-Controlled DC Motor 62


5.2 Building Model in Simulink 64

LAB 6. CHARACTERISTICS OF FEEDBACK CONTROL SYSTEMS 71

6.1 Speed Tachometer System 72


6.2 English Channel Boring Machines 75
6.3 System Sensitivity to Plant Variations 79

LAB 7. STABILITY OF CONTROL SYSTEM 83

7.1 Routh-Hurwitz Stability Method 84

ii
7.2 Design Problem: Tracked Vehicle Turning Control 86

LAB 8. THE ROOT LOCUS METHOD 91

8.1 Obtaining a Root Locus 92


8.2 Constant ζ and Constant ωn Loci 96
8.3 Design Using Root Locus 98

LAB 9. CONTROLLER DESIGN VIA ROOT LOCUS 105

9.1 Preliminary Design Consideration 106


9.2 Lead Compensator Design 108
9.3 Lag Compensator Design 115

LAB 10. INTRODUCTION TO PID CONTROLLERS 123

10.1 Theory of Three-Term Controller 124


10.2 Design Problem: Ball & Beam System 131

iii
Lab Session 1: MATLAB Review for Control Systems

LAB SESSION 1:

MATLAB REVIEW FOR CONTROL


SYSTEMS
Pre Requisites:
The students are expected to be competent in opening and closing the MATLAB.

Objectives:
This lab presents a brief revision of MATLAB environment. It also provides
tutorial on variables, vectors, matrices, basic linear algebra, plotting and flow
control in MATLAB.

Deliverables:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

Introduction:
In this exercise you will be introduce to the concept of mathematical
programming using MATLAB. We shall study how to define variables, handle
matrices and see how we can plot results and write simple MATLAB codes to
perform our desired task.

1.1 MATLAB VARIABLS


MATLAB stands for MATrix LABoratory and it was designed to make matrix
computation particularly easy. The basic data type of MATLAB is, thus, Matrix.
There is no need to declare a variable in MATLAB before it can be used, as in the
case of other high level programming languages like, C, Basic or Java etc. The
user just writes the names of the variable and assigns it a value.

1 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

variable_name = value
variable_name = expression

There are, however, some rules that must be followed, while naming the
variables, such as;

 Variable name must start with a letter


 It may contain only letters, digits, and the underscore “_”
 MATLAB 2010 only recognizes the first 63 characters in a variable name

Note that MATLAB is case sensitive, i.e. one & OnE are different variables.

SOME SPECIAL VARIABLES:


 ans: default variable name for the result
 pi: = 3.1415926…………
 eps: = 2.220446049250313e-016, smallest amount by which 2 numbers
can differ in MATLAB
 Inf or inf : infinity
 NaN or nan: not-a-number
 j or i: Mathematical iota

Note: By default MATLAB uses double-precision for floating point numbers.


MATLAB does its internal arithmetic in IEEE floating point precision using 16
decimal digits, but the default display is only 5 decimal digits. The display can
be changed from the default display (format short) to 15 digit display with
exponent by the following command:

>> format long

To go back to the normal 5-digit display use;


>> format short

For more sub-option of format command write;

>> help format

1.1.2 VECTORS
A row vector in MATLAB can be created by an explicit list, starting with a left
square bracket, entering the values separated by spaces (or commas) and
closing the vector with a right square bracket. A column vector can be created
the same way, and the rows are separated by semicolons.
2 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

>> x = [ 0 0.25*pi 0.5*pi 0.75*pi pi ]


x =
0 0.7854 1.5708 2.3562 3.1416

>> y = [ 0; 0.25*pi; 0.5*pi; 0.75*pi; pi ]


y =
0
0.7854
1.5708
2.3562
3.1416

ARRAY ADDRESSING:
A vector element is addressed in MATLAB with an integer index enclosed in
parentheses like;

>> x(3)
ans =
1.5708

The colon notation may be used to address a sub-array of elements.

(start : increment : end)

Where start is the starting index, increment is the amount to add to each
successive index, and end is the ending index. A shortened format (start:end)
may be used if increment is 1. Verify the following code and outcomes.

>> x = [ 1.0000 2.5000 4.0000 5.5000 7.0000 8.5000 10.0000


11.5000 ];

>> x(1:4)
ans =
1.0000 2.5000 4.0000 5.5000

>>x(2:2:8)
ans =
2.5000 5.5000 8.5000 11.5000

Note that MATLAB index starts at 1 and the default increment in an array index
is also 1.

SOME USEFUL COMMANDS:


x = start:end creates row vector x starting with start,
counting by one, and ending at end

3 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

x = start:increment:end creates row vector x starting with start,


counting by increment, ending at or
before end

linspace(start,end,number) creates row vector x starting with start,


ending at end, having number elements

length(x) returns the length of vector x

y = x’ takes transpose of vector x

dot (x, y) returns the scalar dot product of the


vector x and y

1.1.3 MATRICES
A Matrix is a two-dimensional array, having multiple rows and multiple
columns. Similar to vector arrays;

 It begins with ‘[‘ and ends with ‘]’


 Spaces or commas are used to separate elements in a row
 Semicolon or enter key is used to separate rows

>> f = [ 1 2 3; 4 5 6]
f =
1 2 3
4 5 6

>> h = [ 2 4 6
1 3 5]
h =
2 4 6
1 3 5

MATRIX ADDRESSING:
Any element in a matrix can be accessed by

matrix_name (row, column)

Colon may be used in place of a row or column reference to select the entire
row or column. For example for the abovementioned matrix f;

>> f(:,1)
ans =
1
4
4 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

>> f(1,:)
ans =
1 2 3

SOME USEFUL COMMANDS:


zeros(n) returns an n x n matrix of zeros

zeros(m,n) returns an m x n matrix of zeros

ones(n) returns an n x n matrix of ones

ones(m,n) returns an m x n matrix of ones

rand(n) returns an n x n matrix of random numbers uniformly


distributed in the interval [0 1]

rand(m,n) returns an m x n matrix of random numbers uniformly


distributed in the interval [0 1]

size (A) for an m x n matrix A, returns the row vector containing the
number of rows and columns in matrix.

length(A) returns the larger of the number of rows or columns in A

B = A’ takes transpose of matrix A

eye(n) makes an n x n identity matrix

eye(m,n) makes an m x n matrix with ones on the main diagonal and


zeros elsewhere

A+B adds two matrices

A-B subtracts two matrices

B = αA multiplies matrix A with scalar α

A*B multiplies two matrices. Number of columns of A must be


equal to number of rows of B

B = inv(A) takes inverse of matrix A. A must be square matrix

rank(A) finds rank of A

B = A.^2 takes square of each element of A

C = A*A multiplies A with A. A must be a square matrix

5 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

det(A) finds determinant of square matrix A

1.2 PLOTTING IN MATLAB:


Try the following command in MATLAB to plot a single point.

>> z = 1 + 0.5j;
>> plot (z, ‘.’)

To plot curves following commands may be used.

plot (x,y) generates a linear plot of the values of x (horizontal


axis) and y (vertical axis)

semilogx (x,y) generates a plot of the values of x and y using a


logarithmic scale for x and a linear scale for y

semilogy (x,y) generates a plot of the values of x and y using a linear


scale for x and a logarithmic scale for y

loglog(x,y) generate a plot of the values of x and y using


logarithmic scales for both x and y

Multiple curves can be plotted on the same graph by using multiple arguments
in a plot command.

plot(x, y1, x, y2)

To plot curves on multiple windows use figure(n) command before each


plot() command and the corresponding figure will be labeled as figure (n)

For more information on 2D graphs type help graph2d in the command


window.

1.3 POLYNOMIALS IN MATLAB:


MATLAB provides functions for standard polynomial operations, such as
polynomial roots, evaluation, and differentiation. In addition, there are
functions for more advanced applications, such as curve fitting and partial
fraction expansion. We will learn some of them here.

6 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

SOME USEFUL COMMANDS:


w = conv(u,v) Multiplies two polynomials. Algebraically, convolution
is the same operation as multiplying the polynomials
whose coefficients are the elements of u and v

[q,r]=deconv(u,v) Divides u by v and stores quotient in q and remainder


in r

p = poly(r) takes a row vector r with specified roots and returns


corresponding polynomial p

k = polyder(p) returns the derivative of polynomial p

y = polyval(p,x) returns the value of a polynomial p of degree n


evaluated at x

y = polyvalm(p,X) evaluates a polynomial in a matrix sense. This is the


same as substituting matrix X in the polynomial p

r = roots(p) returns a column vector whose elements are the roots


of the polynomial p

Note: Symbolic Math Toolbox contains additional specialized support for


polynomial operations.

MATLAB represents polynomials as row vectors containing coefficients ordered


by descending powers. For example, consider the equation

( )

This is the celebrated example Wallis used when he first represented Newton's
method to the French Academy. To enter this polynomial into MATLAB, use

>> p = [1 0 -2 -5];

Now use roots function to find the roots of this polynomial and note them
down,

>> r = roots(p);

By convention, MATLAB stores roots in column vectors.

7 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

The function poly returns the polynomial coefficients. Try it and record the
output.

You may have noticed that poly and roots are inverse functions.

The poly function also computes the coefficients of the characteristic


polynomial of a matrix.

>>A = [1.2 3 -0.9 ; 5 1.75 6 ; 9 0 1];


>>poly(A)
ans =

The roots of this polynomial, computed with roots, are the characteristic roots,
or eigenvalues, of the matrix A. You may also use eig to compute the
eigenvalues of a matrix directly.

The polyval function evaluates a polynomial at a specified value. Evaluate the


above polynomial at two different values and write your commands and result
below.

It is also possible to evaluate a polynomial in a matrix sense. In this case the


equation ( ) becomes ( ) , where X is a square
matrix and I is the identity matrix. Now create a square matrix X and evaluate
the polynomial p at X.

8 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

Polynomial multiplication and division correspond to the convolution and


deconvolution. The functions conv and deconv implement these operations.
Consider the polynomials ( ) and ( ) . Compute
their product and save the result in c.

Now use deconvolution to divide back out of the product.

Explore the polyder() function using help command and use its all three
variants.

1.3.1 PARTIAL FRACTION EXPANSION


residue function finds the partial fraction expansion of the ratio of two
polynomials. This is particularly useful for applications that represent systems
in transfer function form. For polynomials b and a,

( )
( )

if there are no multiple roots. Here r is a column vector of residues, p is a


column vector of pole locations, and k is a row vector of direct terms.

9 | Page
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

>> b = [-4 8];


>> a = [1 6 8];
>> [r,p,k] = residue(b,a)

Right down the output.

Given three input arguments (r, p, and k), residue converts back to
polynomial form, try this out.

>> [b2,a2] = residue(r,p,k)

1.4 LAPLACE TRANSFORM


Calculating the Laplace F(s) transform of a function f(t) is quite simple in
MATLAB. MATLAB performs Laplace transform symbolically. Thus, you need to
first define the variables t and s as a "symbol". This is done by the command

>> syms t s

Next you define the function f(t). The actual command to calculate the
transform is

>> F = laplace(f,t,s)

Here is an example of the function f(t) defined as,

( )

>> syms t s
>> f=-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t);
>> F=laplace(f,t,s)

F =

5/(4*(s + 2)) + 7/(2*(s + 2)^2) - 5/(4*s)


10 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

To make the expression more readable one can use the commands simplify
and pretty.

>> simplify(F)

ans =
(s-5)/s/(s+2)^2

>> pretty(ans)

s - 5
----------
s (s + 2)2

which corresponds to F(s);

( )
( )

Alternatively, one can write the function f(t) directly as part of the Laplace
command:

>>F2=laplace(-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t))

SOME MORE EXAMPLES

Function MATLAB Code Output


syms t;
ans =
1 f(t) = t4 f = t^4;
24/s^5
laplace(f)

syms s;
ans =
2 ( ) g = 1/sqrt(s);
√ pi^(1/2)/t^(1/2)
laplace(g)

syms t a x; ans =
( )
3 f = exp(-a*t); 1/(a + x)
laplace(f,x)

12*s^2*laplace(y(t)
G =
4 ( ) , t, s) - 12*s*y(0)
laplace(12*diff(sym('y(t)'),2))
- 12*D(y)(0)

11 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

Note that in the last example, the function y(t) is defined as symbol with the
command sym. The number 2 in diff function means we wish to take the
second derivative of the function y(t).

1.4.2 INVERSE LAPLACE TRANSFORM


The command we use now is ilaplace. We also need to define the symbols t
and s. Let’s calculate the inverse of the previous function F(s),

( )
( )

>> syms t s
>> F=(s-5)/(s*(s+2)^2);
>> ilaplace(F)

ans =
-5/4+(7/2*t+5/4)*exp(-2*t)

>> pretty(ans)
- 5/4 + 7/2 t exp(-2 t) + 5/4 exp(-2 t)

Which corresponds to
( )

Alternatively one can write

>> ilaplace((s-5)/(s*(s+2)^2))

Here is another example.

( )
( )
( )
>> F=10*(s+2)/(s*(s^2+4*s+5));
>> ilaplace(F)

ans =
-4*exp(-2*t)*cos(t)+2*exp(-2*t)*sin(t)+4

12 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

SOME MORE EXAMPLES

Function MATLAB Code Output


syms s;
ans =
1 ( ) f = 1/s^2;
t
ilaplace(f)

syms a t;
ans =
2 ( ) g = 1/(t-a)^2;
( ) pi^(1/2)/t^(1/2)
ilaplace(g)

syms x u;
ans =
( ) syms a real;
3 sinh(a*x)/a
f = 1/(u^2-a^2);
simplify(ilaplace(f,x))

ans =
ilaplace(1/s-
4 ( ) 1/exp(5*t) -
2/(s+4)+1/(s+5))
2/exp(4*t) + 1

1.5 SCRIPTS, FUNCTION AND FLOW CONTROL


MATLAB is a powerful programming language and an interactive computational
environment. Files that contain code in the MATLAB language are called M-files.
You create M-files using a text editor, and then use them as you would use any
other MATLAB function or command. There are two kinds of M-files:

1.5.1 SCRIPTS:
Script files do not accept input arguments or return output arguments. They
operate on data in the base workspace, the same workspace that command
window uses. MATLAB provides a full programming language that enables you
to write a series of MATLAB statements into a file and then execute them with a
single command. You write your program in an ordinary text file, giving the file
a name, say, ‘filename.m’. The term you use for ‘filename’ becomes the new
command that MATLAB associates with the program. The file extension of .m
makes this a MATLAB M-file. When you invoke a script, MATLAB simply executes
the commands found in the file.

13 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

Scripts can operate on existing data in the workspace, or they can create new
data on which to operate. Although scripts do not return output arguments,
any variables that they create remain in the workspace, to be used in
subsequent computations. In addition, scripts can produce graphical output
using functions like plot.

1.5.2 FUNCTIONS:
Functions are M-files that can accept input arguments and return output
arguments. The names of the function file and of the function name should be
the same. Functions operate on variables within their own workspace, separate
from the workspace you access at the MATLAB command prompt. An example is
provided below:

function f = fact(n) Function definition line


% Compute a factorial value. H1 line
% FACT(N) returns the factorial of N, Help text
% usually denoted by N!
% Put simply, FACT(N) is PROD(1:N). Comment
f = prod(1:n); Function body

The first definition line of a function M-file starts with the keyword function. It
gives the function name, number and order of input/output arguments. In the
above example, there is one input argument, n, and one output argument, f.
The next several lines, up to the first blank or executable line, are comment
lines that provide the help text. These lines are printed when you type help
fact. The first line of the help text is the H1 line, which MATLAB displays when
you use the lookfor command or request help on a directory. The rest of the
file is the executable MATLAB code defining the function.

The variable n & f introduced in the body of the function as well as the
variables on the first line are all local to the function; they are separate from
any other variables in the MATLAB workspace. This example illustrates one
aspect of MATLAB functions that is not ordinarily found in other programming
languages — variable number of arguments. Many M-files work this way. If no
output argument is supplied, the result is stored in ans. If the second input
argument is not supplied, the function computes a default value.

14 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

1.5.3 FLOW CONTROL


This section covers those MATLAB functions that provide conditional program
control.

IF-ELSE-ELSEIF

The if statement evaluates a logical expression and executes a group of


statements when the expression is true. The optional elseif and else
keywords provide for the execution of alternate groups of statements. An end
keyword, which matches the if, terminates the last group of statements. The
groups of statements are delineated by these four keywords — no braces or
brackets are involved.

It is important to understand how relational operators and if statements work


with matrices. When you want to check for equality between two variables, you
might use

if A == B

This is valid MATLAB code, and does what you expect when A and B are scalars.
But when A and B are matrices, A == B does not test whether they are equal, it
tests where they are equal; the result is another matrix of 0's and 1's showing
element-by-element equality. In fact, if A and B are not the same size, then A ==
B is an error. Write this code and record output

>>A = magic(4);
>>B = A;
>>B(1,1) = 0;
>>A == B

The proper way to check for equality between two variables is to use the
isequal() function:

if isequal(A, B)

isequal() returns a scalar logical value of 1 (representing true) or 0 (false),


instead of a matrix, as the expression to be evaluated by the if function. Try
this code using the A and B matrices from above

>>isequal(A, B)

15 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

ans =
0

Here is another example to emphasize this point. If A and B are scalars, the
following program will never reach the "unexpected situation". But for most
pairs of matrices, including our magic squares with interchanged columns,
none of the matrix conditions A > B, A < B, or A == B is true for all elements
and so the else clause is executed:

if A > B
'greater'
elseif A < B
'less'
elseif A == B
'equal'
else
error('Unexpected situation')
end

SWITCH AND CASE


The switch statement executes groups of statements based on the value of a
variable or expression. The keywords case and otherwise delineate a group.
Only the first matching case is executed. There must always be an end to
match the switch. An example is shown below.

n=5
switch rem(n,2) % to find remainder of any number ‘n’
case 0
disp(‘Even Number’) % if remainder is zero
case 1
disp(‘Odd Number’) % if remainder is one
end

Unlike the C language switch statement, MATLAB switch does not fall through.
That is, if the first case statement is true, the other case statements do not
execute. So, break statements are not required.

FOR AND WHILE LOOPS


The for loop is used to repeat a group of statements for a fixed, predetermined
number of times. A matching end complements the statements.

for n = 1:4
16 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

r(n) = n*n; % square of a number


end
r

The semicolon terminating the inner statement suppresses repeated printing,


and the r after the loop displays the final result.

The while loop repeats a group of statements indefinite number of times under
control of a logical condition. So a while loop executes at least once before it
checks the condition to stop the execution of statements. A matching end must
complement the statement. Syntax is given below.

while <condition>
<statements>;
end

BREAK AND CONTINUE


The break statement lets you exit early from a for loop or while loop. In nested
loops, break exits from the innermost loop only. The continue statement
passes control to the next iteration of the for loop or while loop in which it
appears, skipping any remaining statements in the body of the loop. The same
holds true for continue statements in nested loops. That is, execution
continues at the beginning of the loop in which the continue statement was
encountered.

17 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

EXERCISE 1:
Explore magic() command of MATLAB. Try A = magic(5), record your output
and explain.

EXERCISE 2:
Consider two polynomials ( ) and ( ) . Using MATLAB,
find

 p(s)*q(s)
 Roots of p(s) and q(s)
 p(-1) and q(6)
Write code and record output.

EXERCISE 3:
Use MATLAB to find partial fraction of the following

( )

( )
( )

( ) ( )
EXERCISE 4:
Use MATLAB to generate the first 100 terms in the sequence a(n) define
recursively by

( ) ( ) ( ( ))

with p=2.9 and a(1) = 0.5.

EXERCISE 5:
Use for or while loop to convert degrees Fahrenheit to degrees Celsius using
the following equation

Use any starting temperature, increment and ending temperature (example:


starting temperature=0, increment=10, ending temperature = 200).

18 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 1: MATLAB Review for Control Systems

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

19 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

Lab Session 2:

MATHEMATICAL MODELIN G OF
PHYSICAL SYSTEMS
PREREQUISITES:
The students are expected to be familiar with MATLAB environment in addition
to the understanding of physical laws governing electrical, mechanical and
translational systems.

OBJECTIVES:
The objective of this lab is to be able to develop mathematical models of
physical systems such as electrical circuits or mass-spring translational
systems.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
“All models are wrong but some are useful”
(George Box)
Mathematical Modeling means describing a physical system using
mathematical concepts and language. It is the first step in studying the
behavior of the system at hand. These mathematical models help the designers
in not only analyzing an existing system but also designing new systems with
more desirable behavior as per the specific needs of an application.
Unfortunately we can never make a completely precise model of a physical
system. There are always phenomena which we will not be able to model. Thus,
there will always be model errors or model uncertainties. But even if a model

21 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

describes just a part of the reality it can be very useful for analysis and design
— if it describes the dominating dynamic properties of the system.

There may be various representations of a mathematical model for a system


each with their own inherent advantages. After modeling a system we will learn
two representations of the developed model. Either representation gives us
insight into the system from a different perspective.

2.1 MODELING A TRANSLATIONAL MECHANICAL


SYSTEM
A shock absorber, commonly found in motorbikes and automobile, can be
represented by a mass-spring system shown in figure 2.1. This system can be
mathematically modeled by Newton’s second law of motion which states that

the acceleration a of a body is parallel and directly proportional to the net force
F acting on it and inversely proportional to the mass M of the body. Let we
apply a force Fa(t) on the mass M and displace it from its mean position, say

22 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

x0, to a new position, say x1. At this point there will be other forces acting on
the mass M besides our applied force.

One of these three forces is Friction Force, Ff(t). For the simplicity we assume
here that the wall friction b is a viscous damper, that is, the friction force is
linearly proportional to the velocity of the mass. In reality, however, this friction
force may behave as a coulomb damper, also known as dry friction, which is a
nonlinear function of the mass velocity. For a well-lubricated, sliding surface,
the viscous friction is an appropriate approximation. Hence for friction force,
Ff(t), we can write that

( ) ( ) (2.1)

This friction force will obviously be in the reverse direction of applied force.

Another force acting on the mass is the spring force which is also in the
opposite direction to the applied force. According to Hook’s Law the extension
of a spring is directly proportional to the applied load as long as the load does
not exceed spring’s elastic limits. Mathematically Hook’s law can be stated as

( ) ( ) (2.2)

Here Fs(t) is spring force, k is the spring constant and x is the displacement as
a result of applied force.

Finally from Newton’s second law of motion we know that

∑ (2.3)

from figure 2.1(b) we note that there are a total of three forces acting on the
mass M. So,

∑ (2.4)

Putting (1), (2), and (4) in (3) and rearranging the term, we get

( ) ( ) (2.5)
( ) ( )

Equation (5) is a second-order linear constant-coefficient differential equation


which completely models the behavior of the given shock absorber system.

23 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

2.1.1 TRANSFER FUNCTION REPRESENTATION


A transfer function is a mathematical representation of the relationship
between the input and output of a system. This function allows separation of
the input, system, and the output into three separate and distinct parts. The
function also allows us to algebraically combine mathematical representations
of subsystems to yield a total system representation. The general form of a
transfer function, H(s), is,

( )
( )
( )

Where R(s) is and E(s) are Laplace Transforms of Response (output) and
Excitation (input) respectively.

Converting differential equation labeled by (5) into transfer function


representation greatly eases the manipulation of the model and gives extended
liberty to investigate various hidden aspects of the system in rather greater
detail. To make transfer function out of equation (5) first we need to identify
input and output variables from the model and then we need to take Laplace
Transform of the equation.

For the system given above we take applied force Fa to be input to the system
and let displacement x(t) be out output. So after taking Laplace transform we
get the following expression assuming zero initial conditions.

( ) ( ) ( ) ( ) (2.6)

( ) ( ) ( ) (2.7)

( )
Hence the transfer function will be,
( )

( ) (2.8)
( )

To represent this transfer function in MATLAB we need to store its numerator


and denominator coefficients in two separate vectors like

>> M = 200; b = 25; k = 10;


>> num = [0 0 1];
24 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

>> den = [M b k];

Now use tf command as follows

>> sys = tf(num, den)

You will get the following output

Transfer function:

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

200 s^2 + 25 s + 10

If we have a transfer function object sys and we want to find the numerator
and denominator polynomials we can use the following command

>> [num, den] = tfdata(sys)

Please note that in transfer function model you have direct control over
coefficients or weights of each and every term involved in the system. By
changing these parameters we can observe the change in the system response.
You may remember from your DSP course that these weights in a filter transfer
function are of utmost importance and having direct access to these
coefficients means that you can easily change the gain response of the filter as
per you requirement.

2.1.2 POLE-ZERO-GAIN REPRESENTATION


While transfer function allows us to examine the effects of coefficients of a
system, it does not give any explicit information about the poles and zeros of
the system. Poles and zeros are vital parameters for determining system’s
stability and they can never be overlooked. We can find the poles and zeros of
any system either by applying roots() function on numerator and
denominator polynomials separately or by using pole() and zero() functions
as

>> p = pole(sys)
>> z = zero(sys)

We can also use pzmap() function to find both poles and zeros in one go as

>> [p, z] = pzmap(sys)

25 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

When used without left-hand-side arguments, pzmap() command plots the


poles and zeros in s-plane where poles are represented by cross (×) and zeros
are shown by circles (o).

We can also store the complete system in pole-zero-gain form in a single object.
Explore the following command

>> sys2 = zpk(z,p,k)

This command will create and store a mathematical model by using given
locations of zeros (stored in z vector), poles (stored in p vector) and a scalar
value k.

We can infer from the above command that this model gives direct access to
the poles’ and zeros’ locations and designer can easily change these locations
to study the response and stability of a system.

As with transfer function model we have a reciprocal command for zpk()


function that takes system object as an input and returns zeros, poles and
gain.

>> [z,p,k] = zpkdata(sys1)

However there are commands that can transform one model representation to
the other. Explore the following commands

[z,p,k] = tf2zp(num, den)

[num,den] = zp2tf(z,p,k)

2.2 MODELING AN ELECTRICAL SYSTEM


Now let’s take an example of commonly used electrical circuit and try to
develop its mathematical model. Given below is a series RLC circuit. By
applying Kirchhoff’s voltage law in the single loop, we obtain

(2.9)

26 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

If we are interested in observing the capacitor voltage then our output will be

(2.10)

Taking Laplace transform of (9) and (10) will yield,

(2.11)
( ) ( ) ( ) ( )

(2.12)
( ) ( )
Now dividing (12) with (11) will result in the transfer function of this RLC
Circuit

( ) (2.13)
( )

You can now describe this system in MATLAB either by tf() command or zpk()
command.

2.2.1 TRANSFER FUNCTION OF CASCADED ELEMENTS


Many feedback systems have components that load each other. Consider the
system shown in Figure 2.3. Assume that ei is the input and eo is the output.
The Capacitances C1 and C2 are not charged initially. It will be shown that the
second stage of the circuit (R2C2 portion) produces a loading effect on the first
stage (R1C1 portion). The transfer function of this network is calculated below.
The derivation of this transfer function is left as a home assignment.

27 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

( ) (2.14)
( ) ( )( )

Kindly note that R1C1s in the denominator of the transfer function represents
the interaction of two simple RC circuits. If this term were not present in the
transfer function then this system could be modeled as cascade of two RC
circuits but in this case it’s not possible. The reason for this is that, when we
derive the transfer function for an isolated circuit, we implicitly assume that
the output is unloaded. In other words the load impedance is assumed to be
infinite, which means that no power is being withdrawn at the output. When
the second circuit is connected to the output of the first, however, a certain
amount of power is withdrawn, and thus the assumption of no-loading is
violated. However, if the input impedance of the second system is infinite (or
sufficiently large), the output of the first system is not affected by connecting it
to the second system. Then the overall transfer function of the whole system
can be thought of as the product of the two transfer functions corresponding to
the individual systems. Alternatively, we can introduce an isolating amplifier
for impedance matching between the two cascaded stages.

2.3 MODELING AN ELECTRONIC SYSTEM


In today’s industry almost all of the controllers are electronic in nature.
Operational Amplifiers are the most common circuit elements that are used in
these controllers. Besides controllers, many of the control system elements are
implemented using Op-Amps. In this section we shall discuss electronic
controllers using operational amplifiers.
28 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

Operational Amplifiers are frequently used to amplify signals in sensor circuits.


They are also used in filters for compensation purpose. Another beauty of Op-
Amps is that they can be easily cascaded with other circuits because of their
relatively high (near to infinity) input impedance.

Consider simple Op-Amp circuits shown above in Figure 2.4. The configuration
in Figure 2.4(a) is known as an integrator because it integrates the given signal
over time and the circuit in 2.4(b) is a diffentiator. These two circuits along with
the most basic configuration of Op-Amp as an amplifier constitute majority of
the electronic controllers commonly referred to as PID controllers (PID stands
for Proportional plus Integral plus Differential). PID controllers will be studied
in depth in the forthcoming labs. For now, let’s find transfer function for these
simple controllers.

An important fact about Op-Amps to remember is that as their input


impedance is very high so the current going into the Op-Amp is normally
negligible. Also the voltage difference at the terminals of Op-Amp is nearly zero.
Considering these characteristics we can write input and output equations for
Op-Amp as follows,

(2.15)

( )

As no current flows into the Op-Amp, we can say that , hence

( ) (2.16)

29 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

Since , so

( ) (2.17)

Taking Laplace transform and rearranging the terms gives the transfer
function.

(2.18)

(2.19)

Similarly we can find the transfer function of Differentiator as

(2.20)

Derivation of this differentiator is left as a home assignment.

30 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

EXERCISE 1:
Develop mathematical model of the following lead-lag network. Represent this
model in both transfer function form and pole-zero-gain form.

EXERCISE 2:
The output of the above network is inverted. This is normally rectified by
cascading an inverting amplifier at the output of the lead-lag network as shown
below. Find the overall transfer function of two cascaded system.

31 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 2: MATHEMATICAL MODELING OF PHYSICAL SYSTEMS

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

32 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Lab Session 3:

SIMULATION OF LTI SYSTEMS


PRE REQUISITES:
The students are expected to have basic understanding of block diagram
representation. As for MATLAB, firm understanding of Lab 1 is expected.

OBJECTIVES:
This lab starts with block diagram reduction techniques, and their MATLAB
implementation. The simulation of a given system against simple inputs is then
presented. Finally, an introduction to Simulink is given to familiarize the
students with modeling and simulation in graphical environment.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
In this exercise our prime objective is to simulate Linear Time-Invariant
Systems. We will start by understanding the interconnection of various system
components and methods to reduce a rather complex-looking system to a
simple transfer function. These techniques facilitate the control engineers to
analyze the whole system as a single unit and study its overall behavior.

3.1 THE BLOCK DIAGRAMS


A block diagram is a specialized, high-level type of flow chart. Its highly
structured form presents a bird’s eye view of major process steps and key
process participants, as well as their relationships and interfaces involved.

33 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Various components in a system may be related to one another in different


fashions, like series, parallel, or feedback. We shall first learn how to deal with
these relations in MATLAB.

3.1.1 SERIES FUNCTION:


Two or more blocks are said to be connected in series only if the output of one
block is not affected by the next following block. Any number of cascaded
blocks representing non-loading components can be replaced by a single block,
the transfer function of which is simply the product of the individual transfer
functions. Figure 3.1 shows a system comprising of two subsystems,

represented by their transfer functions G1(s) and G2(s), connected in series.

Let the G1(s) is of the form,

( )

And G2(s) is

( )

Then the overall transfer function, T(s), can be represented by,

( )

If we know the transfer functions of the subsystems, G1(s) and G2(s), then we
can find the transfer function of T(s) by using the following MATLAB command.

>> sys = series (sys1, sys2)

3.1.2 PARALLEL FUNCTION:


Block diagrams quite often have transfer functions in parallel configuration as
shown in figure 3.2.
34 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

To solve this problem we use the following MATLAB command,

>> sys = parallel(sys1, sys2)

It will consume both transfer functions and the summing junction and give a
single block between U(s) and Y(s) equivalent to the consumed components

3.1.3 FEEDBACK SYSTEM:


Feedback paths are present in every other control system. They enable us to
continuously monitor the response of a system and make necessary changes in
the reference input to get the desired output. Figure 3.3 shows a typical control
system with G2(s) in feedback path.

The overall transfer function of this system can be calculated as,

( ) ( )
( )
( ) ( ) ( )

MATLAB command feedback is used to resolve transfer functions connected in

35 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

feedback style.

>> sys = feedback(sys1,sys2)

By default feedback(sys1,sys2) assumes negative feedback and is


equivalent to feedback(sys1,sys2, -1). For positive feedback +1 has to be
written explicitly as third argument.

Now assume that G2(s) = 1, that means we have connected output back to the
input directly without any transfer function involved. It would result in a
special feedback loop, called unity feedback, as shown in figure 3.4. Total
transfer function, T(s), in this case would then be,

( ) ( )
( )
( ) ( )

Now we can use the same feedback command to calculate T(s),

>> sys = feedback(sys1, 1)

Here 1 represents unity feedback.

3.1.4 BLOCK DIAGRAM REDUCTION BY MOVING BLOCKS:


Before we finish this topic of block diagram reduction it should be explained
that abovementioned forms of subsystems interconnection are not always
obvious in a practical block diagram model. For example, in the feedback form,
if there is a pickoff point after the summing junction, we cannot use the
feedback command to reduce the loop to a single block. That signal
disappears, and there is no place to establish the pickoff point. We need to

36 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

move summing junction and/or pickoff points back or forth to save the signals.
Figure 3.5 illustrates the rules governing such movements.

37 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Use the block diagram algebra given in figure 3.5 to reduce the following block
diagram to a single block.

( )
Now use MATLAB to find the equivalent transfer function, , given that
( )

(Attach MATLAB code with your lab report)

3.2 SIMULATION IN MATLAB


Simulation means studying the system behavior without actually constructing
the system. In this section we will use MATLAB commands to find the response
of the systems, discussed in previous lab, against various simple inputs. We
will start by understanding some of the useful MATLAB commands for system
simulation and then we will apply these commands on our developed systems.

3.2.1 IMPULSE RESPONSE


As we already know that the impulse response of any LTI system is of utmost
importance because the Laplace transform of impulse response describes the
transfer function of the LTI system. An impulse is a signal of arbitrary
magnitude that lasts for very short interval of time. Ideally an impulse has
infinite magnitude and the time span for which it lasts is zero. If we have an
LTI system described by its transfer function in MATLAB as

>> LTIsys = tf(num, den);


38 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Then we can find the impulse response of such a system by using impulse
command

>> impulse(LTIsys)

The system represented by LTIsys may be continuous or discrete. The


duration of simulation is determined automatically to display the transient
behavior of the response.

There exists another variant of impulse command that allows us to observe the
impulse response over a specified duration of time. The variant is,

>> impulse(LTIsys,t)

This command sets the simulation horizon explicitly. We can specify either a
final time t = Tfinal (in seconds), or a vector of evenly spaced time samples
of the form

>> t = 0 : dt : Tfinal

For discrete systems, the spacing dt should match the sample period. For
continuous systems, dt becomes the sample time of the discretized simulation
model, so in this later case the choice of dt should be small enough to capture
transient phenomena.

To plot the impulse responses of several LTI models sys1,..., sysN on a


single figure, use

>> impulse(sys1,sys2,...,sysN)

>> impulse(sys1,sys2,...,sysN,t)

As with plot, we can specify a particular color, line style, and/or marker for
each system, for example,

>> impulse(sys1,'y:',sys2,'g--')

3.2.2 STEP RESPONSE


From a practical standpoint, knowing how the system will respond to a sudden
input is important because large and possibly fast deviations from the long
term steady state may have extreme effects on the component itself and on
other portions of the overall system dependent on this component.

39 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Furthermore, the overall system cannot proceed until the component's output
settles down to some vicinity of its final state, consequently delaying the overall
system response. Normally, knowing the step response of a dynamical system
gives information on the stability of such a system, and on its ability to reach
one stationary state when starting from another.

In MATLAB we use the following commands to find the step response of an LTI
system.

>> step(LTIsys)

This command plots the step response of an arbitrary LTI model. This model
can be continuous or discrete, and SISO or MIMO. The step response of multi-
input systems is the collection of step responses for each input channel. The
duration of simulation is determined automatically, based on the system poles
and zeros.

>> step(sys,t)

Similar to impulse command, step also has a variant to set the simulation
horizon explicitly. We can specify either a final time t = Tfinal (in seconds),
or a vector of evenly spaced time samples of the form t = 0 : dt : Tfinal.

To plot the step response of several LTI models sys1,..., sysN on a single
figure, use

>> step(sys1,sys2,...,sysN)
>> step(sys1,sys2,...,sysN,t)

All of the systems plotted on a single plot must have the same number of
inputs and outputs. We can, however, plot a mix of continuous- and discrete-
time systems on a single plot. This syntax is useful to compare the step
responses of multiple systems.

We can also specify a distinctive color, line style, marker, or all three for each
system. For example,

>> step(sys1,'y:',sys2,'g--')

plots the step response of sys1 with a dotted yellow line and the step response
of sys2 with a green dashed line.

40 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

When invoked with output arguments,

>> [y,t] = step(LTIsys)

return the output response y and the time vector t used for simulation. No plot
generates on the screen.

3.2.3 ARBITRARY RESPONSE


While impulse and step responses of any system are useful to study the system
behavior and stability in general, the type of inputs the system will be
subjected to, in practical scenarios, may be arbitrary in nature. To analyze the
system response against some particular signal, MATLAB provides us with lsim
command. The syntax of this command is as under,

>> lsim(LTIsys,u,t)

It produces a plot of the time response of the LTI model LTIsys to the input
vector u over time t. The vector t specifies the time for the simulation and
consists of regularly spaced time samples.

>> t = 0:dt:Tfinal

If the system is multi-input, we can make u as a matrix. In this case the matrix
u must have as many rows as time samples (length(t)) and as many columns
as system inputs. Each row u(i,:) specifies the input value(s) at the time
sample t(i).

The LTI model LTIsys can be continuous or discrete, SISO or MIMO. In


discrete time, u must be sampled at the same rate as the system (t is then
redundant and can be omitted or set to the empty matrix). In continuous time,
the time sampling dt=t(2)-t(1) is used to discretize the continuous model. If
dt is too large (undersampling), lsim issues a warning suggesting that we
should use a more appropriate sample time, but will use the specified sample
time.

>> lsim(sys1,sys2,...,sysN,u,t)

simulates the responses of several LTI models to the same input history t, u
and plots these responses on a single figure.

When invoked with left-hand arguments,

41 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

>> [y,t] = lsim(sys,u,t)

it returns the output response y and the time vector t used for simulation. No
plot is drawn on the screen.

As lsim command requires a user defined input vector u, let’s now see a couple
of techniques to construct this vector.

Suppose we want to simulate a system sys1 for an input defined as

( ) ( ) ( )

over an interval [0 - 4π]. We can do it as follows.

>> t = 0 : 0.02 : 4*pi;


>> u = 3*sin(t) – 0.75*cos(2*t);
>> lsim(sys1,u,t)

This will plot the system response to the given input over the given interval.

To construct periodic signals, MATLAB has a very handy command gensig. Its
syntax is,

>> [u,t] = gensig(type,tau)

This command generates a scalar signal u of class type and with period tau (in
seconds). The following types of signals are available.

'sin' Sine wave

'square' Square wave

'pulse' Periodic pulse

gensig returns a vector t of time samples and the vector u of signal values at
these samples. All generated signals have unit amplitude.

>> [u,t] = gensig(type,tau,Tf,Ts)

The abovementioned command also specifies the time duration Tf of the signal
and the spacing Ts between the time samples t.

Now that we have learnt how to apply various inputs to a given system, it’s
time to apply these commands to the systems developed in the previous lab.

42 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

3.3 DESIGN AND SIMULATION IN SIMULINK


Having studied how to model and simulate a physical system in MATLAB, let’s
draw our attention to MATLAB’s graphical simulation tool called Simulink.
Simulink is an environment for multi-domain simulation and Model-Based
Design for dynamic and embedded systems. It provides an interactive graphical
environment and a customizable set of block libraries that let us design,
simulate, implement, and test a variety of time-varying systems, including
communications, controls, signal processing, video processing, and image
processing.

Simulink can be invoked either by writing simulink in MATLAB Command


Window or by clicking Simulink icon on MATLAB Tool Bar.

Once we get Simulink Library Browser, a design can be developed and


simulated by following below mentioned steps.

1. Create a new block diagram by clicking File -> New -> Model
2. Rearrange the differential equation representing physical system in terms
of the highest derivative present in the equation. Make sure the highest
derivative has unit coefficient. For example to model the mass-spring
system described by equation (5) in the previous lab, we will rearrange
the equation as
( ) ( )
( ( ) ( ))
3. Identify the system components in your design. Find them from
appropriate library in Simulink Library Browser. Drag and Drop desired
components to the model file. For this mass-spring system we recognize
that;
a. Left-hand side term is equal to summation of three terms (two of
which are negative), so we need a summing component. Find it
under “Commonly Used Blocks” Library.
b. Two of the summing terms have weights i.e. they are multiplied by
some scalar coefficients. So we may need two scalar gain
components. We can find them under the same library as Gain
Components.

43 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

c. One of the summing terms is our input signal so we need a source.


All the input components are listed under “Sources” Library. For
now we will use Step input.
d. Second summing term is immediate lower derivate of left-hand side
term. We can get it by integrating left-hand side term. Select an
integrator from “Continuous” Library. As third term is immediate
lower derivative of the second term, so we may need another
integrator to achieve it.
e. To observe the output we need an Oscilloscope. Look for it in
“Sinks” Library.
4. Now that we have all of the desired components at hand, let’s join them
to complete the model. To do this, place your cursor over the output of a
block and drag it to the input of the other block to which you want it to
connect. Complete the design as shown below.

5. Set the design parameters. For this case double click step signal to set
an amplitude of 3 and step time equal to zero, set the coefficient values
as

M = 200 b = 25 k = 10

We can do it by double right clicking on the relevant parameters and


adjusting the appropriate values. Furthermore select the simulation time
to 100.

6. To run the simulation, simple click the run icon or selecting, from the
menu bar, Simulation -> Start. Double right click on the scope to observe
the output

44 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

3.3.1 VERIFYING SIMULATION RESULTS


The results obtained in MATLAB or Simulink simulation should be compared to
the theoretical calculation to validate their accuracy. To do this we need to
know the general form of a second order feedforward system under no external
force, given as;

( ) ( )
( )
Compare this to rearranged equation of mass-spring system given below

( ) ( )
( )
We find that

Natural Frequency of the system is,

Damping Ratio of the system is, or


DC Gain of the system is,

Natural Frequency is the frequency of oscillation that occurs when the


damping equals zero. Damping Ratio is a measure of damping in the
oscillations. If , the system is said to be underdamped; if , the system
is said to be overdamped; and if , the system is called critically damped.
DC gain is the final value of the system response when time → ∞.

Calculate the values of , , and K and see if the simulation results are
correct.

Check out the following link to understand the relationship of these system
parameters on system response.

http://math.mit.edu/daimp/DampingRatio.html

45 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

EXERCISE 1:

(a) Obtain the impulse response of the following system

( )

(b) Obtain the step response of the following system

( )

(c) Explain why the results in (a) and (b) are same?

EXERCISE 2:
Design and simulate the RLC circuit given in last lab in MATLAB and Simulink
with the following input

( ) ( )

HINT: In Simulink you would need to add a DC source in an AC source to get


this input. DC source is referred to as “Constant” and AC source is called “Sine
Wave” in Simulink.

EXERCISE 3:
A system has a transfer function

( )
( )

Find the response of this system if the input is a ramp function with slop equal
to 4.

46 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 3: SIMULATION OF LTI SYSTEMS

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

47 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

Lab Session 4:

PERFORMANCE PARAMETERS OF
A CONTROL SYSTEM
PRE REQUISITES:
The students are expected to have firm understanding of block diagram
reduction techniques. As for MATLAB, they should be able to simulate any given
system against any input signal.

OBJECTIVES:
The objective of this exercise is to study the performance characteristics of first
and second-order systems using MATLAB.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
Primary concerns in control system design are performance and stability. In
order to design and analyze control systems, we must first establish adequate
performance specifications. Performance specifications can be presented in the
time domain or the frequency domain. Time-domain specifications generally
take the form of settling time, percent overshoot, rise time, and steady-state
error. Stability and frequency-domain specifications are addressed in coming
labs.

4.1 TIME-DOMAIN SPECIFICATIONS


Time-domain performance parameters are generally given in terms of the
transient response of a system to a given input signal. Since the actual input,

49 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

which the system will be subjected to in practice, is generally unknown, a


standard test input signal is used. The test signals are of the general form

( )

And the corresponding Laplace transform is

( )

When n = 1, 2 and 3, we have step, ramp, and parabolic inputs respectively. An


impulse function may also be used as a test signal.

The standard performance measures are usually defined in terms of the step
response and the impulse response. The most common step response
performance measures are percent overshoot (P.O), rise time (tr), peak time (tp),
settling time (ts) and steady-state error (ess) as shown in figure 4.1.

The performance parameters depicted in the figure above can be described as


follows.

50 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

4.1.1 RISE TIME


Rise time refers to the time required for a signal to rise from a specified low
value to a specified high value. Typically, these values are 10% and 90% of the
step height. The 0-100% rise time, Tr, measures the time to reach 100% of the
input magnitude. Alternatively, Tr1, may measure the time from 10% - 90% of
the response to the step input.

4.1.2 PEAK TIME


The peak time is the time required for the response to reach the highest peak of
the overshoot. Peak time is inversely proportional to the amount of overshoot.

4.1.3 SETTLING TIME


The time required for the system’s output to settle within a certain percentage
of the input amplitude (which is usually taken as 2%) is called settling time.
Settling time, Ts, is calculated as

4.1.4 OVERSHOOT
Overshoot is the maximum peak value of the response curve measured from
the desired response of the system. It is calculated as

Where Mp is the highest peak magnitude of output and fv is the final value of
the output.

4.1.5 STEADY-STATE ERROR


It is the difference between the desired final output and the actual one.
Practically this difference can never be reduced to zero. However, a suitable
tolerance range may be defined to assume that the system has reached its
desired value.

In MATLAB, we use stepinfo command to get all the step response parameters.

>> stepinfo(sys)

51 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

For a system defined as

>> sys = tf([0 0 1],[200 40 20]);

>> stepinfo(sys)

We will get the following output

ans =

RiseTime: 4.2568

SettlingTime: 35.3593

SettlingMin: 0.0438

SettlingMax: 0.0675

Overshoot: 35.0913

Undershoot: 0

Peak: 0.0675

PeakTime: 10.4917

4.2 REVIEW EXAMPLES


We shall now take some examples to review our concepts learnt so far. The
examples have been chosen to be practical and reflect real-world problems.

4.2.1 ELECTRIC TRACTION MOTOR CONTROL


If you ever have visited Khewra Salt Mines, you would definitely have caught
sight of a little electric train which was once used to draw salt out of the mine
but today it serves as a tourist transit train. The basic principle of such an
electric train is given in figure 4.2.

The substation at the right of figure 4.2 performs the task of taking the power
provided by an electric utility power plant and converting it into a form of
power that the electric rail car can use to operate its traction motors. The two
terminals of this substation are connected via a trolley wire and the two rails
that the train runs on. The electric train has a spring-loaded arm called a
pantograph on its roof that touches the trolley wire, allowing electrical current
to flow into a speed control system housed under the train. This speed control
52 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

system performs the task of varying the flow of electrical current to the traction
motors, enabling the car to move, before it eventually exits the motor through
its wheels, then back to the substation where it originated, thus completing an
electrical circuit.

The speed control system of an electric train is shown in figure 4.3. Our goal in
this problem is to find the closed-loop transfer function and investigate the
response of to a commanded . The first step in this direction would be to
apply block diagram reduction techniques learnt in previous labs to compute
the closed-loop transfer function . We observe that closed-loop
characteristic equation is second-order with and . Since the

53 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

damping is low, we might expect the response to be highly oscillatory as shown


in figure 4.4.

To quantitatively observe step response parameters of this system we may use


stepinfo command which, in this case, yields,

RiseTime: 0.0202

SettlingTime: 6.2294

SettlingMin: 0.0728

SettlingMax: 1.9624

Overshoot: 96.2920

Undershoot: 0

Peak: 1.9624

PeakTime: 0.0605

54 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

4.2.2 MOBILE ROBOT STEERING CONTROL


A severely disabled person could use a mobile robot as an assisting device or
servant. The steering control system for such a robot can be represented by the
block diagram shown in figure 4.5. The steering controller is

( )

We will later show that this G1(s) is a proportional plus integral (PI) controller.

When the input is a ramp signal, the steady-state error is

Here . The effect of the controller constant, , on the steady-state


error is evident from above equation. Whenever is large, the steady-state
error is small, and vice versa.

We can simulate the closed-loop system to a ramp input using the lsim
command. The controller gains , and the system gain can be
represented symbolically in the script so that various values can be selected
and simulated.

Show the simulation results for , and . Also determine


exact values of time-domain performance parameter of this system. (Attach
your code and results with your report)

Experimenting with this system by changing the control system’s error


constants, and reveals the ability of a system to reduce or eliminate the
steady-state error. Therefore, they are utilized as a numerical measure of the
steady-state performance. The designer determines the error constants for a
given system and attempts to find methods of increasing their values while

55 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

maintaining an acceptable transient response. In the case of steering control


system, we want to increase the gain factor in order to increase and
reduce the steady-state error. However, an increase in results in an
attendant decrease in the system’s damping ratio and therefore a more
oscillatory response to a step input is obtained. Thus, we want a compromise
that would provide the largest based on the smallest allowable.

56 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

EXERCISE 1:
Apply block diagram reduction techniques on model below to show that its
complete transfer function is

( )
( )

Attach MATLAB code with your report.

EXERCISE 2:
An electrical RC-circuit is the simplest example of a first order system. It
comprises of a resistor and capacitor connected in series to a voltage supply as
shown below. If and and we apply a DC voltage source of
8V, verify that capacitor’s charging curve follows the following proportions.

( )
( )
( )
( )
( )

57 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

EXERCISE 3:
To study the effects of damping ratio on the performance measures, consider
the following second-order single-loop unity feedback system.

Find the step response of the system for values of ωn = 1 and ζ = 0.1, 0.4, 0.7,
1.0 and 2.0.

Plot all the results in the same figure window and fill the following table.

Settling Percent Steady-


ζ Rise Time Peak Time
Time Overshoot State Error

0.1
0.4
0.7
1.0
2.0

58 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 4: PERFORMANCE PARAMETERS OF A CONTROL SYSTEM

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

59 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

Lab Session 5:

DC MOTOR CHARACTERIS TICS


PRE REQUISITES:
By now the students are expected to be able to derive mathematical models of
simple electrical and mechanical systems and build and simulate Simulink
models based on differential equation corresponding to the physical systems.

OBJECTIVES:
The objective of this experiment is to show how a permanent-magnet DC motor
may be controlled by varying the magnitude and direction of its armature
current and recognize its torque/speed characteristics.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results
INTRODUCTION:
DC motors that are used in feedback controlled devices are called DC
servomotors. Applications of DC servomotors abound, e.g. in robotics,
computer disk drives, printers, aircraft flight control systems, machine tools,
flexible manufacturing systems, automatic steering control etc. DC motors are
classified as armature-controlled DC motors and field-controlled DC motors.

This experiment will focus on modeling, identification, and position control of


an armature-controlled DC servomotor. In particular, we will first develop the
governing differential equations and the Laplace domain transfer function
model of an armature controlled DC motor. Next, we will tend to the
identification of the unknown system parameters that appear in the transfer
function model of the DC servomotor. Finally, we will develop and implement a
position-plus-velocity feedback controller to ensure that the DC motor angular
position response tracks a step command.

61 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

The motor, we would be discussing, is a permanent-magnet type and has a


single armature winding. Current flow through the armature is controlled by
power amplifiers as in figure 5.1 so that rotation in both directions is possible
by using one, or both of the inputs.

5.1 MODELLING OF ARMATURE-CONTROLLED


DC MOTOR
As the motor accelerates, the armature generates an increasing back-emf, ,
which tends to oppose the driving voltage . The armature current is thus
roughly proportional to . If the speed drops (due to loading) reduces,
the current increases and so does the motor torque. This tends to oppose the
speed drop. That is why this mode of control is called 'armature-control' and
gives a speed proportional to .

To derive a mathematical model for the motor under discussion, consider the
schematic shown in figure 5.2. As we know that a motor is an electro-
mechanical device so its mathematic model consists of two differential
equations each representing one of its aspects.

First, we observe that the torque of a permanent-magnet DC motor is directly


proportional to its armature current. Stating mathematically, we say,

( ) (5.1)

Here is motor torque constant.

We also note that the back-emf produced in armature-controlled DC motor is


directly proportional to the angular velocity of armature. Thus,

( ) (5.2)

62 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

Here is motor constant. In SI units, however, the value of and is equal.

When the motor rotates and produces a torque as given in equation 5.1, there
emerges a retarding torque, because of friction, in response to . If we assume
the friction to be viscous friction, as we assumed for the case of mass-spring
model in previous labs, we get

( ) (5.3)
Newton’s second law of motion, when translated into angular mechanics, takes
the following form.

∑ ( ) (5.4)
Here is moment of inertia and ( ) is angular acceleration. Putting value we
get
( )
( ) (5.5)
Or,
( )
( ( ) ( )) (5.6)
Equation 5.6 is the mechanical equation for an armature-controlled DC motor.

Now we turn to the electrical aspect of this motor. Applying Kirchhoff’s Voltage
Law to figure 5.2, we get,
( )
( ) (5.7)
Substituting equation 5.2 and rearranging the terms gives,

63 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

( )
( ( ) ( )) (5.8)
Equation 5.8 gives electrical equation of the motor. Combining these two
equations results in a complete model of armature-controlled DC motor.

5.2 BUILDING MODEL IN SIMULINK


Using equations 5.6 and 5.8 build a Simulink model. Feel free to ask your lab

instructor if you stuck anywhere. Your final model should look like the one
shown in figure 5.3.

Once the model is built, save it and run the following commands on MATLAB
command window.

>> J=3.2284E-6;
>> b=3.5077E-6;
>> Kt=0.0274;
>> Kb = 0.0274;
>> R=4;
>> L=2.75E-6;
64 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

To simulate this system, first an appropriate simulation time must be set.


Select Parameters from Simulation menu and enter "0.4" in the Stop Time
field. 0.4 seconds is long enough to view the open-loop response. Also in the
Parameters dialog box, it is helpful to change the Solver Options method.
Click on the field which currently contains "ode45 (Dormand-Prince)".
Select the option "ode15s (stiff/NDF)". Since the time scales in this
example are very small, this stiff system integration method is much more
efficient than the default integration method.

Now run the simulation (Ctrl-t or Start on the Simulation menu). When the
simulation is finished, double-click on the scope and hit its autoscale button.

5.2.1 EXTRACTING A LINEAR MODEL INTO MATLAB


A linear model of the system (in state space or transfer function form) can be
extracted from a Simulink model into MATLAB. This is done through the use of
In and Out Connection blocks and the MATLAB function linmod. First, replace
the Step Block and Scope Block with an In Connection Block and an Out
Connection Block, respectively (these blocks can be found in the Connections
block library). This defines the input and output of the system for the
extraction process.

Save your file as "DCmotor.mdl" (or any other name of your liking). MATLAB will
extract the linear model from the saved model file, not from the open model
window. At the MATLAB prompt, enter the following commands:

>> [A,B,C,D]=linmod('motormodel')
>> [num,den]=ss2tf(A,B,C,D)
>> sys = tf(num,den)

To verify the model extraction, you may generate an open-loop step response of
the extracted transfer function in MATLAB. Enter the following command.

>> step(sys)

You should get the same response as obtained from Simulink.

5.2.2 CREATING A FUNCTION BLOCK IN SIMULINK

65 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

We can encapsulate the whole Simulink model designed above in a single block
to be used as a component in subsequent designs. It enables us to abstract
unnecessary details of a subsystem and let us work with the block through its
interface only. To do so, remove the input(s) and output(s) of a Simulink model
and replace them with In and Out blocks. Now select the whole system and hit

on Create Subsystem option from Edit menu. Alternatively, you may right
click on the selected model and select Create Subsystem from the menu. The
complete model will be housed in a single block with input(s) and output(s)
going in and coming out of it as shown in figure 5.4.

Next, we need to set the parameters of this subsystem. To do this, select the
subsystem and click on Mask Subsystem from Edit menu. The following
window will appear as a result.

66 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

Select the Parameter tab and then click on the Add icon on top right corner of
the window. It will add a new parameter entry in Dialog Parameters table.
Write the name of the parameter, for your own reference, in prompt field and
give the very same variable as used in the model for this parameter in
variable field. Continue to declare all the parameters used in the design.
When finished, click on the Apply button and close the window.

Our model is now ready to use. Just double click on it to initialize the
parameter values and use it in any bigger system as a component. The
initialization window looks like the one shown below.

Apply step input to this block to verify that it gives the same output as
obtained from the original design.

67 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

EXERCISE 1:

Fill the following table for the DC Motor design developed above.

DC Voltage Max ( ) Max ( ) DC Voltage Max ( ) Max ( )

1 -1

2 -2

3 -3

4 -4

EXERCISE 2:
Interpret the results obtained in exercise 1 and draw a conclusion as to how to
control angular velocity and direction of rotation of an armature-controlled DC
motor.

EXERCISE 3:
Apply a 5V sinusoid signal with 50 Hz frequency to this model and observe
velocity and displacement response of the motor. Explain the motor response in
transient phase i.e. before 0.05 sec.

68 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 5: DC MOTOR CHARACTERISTICS

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

69 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

Lab Session 6:

CHARACTERISTICS OF
FEEDBACK CONTROL SYS TEM
PRE REQUISITES:
Students should have firm understanding of performance parameters and
simulation of systems against various inputs.

OBJECTIVES:
The objective of this exercise will be to study the effects of feedback on the
response of the system to step input and step disturbance taking the practical
example of English Channel boring machine and design a control system
taking into account performance measurement.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
We use feedback in a control system to

1. Decrease the sensitivity of the system to plant variations,


2. Enable adjustment of the system’s transient response,
3. Reject disturbance, and
4. Reduce steady-state tracking error.

The aforementioned advantages of feedback come at the cost of increased


number of components and system complexity, reduced closed-loop gain, and
the introduction of possible instabilities. However, the advantages of feedback
outweigh the disadvantages to such an extent that feedback control systems
are found everywhere. In this lab, the advantages of feedback are illustrated

71 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

with two examples. As always, our prime focus would be to emphasis the use of
MATLAB in the control system analysis.

6.1 SPEED TACHOMETER SYSTEM


A tachometer is an instrument designed to measure the rotation speed of an
object, such as a gauge in an automobile that measures the revolutions per
minute (RPMs) of the engine's crankshaft. The word "tachometer" is derived
from the Greek words tachos, meaning "speed," and metron, meaning "to
measure." The simplest realization of a tachometer is a small generator
attached to the motor shaft, and the RPM measurement is based on the electric
current generated by the device.

6.1.1 OPEN-LOOP DISTURBANCE RESPONSE


The open-loop block diagram description of the armature-controlled DC motor
with a load torque disturbance, ( ), is shown in figure 6.1. The values for
various parameters are given below.

We have two inputs to our system, ( ) and ( ). Relying on the principle of


superposition, which applies to all the LTI systems, we consider each input
separately. To investigate the effects of disturbance on the system, we
72 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

momentarily let ( ) and consider only the disturbance ( ). Conversely,


to study the response of the system to a reference input, we would let ( )
and consider only the input ( ). We have already found this system’s step
response, in absence of any disturbance, in the last lab. Here we will find the
transfer function of the system from ( ) to ( ) assuming applied voltage to
be zero.

Write the following script in an m-file and run it. You will get the response
shown in figure 6.2.

clc, clf

R = 1;
Kt = 10; Kb = 0.1;
b = 0.5; J = 2;

plant = tf([1],[J b])


gain = tf([Kt*(-Kb/R)],[1])
sys = feedback(plant,gain,+1)
sys = -sys

[yo,t] = step(sys);
plot(t,yo)
title('Open-Loop Disturbance Step Response')
xlabel('Time (sec)'), ylabel('Speed'), grid
yo(length(t))

73 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

Since our desired value of ( ) is zero because we haven’t applied any input
voltage ( ( ) = 0), the steady-state error is just the final value of ( ), which we
denote by ( ) to indicate open-loop. The steady-state error, shown on the plot
in figure 6.2, is approximately the value of the speed when t = 7 sec. We can
obtain an approximate value of the steady-state error by looking at the last
value in the output vector , which we generated in the process of making the
plot of figure 6.2. The approximate steady-state value of is

( ) ( ) rad/sec

6.1.2 CLOSED-LOOP DISTURBANCE RESPONSE


In a similar fashion, we begin the closed-loop system analysis by computing
the closed-loop transfer function from ( ) to ( ), and then generating the
time-response of ( ) to a unit step disturbance. Write MATLAB code to do the
job by yourself. Block diagram of the closed-loop speed tachometer system is
given in figure 6.3.

As before, the steady-state error is just the final value of ( ), which we denote
by ( ) to indicate closed-loop. The disturbance response is shown in figure
6.4. We might need following additional parameter values to generate this plot.

We notice that the value of steady-state error, in this case, is

( ) ( ) rad/sec
74 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

From figure 6.4 it is evident that not only the steady-state error has been
greatly reduced, but also the settling time of the system has decreased from
approximately 7 seconds to almost 0.02 seconds.

We have achieved a remarkable improvement in disturbance rejection. It is


clear that the addition of the negative feedback loop has reduced the effect of
disturbance on the output. This demonstrates the disturbance rejection
property of closed-loop feedback system.

6.2 ENGLISH CHANNEL BORING MACHINES


The construction of the tunnel under the English Channel from France to the
Great Britain began in December 1987. The first connection of the boring
tunnels from each country was achieved in November 1990. The tunnel is 23.5
miles long and bored 200 feet below sea level. Costing $14 billion, it was
completed in 1992 making it possible for a train to travel from London to Paris
in just three hours.

The machines operated from both ends of the channel and bored towards the
middle. To link up accurately in the middle of the channel, a laser guidance
system kept the machines precisely aligned. A model of the boring machine
control is shown in the figure 6.5, where ( ) is the actual angle of direction of

75 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

travel of the boring machine and ( ) is the desired angle. The effect of load on
the machine is represented by the disturbance ( ).

The response of the closed-loop system to both the inputs, considering them
simultaneously, can be given as

( ) ( ) ( )

The effect of the control gain K on the transient response is shown in figure 6.6
along with the script used to generate the plot.

k1 = 50; k2 = 100; k3 = 200;

den = [1 12 0];

sys1 = feedback((tf([k1], den)),1)


sys2 = feedback((tf([k2], den)),1)
sys3 = feedback((tf([k3], den)),1)

t = 0:0.05: 2;

[y1,t] = step(sys1,t);
[y2,t] = step(sys2,t);
[y3,t] = step(sys3,t);

subplot(3,1,1)
plot(t,y1)
title('Step Response for K = 50')
xlabel('Time (sec)')
ylabel('Y(s)')
76 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

grid
subplot(3,1,2)
plot(t,y2)
title('Step Response for K = 100')
xlabel('Time (sec)')
ylabel('Y(s)')
grid

subplot(3,1,3)
plot(t,y3)
title('Step Response for K = 200')
xlabel('Time (sec)')
ylabel('Y(s)')
grid

Comparing the three plots in figure 6.6, it can be seen that increasing K
increases the overshoot. Although it may not be obvious from the plot in figure
6.6, it is also true that increasing K decreases the settling time. This can be
verified by taking a closer look (at the command level) at the data used to
generate the plot. This example demonstrates how the transient response can
be altered by feedback control gain K. based on our analysis thus far, we would
prefer to use K = 50. However, there are other considerations that must be
taken into account before we can establish the final design.

77 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

Before making the final choice for K, it is important to consider the system
response to a unit step disturbance. This is shown in figure 6.7. We see that
increasing K reduces the steady-state response of Y(s) to the step disturbance.
The steady-state value of Y(s) is 0.02, 0.01, and 0.005 for K=50, 100, and 200
respectively.

Note that the steady-state values are predicted from the final value theorem as
follows:

( )
( )

If our only design consideration is disturbance rejection, we would prefer to us


K = 200.

We have just experienced a very common trade-off situation in control system


design. In this particular example, increasing K leads to better disturbance
rejection, while decreasing K leads to better performance (via less overshoot
and quicker settling time). The final decision on how to choose K rests with the
designer. So we see that while MATLAB can certainly assist us in the control
system design, it cannot replace our decision-making capability and intuition.

78 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

6.3 SYSTEM SENSITIVITY TO PLANT


VARIATIONS
Controller parameters are usually matched to the process characteristics and
since the process may change, it is important that the controller parameters
are chosen in such a way that the closed-loop system is not sensitive to the
variation in process dynamics. We will summarize this lab by looking at the
system sensitivity to changes in the plant. The system sensitivity is given by
the following equation.

( )
( ) ( )

Here G(s) is the plant and C(s) is the controller which is equal to K in our given
example. We can compute the value of S(s) for different values of s and
generate a plot of system sensitivity. For low frequency, we can approximate
the system sensitivity by

( )

Above equation shows that increasing the gain K reduces the system
sensitivity.

79 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

EXERCISE 1:

For the motor system given below, you need to design feedback such that the
overshoot is limited and there is less oscillatory nature in the response based
on the specifications provided below. Assume no disturbance.

Percent Overshoot : maximum 8%


Settling Time: maximum 400 ms

Use MATLAB, to find the system performance for different values of Ka and find
which value of the gain Ka satisfies the design conditions specified. Use the
following table.

Ka 20 40 60 80 100
PO
Ts

EXERCISE 2:
Consider the system given below.

a) Get the transfer function from R(s) to Y(s)

b) Get the transfer function from D(s) to Y(s)

80 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

c) Generate the system response; for K= 10, 20, 50, 100; due to a unit step
input, r(t)

d) Generate the system response; for K= 10, 20, 50, 100; due to a unit step
disturbance, d(t)

e) For each case find the percentage overshoot, rise time, settling time,
steady state of y(t)

f) Compare the results of the two cases

g) Investigate the effect of changing the controller gain on the influence of


the disturbance on the system output

Attach .m files and results along with your lab report.

81 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 6: CHARACTERISTICS OF FEEDBACK CONTROL SYSTEM

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

82 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

Lab Session 7:

STABILITY OF CONTROL SYSTEM


PRE REQUISITES:
This lab is based on Routh-Hurwitz stability criterion, so the students are
expected to have sound understanding of this method. They should be able to
construct Routh Array for any given characteristic equation.

OBJECTIVES:
The objective of this exercise is to verify the Routh-Hurwitz stability criterion
studied in theory class. Furthermore, this RH criterion will be exploited to find
the region of stability of any linear system.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
The stability of a closed-loop control system is a fundamental issue in control
system. Generally speaking, an unstable closed-loop control system is of little
practical value. For linear systems, a necessary and sufficient condition for a
feedback control system to be stable is that all the poles of the system transfer
function have negative real parts. In other words, the poles must lie in the left-
half plane for the system to be stable. The Routh-Hurwitz stability method
provides a structured mechanism for determining the number of unstable poles
of the closed-loop characteristic equation. This allows us to obtain a yes or no
answer to stability without explicitly calculating the values of poles.

In this lab we begin with a discussion of the Routh-Hurwitz stability method.


We will see how MATLAB can assist us in the stability analysis by providing an

83 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

easy and accurate method for computing the poles of the characteristic
equation.

7.1 ROUTH-HURWITZ STABILITY METHOD


The Routh-Hurwitz criterion is a necessary and sufficient criterion for stability.
Given a characteristic equation with fixed coefficients, we can use Routh-
Hurwitz method to determine the number of roots in the right-half plane. For
example consider the equation

( )

associated with the closed-loop control system shown in figure 7.1(a). The
corresponding Routh-Hurwitz array is shown in figure 7.1(b).

The two sign changes in the first column of figure 7.1(b) indicate that there are
two roots of characteristic polynomial in the right-half plane; hence the closed-
loop system is unstable. Using MATLAB we can verify the Routh-Hurwitz results
by directly computing the roots of the characteristic equation, as shown below.

>> num = [1]; den = [1 1 2 23];


>> sys = tf(num, den);
>> clsys = feedback(sys,1);
>> pole(clsys)

84 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

ans =

-3.0000
1.0000 + 2.6458i
1.0000 - 2.6458i

7.1.1 RANGE OF STABILITY


Whenever the characteristic equation is a function of a single parameter, the
Routh-Hurwitz method can be utilized to determine the range of values that the
parameter may take while maintaining stability. Consider the closed-loop
feedback system in figure 7.2. Its characteristic equation is

( )

Using a Routh-Hurwitz array shown above we find that we require


for stability. We can use MATLAB to verify this result graphically. A shown in the
script below, we establish a vector of values for K at which we wish to compute
the roots of the characteristic equation. Then using the roots function we
calculate and plot the roots of the characteristic equation as shown in figure
7.3. It can be seen that the roots of the characteristic equation move towards
the right-half plane as the gain increases from 0 and tends towards 8, and
eventually into the right-half plane when K is greater than 8. Figure 7.3 is a
graphical verification of the Routh-Hurwitz result obtained above.

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

85 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

The Routh-Hurwitz method allows us to make definitive statements regarding


absolute stability of a linear system. The method does not address the issue of
relative stability, which is directly related to the location of the roots of the
characteristic equation. This method tells us how many poles lie in the right-
half plane, but not the specific location of the poles. With MATLAB, however, we
can easily calculate the poles explicitly, thus allowing us to comment on the
system’s relative stability.

7.2 DESING PROBLEM: TRACKED VEHICLE


TURNING CONTROL
A tracked vehicle is a vehicle that runs on continuous tracks, instead of
wheels, like military tanks and armored personnel vehicles (APVs). The
principal design advantages of tracked over wheeled vehicles are that they are
in contact with a larger surface area than would generally be the case with a
wheeled vehicle, and as a result exert a much lower force per unit area on the
ground being traversed than a conventional wheeled vehicle of the same
weight. This makes them suitable for use on soft, low friction and uneven
ground such as mud, sand and snow.

In order to steer a tracked vehicle, it is necessary to drive one track faster than
the other, causing the vehicle to turn toward the slower track. This is called
skid steering or differential steering. While the theory is simple, its execution is

86 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

not. (A detailed discussion on tracked vehicle steering system may be found on


http://www.gizmology.net/tracked.htm)

The design of a turning control for a tracked vehicle involves the selection of
two parameters. Figure 7.4 shows model of steering control of a two-track
vehicle. The two tracks are operated at different speeds in order to turn the
vehicle. We must select K and a so that the system is stable and the steady-
state error for a ramp command is less than or equal to 24% of the magnitude
of the command.

If we denote controller transfer function with C(s) and power train plus vehicle
transfer function with G(s) then the characteristic equation of this feedback
system is
( ) ( )

or

( )

Using the Routh-Hurwitz array we determine that for this system to be stable,
we require that

( )( )

The following code helps determine the suitable combinations of K and a that
satisfy the abovementioned conditions and result in stable system.
a = [0.1 : 0.01 : 3.0];
k = [20 : 120];
x = 0*k; y = 0*k;
n = length(k);
m = length(a);

87 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

for i = 1 : n
for j = 1 : m
q = [1, 8, 17, k(i)+10, k(i)*a(j)];
p = roots(q);
if max(real(p)) > 0
x(i) = k(i);
y(i) = a(j-1);
break;
end;
end
end
plot(x,y)
grid, xlabel('K'), ylabel('a')
title('Stability Region for Two-Track Vehicle Steering Control')

The plot in figure 7.5 shows the outcome of this code. Note that the region to
the left of the plot of a versus K is the stable region, since that corresponds to
.

The steady-state error to a ramp input ( ) is.

where

( ) ( )

Therefore, we have
88 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

Given the steady-state specification, , we find that the specification


is satisfied when

or

Any values of a and K that lie in the stable region in figure 7.5 and satisfy
above equation will lead to an acceptable design. For example, and
will satisfy all the design requirements. The closed loop transfer
function will then be

( )

And the associated closed-loop poles are

The corresponding unit ramp response is shown in figure 7.6 below. The
steady-state error is less than 0.24 as desired.

89 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 7: STABILITY OF CONTROL SYSTEM

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

90 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

Lab Session 8:

THE ROOT LOCUS METHO D


PRE REQUISITES:
Before coming to this lab, the students must be aware of the fact that open-
loop gain has profound impact on system’s stability and its transient response.
They are expected to have learnt how to manually draw a root locus diagram
and interpret it.

OBJECTIVES:
This lab aims to facilitate the students in drawing root locus of any given
system quickly, easily and precisely using MATLAB. It also expects the students
to develop an insight as how the system will behave if the gain is varied. The
ultimate objective of this lab is to enable the students to design proportional-
gain controller, in compliance with the performance parameters set forth.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
In the previous lab session, we discussed absolute stability of a closed-loop
feedback control system using Routh-Hurwitz method. We also studied how the
performance of a feedback system can be described in terms of the location of
the roots of the characteristic equation in the s-plane. We know that the
response of a closed-loop feedback control system can be adjusted to achieve
the desired performance by judicious selection of one or more system
parameters. It is, therefore, very useful to determine how the roots of the
characteristic equation move around the s-plane as we change one parameter.

91 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

The Root Locus method, as the name suggests, looks at the loci of the roots as
some parameter of interest, within the system, is varied. Since we already know
that the position of the roots of the characteristic equation strongly influence
the step response of the system, we can find values of the parameter which will
position the roots appropriately, using the method of Root Locus. This method
involves root locus diagrams which the students are expected to have learnt in
the theory class. In this lab we will use MATLAB’s powerful computing capability
to find and trace root locus of a given system.

8.1 OBTAINING A ROOT LOCUS PLOT


Let we have a unity feedback system as shown in figure 8.1. In plotting root
loci with MATLAB we need the characteristic equation of this system defined as

( )
( )( )

8.1.1 CONTINUOUS ROOT LOCUS PLOT


MATLAB provides us with rlocus command to compute and display root locus
of any system. The syntax of this command is as follows

>> rlocus(num,den)

Here num is array of open-loop numerator coefficients and den is array of open-
loop denominator coefficients. Using this command, the root locus is plotted on
the figure window as shown in figure 8.2. The gain vector K is automatically
determined and contains all the gain values for which the closed-loop poles are
to be computed. However, we can define vector K as per our own will and
provide it to rlocus command as

92 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

>> rlocus (num,den,K)

If this command is invoked with left-hand arguments, like

[r,k] = rlocus(num,den)

[r,k] = rlocus(num,den,k)

[r,k] = rlocus(sys)

the command window will show the matrix r and gain vector K. The columns of
matrix r are equal to length of K and its rows are den-1, containing the
complex root locations. Each row of the matrix corresponds to a gain from
vector K. We can then plot the loci by using the plot command

>> plot(r,’-’)

8.1.2 DISCRETE ROOT LOCUS PLOT


Plotting root loci using marks ‘o’ or ‘x’ is instructive, since each calculated
closed-loop pole is graphically shown; in some portion of the root loci those
marks are densely placed and in other portion they are sparsely placed. MATLAB
93 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

supplies its own set of gain values used to calculate a root locus plot. The
following example illustrates this point in rather detail.

Consider the system whose open-loop transfer function is

( )
( )( )

Entering the following code in the MATLAB results in the plot shown in figure
8.3.

num = [ 0 0 0 0 1 ];
den = [ 1 1.1 10.3 5 0];
r = rlocus(num,den);
plot(r,’o’)
axis([-6 6 -6 6])
grid;

Notice that in the region near , and , two


loci approach each other. We may wonder if these two branches should touch
or not. To explore this situation, we may plot the root loci using smaller
increments of K in the critical region.

By a conventional trial-and-error approach or using the rlocfind command to


be presented in the later section, we find the particular region of interest to
be . By entering the following code, we obtain the root locus plot

94 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

shown in figure 8.4. From this plot it is clear that the two branches, that
approach each other, do not actually touch.

num = [ 0 0 0 0 1 ];
den = [ 1 1.1 10.3 5 0];
K1 = 0 : 0.2 : 20;
K2 = 20: 0.1 : 30;
K3 = 30: 5.0 : 1000
K = [K1 K2 K3];
r = rlocus(num,den,K);
plot(r,’o’)
axis([-4 4 -4 4])
grid;

8.1.3 COMMENTS ON THE ROOT LOCUS PLOT


In root locus, we examine system’s stability against all possible values of K. No
matter what we pick K to be, the closed-loop system must always have n poles,
where n is the number of poles of open-loop transfer function, G(s)H(s). The
root locus must have n branches; each branch starts at a pole of G(s)H(s) and
goes to a zero of G(s)H(s). If G(s)H(s)has more poles than zeros (as is often the
case), m < n, we say that G(s)H(s) has zeros at infinity. In this case, the limit of
G(s)H(s) as is zero. The number of zeros at infinity is n-m and is the
number of branches of the root locus that go to infinity (asymptotes).

Since the root locus is actually the locations of all possible closed-loop poles,
from the root locus we can select a gain such that our closed-loop system will

95 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

perform the way we want. If any of the selected poles is on the right half plane,
the closed-loop system will be unstable. The poles that are closest to the
imaginary axis have the greatest influence on the closed-loop response, so even
though the system has three or four poles, it may still act like a second or even
first order system depending on the location(s) of the dominant pole(s).

8.2 CONSTANT ζ AND CONSTANT LOCI


Recall that in the complex plane the damping ratio ζ of a pair of complex-
conjugate poles can be expressed in terms of the angle φ, which is measured
from the negative real axis.

In other words, lines of constant damping ratio are radial lines passing through
the origin as shown in figure 8.5. For example, a damping ratio of 0.5 requires
that the complex poles lie on the lines drawn through the origin making angles
of ± 60o with negative real axis. If the real part of a pair of complex poles is
positive, which means that the system is unstable, the corresponding ζ is
negative. The damping ratio determines the angular location of the poles, while
the distance of the pole from the origin is determined by the undamped natural
frequency . The constant loci are circles.

8.2.1 PLOTTING POLAR GRIDS IN THE ROOT LOCUS DIAGRAM


To draw constant ζ lines and constant circles on the root locus diagram with
MATLAB, we use the sgrid command. This command overlays lines of constant
damping ratio ( with 0.1 increment) and circles of constant on the
root locus plot. Run the following code in MATLAB and observe the output.

sgrid
axis ([-2 2 -2 2])
axis ('square')
title ('Constant \zeta Lines and Constant \omega_n Circles')
xlabel ('Real Axis')
ylabel('Imaginary Axis')

If only a particular constant ζ lines and particular constant circles are


desired, we may use the following variant of sgrid command

96 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

>> sgrid ([0.5, 0.707],[ 0.5, 1, 1.5])

Enter the following code into MATLAB and show that the resulting plot is similar
to the one shown in figure 8.5.

num = [ 0 0 0 1 ]
den = [ 1 4 5 0 ]
axis ('square')
rlocus (num , den)
axis ([- 3 1 -2 2])
sgrid ([0.5 , 0.707],[0.5 , 1.0 , 1.5])
title ('Root Locus Plot with \zeta = 0.5 and 0.707 Lines and
\omega_n = 0.5, 1.0 and 1.5 Circles')

If we want to omit either the entire constant ζ lines or entire constant


circles, we may use empty brackets [] in the arguments of the sgrid
command. For example, if we want to overlay only the constant damping ratio
lines corresponding to ζ = 0.5 and no constant circles to the root locus plot
shown in figure 8.5, then we may use the command

97 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

sgrid (0.5,[])

Try this and observe the output plot.

8.3 DESIGN USING ROOT LOCUS

Consider an open-loop system which has a transfer function of

( ) ( )
( )
( ) ( )( )( )

We want to design a feed-back controller for the system by using the root locus
method and our design criteria are 5% overshoot and 1 second rise time.

We can draw root locus for this system as

num=[1 7];
den=conv(conv([1 0],[1 5]),conv([1 15],[1 20]));
rlocus(num,den)
axis([-22 3 -15 15])

The plot shows all possible closed-loop pole locations for a pure proportional
controller. Obviously not all of those closed-loop poles will satisfy our design
criteria. To determine what part of the locus is acceptable, we can use the
command sgrid(Zeta,Wn) to plot lines of constant damping ratio and natural
frequency. In our problem, we need an overshoot less than 5% (which means a
damping ratio greater than 0.7 and a rise time of 1 second (which means a
natural frequency greater than 1.8. Append the code given above with the code
given below.

zeta=0.7;
Wn=1.8;
sgrid(zeta, Wn)

On the plot, the two white dotted lines at about a 45 degree angle indicate pole
locations with ζ = 0.7; in between these lines, the poles will have ζ > 0.7 and
outside of the lines ζ < 0.7. The semicircle indicates pole locations with a

98 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

natural frequency = 1.8; inside the circle, < 1.8 and outside the circle
> 1.8.

Going back to our problem, to make the overshoot less than 5%, the poles have
to be in between the two white dotted lines, and to make the rise time shorter
than 1 second, the poles have to be outside of the white dotted semicircle. So
now we know only the part of the locus outside of the semicircle and in
between the two lines are acceptable. All the poles in this location are in the
left-half plane, so the closed-loop system will be stable.

From the plot we see that there is part of the root locus inside the desired
region. So in this case we need only a proportional controller to move the poles
to the desired region. You can use rlocfind command in MATLAB to choose the
desired poles on the locus.

[k,poles] = rlocfind(num,den)

Click on the plot the point where you want the closed-loop pole to be.

Note that since the root locus may have more than one branch, when you
select a pole, you may want to find out where the other pole(s) are. Remember
they will affect the response too. From the plot we should make sure that all
the poles selected (all the red "+") are at reasonable positions only then we can
go ahead and use the chosen K as our proportional controller.

99 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

In order to find the step response, we need to know the closed-loop transfer
function. We could compute this using the rules of block diagrams, or let
MATLAB do it for us:

sys = tf(k*num, den)


sysCL = feedback(sys,1)

The two arguments to the tf command are the numerator and denominator of
the open-loop system. We need to include the proportional gain that we have
chosen. Unity feedback is assumed in this case.

The step response of this closed-loop system can be computed to see if our
design meets the desired criteria:

step(sysCL)

As we expected, this response will have an overshoot less than 5% and a rise
time less than 1 second.

The selected point for the response shown above has K = 511.5287 and the
system’s poles corresponding to this K are

-22.6275
-11.4095
-2.9815 + 2.2317i
-2.9815 - 2.2317i

100 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

And the open-loop transfer function becomes

( ) ( )
( )
( )

101 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

EXERCISE 1:

Given is a plant described by the transfer function

1
GP ( s) 
s( s  3)(s  5)

For this plant a controller must be designed, such that the step response of the
closed loop shows the following properties:

P.O = 16% and tr,50 =0.6s

EXERCISE 2:

Lasers can be used to drill the hip socket for the appropriate insertion of an
artificial hip joint. The use of the laser surgery requires high accuracy for
position and velocity response. Let us consider the system shown below which
uses a DC motor manipulator for the laser.

The amplifier gain K must be adjusted so that the steady state error for a ramp
input, r(t) = At (where A = 1mm/s), is less than or equal to 0.1 mm, while a
stable response is maintained.

To Obtain the steady-state error required and a good response, we select motor
with a field time constant τ1 = 0.1 sec and a motor-plus-load time constant τ2 =
0.2 sec.

a) Find the value of K for which ess is less than 0.1 mm. Expression for ess
for ramp input is

ess =
b) Find the rang of K for which the system is stable using root locus.
c) Apply a ramp input and observe the output for t = 0 sec to t = 6 sec
102 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 8: THE ROOT LOCUS METHOD

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

103 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

Lab Session 9:

CONTROLLER DESIGN VIA ROOT


LOCUS
PRE REQUISITES:
This lab is based on the method of Root Locus. The students are supposed to
be comfortable with drawing root locus both by hand and using MATLAB. They
must also be aware of effects of adding a zero and/or pole to a system.

OBJECTIVES:
The primary objective of this lab is to present procedures for the design and
compensation of single-input-single-output linear time-invariant control
systems using Root Locus approach.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
It is often possible to achieve stability and satisfactory system performance by
adjusting the gain of the system. We discussed many examples in the previous
labs illustrating design by adjusting one or two parameters. However, in many
practical cases the adjustment of gain alone may not provide sufficient
alteration of the system behavior to meet the given specifications. As is
frequently the case, increasing the gain value will improve steady-state
behavior but will result in poor stability or even instability. It is then necessary
to redesign the system (by modifying the structure or by incorporating
additional devices and components) to tailor the overall behavior so that the
system will behave as desired. Such a redesign or addition of a suitable device
is called compensation.

105 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

The design via root locus method is based on reshaping the root locus of the
system by adding poles and zeros to the system’s open-loop transfer function
and forcing the root loci to pass through desired closed-loop poles in the s-
plane. This design approach is based on the assumption that the closed-loop
system has a pair of dominant closed-loop poles.

9.1 PRELIMINARY DESIGN CONSIDERATIONS


Control systems are designed to perform specific tasks. The requirements
imposed on the control systems are usually spelled out as performance
specifications. These specifications are given before the design process begins
and are generally in terms of transient response requirements (such as the
maximum overshoot and settling time in step response) and of steady-state
requirements (such as steady-state error in following a ramp input).

For routine design problems, the performance specifications (which relate to


accuracy, relative stability, and speed of response) may be given in terms of
precise numerical values or in terms of qualitative statements. In latter case
the specifications may have to be modified during the course of design, since
the given specifications may never be satisfied (because of conflicting
requirements) or may lead to a very expensive system. Generally, the
performance specifications should not be more stringent than necessary to
perform the given task.

9.1.1 SYSTEM COMPENSATION


Altering a control system to meet relative stability and performance
specifications is called compensation and a device inserted into the system for
the purpose of satisfying the specifications is called compensator. Figure 9.1 (a)
and (b) show compensation schemes commonly used for feedback control
system. The choice between cascade compensation and feedback compensation
depends in the nature of the signals in the system, the power levels at various
points, available components, the designer’s experience, and economic
considerations etc.

Normally, cascade (or series) compensation may be simpler than feedback (or
parallel) compensation; however, series compensation frequently requires

106 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

additional amplifiers to increase the gain and/or to provide isolation. Note that,
in general, the number of components required in parallel compensation will be
less than the number of components in series compensation, provided a
suitable signal is available. In this lab we will discuss series compensation in
detail.

9.1.2 TYPES OF COMPENSATORS


If a compensator is needed to meet the performance specifications, the designer
must realize a physical device that has the prescribed transfer function of the
compensator.

If a sinusoidal input is applied to a network, and the steady-state output


(which is also sinusoidal) has a phase lead, then the network is called a lead
network and the device to eliminate this phase lead is called lead compensator.
The amount of phase lead angle is a function of the input frequency. If the
steady-state output has a phase lag, then the network is called a lag network
and the corresponding device to remove this phase lag is called lag
compensator. These compensators may be electronic devices, such as
operational amplifiers, or RC networks and amplifiers.

9.1.3 ROOT LOCUS APPROACH TO CONTROL SYSTEM DESIGN


As discussed earlier, the root locus plot of a system may indicate that the
desired performance or stability cannot be achieved just by the adjustment of
gain. Then it is necessary to reshape the root loci to meet the performance
specifications.

In designing a control system, if other than a gain adjustment is required, we


must modify the original root loci by inserting a suitable compensator so that a

107 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

pair of dominant closed-loop poles can be placed at the desired location. Often,
the damping ratio and undamped natural frequency of a pair of dominant
closed-loop poles are specified.

9.1.4 EFFECTS OF THE ADDITION OF POLES AND ZEROS


When we add a pole to the open-loop transfer function of a system it

 Pulls the root locus to the right


 Tends to lower the system’s relative stability
 Slows down the settling of the response

On the contrary, addition of a zero to the open-loop transfer function

 Pulls the root locus to the left


 Tends to make the system more stable
 Speeds up the settling of the response

9.2 LEAD COMPENSATOR DESIGN

A first-order lead compensator can be designed using the root locus. The
transfer function of a lead compensator is given by

( )

where the magnitude of z is less than the magnitude of p. A phase-lead


compensator tends to shift the root locus toward the left-half plane. This
results in an improvement in the system's stability and an increase in the
response speed.

How is this accomplished? If you recall finding the asymptotes of the root locus
that lead to the zeros at infinity, the equation to determine the intersection of
the asymptotes along the real axis is:

∑ ∑
( ) ( )

108 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

When a lead compensator is added to a system, the value of this intersection


will be a larger negative number than it was before. The net number of zeros
and poles will be the same (one zero and one pole are added), but the added
pole is a larger negative number than the added zero. Thus, the result of a lead
compensator is that the asymptotes' intersection is moved further into the left
half plane, and the entire root locus will be shifted to the left. This can increase
the region of stability as well as the response speed.

In MATLAB a phase lead compensator in root locus form is implemented by


using the transfer function in the form,

numLead = kc*[1 z];


denLead = [1 p];
lead = tf(numLead,denLead);

9.2.1 SOLVING BALL AND BEAM PROBLEM USING LEAD


COMPENSATOR
The ball and beam system is one of the most enduringly popular and important
laboratory models for teaching control systems engineering. The ball and beam
system is widely used because it is very simple to understand as a system, and
yet the techniques that can be studies to control it cover many important
classical and modern design methods. It has a very important property – it is
open-loop unstable.

109 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

The system is shown in figure 9.2. A steel ball is rolling on top of a long beam.
The beam is mounted on the output shaft of an electric motor and so the beam
can be tilted about its center axis by applying an electrical control signal to the
motor amplifier. The position of the ball on the beam can be measured using a
special sensor.

The control job is to automatically regulate the position of the ball on the beam
by changing the angle of the beam. This is a difficult task because the ball does
not stay in one place on the beam but moves with an acceleration that is
proportional to the tilt of the beam. In control technology this system is open-
loop unstable because the system output (the ball position) increases without
limit for a fixed input (beam angle). Feedback control must be used to keep the
ball in desired position on the beam.

The complete description of the dynamics of the ball rolling on the beam is
quite complicated and for control system perspective a simplified derivation is
used to give a model that is good for controller design.

The force that accelerates the ball as it rolls on the beam comes from the
component of gravity that acts parallel to the beam. The dotted line in figure
9.3 shows this force to be . The ball actually accelerates along the beam
by rolling, but we can simplify the derivation by assuming that the ball is
sliding without friction along the beam. Then, using the second law of Newton,
the simplified ball and beam model is,

110 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

where m is the mass of the ball, g is the gravitational constant, is the beam
angle and x is the position of the ball on the beam.

For small angles, , so the model becomes,

This simple model of the ball and beam is a good approximation to the true
system dynamics, and is the one normally used in text books and design
studies for controller design. Combining actuator and sensor constants with
the gravity constant, we get a single constant b. This represents the overall
gain of the response from control voltage input to measured output
acceleration. The transfer function representation of the above equation is

( )
( )

where

( )

Let’s now set the design criteria and system parameter of this problem as,

 Settling time less than 3 seconds


 Overshoot less than 5%

And the parameters are

The main idea of the root locus design is to estimate the closed-loop response
from the open-loop root locus plot. By adding zeroes and/or poles to the

111 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

original system (adding a compensator), the root locus and thus the closed-loop
response will be modified. Let us first view the root locus for the plant in open-
loop. Create an m-file with the following MATLAB code in order to model the
plant and plot the root locus.

m = 0.111;
R = 0.015;
g = -9.8;
L = 1.0;
d = 0.03;
J = 9.99e-6;
K = (m*g*d)/(L*(J/R^2+m)); %simplifies input
num = [-K];
den = [1 0 0];
plant=tf(num,den);
rlocus(plant)

The following root locus plot is generated as a result of the above code.

As you can see the system has two poles at the origin which go off to infinity
along the imaginary axes.

Now we plot the design criteria on the root locus using sgrid command and
the following formulae.

112 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

sgrid(0.70, 1.9)
axis([-4 4 -4 4])

The area between the two dotted diagonal lines represents locations where the
percent overshoot is less than 5%. The area outside the curved line represents
locations where the settling time is less than 3 seconds. Note that no region of
the plot falls within the design criteria shown by these lines. To remedy this
and bring the root locus into the left-hand plane for stability we will try adding
a lead-compensator to the system.

A first order lead compensator tends to shift the root locus into the left-hand
plane. We will position the zero near the origin to cancel out one of the poles.
The pole of our compensator will be placed to the left of the origin to pull the
root locus further into the left-hand plane. Add the following lines of MATLAB
code to your m-file.

113 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

p = 5;
z = 0;
contr=tf([1 z],[1 p]);
rlocus(contr*plant)
sgrid(0.70, 1.9)

Run your m-file and you should see the following,

You can see that the branches of the root locus are within our design criteria.

Now that we have moved the root locus into the left-hand plane, we may select
a gain that will satisfy our design requirements. We can use the rlocfind
command to help us do this.

[k,poles]=rlocfind(contr*plant)

Go to the plot and select a point in the desired region. You will get a value of K
corresponding to the point you selected on the s-plane. This value of K can be
114 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

put into the system and the closed-loop response to a step input of 0.25 m can
be obtained.

sys_cl=feedback(k*contr*plant,1);
t=0:0.01:5;
figure(1)
step(sys_cl,t)

Run the code and get the output. From this plot we see that when a 0.25 m
step input is given to the system, both the settling time and percent overshoot
design criteria are met.

9.3 LAG COMPENSATOR DESIGN


A first-order lag compensator can be designed using the root locus. A lag
compensator in root locus form is given by

( )

where the magnitude of z is greater than the magnitude of p. A lag


compensator tends to shift the root locus to the right, which is undesirable. For
this reason, the pole and zero of a lag compensator must be placed close
together (usually near the origin) so they do not appreciably change the
transient response or stability characteristics of the system.

How does the lag controller shift the root locus to the right? The answer is the
same as that to lead compensator. Again recall finding the asymptotes of the
root locus that lead to the zeros at infinity, the equation to determine the
intersection of the asymptotes along the real axis is

∑ ∑
( ) ( )

When a lag compensator is added to a system, the value of this intersection will
be a smaller negative number than it was before. The net number of zeros and
poles will be the same (one zero and one pole are added), but the added pole is
a smaller negative number than the added zero. Thus, the result of a lag
compensator is that the asymptotes' intersection is moved closer to the right-
half plane, and the entire root locus will be shifted to the right.
115 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

It was previously stated that that lag controller should only minimally change
the transient response because of its negative effect. If the phase-lag
compensator is not supposed to change the transient response noticeably,
what is it good for? The answer is that a phase-lag compensator can improve
the system's steady-state response. It works in the following manner. At high
frequencies, the lag controller will have unity gain. At low frequencies, the gain
will be z/p which is greater than 1. This factor z/p will multiply the position,
velocity, or acceleration constant (Kp, Kv, or Ka), and the steady-state error will
thus decrease by the factor z/p.

9.3.1 DC MOTOR SPEED CONTROL USING LAG COMPENSATOR

The open-loop transfer function of a DC motor speed is given by

̇
( )( )

And the schematic looks like figure 9.7.

With a 1 rad/sec step reference, the design criteria are:

 Settling time less than 2 seconds


 Overshoot less than 5%
 Steady-state error less than 1%

Now let's design a controller using the root locus method.

Create a new m-file and type in the following

J=0.01;
b=0.1;
116 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

K=0.01;
R=1;
L=0.5;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
motor=tf(num,den);
rlocus(motor)
sgrid(.8,2.5)

Remember that, we need the settling time and the overshoot to be as small as
possible. Large damping corresponds to points on the root locus near the real
axis. A fast response corresponds to points on the root locus far to the left of
the imaginary axis. To find the gain corresponding to a point on the root locus,
we can use the rlocfind command. We can find the gain and plot the step
response using this gain all at once. To do this, enter the following commands
at the end of your m-file and rerun it.

[k,poles] = rlocfind(motor)
sys_cl=feedback(k*motor,1);
t=0:0.01:3;
step(sys_cl,t)

117 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

Go to the plot and select a point on the root locus half-way between the real
axis and the damping requirement, say at -6 + 3i. You should also take step
response with the K found by rlocfind. Figure 9.8 shows root locus of
uncompensated system whereas transient response of the system with K = 10
is shown in figure 9.9.

As you can see, there is no overshoot and the settling time is about one second,
so the overshoot and settling time requirements are satisfied. The only problem
we can see from this plot is the steady-state error of about 50%. If we increase
the gain to reduce the steady-state error, the overshoot becomes too large (Try
this yourself). We need to add a lag controller to reduce the steady-state error.

From the plot we see that this is a very simple root locus. The damping and
settling time criteria were met with the proportional controller. The steady-state
error is the only criterion not met with the proportional controller. A lag
compensator can reduce the steady-state error. By doing this, we might,
however, increase our settling time. The procedure to design a lag controller for
a specific system is laid down here.

The formula to calculate the positions of lag compensator’s pole and zero is

here zc is compensator zero, pc is compensator pole, and Kp is position gain,


which for the case of step input is defined by
118 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

Note that this Kp is position gain and it’s not the same as open-loop gain K.
Now, our current steady-state error, from figure 9.9, is 0.5 or 50%, so our Kp,old
will be,

And we want to reduce our error to less than 0.01, or 10%, so Kp,new will be,

Now, assume any reasonable arbitrary value, near to origin, for compensator
pole, say 0.01, and find the location of compensator zero using the formula,

Try the following lag controller,

Now implement this compensator in MATLAB, apply this compensator in


cascade with the plant and find the response.

We have selected open-loop gain to be 12. As you can see from figure 9.10 that
the step response is not quite satisfactory. You may also note that even though
the gain was selected to correlate with a position close to the damping criterion,
the overshoot is not even close to five percent. This is due to the effect of the
lag controller; its pole is much slower. What this means is that we can go
beyond the dotted lines that represent the limit, and get the higher gains
without worrying about the overshoot. Rerun your m-file; place the gain just
above the white, dotted line. Keep trying until you get a satisfactory response.
It should look similar to the one shown in figure 9.11(we have used open-loop
gain to be 48).

119 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

The steady-state error is smaller than 1%, and the settling time and overshoot
requirements have been met. As you can see, the design process for root locus
is very much a trial and error process. That is why it is nice to plot the root
locus, pick the gain, and plot the response all in one step. If we had not been
able to get a satisfactory response by choosing the gains, we could have tried a
different lag controller, or even added a lead controller.

120 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

EXERCISE 1:

Consider the following unity feedback system,

Design a Compensator to tailor the transient response as per the given criteria

 Percent Overshoot < 10 %


 Settling Time < 2 sec

EXERCISE 2:

You would notice that although the transient response of the above system is
adapted as per the given specifications, yet its steady-state error is beyond any
tolerance range. Now design another compensator and cascade it with the
previous one to reduce the steady-state error to less than 5 %.

Note: Exercise 1 and 2 employ both lead compensator and lag compensator on a
plant. Such controller that compensates both lead effect and lag effect is called
lead-lag compensator.

EXERCISE 3:

Design Simulink model of the system given above. Apply both lead and lag
compensator in cascaded fashion to the plant validate the results obtained in
exercise 1 and 2.

121 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 9: CONTROLLER DESIGN VIA ROOT LOCUS

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

122 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

Lab Session 10:

INTRODUCTION TO PID
CONTROLLERS
PRE REQUISITES:
This lab is quite independent in a sense that it does not require any specific
background knowledge except elementary fundamentals of control theory.
However, a little understanding of compensators discussed in the last lab may
help comprehend the depth and breadth of PID rather rigorously.

OBJECTIVES:
The objective of this lab is to study the three term (PID) controller and its
effects on the feedback loop response. We will investigate the characteristics of
each of proportional (P), integral (I), and derivative (D) controls, and learn how
to use them to obtain a desired response.

DELIVERABLES:
A complete lab report including the following:

 Summarized learning outcomes


 MATLAB scripts and their results

INTRODUCTION:
A proportional–integral–derivative controller (PID controller) is the most
commonly used feedback controller in industrial control systems. A PID
controller calculates an error value as the difference between measured output
and a desired setpoint. The controller attempts to minimize the error by
adjusting the process control inputs.

The popularity of PID controller can be attributed partly to their robust


performance in a wide range of operating conditions and partly to their
functional simplicity, which allows engineers to operate them in a simple and
straightforward manner.

123 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

10.1 THEORY OF THREE-TERM CONTROLLER


The transfer function of the PID controller looks like the following;

here,

Kp = Proportional Gain
Ki = Integral Gain
Kd = Derivative Gain

First, let’s take a look at how the PID controller works in a closed-loop system
using the schematic shown below.

The signal e(t) represents the tracking error, the difference between the
reference input r(t) and the actual output y(t). This error signal will be sent to
the PID controller, and the controller computes both the derivative and integral
of this error signal. The signal u(t) just past the controller is now equal to the
proportional gain (Kp) times the magnitude of the error signal plus the integral
gain (Ki) times the integral of the error signal plus the derivative gain (Kd) times
the derivative of the error signal.

( )
( ) ( ) ∫ ( )

124 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

This signal, u(t), will now be sent to the plant, and the new output, y(t), will be
obtained. This new output will be sent back to the sensor again to find the new
error signal. The controller takes this new error signal and computes its
derivative and it’s integral again. This process goes on and on.

10.1.1 CHARACTERISTICS OF P, I, AND D CONTROLLER


A proportional controller (Kp) will have the effect of reducing the rise time and
will reduce but never eliminate the steady-state error. An integral control (Ki)
will have the effect of eliminating the steady-state error, but it may make the
transient response worse. A derivative control (Kd) increases the stability of the
system, reduces the overshoot, and improves the transient response. Effects of
each controller on closed-loop system are summarized in the table below.

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 Small Change

Note that these correlations may not be exactly accurate, because Kp, Ki, and
Kd 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 Ki, Kp and Kd.

10.1.2 EXAMPLE PROBLEM: MASS-SPRING-DAMPER MODEL


Suppose we have a simple mass-spring-damper system as discussed in lab 2.
The modeling equation of this system is

By taking Laplace transform and solving for the transfer function between the
displacement X(s) and the input Fa(s), we get

( )
( )

For details on derivation of this expression, please refer to lab 2.

Let the system parameters be,

125 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

M=1 kg
b = 10 N.s/m
k = 20 N/m
Fa(s) = 1 N

Plug these values into the above transfer function,

( )
( )

The goal of this problem is to show how each of Kp, Ki, and Kd contribute to
obtain

 Fast Rise Time


 Minimum Overshoot
 No Steady-State Error

Let’s first view the open-loop step response. Create a new m-file and add in the
following code.

num=1;
den=[1 10 20];
plant=tf(num,den);
axis('square')
step(plant)

Running this m-file in the MATLAB command window should give you the plot
shown in figure 10.2.

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 1.5 seconds. Let's design a controller that will reduce
the rise time, reduce the settling time, and eliminates 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:

126 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

( )
( ) ( )

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

Kp=300;
contr=Kp;
sys_cl=feedback(contr*plant,1);
t=0:0.01:2;
step(sys_cl,t)

Running this m-file in the MATLAB command window should give you the
following plot.

127 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

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 PLUS 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:

( )
( ) ( ) ( )

Let Kp equals 300 as before and let Kd equals 10. Enter the following
commands into an m-file and run it in the MATLAB command window.

Kp=300;
Kd=10;
contr=tf([Kd Kp],1);
sys_cl=feedback(contr*plant,1);
t=0:0.01:2;
step(sys_cl,t)

128 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

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 PLUS 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:

( )
( ) ( )

Let's reduce the Kp to 30, and let Ki equals 70. Modify your code as follows,

Kp=30;
Ki=70;
contr=tf([Kp Ki],[1 0]);
sys_cl=feedback(contr*plant,1);
t=0:0.01:2;
step(sys_cl,t)

This code should give the following graph.

129 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

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 PLUS INTEGRAL PLUS 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:

( )
( ) ( ) ( )

After several trial and error runs, the gains Kp = 350, Ki = 300, and Kd = 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;
contr=tf([Kd Kp Ki],[1 0]);
sys_cl=feedback(contr*plant,1);
t=0:0.01:2;
step(sys_cl,t)

Now, we have obtained a


closed-loop system with no
overshoot, fast rise time, and
no steady-state error.

130 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

10.1.3 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 above to find out which
controller controls what characteristics.

Lastly, 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.

10.2 DESIGN PROBLEM: BALL & BEAM SYSTEM


As derived in the previous lab, the open-loop transfer function of the plant for
the ball and beam experiment is:

( )
( ) ( )

The design criteria for this problem are:

 Settling time less than 3 seconds


 Overshoot less than 5%

The block diagram for this example with a controller and unity feedback of the
ball’s position is shown in figure 10.7. First, we will study the response of the
system shown above when a proportional controller is used. Then, derivative
and/or integral control will be added, if necessary.

The closed-loop transfer function for proportional control with a proportional


gain equal to 100, can be modeled by the following code,

131 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

m = 0.111;
R = 0.015;
g = -9.8;
L = 1.0;
d = 0.03;
J = 9.99e-6;
K = (m*g*d)/(L*(J/R^2+m)); %simplifies input
num = [-K];
den = [1 0 0];
ball=tf(num,den);
kp = 1;
sys_cl=feedback(kp*ball,1);

Now, we can model the system's response to a step input of 0.25 m. Add the
following line of code to your m-file and run it:

t = 0:0.5:100
step(0.25*sys_cl,t)

You should get the output as shown in figure 10.8. As, you can see the
addition of proportional gain does not make the system stable. Try changing

132 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

the value of Kp and note that the system remains unstable.

Now, we will add a derivative term to the controller. Copy the following lines of
code to an m-file and run it to view the system's response to this control
method.

m = 0.111;
R = 0.015;
g = -9.8;
L = 1.0;
d = 0.03;
J = 9.99e-6;
K = (m*g*d)/(L*(J/R^2+m)); %simplifies input
num = [-K];
den = [1 0 0];
ball=tf(num,den);
kp = 10;
kd = 10;
contr=tf([kd kp],1);
sys_cl=feedback(contr*ball,1);
t=0:0.01:5;
step(0.25*sys_cl)

Your plot should be similar to the following:

Now the system is stable but the overshoot is much too high and the settling
time needs to go down a bit. From the table given in section 10.1.1, we see that
by increasing Kd we can lower the overshoot and decrease the settling time
slightly. Therefore experiment with the value of Kd and find such differential

133 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

gain that reduces the overshoot below 5%. Furthermore fine tune Kp to reduce
the settling time. The figure below shows the system response for Kp = 15 and
Kd = 40.

As you can see from the above plot all the control objectives have been met
without the use of an integral controller (settling time for this example is
considered achieved when the response is less than 2% of its final value).
Remember, that for a control problem there is usually more than one solution
for the problem.

134 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

EXERCISE 1:

Consider a process given below to be controlled by a PID controller,

( )
( )

a) Obtain the unit step response of Gp(s).


b) Try PI controllers with (Kp = 2, 10, 100), and Ki = Kp/10. Investigate the
unit step response in each case, compare the results and comment.
c) Let Kp = 100, Ki = 10, and add a derivative term with (Kd = 0.1, 0.9, 2).
Investigate the unit step response in each case, compare the results and
comment.
Based on your results in parts b) and c) above what do you conclude as a
suitable PID controller for this process and give your justification.

EXERCISE 2:

The open-loop transfer function of the DC Motor speed is

̇
( )( )

For a 1 rad/sec step input, design a PID controller that gives:

 Settling time less than 2 seconds


 Overshoot less than 5%
 Steady-stage error less than 1%

EXERCISE 3:

The open-loop transfer function of the DC Motor position is

(( )( ) )

With a 1 rad/sec step reference, the design criteria are:

 Settling time less than 0.04 seconds


 Overshoot less than 16%
 No steady-state error

135 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

 No steady-state error due to a disturbance

Design a PID controller that satisfies the given criteria.

NOTE: For exercise 2 and 3 refer to the figure below.

k) The open-loop transfer function of the DC Motor speed is

̇
( )( )

For a 1 rad/sec step input, design a PID controller that gives:

 Settling time less than 2 seconds


 Overshoot less than 5%
 Steady-stage error less than 1%

136 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering
Lab Session 10: INTRODUCTION TO PID CONTROLLERS

Evaluation Chart

Total Marks Obtained Marks

Participation in the Lab 3

Accuracy of Results Obtained 3

Viva 2

Discipline 2

Total 10

Comments from Lab Instructor:

_______________________ _______________________

Date Instructor’s Signature

137 | P a g e
COMSATS Institute of Information Technology, Lahore Department of Electrical Engineering

Potrebbero piacerti anche