Beruflich Dokumente
Kultur Dokumente
Title:Introduction to design and simulation of open loop and close loop control systems using a
Computer Aided Design (CAD) tool---MATLAB.
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.
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.
Command
Description
Description
Identitymatrix
Generatelinearlyspacevectors
Createarrayofallones
Uniformlydistributedrandomnumbersandarrays
Createarrayofallzeros
Description
Displaytextorarray
Determineifinputisemptymatrix
TestarraysforequalityLen
gthofvectorNumberofdim
ensions
NumberofelementsSizeof
matrix
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.
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 product, G(s)H(s), in equation is called the open-loop transfer function, orloop 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-byNX-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
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).
For open loop, overshoot is somewhat 0.114 and steady state value has reached after 1.5 seconds
For close loop, overshoot is somewhat 0.1025(reduced in comparison to open loop) and steady state
value has reached before 1.5 seconds
1.
2.
3.
4.
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 doubleclick 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
Now write the file name at MATLAB prompt to run your file from the directory like
following:
>>Lab1
and then press ENTER.
Simulation:
See the MATLAB Code in appendix section
Command window Output:
p1 =
1
num/den =
s^3 + 5 s + 6
------------1
ans =
12
r1 =
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
OL_TRF_num =
1
OL_TRF_den =
1
15
num/den =
s+1
-------------s^2 + 8 s + 15
G=
1
H=
1
15
CL_TRF_num =
0
CL_TRF_den =
1
16
num/den =
s+1
-------------s^2 + 9 s + 16
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
everyones 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& SonsInc.
Appendices
%EEE 4101 (Control Systems)
%Lab 1
%MATLAB codes
clc;
close all;
clear all;
%Part 1
%Creating equations, Calculating roots, Outputting transfer functions etc.
p1=[1 0 5 6]
printsys(p1,[0 0 0 1],'s')
polyval(p1,1)
%with a value of 1
r1=roots(p1)
p2=poly(r1)
printsys(p2,[0 0 0 1],'s')
exp1=[1 1];
exp2=[1 2];
exp=conv(exp1,exp2)
%Part 2
%Simulating an open loop control system
clear all;
OL_TRF_num = [1 1]
figure (1)
plot(t, y)
grid
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;
G = [1 1]
plot(t, y)
grid
ylabel('y(t)')
%Label y axis
xlabel('time in seconds')
%Label x axis