American International University- Bangladesh Faculty of ......In the 1960s, control engineers...
Transcript of American International University- Bangladesh Faculty of ......In the 1960s, control engineers...
![Page 1: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/1.jpg)
Experiment 1
American International University- Bangladesh Faculty of Engineering (EEE)
Control Systems Laboratory
Title: Introduction to design and simulation of open loop and close loop control systems using a
Computer Aided Design (CAD) tool---MATLAB.
Abstract: This experiment introduces students to the widely used simulation software MATLAB and how it is
used to describe control system related problems and functions. It shows a few basic techniques such
as -
1. Creating polynomial functions, finding roots of a polynomial function, evaluating
polynomials, calculating product of two polynomial functions in MATLAB.
2. Obtaining overall transfer functions of open loop and close loop control systems.
3. Observing the step responses of open-loop and closed-loop control systems.
Introduction: The objectives of this experiment are to complete the above mentioned tasks with the knowledge of
using all the commands associated with the tasks. Basic mathematical skills such as Laplace
transformation in control system and understanding of open loop and close loop systems and their
differences is necessary for this experiment. As all the tasks are associated with MATLAB, some
basic commands and their various uses along with some user guideline for this software is necessary.
This entire experiment is based on MATLAB codes in 3 groups. First group of code shows
polynomial and its mathematical manipulation, second group shows a simulation of open loop control
system and the third group of codes shows a simulation of close loop control system. Doing these in
MATLAB allows a accurate solution for students instead doing them using mathematically. It shows
them another way of doing these tasks and it saves time.
Basic parameters used in MATLAB:
Table 1: Managing workspace and file commands
![Page 2: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/2.jpg)
Command
Description
cd
clc
clear (all)
clear x
copyfile
delete
dir
exist
help
lookfor
mkdir
movefile
pwd
rmdir
type
what
which
who whos
Change current directory
Clear the Command Window
Removes all variables from the workspace
Remove x from the workspace
Copy file or directory
Delete files
Display directory listing
Check if variables or functions are defined
Display help for MATLAB functions
Search for specified word in all help entries
Make new directory Move
file or directory Identify
current directory Remove
directory
Display contents of file
List MATLAB files in current directory
Locate functions and files
Display variables currently in the workspace
Display information on variables in the workspace
Table 2: Elementary matrices and arrays
Command
Description
eye
linspace
ones
rand
zeros
Identity matrix
Generate linearly space vectors
Create array of all ones
Uniformly distributed random numbers and arrays
Create array of all zeros
Table 3: Arrays and Matrices: Basic information
Command
Description
disp
isempty
isequal
length
ndims
numel
size
Display text or array
Determine if input is empty matrix
Test arrays for equality
Length of vector Number
of dimensions Number of
elements Size of matrix
![Page 3: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/3.jpg)
Precautions: Make sure that all the m-files are saved in the current directory of MATLAB.
Otherwise, the m-files will not be found and executed when they are called from the command
window.
Theory and Methodology:
A combination of components that act together is called system. There are two types of systems- open
loop and close loop control systems. Systems in which the output quantity has no effect on the input
quantity are open-loop control systems. A generic open-loop system is shown in Fig. 1.1 below.
Fig. 1.1: Block diagram of an Open-Loop System
The input transducer converts the input into the form that is used by the controller. The controller
then drives a process or plant. Other signals such as disturbances are added to the controller and
process outputs via summing junctions. The drawback of open-loop system is that it cannot
compensate for any disturbances that add to the controller driving signal or the output.
Systems in which the output quantity has an effect upon the input quantity---primarily to maintain the
desired output value---are close-loop control systems. In close loop control systems feedback of the
output quantity is a must. The unit that provides the means for feeding back the output quantity or a
function of the output to compare it with the reference input is called a feedback element. The block
diagram of closed-loop system is given in fig. 1.2. The output transducer or sensor measures the
output response and converts it into the form used by the controller. The first summing junction
algebraically adds the signal from the input to the signal from the output, which arrives via the
feedback path. The result from this is generally called error signal or actuating signal. If the output
signal is directly compared with the reference input then this type of closed-loop system is called a
unity feedback system. If a portion of the output signal is compared with the reference input signal
then this type of closed-loop system is called a non-unity feedback system.
Fig. 1.2: Block diagram of Closed-Loop System
![Page 4: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/4.jpg)
The advantage of closed-loop system over open-loop system is that, it can compensate for the
disturbance by measuring the output response, feeding the measurement back through a feedback path
and comparing that response to the input at the summing junction. Closed-loop systems are less
sensitive to noise, disturbances and changes in the environment.
In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these
systems. The matrix-based mathematics of state space analysis and design drove the need for more
sophisticated computer analysis. C. B. Moler of the University of New Mexico wrote an interactive
program called MATLAB. The introduction of MATLAB was a phenomenal success, as it
revolutionized computer-aided analysis and design of control systems.
Open loop control system block diagram:
The transfer unction for open loop - Ge(s) = C(s)/R(s)
Close loop control system block diagram:
Closed-loop, transfer function shown in the Figure right below,
![Page 5: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/5.jpg)
The product, G(s)H(s), in equation is called the open-loop transfer function, or loop gain.
POLYVAL means Evaluate polynomial.
Y = POLYVAL(P,X) returns the value of a polynomial P evaluated at X. P is a vector of length
N+1 whose elements are the coefficients of the polynomial in descending powers.
Y = P(1)*X^N + P(2)*X^(N-1) + ... + P(N)*X + P(N+1)
PRINTSYS Print system in pretty format.
PRINTSYS is used to print state space systems with labels to the right and above the system
matrices or to print transfer functions as a ratio of two polynomials.
ROOTS Find polynomial roots.
ROOTS(C) computes the roots of the polynomial whose coefficients are the elements of the vector
C. If C has N+1 components, the polynomial is C(1)*X^N + ... + C(N)*X + C(N+1).
POLY Convert roots to polynomial.
POLY(A), when A is an N by N matrix, is a row vector with N+1 elements which are the
coefficients of the characteristic polynomial, DET(lambda*EYE(SIZE(A)) - A) .
POLY(V), when V is a vector, is a vector whose elements are the coefficients of the polynomial
whose roots are the elements of V . For vectors, ROOTS and POLY are inverse functions of each
other, up to ordering, scaling, and roundoff error.
CONV Convolution and polynomial multiplication.
C = CONV(A, B) convolves vectors A and B. The resulting vector is length
LENGTH(A)+LENGTH(B)-1. If A and B are vectors of polynomial coefficients, convolving
them is equivalent to multiplying the two polynomials.
STEP Step response of LTI models.
STEP(SYS) plots the step response of the LTI model SYS (created with either TF, ZPK, or SS).
For multi-input models, independent step commands are applied to each input channel. The time
range and number of points are chosen automatically.
[Y,T,X] = STEP(SYS) also returns, for a state-space model SYS, the state trajectory X, a LT-by-
NX-by-NU array if SYS has NX states.
FEEDBACK Feedback connection of two LTI models.
SYS = FEEDBACK(SYS1,SYS2) computes an LTI model SYS for the closed-loop feedback
system
Negative feedback is assumed and the resulting system SYS maps u to y. To apply positive
feedback, use the syntax SYS = FEEDBACK(SYS1,SYS2,+1).
![Page 6: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/6.jpg)
p1=[1 0 5 6] means defining the function pl = s3 + 0s
2 + 5s
1 + 6s
0
The row vector is defined in left to right descending order.
using polyval, putting s=1; pl is evaluated = 13 + 0 + 5(1) + 6 = 12
roots of pl = s3 + 0s
2 + 5s + 6 = s(s+2)(s+3)
For open loop, overshoot is somewhat 0.114 and steady state value has reached after 1.5 seconds
![Page 7: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/7.jpg)
For close loop, overshoot is somewhat 0.1025(reduced in comparison to open loop) and steady state
value has reached before 1.5 seconds
Pre lab homework: Students should study -
1. Laplace transform and its mathematical manipulations,
2. Basic idea and block diagram of control systems,
3. Basic idea and block diagram of open loop control system,
4. Basic idea and block diagram of close loop control system.
Equipments : Computer
Precautions: Students should take the following precautions while conducting the experiment -
1. check the PC if it is working; otherwise inform lab instructor,
2. be careful while handling the power supply buttons of computers and to keep them off
when they are not needed,
3. Ckeck if MATLAB is working correctly,
Experimental Procedure:
Working in MATLAB environment:
1. To start MATLAB software package, click on the START menu in the desktop, then find the
MATLAB icon from the program group. This will open a MATLAB Command Window for
you. You can find the MATLAB software package in the desktop as well. You can just
double-click it.
2. When the MATLAB Command Window pops up, you will get a prompt (>>). You can write
your MATLAB commands after this prompt and MATLAB will execute them line by line.
Working in the MATLAB environment is generally straightforward as most commands are
entered as you would write them mathematically.
For example, entering the following sample expression
>> a = 4/3
yields the MATLAB response as follows
a =
1.3333.
3. However, it is much more convenient to use an M-file (with .m extension) than to enter
commands line by line at the MATLAB prompt. In MATLAB Command Window, click New-
>M-file to bring up a new M-file.
4. In M-files, statements that begin with a ‘%’ are considered to be comments and are ignored by
MATLAB. The commands in these files are executed in the MATLAB environment simply
by entering the name of the file without the “.m”.
For this lab, an M-file Lab1.m was written in C:\Spring 2012 folder. This same file has been
loaded in all the computers in the lab. To run this file first you have to change your working
directory by writing the following commands at your MATLAB prompt as:
>>C:\ Spring 2012
![Page 8: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/8.jpg)
Now write the file name at MATLAB prompt to run your file from the directory like
following:
>>Lab1
and then press ENTER.
You will get the answers like following:
p1 =
1 0 5 6
num/den =
s^3 + 5 s + 6
-------------
1
ans =
12
5. With the help of the teacher, run the M-file on a PC in MATLAB environment. Write down
the answers from the MATLAB command prompt in a your notebook and analyze them.
Remember, in MATLAB, if the semicolon at the end of a command is not used, it will display
computed answer for that command in the MATLAB command window.
6. After running the M-file, two figures will pop up. Go to Figure No. 2. Click on Tools-Axes
Properties. In Edit Axes Properties window, click the Manual in Tick Step option. Enter 0.2
for “time in seconds”. Keep the default value for “y(t)”. Click Manual in the Limits option.
Enter 1.8 in the right cell for time in seconds. Keep the left cell as 0. Click Apply and then Ok.
This will allow you to analyze both the figures within the same “zone”.
Simulation: See the MATLAB Code in appendix section
Command window Output:
p1 =
1 0 5 6
num/den =
s^3 + 5 s + 6
-------------
1
ans =
12
r1 =
![Page 9: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/9.jpg)
0.5000 + 2.3979i
0.5000 - 2.3979i
-1.0000
p2 =
1.0000 0.0000 5.0000 6.0000
num/den =
s^3 + 1.2212e-015 s^2 + 5 s + 6
-------------------------------
1
exp =
1 3 2
OL_TRF_num =
1 1
OL_TRF_den =
1 8 15
num/den =
s + 1
--------------
s^2 + 8 s + 15
G =
1 1
H =
1 8 15
CL_TRF_num =
0 1 1
![Page 10: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/10.jpg)
CL_TRF_den =
1 9 16
num/den =
s + 1
--------------
s^2 + 9 s + 16
![Page 11: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/11.jpg)
Report: Write a report on this experiment. With the approval and help of the teacher paste the Matlab results
(from the Matlab Command Window), Matlab codes (from the M-file) and Matlab plots in an MS
Word file. Only one group should print out this file. Members of the group and other groups should
make copies of this printout at some other time. These printouts should be attached in the Body of
everyone’s lab reports.
Comment on the step responses for different control systems. Did you find any difference in the step
responses of open loop and closed loop control systems? Provide your comments and
recommendations for it.
Reference: Norman S. Nise, “Control Systems Engineering”, available Edition, John Wiley & Sons Inc.
![Page 12: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/12.jpg)
Appendices
%EEE 4101 (Control Systems)
%Lab 1
%MATLAB codes
clc; %Clears the MATLAB Command Window
close all; %Closes all figures
clear all; %Clears all variables
%Part 1
%Creating equations, Calculating roots, Outputting transfer functions etc.
p1=[1 0 5 6] %Defines the coefficients of a linear equation
printsys(p1,[0 0 0 1],'s') %Outputs the polynomial of the equation
%as a transfer function and also in
%symbolic form, where the variable
%is labelled as "s"
polyval(p1,1) %Evaluates the polynomial of the equation
%with a value of 1
r1=roots(p1) %Calculates the roots of the equation
p2=poly(r1) %Creates an equation from the roots (r1).
%This should match with the original equation(p1).
%But it will not match exactly in this case.
%This is because the imaginary portion of the
%complex root has fractions and MATLAB cannot
%incorporate all digits to the right of a
%fraction in computations.
printsys(p2,[0 0 0 1],'s') %Outputs the equation as a transfer function
%and also in symbolic form, where the variable
%is labelled as "s". This should match with
%the previous transfer function
exp1=[1 1]; %Define an expression called exp1
exp2=[1 2]; %Define an expression called exp2
exp=conv(exp1,exp2) %Multiply these two expresions and store the
%result in exp
![Page 13: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/13.jpg)
%Part 2
%Simulating an open loop control system
clear all; %Clears all variables (i.e. p1,r1,p2 etc.)
OL_TRF_num = [1 1] %Define the numerator of a transfer function
OL_TRF_den = conv([1 3], [1 5]) %Define the denominator of a transfer function
printsys(OL_TRF_num, OL_TRF_den, 's')
%Outputs the transfer function (open-loop) in
%symbolic form, where the variable is "s"
[y, x, t]=step(OL_TRF_num, OL_TRF_den);
%Simulate this system for a step input.It will
%store the simulation results in certain
%variables like y,x,t
figure (1) %Label the figure
plot(t, y) %Display the simulation in a 2-D plot
grid %Add gridlines in the figure
title('Unit step responce for open loop') %Add a title to the figure
ylabel('y(t)') %Label y axis
xlabel('time in seconds') %Label x axis
%Part 3
%Simulating a close loop control system
%This control system has unity feedback
clear all; %Clears all variables (i.e. p1,r1,p2,Gnum,
%Gden,y,x,t etc.)
G = [1 1] %Define the feedforward transfer function
H = conv([1 3], [1 5]) %Define the feedback transfer function
[CL_TRF_num, CL_TRF_den] = cloop(G, H)
%Form the resulting close-loop transfer function
printsys(CL_TRF_num, CL_TRF_den, 's')
%Outputs the transfer function (open-loop) in
%symbolic form where the variable is "s"
[y, x, t]=step(CL_TRF_num, CL_TRF_den);
![Page 14: American International University- Bangladesh Faculty of ......In the 1960s, control engineers turned to linear algebra techniques of state space modeling for these systems. The matrix-based](https://reader035.fdocuments.us/reader035/viewer/2022071409/6101b45dea6b00624b709e7b/html5/thumbnails/14.jpg)
%Simulate this system for a step input.It will
%store the simulation results in certain
%variables like y,x,t
figure (2) %Label the figure
plot(t, y) %Display the simulation in a 2-D plot
grid %Add gridlines in the figure
title('Unit step responce for close loop') %Add a title to the figure
ylabel('y(t)') %Label y axis
xlabel('time in seconds') %Label x axis