You are on page 1of 5

1/5

EEE 4101: Control Systems Laboratory Experiment # 1: Introduction to design and simulation of open loop and close loop control systems using a Computer Aided Design (CAD) tool---MATLAB version 5.3. Objectives: 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: 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. 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. 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. 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. Procedure: Working in MATLAB environment: 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. 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.

Prepared by Shahriyar Masud Rizvi

2/5

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. 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, create a new M-file Lab1.m and write the MATLAB code provided by the teacher in this file. Save the file in the D:\Control_SP_08\SecD folder. To execute the commands written in this file you have to change your working directory by writing the following commands at your MATLAB prompt as: >>D:\Control_SP_08\SecD 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 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 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. 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. Report: Write a report on this experiment. The MATLAB code and plots will be provided in the course website. 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.

Prepared by Shahriyar Masud Rizvi

3/5

Matlab codes: %EEE 4101 (Control Systems) %Lab 1 %MATLAB codes clc; %Clears the MATLAB Command Window close all; clear all; %Closes all figures %Clears all variables

%Part 1 %Creating equations, Calculating roots, Displaying transfer functions etc. p1=[1 0 5 6] printsys(p1,[0 0 0 1],'s') %Defines the coefficients of a linear equation %Outputs the polynomial of the equation %as a transfer function and also in %symbolic form, where the variable %is labelled as "s" %Evaluates the polynomial of the equation %with a value of 1 %Calculates the roots of the equation %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. %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

polyval(p1,1)

r1=roots(p1) p2=poly(r1)

printsys(p2,[0 0 0 1],'s')

exp1=[1 1]; exp2=[1 2]; exp=conv(exp1,exp2)

%Define an expression called exp1 %Define an expression called exp2 %Multiply these two expresions and store the %result in exp

Prepared by Shahriyar Masud Rizvi

4/5

%Part 2 %Simulating an open loop control system clear all; OL_TRF_num = [1 1] OL_TRF_den = conv([1 3], [1 5]) %Clears all variables (i.e. p1,r1,p2 etc.) %Define the numerator of a transfer function %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) plot(t, y) grid %Label the figure %Display the simulation in a 2-D plot %Add gridlines in the figure %Add a title to the figure %Label y axis %Label x axis

title('Unit step responce for open loop') ylabel('y(t)') xlabel('time in seconds') %Part 3 %Simulating a close loop control system %This control system has unity feedback

[CL_TRF_num, CL_TRF_den] = cloop(OL_TRF_num, OL_TRF_den) %Calculates the close-loop transfer function %from the open-loop transfer function printsys(CL_TRF_num, CL_TRF_den, 's') %Outputs the transfer function (closed-loop) in %symbolic form where the variable is "s" [y, x, t]=step(CL_TRF_num, CL_TRF_den); %Simulate this system for a step input.It will %store the simulation results in certain %variables like y,x,t Prepared by Shahriyar Masud Rizvi 4

5/5

figure (2) plot(t, y) grid

%Label the figure %Display the simulation in a 2-D plot %Add gridlines in the figure %Add a title to the figure