Sie sind auf Seite 1von 40

0

Control Systems
Lab Manual
Submitted by: Matloob Anwar Shad10Es184 Waleed Raza.10Es160 Saad Sarwar Cheema10Es165 Muhammad Sohail10Es174 6th Semester Electronics Section(C) Submitted to: Engr. S.M Fasih-ur-Rehman

University College of Engineering & Technology The Islamia University of Bahawalpur

List of Experiments
Sr No. 01 02 03 04 05 06 07 08 09 10 11 Name An Introduction to MATLAB Symbolic Math Function and Transfer Function Partial Fraction using MATLAB Inverse Laplace using MATLAB Block Diagram Reduction Transfer Function to State Space State Space to Transfer Function Step/Impulse response of 1st and 2nd order Systems Introduction to Simulink Ramp Response using Simulink Introduction to Root Locus Page No. 02 06 10 13 15 19 22 25 30 34 37

EE-303 Lab Grading Sheet


LAB#01 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: Introduction to MATLAB MATLAB basics Some general used commands in MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

LAB NO.01

An Introduction to MATLAB
Introduction to MATLAB:
MATLAB (matrix laboratory) is a numerical computing environment. It is the language of technical computing. It is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, we can analyze data, develop algorithms, and create models and applications. The language, tools, and built-in math functions enable us to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages. MATLAB provides a number of features for documenting and sharing our work. We can integrate our MATLAB code with other languages and applications, and distribute our MATLAB algorithms and applications. Features include:

High-level language for technical computing Development environment for managing code, files, and data Interactive tools for iterative exploration, design, and problem solving Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, and numerical integration 2-D and 3-D graphics functions for visualizing data Tools for building custom graphical user interfaces Functions for integrating MATLAB based algorithms with external applications and languages, such as C, C++, Fortran, Java, COM, and Microsoft Excel

Some General Used Commands: Command window is used to type the commands and some input values if required to get with the immediate results. The command window in MATLAB appears as follows:

We write the commands and get desired results based on our requirement. Some simple commands are shown below: Way of declaring a variable in MATLAB: x=20 x = 20 Way of creating an Arithmetic series: To create an arithmetic series we write the command as follows: Starting number: Increment/Decrement: Ending Number >> z=-2:1:3 z = -2 -1 0 1 2 3

The way of declaring a geometric series: Suppose we want to declare a geometric series as this 3 9 27 81 243 We see that the constant ratio of the series is 3 and it consists of 5 elements so we first declare an arithmetic series from 1 to 5 and then take this arithmetic series as the power if the constant ratio which is 3 as follows: >> y=1:1:5 y = 1 2 >> x=3; >> z=x.^y z = 3 9 Way of declaring a matrix: The way of declaring a matrix is as follows: matrix= [a11 a12 a13..a1n ; a21 a22 a23..a2n ;.; an1 an2

27

81

243

an3..ann]

Example: >> matrix=[1 2 3 pi;1 2 pi 4;1 pi 3 4; pi 2 3 4] matrix = 1.0000 2.0000 3.0000 3.1416 1.0000 2.0000 3.1416 4.0000 1.0000 3.1416 3.0000 4.0000 3.1416 2.0000 3.0000 4.0000

Moreover, there are many built-in matrices such as identity matrix magic matrix etc. they can be called by writing eye(m,n) for identity matrix where m and n are no. of rows and columns. magic(m) for magic matrix. The way to take natural log of a number series or a matrix: log command is used to take natural log of a number. The syntax of the command is log(number, series or matrix) Example: >> log(10) ans = 2.3026 We can also take the natural log of a series or a matrix. The way to take base-10 log of a number series or a matrix: The log10 command is used to take the base-10 log of a number series or a matrix. The syntax of the command is log10(number, series or matrix) Example: >> log10(10000) ans = 4

******************************************************************

EE-303 Lab Grading Sheet


LAB#02 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: Introduction to Symbolic Math & Symbolic Math Toolbox of MATLAB Symbolic Math function & Transfer Function How to create transfer function objects in MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

LAB NO.02

Symbolic Math Function and Transfer Function


Symbolic Math:
Symbolic Math means the math of symbols not including arithmetic numbers. Symbolic Math Toolbox software inside the MATLAB able us to perform symbolic computations within the MATLAB numeric environment. It provides tools for solving and manipulating symbolic math expressions and performing variable-precision arithmetic. The toolbox contains hundreds of symbolic functions that leverage the MuPAD engine for a broad range of mathematical tasks such as:

Differentiation Integration Linear algebraic operations Simplification Transforms Variable-precision arithmetic Equation solving

Symbolic Math Toolbox software also includes the MuPAD language, which is optimized for handling and operating on symbolic math expressions. In addition to covering common mathematical tasks, the libraries of MuPAD functions cover specialized areas such as number theory and combinatorics. We can extend the built-in functionality by writing custom symbolic functions and libraries in the MuPAD language. We can access the Symbolic Math Toolbox functionality directly from the MATLAB Command Window.

Symbolic Math Functions:


Defining a symbolic object: The syntax of defining a symbolic object is as follows: syms variable1-name variable2-name variable3-name Example:

>> syms x y z

% Define x, y and z as symbolic objects

Differentiation: The syntax of differentiation is as follows: diff(name of a defined variable which is the function of a symbolic object/s, name of symbolic object w.r.t differentiate) Example: >> syms x % Define x as a symbolic object % Define a function of x

>> y=3*(x^2)-(4*x); >> z=diff(y,x) z= 6*x - 4 Integration: The syntax of integration is as follows:

% Differentiate y w.r.t x

int(name of a defined variable which is the function of a symbolic object/s, name of symbolic object w.r.t integrate) Example: >> syms x % define x as a symbolic object >> y=x; % define a function of x % integrate y w.r.t x

>> z=int(y,x) z = x^2/2

There are also some other commands such as pretty and simplify that corresponds to Symbolic Math Toolbox of MATLAB.

Transfer Function:
Transfer function is the ratio of o/p of a system and i/p of a system in frequency domain (usually in Laplace domain) provided that the system is linear.

Transfer Function in MATLAB:


The syntax of creating a transfer function object in MATLAB is as follows: tf(num,den) Where num is the series of coefficients of numerator of the transfer function and den is the series of coefficients of denominator of transfer function. Example: As an example we create the t.f object of the following transfer function in MATLAB: ( ) >> num=[1 0 -2]; >> den=[1 1]; >> G=tf(num,den) % Define series of coefficients of numerator % Define series of coefficients of denominator % Create transfer function

Transfer function: s^2 - 2 ------s + 1 The transfer function object G now is created by above code and is now ready to be used to analyze the system with t.f G(s). The transfer function object can then be used to check the impulse, step or ramp response of the system and pole zero map of the system etc.

******************************************************************************

10

EE-303 Lab Grading Sheet


LAB#03 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Partial Fraction How to convert polynomial form to partial fraction in MATLAB How to convert partial fraction to polynomial form in MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

11

LAB NO.03

Partial Fraction using MATLAB


Partial Fraction:
Partial fraction is another representation of ratio of polynomials in the form of sum of terms and each term has a constant numerator and a denominator with 1 as the maximum possible power of variable of partial fraction.

Partial Fraction in MATLAB:


MATLAB provides an easy way to convert from polynomial form to partial fraction or from partial fraction to polynomial form. The command that performs this task is residue and its syntax is as follows: [r,p,k]=residue(num,den) Or [num,den]=residue(r,p,k) Where r is a column vector of residues, p is a column vector of pole locations, and k is a row vector of direct terms, num is the series of coefficients of numerator of the ratio of polynomials and den is the series of coefficients of denominator of ratio of polynomials. Polynomial form to Partial Fraction: [r,p,k]=residue(num,den) Example: Consider a ratio of polynomials as follows:

num = [-4 8]; den = [1 6 8]; [r,p,k] = residue(num,den) r = -12 8 p = -4 -2 k = []

Which means that the resultant partial fraction is as follows:

12

Partial Fraction to Polynomial form: [num,den]=residue(r,p,k) Example: Consider the following partial fraction:

r=[-12;8]; p=[-4;-2]; k=0; [num,den] = residue(r,p,k) num = -4 den = 1 8 6 8

Which means that following ratio of polynomials is created:

******************************************************************************

13

EE-303 Lab Grading Sheet


LAB#04 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Laplace domain What is inverse Laplace How to find inverse Laplace using MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

14

LAB NO.04

Inverse Laplace using MATLAB


What is Laplace? Laplace is a frequency domain having two main formulas of conversion from time domain to frequency domain and vice versa. This domain provides help to analyze much type of systems in frequency and time domain and provides convenience while working with and solving differential equations. Inverse Laplace: Inverse Laplace is a process of converting back a function from frequency domain to time domain. MATLAB provides an easy way to do this by providing us a command of ilaplace. The syntax of this command is as follows: ilaplace(a polynomial or a ratio of polynomials in s) Example: Lets consider the following ratios of polynomials in s: ( ) >> syms s % define s as a symbolic object >> Y=((1/(s+1))-2*((1)/(s-3))); % define a polynomial in s >> z=ilaplace(Y) % calculate inverse Laplace of Y z = 1/exp(t) - 2*exp(3*t) >> pretty(z) 1 ------ - 2 exp(3 t) exp(t) This means that the inverse Laplace of Y(s) is as follows: ( )

******************************************************************************

15

EE-303 Lab Grading Sheet


LAB#05 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What are block diagrams What commands are used in Reduction of Block Diagrams How to reduce Block Diagrams using MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

16

LAB NO.05

Block Diagram Reduction


What are block diagrams?
Block diagrams are graphical representations of systems using blocks, these representations are used mostly for the systems which consist of multiple subsystems. Then each of the subsystem in the representation is represented as a block which contains a transfer function inside it of that subsystem. In many of the cases for block diagrams we have to find the overall transfer function of the system, so we need to simplify/reduce the block diagram to a single block. This is what is called Block Diagram Reduction.

Block diagram reduction in MATLAB:


MATLAB provides an easy way to reduce block diagrams. It provides three main commands that are used in this reduction process which are explained as follows: Series command: series connects two LTI models in series. This function accepts any type of LTI model. The two systems must be either both continuous or both discrete with identical sample time. Let a system be the combination of two LTI systems G1 and G2 in series as shown below:

The overall transfer function of this system is calculated using MATLAB by a command series whose syntax is as follows: series(G1,G2) Where G1 and G2 both are transfer function objects of two systems. Parallel command: parallel connects two LTI models in parallel. This function accepts any type of LTI model. The two systems must be either both continuous or both discrete with identical sample time. Let a system be the combination of two LTI systems G1 and G2 in parallel as shown below:

17

The overall transfer function of this system is calculated using MATLAB by a command parallel whose syntax is as follows: parallel(G1,G2) Where G1 and G2 both are transfer function objects of two systems. Feedback command: feedback connects two LTI models in feedback. This function accepts any type of LTI model. The two systems must be either both continuous or both discrete with identical sample time. The syntax for negative feedback is as follows: feedback(sys1,sys2) The syntax for positive feedback is as follows: feedback(sys1,sys2,+1) Where sys1 and sys2 are two t.f objects of two LTI systems. Example of Reduction: Consider the following system which is to be reduced to a single transfer function:

18

The coding in MATLAB that is used to do this is as follows: G1a=tf([1 0],1); G1b=tf([1 0],1); G1=series(G1a,G1b); G2a=tf(1,[1 0]); G2=parallel(G1,G2a); G3a=tf(1,1); G3=feedback(G2,G3a); G4a=tf(1,[1 0]); G4=series(G3,G4a); G5a=tf([1 0],1); G=feedback(G4,G5a) Transfer function: s^3 + 1 ----------------2 s^4 + s^2 + 2 s

******************************************************************************

19

EE-303 Lab Grading Sheet


LAB#06 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is State Space How to Convert from Transfer Function to State Space Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

20

LAB NO.06

Transfer Function to State Space


What is State Space? State Space is the representation of systems in time domain in the form of four matrices A,B,C and D called System Matrix, Input Matrix, Output Matrix and Feed-forward matrix respectively. Conversion from Transfer Function to State Space: Many times we are given system representations in Transfer Functions and we have to convert them into State Space, MATLAB provides an easy way to do this by providing us a command tf2ss whose syntax is as follows: [A,B,C,D]=tf2ss(num,den) Where num is the series of coefficients of numerator of the transfer function, den is the series of coefficients of denominator of transfer function and A, B, C & D are State Space matrices. Example: Consider the following transfer function: ( ) The MATLAB code to convert it into State Space is as follows: num1=[1 2 12 7 3]; den1=[1 9 10 8 0 0]; Hs1=tf(num1,den1) Transfer function: s^4 + 2 s^3 + 12 s^2 + 7 s + 3 -----------------------------s^5 + 9 s^4 + 10 s^3 + 8 s^2 [A1,B1,C1,D1]=tf2ss(num1,den1) A1 = -9 1 0 0 0 -10 0 1 0 0 -8 0 0 1 0 0 0 0 0 1 0 0 0 0 0

21

B1 = 1 0 0 0 0 C1 = 1 D1 = 0 2 12 7 3

******************************************************************************

22

EE-303 Lab Grading Sheet


LAB#07 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: Command used to convert from State Space to Transfer Function How to Convert from State Space to Transfer Function Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

23

LAB NO.07

State Space to Transfer Function


Conversion from State Space to Transfer Function: Many times we are given system representations in State Space and we have to convert them into Transfer Function, MATLAB provides an easy way to do this by providing us a command ss2tf whose syntax is as follows: [num,den]=tf2ss(A,B,C,D) Where num is the series of coefficients of numerator of the transfer function, den is the series of coefficients of denominator of transfer function and A, B, C & D are State Space matrices. Example: Consider the following State Space representation:

The code to convert this State Space to Transfer Function is as follows:

A2=[3 1 0 4 -2;-3 5 -5 2 -1; 0 1 -1 2 8; -7 6 -3 -4 0; -6 0 4 -3 1]

24

A2 = 3 1 -3 5 0 1 -7 6 -6 0 B2=[2;7;6;5;4] B2 = 2 7 6 5 4 C2=[1 -2 -9 7 6] C2 = 1 D2=0 D2 = 0 [num2,den2]=ss2tf(A2,B2,C2,D2); Hs2=tf(num2,den2) Transfer function: -7 s^4 - 408 s^3 + 1708 s^2 + 1.458e004 s + 2.767e004 ----------------------------------------------------s^5 - 4 s^4 - 32 s^3 + 148 s^2 - 1153 s - 4480 -2 -9 7 6 0 -5 -1 -3 4 4 2 2 -4 -3 -2 -1 8 0 1

*************************************************************************************

25

EE-303 Lab Grading Sheet


LAB#08 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Step Response and how to Find Step Response of 1st and 2nd order Systems What is Impulse Response and how to Find Impulse Response of 1st and 2nd order Systems Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

26

LAB NO.08

Step/Impulse response of 1st and 2nd order Systems


Step response of 1st and 2nd order Systems:
What is Step Response? Step response of system is the output/response of the system when the input to the system is unit step signal. MATLAB provides an easy way to compute the step response of systems by providing us the command step whose syntax is as follows: step(G) Where G is Transfer Function object in MATLAB. Example of Step Response of 1st order systems: Consider a 1st order system with following Transfer Function: ( ) Code to find step response: num=[5]; den=[1 5]; sys1=tf(num,den); step(sys1) Response:
Step Response 1 0.9 0.8 0.7

Amplitude

0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.2 0.4 0.6 Time (sec) 0.8 1 1.2

27

Example of Step Response of 2nd order systems: Consider the following Transfer Functions: ( ) ( ) ( ) ( ) Code to find Step Responses of above systems: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Response:
2.5 H1 2 H2 H3 H4 1.5

num1=[1]; den1=[1 8 1]; num2=[1]; den2=[1 1 1]; num3=[1]; den3=[1 2 1]; num4=[1]; den4=[1 0 1]; H1=tf(num1,den1); H2=tf(num2,den2); H3=tf(num3,den3); H4=tf(num4,den4); step(H1,H2,H3,H4) axis([0 30 -0.5 2.5]) grid on legend('H1','H2','H3','H4')
Step Response

Amplitude

0.5

-0.5

10

15 Time (sec)

20

25

30

28

Impulse Response of 1st and 2nd order Systems:


What is Impulse Response? Impulse response of a system is the output of the system when input to the system is Unit Impulse signal. Example of Impulse Response of 1st order Systems: Consider a 1st order system with following Transfer Function: ( ) Code to find impulse response: num=[5]; den=[1 5]; sys1=tf(num,den); impulse(sys1)

Response:
Impulse Response 5 4.5 4 3.5

Amplitude

3 2.5 2 1.5 1 0.5 0 0 0.2 0.4 0.6 Time (sec) 0.8 1 1.2

Example of Impulse Response of 2nd order systems: Consider the following Transfer Functions: ( )

29

( ) ( ) ( ) Code to find Impulse Responses of above systems: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> num1=[1]; den1=[1 8 1]; num2=[1]; den2=[1 1 1]; num3=[1]; den3=[1 2 1]; num4=[1]; den4=[1 0 1]; H1=tf(num1,den1); H2=tf(num2,den2); H3=tf(num3,den3); H4=tf(num4,den4); impulse(H1,H2,H3,H4) axis([0 30 -1.5 1.5]) grid on legend('H1','H2','H3','H4')
Impulse Response

Response:

1.5 H1 1 H2 H3 H4 0.5

Amplitude

-0.5

-1

-1.5

10

15 Time (sec)

20

25

30

************************************************************************

30

EE-303 Lab Grading Sheet


LAB#09 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Simulink How to design a simple model on Simulink Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

31

LAB NO.09

Introduction to Simulink
What is Simulink? Simulink is a block diagram environment for multidomain simulation and Model-Based Design. Simulink provides a graphical user interface (GUI) that is used in building block diagrams, performing simulations, as well as analyzing results. Simulink provides a graphical editor, customizable block libraries, and Solvers for modeling and simulating dynamic systems. When we open the Simulink the following window appears which is called Simulink library browser:

32

The Simulink library consists of a lot of devices, elements, instruments and many more equipment related to almost any field of science and engineering. All of them are represented in the form of blocks. We are able to add these blocks while designing a model according to our requirement.

Designing a simple model on Simulink:

We are going to design a simple model on Simulink which shows the graph of sine wave along with its derivative and integration The modeling consists of the following steps: (i) (ii) Click on the New Model icon Add the following blocks into the New Model window by right clicking on each and adding them: (i) Signal Generator (used to generate sine wave) (ii) Derivative (performs derivation) (iii) Integrator (performs integration) (iv) Gain (used to produce gain) (v) Scope(used to get output) Connect all the blocks as shown in block diagram below The properties of blocks are set by double clicking on them according to followings: (i) (ii) Signal Generator (amplitude=1, frequency=1) Gain (1/(2*pi) for the gain block following derivative block and 2*pi for the gain block following integrator block. This is done to get the same amplitude of the derivative and integration of the sine wave as that of original sine wave Scope (number of axis= 3)

(iii) (iv)

(iii)

After all of the above steps click the Run Simulation button and then double click on the scope the output graph is shown in figure below. Subsystem: By selecting more than one block we can make a subsystem which shows the no. of inputs and outputs as equal to contain by all the blocks closed in it. The subsystem shows a single block the blocks enclosed by it are hidden. The block diagram with subsystems is also shown below.

33

Block Diagram:

Output:

******************************************************************************

34

EE-303 Lab Grading Sheet


LAB#10 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Ramp Response How to find Ramp Response of a system in Simulink Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

35

LAB NO.10

Ramp Response using Simulink


What is Ramp Response? Ramp Response is the output of a system when input to the system is Ramp Signal. Ramp Response in Simulink: Lets consider the system with following Transfer Function: ( ) Build the following model in Simulink:

By double clicking on the Transfer Fcn block set the parameter values as follows:

Now double click the scope and observe the response of the system. The response is shown as follows:

36

Ramp Response of above system:

******************************************************************************

37

EE-303 Lab Grading Sheet


LAB#11 Student Name: . Instructions Print this grading sheet, write your name and roll number at the top, and give it to the Instuctor/lab Engineer during your lab check off. Include this as the cover page to your lab report. Instructor/Lab Engineer Grading Section Check Off During your in-lab check off, be prepared to show the instructor/lab Engineer the following: What is Root Locus How to find Root Locus in MATLAB Roll No: ..

Date

Instructor/Lab Engineer Engr. S.M Fasih-ur-Rehman

Score

Reminder: This lab requires a Full Report Worksheet Score Instructor Report Score(0-15) Total Score(0-20)

Instructor/Lab Engineer comments -------(of 5) Organization & Quality -------(of 5) Completeness & Correctness of Figures -------(of 5) Discussion Topics/ Q&A

38

LAB NO.11

Introduction to Root Locus

What is Root Locus? Root Locus is the graphical representation of the path of movement of poles in s-plane of a system with feedback when its gain is varied. The root locus gives the closed-loop pole trajectories as a function of the feedback gain k (assuming negative feedback). Root loci are used to study the effects of varying feedback gains on closed-loop pole locations. In turn, these locations provide indirect information on the time and frequency responses.

Command to find Root Locus: The command used to find Root Locus is as follows: rlocus(sys) Where sys is the Transfer Function object of a system in MATLAB.

Example: Consider the following transfer function:

( ) Code: num=[1 2 12 7 3]; den=[1 9 10 8 0 0]; H=tf(num,den) rlocus(H)

39

Output Root Locus:


Root Locus 4

Imaginary Axis

-1

-2

-3

-4 -16

-14

-12

-10

-8

-6

-4

-2

Real Axis

******************************************************************************

Das könnte Ihnen auch gefallen