Practical Work Book LCS
Practical Work Book LCS
NHU NAZEER
HUSSAIN UNIVERSITY
DEPARTMENT OF ELECTRICAL ENGINEERING
FACULTY OF ENGINEERING PRACTICES AND SCIENCES-FEPS
Name:
Roll Number:
Semester:
Batch:
1|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
2|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Table of Contents
Synchronization with
Lab the Course
Experiment
No.
Chapter_1
1 Introduction to MATLAB
Chapter_1,2
2 Introduction to Control System Commands
Chapter_5,6,7
13 Exploring the DC Motor Characteristics
Verifying the Block Diagram Reduction Technique Chapter_4,5
14
Chapter_5,6,7
15 Open Ended Lab
LAB SESSION 01
Introduction to MATLAB
OBJECTIVE:
To gain familiarity with MATLAB basics, learn to use help files for different
operations such as differentiation, integration, solution of simultaneous
equations, graphics, Laplace, and inverse Laplace etc.
Software:
MATLAB 7.7 Release 14
Theory:
MATLAB is a "Matrix Laboratory" program which operates as an interactive
programming environment. It is extensively used in all areas of applied
mathematics in various fields.
Toolboxes:
Toolboxes are comprehensive collection of MATLAB functions available for
control systems, neural networks, fuzzy logics, wavelets, simulation, etc.
The Basics:
Calculator functions work as you'd expect:
>>(1+4)*3
+ and - are addition, / is division, * is multiplication, ^ is an exponent. Assign
variables from the MATLAB workspace. Everything in MATLAB is a matrix.
(If it's a scalar, it's actually a 1x1 matrix, and if it's a vector, it's a Nx1 or 1xN
matrix.)
>>a = 3
To create a vector is pretty similar. Each element is separated by spaces, the
whole vectore is in square brackets:
>>v = [1 3 6 8 9]
To create a vector of values going in even steps from one value to another
value,
>>b = 1:.5:10
This goes from 1 to 10 in increments of .5, any increment, positive or negative
can be used. To turn a row vector into a column vector, just put a ' at the end of
it. (This is also how to get the transpose of a matrix.) To create a matrix, you
could do something like c = [1 3 6; 2 7 9; 4 3 1]. The semicolons indicate the
end of a row. All rows have to be the same length. Whenever you assign a
value in MATLAB, it will print out the entire value you have just assigned. If
you put a semicolon at the end, it will not print it out, which is much faster.
4|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
.*
./
.^
so that MATLAB will multiply each element in the matrix instead of trying to
do matrix multiplication or division. Of course, it can also treat matrices as
actual matrices, so you can solve something like [A]x =b where A is a matrix of
coefficients, x is a column vector of the x values you want to find, and b is also
a column vector just by doing x = A\b after you define A and b. The \
represents "left division" (since to solve that equation you would have to divide
both sides by A on the *left* side, since order is significant when dealing with
matrices.). Help and other tools.
Places to get help:
5|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Typing "help" at the MATLAB prompt gives you a list of all the possible
directories MATLAB can find commands in (which also tells you its
"search path", or a list of the directories it is looking in for commands.).
Typing "help directoryname" gives you a list of the commands in that
directory and a short description of them.
Typing "help commandname" gives you help on a specific command.
Typing "lookfor keyword" gives you a list of commands that use that
keyword. i.e.,"lookfor integral" lists commands that deal with integrals.
It's pretty slow, choose the word wisely. You can use control-c to stop
searching when you think you've found what you need.
Typing "doc" starts up a web browser with the MATLAB on Athena
home page. This includes the entire reference manual for MATLAB, a
whole lot of other information on using MATLAB, and a pointer to the
MATLAB Primer, a good introduction to using MATLAB.
You can get copies of "MATLAB on Athena" at Graphic Arts. You can
also get copies of the MATLAB Primer mentioned above. (There's a
small fee for copying costs on both.)
The MATLAB manual and manuals for many of the toolboxes are
available in some clusters and can be borrowed from the consultants'
office in 11-115.
Some Useful Tools:
If you accidentally reassign a function name to a variable (i.e., you try
saying sum = 3 and then you get errors when you try to use the sum
function because it doesn't know it's a function anymore), you can restore
it to its normal state using "clear function name". You can also use clear
to get rid of all variable values with "clear all".
Who: will tell you all the variables you have currently defined.
Whos: will tell you the variables, their sizes, and some other info.
pi: is a function of that returns the value of pi. eps: is a function that
returns MATLAB’s smallest floating-point number.
eps: is a function that returns MATLAB’s smallest floating-point number.
format long/ format short: switch between the long and short display
format of numbers. Either way MATLAB uses the same number of digits
for its calculations, but normally (format short) it will only display the
first four digits after the decimal point.
Typing: Type function name for any function in MATLAB’s search path
lets you see how that function is written.
Plotting:
The basic syntax to get a plot in MATLAB is:
>>plot (x1, y1).
(The x values always come before the y values, x1 and y1 represent variables
that your data is stored in.) If you type a second plot command later, it will clear
6|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
your first plot. If you type "hold on" it will hold the current plot so you can add
plots on top of one another (until you reset, it by typing "hold off").
You can plot multiple values with plot (x1, y1, x2, y2) and you can specify the
color and line type of a plot as something like plot (x1, y1,'w*') to get white *'s
for each data point.
To split your plot into a bunch of smaller plots, you can use the subplot
command to split it up into rows and columns.
>>subplot (r, c, n)
will split the plot window into r rows and c columns of plots and set the current
plot to plot number n of those rows and columns. For example, subplot (2,1,1)
splits the plot window into two rows in a single column and prepares to plot in
the top plot. Then your plot command will plot in the top plot. Then you could
switch to the bottom plot with subplot (2,1,2) and use another plot command to
plot in the bottom plot.
You can add titles, labels, and legends to plots:
title ('This is a Title')
xlabel ('My X axis')
ylabel ('My Y axis')
legend ('First Thing Plotted’, ‘Second Thing Plotted')
legend creates a legend box (movable with the mouse) that automatically uses
the right symbols and colors and sticks the descriptions in the legend command
after them.
Differentiation
Indefinite integrals
7|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Definite integrals
Conversion to numeric (“double”) variables for subsequent numeric
calculations
Substitution
Plotting of equations and functions
Solution of equations: graphical approximations, single equations,
multiple
simultaneous equations, non-linear equations.
Limits
Taylor series
Variable precision arithmetic
Differentiation: The MATLAB symbolic toolbox is very useful for checking
calculus problems. For the syntax for symbolic differentiation, see >> help
df
sym/diff. For example, to find diff_f = dx , where f =e−ax x 3 b sin cx and a, b and c
are unspecified constants, we do the following:
Notice that the result is quite complex. To ask MATLAB to try to simplify it,
type:
(see >> help sym/simple). MATLAB uses several algorithms for algebraic
simplification and chooses as a final answer the shortest of the results.
d2 f
MATLAB can take higher order differentials. For example, to find diff2_f=
dx 2
>> diff2_f=diff (f, x, 2) using the already defined expression for f.
Indefinite integrals: For the syntax for symbolic integration, see >> help
sym/int. Thus, for example, to find the indefinite integral int_g = ʃgdx, where
g=e−ax sin cx , we do
>> clear, syms a c x; g=exp(-a*x) *sin(c*x), int_g = int (g, x)
Check this by taking >>diff_int = diff (int_g, x). This should give back g, but
it doesn’t look the same because MATLAB doesn’t always give things in the
simplest format. In this case, we again use the simple command >>
diff_int_simp = simple(diff_int).
8|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Note that MATLAB does not add the constant of integration (“C”) customarily
shown for indefinite integrals -- this you must do by adding C after the int
command.
Sometimes MATLAB is not able to integrate an expression symbolically. For
example, try to ʃfdx (where, as before, f =e−ax x 3 b sin cx and a, b and c are
unspecified constants).
>> clear, syms a b c x; f = exp(-a*x) *x^(3*b) *sin(c*x), int (f, x)
When MATLAB cannot find a solution, it gives a warning message and repeats
the command. When this happens, you’re out of luck.
Π
>> clear, syms a c x; g = exp(-a*x) *sin(c*x), int_def_g = int (g, x, -pi, pi)
>> int_def_h_doub=double(int_def_h)
Substitution: Sometimes it is desired to substitute one value or parameter for
another in an expression. This can be done using the “subs” command (see >>
9|Page
Linear Control System EE-304 Department of Electrical Engineering,
NHU
help sym/subs). For example, imagine we want a=2 and c=4 in int_def_g.
This is done by:
>> clear, syms a c x; g = exp(-a*x) *sin(c*x), int_def_g = int (g, x, -pi, pi)
>> int_sub=subs (int_def_g, {a, c}, {2,4})
Do not try to assign the values to the variables before the integration or
differentiation is performed. (Try it in the above example and see what
happens.)
Step 1: Move everything to the left-hand side of the equation, i.e. x 2+ y 2=4
Step 2: Clear and define x and y as symbolic.
Step 3: Define a variable equal to the left-hand side of the equation, inside
single straight1 quotation marks.
Step 4: Use ezplot, as follows:
>> clear; syms x y; lhs = 'x^2+y^2 - 4’; ezplot (lhs, [-3, 3, -2.5, 2.5])
The [-3, 3, -2, 2] tells MATLAB that the x scale is to go from -3 to +3, and the y
scale is to go from -2.5 to +2.5. Note that we have assigned x 2+ y 2=4 to the
character variable “eq” (see the Workspace window or type >> whos). You can
edit the figure in the Figure window. First save it as “circle. Fig” using
File/Save As so you can retrieve it later from the Command window, without
having to recreate it. Here are some things you can do in the Figure window:
Click on the arrow icon and then double-click on any portion of the
figure you’d like to edit. In this way you can change the color and
thickness of the curve, add points, change the axes, and edit the title.
Edit / Copy Figure to place it on the Windows Clipboard. Then you can
paste it into a Word document, for example.
While in the Figure window, press the Alt and Print Screen keys at the
same time, to place the entire figure window on the clipboard. This can
also be pasted into a Word document.
10 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Three-dimensional plots can be created using the ezmesh and ezsurf commands.
For these commands an explicit form must be used, i.e. z = f (x, y). It is the f
(x, y) that is entered into the command. The code below illustrates some
possibilities. The lines with % are comments and are not executed by
MATLAB.
% symplot3D.m
clear,
clc
syms x y
ex1='sqrt(4-x^2-y^2)';
figure (1); ezsurf (ex1, [-2, 2, -2, 2]);
ex2='x^2-y^2';
figure (2); ezsurf(ex2);
ex3='x^2+2';
figure (3); ezmesh(ex3);
ex4='x + y';
figure (4); ezmesh(ex4);
% Some 3d plots, where z = the expressions shown
% In the figure window, click on Tools, Rotate 3D.
% Then put cursor on figure, hold down left mouse,
% Move cursor to rotate figure, notice that this gives you a better feeling for its
3D
shape.
% Have some fun and create your own shapes.
Open the excellent MATLAB editor by >> edit, cut and paste the above code
into your editor, save it on your Current Directory as symplot3D.m, make
certain the Current Directory is in MATLAB’s path (File/Set Path), and then
execute it in the Command window by >>symplot3D. Select each figure in
turn, and in the Figure window Tools / Rotate 3D. Put the cursor anywhere on
the figure, hold down the left mouse button, and move the mouse to rotate the
figure.
Step 1: Define the variables in the equations as symbolic using the “syms”
command.
Step 2: Define the equations (see the examples below).
11 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
(Note that single quotation marks must be placed around an equation that is
assigned to a variable, here eq.) As expected, we obtain two solutions. Suppose
we want only the first. This is extracted by >> x1 = x (1). This should be done
manually or using a logical operator (“if” command), because MATLAB's
symbolic engine doesn't always give multiple solutions in the same order. What
is x (1) now could be x (2) in a subsequent trial.
Notice that we did not have to enter x, y and z in any particular order in defining
the
equation variables (unlike the numerical MATLAB method using matrices
with \ or inv). However, the variables in the output are in alphabetical order,
regardless of how they are written in the command. So, take care to list the
variables in the brackets in alphabetical order. (For example, if you use [z, x, y]
rather than [x, y, z] in the above example the result produced for z is actually x,
12 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
that for x is actually y, and that for y is actually z.). Again, the results may be
symbolic and require conversion to numeric form for subsequent calculations:
The "hold on" command tells MATLAB to write the following plots on top of
the first one, rather than replacing it. Approximate values of the solutions
(intersections) can be obtained in the Figure window by clicking on Tools /
Zoom In, clicking on a desired intersection to enlarge that area of the graph,
clicking on Tools / Data Cursor, and then clicking on that intersection again to
give the approximate values of x and y there. Compare these results with those
found above using the solve command.
>> clear, syms x; eq='y - sin(x) + 1/2’; ezplot (eq, [-6, 6, -2, 1])
>> hold on; eq0='0'; ezplot(eq0); hold off
The "hold on" command tells MATLAB to write the following plots on top of
the first one, rather than replacing it. Plotting 0 puts a horizontal line on the
graph. Intersections of the sine wave with this line represent solutions of the
first equation. Approximate values can be obtained in the Figure window by
clicking on Tools / Zoom In, clicking on a desired intersection to enlarge that
area of the graph, clicking on Tools / Data Cursor, and then clicking on that
intersection again to give the approximate values of x and y there. Try this on
13 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
the first two intersections to the right of the origin (x > 0). Write down your
results to compare with those found below using solve commands.
The symbolic solve command finds only one of these solutions and then stops:
>> clear, syms x; eq = 'sin(x)-1/2=0’; [x] = solve (eq, x); x_doub=double(x)
But suppose we want the solution that lies between x = 2 and x = 3. This must
be done numerically.
Limits: The symbolic toolbox also contains a command for finding limits of
expressions,e.g.
sin (ax)
lim
x →0 x
>> clear, syms x a; value = limit(sin(a*x)/x, x, 0)
There are cases where the limit depends on the direction from which it is
approached.
Consider the plot of tan(x) versus x generated by:
>> ezplot('tan(x)')
Suppose we want the value of tan(x) at x = /2. We could use MATLAB's
numeric engine as follows:
>> tan(pi/2)
Does this give a correct result? Recall that tan (𝜫 /2) can be either + or - ,
depending whether we approach from the left or the right. The numeric solution
is a very large number, which might by okay for some applications but not for
others. We can use the symbolic engine to find the two correct solutions, as
follows:
Taylor series: Taylor series are polynomial approximations for functions that
are valid near a particular point. Differentials of increasingly higher order are
used to generate this polynomial (e.g., see your calculus test). The syntax is
Taylor (expression, order, variable, point).
Example: Expand e x .
about x = 3 to order 5:
The approximation improves as one adds more terms to the polynomial (order)
or moves closer to the point about which the expansion was made. This can be
illustrated by:
is used (see help symsum). Let us consider ∑ f (k), where f(k) is a function of
k=m
1 xk
∞ ∞
As an exercise find, ∑ and ∑ , the result may surprise you.
k =1 k2 k=0 k !
The inverse transform can also be computed using MATLAB. If you want to
compute the inverse Laplace transform of F (S)=24/(s*(s+8));
.>> syms F S
>> F=24/(s*(s+8));
>> ilaplace(F)
15 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
ans = 3-3*exp(-8*t)
We can also do inverse Laplace transform using partial fraction expansion, and
MATLAB can help you with that. If you want to find the partial-fraction
expansion of
4 s 2+ 4 s+ 4
Y(s) = 2 2
s (s + 3 s+ 2)
You write the coefficients of the numerator and the denominator in separate
vectors
and MATLAB gives you the coefficients with the corresponding poles in the
expansion.
>> n= [0 0 4 4 4];
>> d= [1 3 2 0 0];
>> [r, p, k] = residue (n, d)
LAB SESSION 02
Theory: -
Control System:
A control system is an interconnection of components forming a system
configuration that will provide a desired system response. Hence, a control
system is an arrangement of physical components connected or related in such a
manner as to command, regulate, direct, or govern itself or another system. A
control system provides an output or response for a given input or stimulus.
There are three basic forms to describe linear time invariant (LTI) systems in
MATLAB.
Transfer function form:
Zero-pole-gain form:
1)Transfer Function:
H=tf (num, den)
H=zpk ([], [-1, -2],2)
17 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
18 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
[num, den] =parallel (num1, den1, num2, den2), this function gives parallel
connection of two LTI models. The arguments for the function are num1, num2
and den1, den2 that are the numerators and denominators of the two function
this function returns the num and den as the output.
SYS = FEEDBACK (SYS1, SYS2) computes an LTI model SYS for the
closed-loop feedback system. To apply positive feedback, use the syntax.
SYS = FEEDBACK (SYS1, SYS2, +1).
19 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Program # 01: -
disp('NHU ')
disp('Created by xyz ')
disp(' Reg# ‘)
num=[2 5 3 6]
den=[1 6 11 6]
[r,p,k]=residue(num,den)
[num,den]=residue(r,p,k)
printsys(num,den,'S')
OUTPUT:
Program # 02: -
m = 2;
b = 5;
k = 3;
num = [ 1 ];
den = [ m b k ];
tutorial_tf = tf(num, den)
OUTPUT: -
20 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Program # 03: -
num=[2 5 3 6]
den=[1 6 11 6]
[z,p,k]=tf2zp(num,den)
disp('Zeros of the function is = ')
disp(z)
disp('Poles of the function is = ')
disp(p)
disp('Gain of the function is = ')
disp(k)
OUTPUT: -
21 | P a g e
Linear Control System EE-304NAZEER
Department
HUSSAIN of Electrical Engineering,
UNIVERSITY
NHU
DEPARTMENT OF ELECTRICAL ENGINEERING
FACULTY OF ENGINEERING PRACTICES AND SCIENCES-FEPS
LAB SESSION 03
OBJECT: -
Finding impulse and step response of the following system by using Simulink
and compare the results.
Apparatus Required: MATLAB is required to perform all the experiments for this lab.
Theory: -
G(s)=10/s^2+2s+20
Design two systems in Simulink, one for impulse response and one for step response.
Then use the given equation to obtain the result using scope. To find both the
responses in MATLAB, write the required code and finally compare both the results
(of Simulink and MATLAB).
Step Response Using Simulink:
Procedure:
1. Type “Simulink” in MATLAB command prompt.
2. “Simulink Library Browser” window will appear.
3. Create a new file by selecting “model” from the file option (file>>New>Model).
4. Drag the step function from the Simulink library browser to the new file created
followed by transfer function and scope. Scope is used to see the result (resulting
waveform).
5. Give values to the transfer function according to the question.
6. After saving followed by simulation, click on the scope in the figure to see
the resulting waveform(graph).
7. A window showing the step response will appear.
OUTPUT: -
22 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
OUTPUT: -
Analysis:
23 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
24 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 04
Programme:
n=[4]; n=[4];
d=[1 2]; d=[1 6 16];
sys=tf(n,d); sys=tf(n,d);
step(sys) step(sys)
impulse(sys) impulse(sys)
25 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
RESULT:
LAB SESSION 05
26 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
T. F= 4/s2+6s+16
Verifying the Response of Open
Loop Systems.
SIMULINK Modelling
OBJECT: - To digitally simulate the Step Input Close Loop –I1 Order:
time response characteristics of Linear
Closed loop SISO systems using state
variable formulation.
Impulse Input Close Loop –II Order:
Apparatus Required: A PC with
MATLAB package.
Theory:
State Variable approach is a more
general mathematical representation of a
system, which, along with the output,
yields information about the state of the
system variables at some predetermined
points along the flow of signals. It is a
direct time-domain approach, which provides a basis for modern control theory
and system optimization. SISO (single input single output) linear systems can
be easily defined with transfer function analysis. The transfer function approach
can be linked easily with the state variable approach.
Programme:
27 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
SIMULINK Modelling:
Step Input Close Loop –I Order:
Analysis:
LAB SESSION 06
Theory: This lab is based on finding the root locus of system. Two basic
commands can be used to get the root locus. Sisotool(sys) and rootlocus(sys)
are used to find root locus but restriction for this lab is usage of rlocus(sys)
command only. The method adopted by W.R. Evans to find the roots of a
characteristic’s equation is called root-locus method. Function for drawing a
root locus in MATLAB is the rlocus () function. Rlocus () computes and plots
the root locus of the single-input, single-output LTI model sys. Rlocus (sys, k)
uses a user-specified vector K of gains.
28 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
K (s−2)
G ( s ) H ( s )=
( s+ 2)(s−2 j)(s+ 2 j)
Simplification of Transfer function:
=(s-2)/(s+2)(s+2j)(s-2j)
=(s-2)/(s+2)(s^2+2s+3)
=(s-2)/(s^3+2s^2+4s+8)
So num= [1 -2] & denum= [1 2 4 8]
Procedure:
Simplify the transfer function to generate num and denum.
Using MATLAB write the code 1, given below, to find the root locus.
After executing code1 a graph will appear showing root locus of a system.
MATLAB Code-2 is executed to give different values of gain (K) to the system
and this time rlocus (sys, k) command is used to plot root locus with different
value of gains.
Graph is plotted only for range of K given in code2 where range of K is from 0
to 10.
By changing the values of K, the value of poles of a system change.
In MATLAB code-2 for different values of K the value of poles is observed
and are shown in figures below.
Students are advised to get the results and verify the results by applying
mathematical ways of calculating transfer function.
MATLAB Code-1:
num=[1 -2]
denum=[1 2 4 8]
sys=tf(num, denum)
rlocus(sys)
title('Root locus of G(S)H(S)= K(s -2)/(s^3+ 2s^2+ 4s+ 8)').
Graph:
29 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
30 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
0 -2,6.11e-16+2i, 6.11e-16-2i
1 -1.43, -0.284+2.03i, -0.284-2.03i
Analysis:
31 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Conclusion:
LAB SESSION 07
Theory: The time response of control system consists of two parts. Transient
response and steady state response. C (t) = Ctr(t) + Css(t). Most of the control
systems use time as its independent variable. Analysis of response means to see
the variation of output with respect to time. The output of the system takes some
finite time to reach to its final value. Every system has a tendency to oppose the
oscillatory behavior of the system which is called damping. The damping is
measured by a factor called damping ratio of the system. If the damping is very
high, then there will not be any oscillations in the output. The output is purely
exponential. Such system is called an over damped system. If the damping is
less compared to over damped case, then the system is called a critically
damped system. If the damping is very less than the system is called under
damped system. With no damping system is undamped.
32 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Graph: -
33 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Tabular Columns: -
sys2=zpk(z, p, k2)
sys3=zpk(z, p, k3)
t= [0:0.01:20];
[y1, t] =step(sys1, t)
[y2, t] = step(sys2, t)
[y3, t] = step(sys3, t)
plot (t, y1, t, y2, t, y3)
legend (‘k=1’, ‘k=2’, ‘k=3’)
grid;
Result:
Questions:
1-What is meant by time response of a system?
2-What do you mean by damping factor?
35 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 08
KI K D s2 + K p + K I
K p+ + K D s=
s s
K p =Proportional gain, K D=Derivative gain and K I =Integral gain respectively. First,
let’s take a look at how the PID controller works in a closed-loop system using
36 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
the schematic shown above. The variable (e) represents the tracking error, the
difference between the desired input value (R) and the actual output (Y). This
error signal (e) will be sent to the PID controller, and the controller computes
both the derivative and the integral of this error signal. The signal (u) just past
the controller is now equal to the proportional gain (KP) times the magnitude of
the error plus the integral gain (KI) times the integral of the error plus the
derivative gain (KD) times the derivative of the error.
de (t)
u=K p e ( t )+ K I ʃe ( t ) dt + K D
dt
This signal (u) will be sent to the plant, and the new output (Y) will be obtained.
This new output (Y) will be sent back to the sensor again to find the new error
signal (e). The controller takes this new error signal and computes its
derivatives and its internal again. The process goes on and on.
X (s ) 1
G ( s )= = 2 =Plant Function
F ( s ) s +10 s+20
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:
The closed-loop transfer function of the above system with a proportional
controller is:
X (s ) Kp
= 2
F ( s ) s +10 s+(20+ K p )
37 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Note: The MATLAB function called feedback was used to obtain a closed-loop transfer
function directly from the open-loop transfer function (instead of computing closed-loop
transfer function by hand). We have to analyze 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.
38 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 09
Introduction to Proportional-Integral
Controller
OBJECT: - Investigate the characteristics of the proportional-Integral
Controller.
Apparatus Required: PC loaded with MATLAB.
Theory:
Introduction: Consider the following unity feedback system:
KI K D s2 + K p + K I
K p+ + K D s=
s s
K p =Proportional gain, K D=Derivative gain and K I =Integral gain respectively. First,
let’s take a look at how the PID controller works in a closed-loop system using
the schematic shown above. The variable (e) represents the tracking error, the
39 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
difference between the desired input value (R) and the actual output (Y). This
error signal (e) will be sent to the PID controller, and the controller computes
both the derivative and the integral of this error signal. The signal (u) just past
the controller is now equal to the proportional gain (KP) times the magnitude of
the error plus the integral gain (KI) times the integral of the error plus the
derivative gain (KD) times the derivative of the error.
de (t)
u=K p e ( t )+ K I ʃe ( t ) dt + K D
dt
This signal (u) will be sent to the plant, and the new output (Y) will be obtained.
This new output (Y) will be sent back to the sensor again to find the new error
signal (e). The controller takes this new error signal and computes its
derivatives and its internal again. The process goes on and on.
X (s ) 1
G ( s )= = 2 =Plant Function
F ( s ) s +10 s+20
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-Integral control:
Before going into a PID control, let's take a look at a PI control. For the given system,
the
closed-loop transfer function with a PI control is:
X (s ) K p s +KI
= 3 2
F ( s ) s +10 s + ( 20+ K p ) s+ K I
40 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Analyze:
Analysis:
41 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
KI K D s2 + K p + K I
K p+ + K D s=
s s
K p =Proportional gain, K D=Derivative gain and K I =Integral gain respectively. First,
let’s take a look at how the PID controller works in a closed-loop system using
the schematic shown above. The variable (e) represents the tracking error, the
difference between the desired input value (R) and the actual output (Y). This
42 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
error signal (e) will be sent to the PID controller, and the controller computes
both the derivative and the integral of this error signal. The signal (u) just past
the controller is now equal to the proportional gain (KP) times the magnitude of
the error plus the integral gain (KI) times the integral of the error plus the
derivative gain (KD) times the derivative of the error.
de (t)
u=K p e ( t )+ K I ʃe ( t ) dt + K D
dt
This signal (u) will be sent to the plant, and the new output (Y) will be obtained.
This new output (Y) will be sent back to the sensor again to find the new error
signal (e). The controller takes this new error signal and computes its
derivatives and its internal again. The process goes on and on.
X (s ) 1
G ( s )= = 2 =Plant Function
F ( s ) s +10 s+20
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-Derivative control:
The closed-loop transfer function of the given system with a PD controller is:
X (s ) K D s+ K P
= 2
F ( s ) s + ( 10+ K D ) s+¿ ¿
Let KP equal 300 as before and let KD equal 10.
Kp=300;
Kd=10;
contr=tf([Kd Kp],1);
sys_cl=feedback(contr*plant,1);
t=0:0.01:2;
step(sys_cl,t)
Output:
43 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Analysis:
44 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
KI K D s2 + K p + K I
K p + + K D s=
s s
K p =Proportional gain, K D=Derivative gain and K I =Integral gain respectively. First,
let’s take a look at how the PID controller works in a closed-loop system using
the schematic shown above. The variable (e) represents the tracking error, the
difference between the desired input value (R) and the actual output (Y). This
error signal (e) will be sent to the PID controller, and the controller computes
both the derivative and the integral of this error signal. The signal (u) just past
45 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
the controller is now equal to the proportional gain (KP) times the magnitude of
the error plus the integral gain (KI) times the integral of the error plus the
derivative gain (KD) times the derivative of the error.
de (t)
u=K p e ( t )+ K I ʃe ( t ) dt + K D
dt
This signal (u) will be sent to the plant, and the new output (Y) will be obtained.
This new output (Y) will be sent back to the sensor again to find the new error
signal (e). The controller takes this new error signal and computes its
derivatives and its internal again. The process goes on and on.
X (s ) 1
G ( s )= = 2 =Plant Function
F ( s ) s +10 s+20
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-Integral-Derivative control:
Now, let's take a look at a PID controller. The closed-loop transfer function of the given
system with a PID controller is:
X (s ) K D s2 + K P + K I
= 3
F ( s ) s + ( 10+ K D ) s2 + ( 20+ K P ) s+ K I
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)
The characteristics of P, I, and D controllers:
The proportional controller (KP) will have the effect of reducing the rise time
and will reduce, but never eliminate, the steady state error. An integral
controller (KI) will have the effect of eliminating the steady state error, but it
46 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
may make the transient response worse. A derivative control (KD) will have the
effect of increasing the stability of the system, reducing the overshoot and
improving the transient response.
Output:
Conclusion:
47 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 12
1
x˙1
[ ]
x˙2
=
[ ][ ] [ ]
0
1
L
PROCEDURE:
C x 1 + 0 [u ]
−R x 2
L
1
L
Graph:
49 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Observations:
Parameter Behavior of System
Voltage Source (e)
Resistance (R)
Inductance (L)
Capacitance (C)
Conclusion:
50 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 13
51 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Va). If the speed drops (due to loading) Va reduces, the current increases and thus so
does the motor torque. This tends to oppose the speed drop. This mode of control is
called 'armature control' and gives a speed proportional to Vin as in figure.
Student should be able to understand how electrical terms (voltage, current, emf)
interact with mechanical terms (speed, position) via electro-magnetic circuit
(inductance). The motor torque, T, is related to the armature current, i, by a constant
factor Kt. The back emf, e, is related to the rotational velocity by the following
equations:
T =K t i
dθ
e=K e
dt
di
∫ dt =i
52 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Insert an Integrator block (from the Linear block library) and draw lines to and from its
input and output terminals.
Label the input line "d2/dt2(theta)" and the output line "d/dt(theta)" as shown
below.
To add such a label, double click in the empty space just above the line.
Insert another Integrator block attached to the output of the previous one and
draw a line from its output terminal.
Label the output line "theta".
Insert a third Integrator block above the first one and draw lines to and from its
input and output terminals.
Label the input line "d/dt(i)" and the output line "i".
Next, we will start to model both Newton's law and Kirchhoff’s law. These laws
applied to the motor system give the following equations:
d2 θ dθ
dθ
=T −b => −b
J => 1 (K ¿ ¿t i−b dθ )¿
dt 2
dt dt J dt
di 1 dθ
L =−Ri+V −e=¿ (−Ri +V −K e )
dt L dt
The angular acceleration is equal to 1/J multiplied by the sum of two terms (one pos.,
one
neg.). Similarly, the derivative of current is equal to 1/L multiplied by the sum of three
53 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
terms
(one pos., two neg.).
Insert two Gain blocks, (from the Linear block library) one attached to each of
the leftmost integrators.
Edit the gain block corresponding to angular acceleration by double-clicking it
and changing its value to "1/J".
Change the label of this Gain block to "inertia" by clicking on the word "Gain"
underneath the block.
Similarly, edit the other Gain's value to "1/L" and its label to Inductance.
Insert two Sum blocks (from the Linear block library), one attached by a line
to each of the Gain blocks.
Edit the signs of the Sum block corresponding to rotation to "+-" since one
term is positive and one is negative.
Edit the signs of the other Sum block to "-+-" to represent the signs of the
terms in Kirchhoff’s equation.
Now, we will add in the torques which are represented in Newton's equation. First, we
will add in the damping torque.
Insert a gain block below the inertia block, select it by single-clicking on it, and
select Flip from the Format menu (or type Ctrl-F) to flip it left-to-right.
Set the gain value to "b" and rename this block to "damping".
54 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Tap a line (hold Ctrl while drawing) off the first rotational integrator's output
(d/dt(theta)) and connect it to the input of the damping gain block.
Draw a line from the damping gain output to the negative input of the rotational
Sum block.
Next, we will add in the torque from the armature.
Insert a gain block attached to the positive input of the rotational Sum block
with a line.
Edit its value to "K" to represent the motor constant and Label it "Kt".
Continue drawing the line leading from the current integrator and connect it to
the Kt gain block.
Now, we will add in the voltage terms which are represented in Kirchhoff’s equation.
First, we will add in the voltage drop across the coil resistance.
Insert a gain block above the inductance block and flip it left-to-right.
Set the gain value to "R" and rename this block to "Resistance".
Tap a line (hold Ctrl while drawing) off the current integrator's output and
55 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
The third voltage term in the Kirchhoff equation is the control input, V. We will apply
a step input.
Insert a Step block (from the Sources block library) and connect it with a line to
the positive input of the current Sum block.
56 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
To view the output speed, insert a Scope (from the Sinks block library)
connected to the output of the second rotational integrator (theta).
To provide an appropriate unit step input at t=0, double-click the Step block
and set the Step Time to "0".
57 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Step input:
Use step input from 0 volts to 2 volts and observe the response.
Save the response to workspace variable to further compare with the
experimental DC motor (DCM 150F).
Now Step the input voltage from 2 volts to 4 volts. Save the response to further
compare with experimental motor.
This is the simulation section for the Exercise 2 – Step input.
Conclusion:
58 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
LAB SESSION 14
OBJECT: The objective of this exercise will be to learn commands in MATLAB that
would be used to reduce linear systems block diagram using series, parallel and
feedback configuration.
Theory:
Series configuration: If the two blocks are connected as shown below then the blocks
are said to be in series. It would like to multiply two transfer functions. The MATLAB
command for the such configuration is “series”.
59 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
Parallel configuration: If the two blocks are connected as shown below then the
blocks are said to be in parallel. It would like to add two transfer functions.
Feedback configuration: If the blocks are connected as shown below then the blocks
are
said to be in feedback. Notice that in the feedback there is no transfer function H(s)
defined.
When not specified, H(s) is unity. Such a system is said to be a unity feedback system.
60 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU
system
as shown below:
Questions:
Question No:1 Given the transfer functions of individual blocks, generate the system
transfer function of the block combinations?
Example 2: For the systems defined in Question No: 1, modify the MATLAB
commands to obtain the overall transfer function when the two blocks are in parallel?
Example 3: Given a unity feedback system as shown in the figure, obtain the overall
transfer
function using MATLAB.
61 | P a g e
Linear Control System EE-304 Department of Electrical Engineering,
NHU NAZEER
HUSSAIN UNIVERSITY
DEPARTMENT OF ELECTRICAL ENGINEERING
FACULTY OF ENGINEERING PRACTICES AND SCIENCES-FEPS
Obtain pole, zero & gain values of a transfer function and Write MATLAB
code to obtain transfer function of a system from its pole, zero, gain values.
Assume pole locations are -2, 1, zero at -1 and gain is 7, also change and choose
according to your own observation.
Observation:
Stability criteria of a system is determined and with the help of various poles
and zeroes and by changing gain values it is observed that what effect system
has on stability and system response.
Learning Outcomes:
Pole, zero values and gain are important parameters for analyzing system
response and all these helps to observe stability of the system and Stability
analysis is very important in the field of Control Systems.
62 | P a g e