Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
73 views

Control Systems Lab 01

This document provides instructions for Lab 1 of the course EE-379: Control Systems. The objectives of the lab are to introduce MATLAB's Control System Toolbox, learn how to compute Laplace and inverse Laplace transforms in MATLAB, represent transfer functions in MATLAB and Simulink, and plot pole-zero diagrams. The document explains how to find Laplace and inverse Laplace transforms, represent transfer functions using the tf() and zpk() functions, plot poles and zeros using pzplot(), and create transfer function blocks in Simulink models. Exercises are provided to have students practice these skills.

Uploaded by

Shanawar Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Control Systems Lab 01

This document provides instructions for Lab 1 of the course EE-379: Control Systems. The objectives of the lab are to introduce MATLAB's Control System Toolbox, learn how to compute Laplace and inverse Laplace transforms in MATLAB, represent transfer functions in MATLAB and Simulink, and plot pole-zero diagrams. The document explains how to find Laplace and inverse Laplace transforms, represent transfer functions using the tf() and zpk() functions, plot poles and zeros using pzplot(), and create transfer function blocks in Simulink models. Exercises are provided to have students practice these skills.

Uploaded by

Shanawar Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

NUST School of Electrical Engineering and Computer Science

Faculty Member:______________ Date: ______________

Semester:_____________ Section: ______________

Department of Electrical Engineering

EE-379: Control Systems

LAB 1: Laplace Transform, Transfer Functions and Control


System Toolbox in MATLAB

Lab Viva
Student name Reg. No. Report Marks Total/15
Marks / 10 /5

EE-379: Linear Control Systems, Lab 1 Page 1

Prepared by: Dr. Ammar Hasan and Engr. Saqib Nazir


LAB 1: Laplace Transform, Transfer Function and Control System
Toolbox in MATLAB

1. Objectives of Lab 1

The objectives of the first lab are:


• An introduction to MATLAB Control systems toolbox, which is one of the most
popular software tools used by control engineers.
• An introduction to MATLAB Simulink, another very popular software tool
• Learn how to find Laplace and inverse Laplace transforms in MATLAB
• Find how to represent transfer functions (or models) in MATLAB and Simulink

2. Laplace and Inverse Laplace Transforms in MATLAB

Laplace transform is an important tool that is very useful when we work with differential
equations. We will also use Laplace transforms in the control systems course. In this
handout we will only show how to find the Laplace/ inverse Laplace transforms in
MATLAB. The use of Laplace transforms in control systems theory will be shown in later
weeks.

The steps to calculate the Laplace transform in MATLAB are:

i. Define a symbolic variable for time using the keyword syms


ii. Define the time domain function
iii. Find the Laplace transform by using the function laplace()

In MATLAB, to display the result of any command you skip the semicolon at the end.

An example of the above steps is given below:


syms t; %Define variable in symbolic form
g1t = 5*t*exp(-5*t); %Function in time domain
G1s = laplace(g1t) %Find Laplace, notice no semicolon

The inverse Laplace transform can be found using the function ilaplace(), for
example you can give the following command:
ilaplace(G1s)

You will agree that it is a lot easier to use a software tool to calculate the transforms in
comparison to doing it manually.

EE-379: Control Systems, Lab 1 Page 2


Exercise 1

Find the Laplace transform of the following time domain functions:


i. g1 t = tsin2t + )
ii. g2 t = sin2tcos2t
iii. g3 t = cos 3
iv. g4 t = − + 9t +5 + −2
v. g5 t = 5 cos 3 + 45

Find the inverse Laplace transform of the following frequency domain functions.
Tip: You will have to start by defining a symbolic variable for frequency.
i. G1 s =
ii. G2 s =
iii. G3 s =
iv. G4 s =

NOTE: You can do the exercise in the command window or using a MATLAB script (m
file). I suggest that you use the m file, because you can save it. This comment also
applies to the rest of MATLAB exercises in all the labs.

3. MATLAB Control System Toolbox

MATLAB Control System Toolbox provides industry-standard algorithms and tools for
systematically analyzing, designing, and tuning linear control systems. It is an important
tool for control engineers and is widely used in industry and academia. We can access
the Control System Toolbox by doing the following steps

• Open MATLAB
• Click Start (the start button inside MATLAB)
• Go to Toolboxes
• Click on the Control System Toolbox

See Figure 1 for details

EE-379:Control Systems, Lab 1 Page 3


Figure 1: Accessing the MATLAB Control Systems Toolbox

In this handout we will introduce some of the basic functions in the Control Systems
Toolbox. We will show you how to use the Control Systems Toolbox to enter the
transfer function in MATLAB and how to plot the poles and zeros of a transfer functions.
In future labs we will look at more advanced functionalities of the Control Systems
Toolbox.

EE-379:Control Systems, Lab 1 Page 4


4. Transfer function in MATLAB

In this handout we will discuss two ways of entering transfer functions in MATLAB. The
first way if by using the function tf(). For using this function you will need two arrays
that represent the coefficients of the numerator polynomial and denominator
polynomial of the transfer function. For example if you have the transfer function
5 + 10
+ 7 + 12
then you can enter it into MATLAB with the following code:
num = [5 10]; %(coefficients of numerator)
den = [1 7 12]; %(coefficients of denominator)
G1 = tf (num,den) %(make transfer function)

Exercise 2

Find the poles and zeros of the transfer function given above in your logbook.
Remember the zeros are the roots of the numerator polynomial and poles are the roots
of the denominator polynomial.

Another way to enter transfer functions in MATLAB is by using the function zpk(). This
function lets you create a transfer function by just specifying the values of zeros, poles
and the gain. For example, the transfer function given above can also be written in the
form
5 +2
+3 +4
You can create this transfer function in MATLAB with the following code:
z = [-2]; %(zeros)
p = [-3 -4]; %(poles)
k = 5; %(gain)
G2 = zpk (z,p,k) %(make transfer function)

Once you have entered a transfer function in any of the above forms, you can easily
convert it to the other form. You can convert G2 to the usual form by using the
command tf(G2). You can also convert G1 to the zero-pole-gain form by using the
command zpk(G1).

EE-379:Control Systems, Lab 1 Page 5


Exercise 3

Create the following transfer functions in MATLAB and convert them to the other form.
Give each transfer function a different name, e.g. G1, G2 etc.

30s − 180
s + 4s + 13s + 7

s +s+1
s +s +6

s + 4 s + 2 − 4i s + 2 + 4i
s − 2 s + 4 s + 5i s − 5i

s + 11s + 35s + 250


s % + 4s & + 39s + 108s

s + 5s + 6
s% + 4s + 15s + 35

s −1
s & + 4s + 6s + 4

5. Pole zero plot in MATLAB

Once you have entered the transfer function in MATLAB, you can plot the poles and
zeros of the transfer function by using the command pzplot(). Here is some example
code
G1 = tf([5 10],[1 2 4 -3]) %(make transfer function)
pzplot(G1) %plot the poles and zeros

The output is shown in Figure 2.

Exercise 4

Plot the poles and zeros of any three transfer functions that you have already created in
the MATLAB.

EE-379:Control Systems, Lab 1 Page 6


Pole-Zero Map
2

1.5

0.5
Imaginary Axis

-0.5

-1

-1.5

-2
-2 -1.5 -1 -0.5 0 0.5 1
Real Axis

Figure 2: Plot of poles and zeros using the command pzplot()

6. Transfer function in Simulink

Simulink is a very useful component of MATLAB that allows you to create models in
form of block diagrams and analyze/simulate these models. It is used by engineers all
over the world. In this section, you will learn how to create a model in Simulink using a
given transfer function.

To start Simulink click on the Simulink icon in the MATLAB window. See Figure 3 for
details.

EE-379:Control Systems, Lab 1 Page 7


Figure 3: Starting Simulink

You will see the Simulink Library browser as shown in Figure 4.

Figure 4: Simulink window

A Simulink file is called a Simulink model. Create a new model by going to File -> New ->
Model.

To create a transfer function in Simulink, use the following steps:


i. In the Simulink library browser click on Simulink
ii. Click on Continuous

EE-379:Control Systems, Lab 1 Page 8


iii. Drag the transfer function block to your new model window
iv. Double click on transfer function block
v. Enter the coefficients of Numerator and Denominator

See Figure 5 for details.

Figure 5: Transfer function block in Simulink

Exercise 5

Create a model for the following transfer functions in Simulink:

30s − 180
s + 4s + 13s + 7

s +s+1
s +s +6

EE-379:Control Systems, Lab 1 Page 9


Another very interesting feature in Simulink is that instead of using numerical values for
coefficients, you can also use symbols/variables. This is useful if you want to keep your
transfer functions in terms of physical parameters, e.g. mass, velocity, etc. Lets say that
we want to create a model for the following transfer function

b
s+a c
where the parameter a=2, b=3 and c=6.

First we will create the transfer function block and enter the values shown in the figure
below:

Now we have to specify the values of these parameters. For this go to File->Model
properties->Callback->InitFcn. Here you can write a script to initialize the values of
parameter. See the figure below for details.

EE-379:Control Systems, Lab 1 Page 10


Exercise 6

The transfer function of a pendulum on a cart is given by


)*
s
+
, - )* . ) )/* )/*
s& + s − s − s
+ + +
where
Mass of cart = M = 0.5 kg
Mass of pendulum = m = 0.5 kg
Friction of cart =b= 0.1 N/m/sec
Length of pendulum = L=0.3m
Inertia of pendulum = I = 0.006 kg m2
q = [ M + m I + mL − mL ]

Create a model for this transfer function in Simulink.

Also create an m file in to create this transfer function in MATLAB

In this handout we have only shown you how to create models in MATLAB and Simulink.
In later weeks we will also analyze and simulate it.

EE-379:Control Systems, Lab 1 Page 11

You might also like