You are on page 1of 14

Sir Syed Center for Advanced Studies in Engineering

Institute of Technology, Islamabad

CONTROL SYSTEMS LAB

Experiment # 1: Introduction to Control Systems, Laplace


Transform and MATLAB / Simulink

Name of Student: …………………………………………………….

Roll No.: ……………………………………………………………….

Date of Experiment: ………………………………………………….

Report submitted on: ………………………………………………..

Marks obtained: ……………………………………

Remarks: ……………………………………………

Instructor’s Signature: ……………………………...


Fall 2018 Semester V
SSCASEIT

Experiment # 1
Introduction to Control Systems, Laplace Transform and
MATLAB / Simulink

Objectives
1. Introduction to Control Systems.
2. Introduction to Matlab/Simulink.
3. Basic Modeling in Simulink.

Software:
MATLAB v7 or latest

Part 1: Introduction to Control Systems


Objective:
To gain familiarity with basic definition and application of control systems.

1.1 Introduction to Control Systems


To this Modern day, different types of engineering techniques are being put together to
make the life easy for a normal man. “Control systems” is just one and the most important
of these fields.
Automatic control has played a vital role in the advance of engineering and science. In
addition to its extreme importance in space-vehicle systems, missile-guidance systems,
robotic systems, and the like automatic control has become an important and integral
part of modern manufacturing and industrial processes. For example, automatic control
is essential in the numerical control of machine tools in the manufacturing industries, and
in the designs of cars and trucks in the automobile industries, and in the design of
autopilot systems in the aerospace industries. It is also essential in such industrial
operations as controlling pressure, temperature, humidity, viscosity, and flow in the
process industries.
WW-II accelerated the development of classical control theory and practice. Heavy guns
had to be rapidly and accurately positioned. Precise navigation and target tracking were
increasingly important, and aircraft performance was improved greatly with the
incorporation of complex control systems to aid the pilot.
Today, control systems are pervasive in industry and in our everyday lives. They range
from governmental regulation (such as that governing monetary policy) to automated and
highly flexible manufacturing plants to sophisticated automobiles, household appliances,
and entertainment systems. It is our purpose to learn to design control systems for a wide
variety of applications.

Control Systems Lab 2


SSCASEIT

Part 2: Introduction to MATLAB


Objective:
To gain familiarity with basic operation/code and finding laplace transform in MATLAB.

2.1 Matrices:
For entering the matrices we followed some basic rules which are as follows: Separate the
elements of the row with a blank or comma. Use a semicolon (;) to indicate the end of
each row. Surround the entire list of elements with square brackets, [ ].
Example:
A = [1 3 2 95; 53 0 1 5; 1 3 8 99; 4 5 1 3];

2.2 Colon Operator:


Used in various situations, the colon is an invaluable tool. It’s uses include:
1:20
Prints numbers from 1 to 20:
1:10
ans =
1 2 3 4 5 6 7 8 9 10

2.3 Polynomial Overview


MATLAB provide function for standard polynomial operator, such as polynomial roots,
evaluation and differentiation.

2.4 Roots of equation and making of equation from roots:


We can find the roots of polynomial using the roots(p) command. e.g find the roots of
s3+3s2+4
>> p= [1 3 0 4]
>> r=roots (p)
>> p=poly(r)
>> r= [1 2]
>> p=poly(r)
>> r= [1 1 1 1 1]
>> p=poly(r)

2.5 Multiplication of two polynomials equation


Polynomial can be multiplied by using conv(a,b) command.
>> p= [3 2 0 1];
>> q= [1 2];
>> n=conv (p , q)
n=38412

Control Systems Lab 3


SSCASEIT

2.6 Defining value in an equation


>> p= [3 2 0 1];
>> q= [1 4];
>>value= polyval (p , 2)
Value = 33
>>value=polyval(n,2)

2.7 Obtaining digits in power form


>>sqrt(7)
>>sqrt(sym(7))
ans = 7^(1/2)

2.8 Finding derivative and use of syms command for defining variable
>>syms x y
>> f=exp(x*y)
>>diff(f);

2.9 Use of pretty command


>>syms x y z
>> z=2*sin(2*x*y)
>>diff(z,x,2)
>> pretty(ans)

2.10 Plotting
The most frequently used function is the plot function, which can accept different
arguments and gives different forms of plots for different equation. t=0:pi/100:6*pi;
y=sin(t); plot(t,y) grid on title(‘text’) xlabel(‘text’) ylabel(‘text’)
plot(t,y,’Y’) // Y means yellow color
plot(t,y,’Y-’) // Y- means yellow color with solid line

2.11 Partial Fraction Expansion


‘Residue’ finds the partial fraction expansion of two ratio of polynomials. This is
particularly useful for application that represent system in transfer form. For polynomial
a and b,

Consider transfer function


>> b=[1 4];

Control Systems Lab 4


SSCASEIT

>> a=[1 2 6];


>> [r,p,k]=residue(b,a)
r=
0.5000 - 0.6708i
0.5000 + 0.6708i
p=
-1.0000 + 2.2361i
-1.0000 - 2.2361i
k=
[]

Given three inputs (r,p and k), residue convert back to polynomial form. >>
[b,a]=residue(r,p,k)

b=
1 4
a=
1.0000 2.0000 6.0000

2.12 Laplace Transform:


In mathematics, the Laplace transform is one of the best known and widely used integral
transforms. It is commonly used to produce an easily solvable algebraic equation from an
ordinary differential equation. It has many important applications in mathematics, physics,
optics, electrical engineering, control engineering, signal processing, and probability
theory.
In mathematics, it is used for solving differential and integral equations. In physics, it is
used for analysis of linear time-invariant systems such as electrical circuits, harmonic
oscillators, optical devices, and mechanical systems. In this analysis, the Laplace transform
is often interpreted as a transformation from the time-domain, in which inputs and
outputs are functions of time, to the frequency-domain, where the same inputs and
outputs are functions of complex angular frequency, or radians per unit time. Given a
simple mathematical or functional description of an input or output to a system, the
Laplace transform provides an alternative functional description that often simplifies the
process of analyzing the behavior of the system, or in synthesizing a new system based on
a set of specifications

MATLAB Implementation
Syntax
laplace(f)
laplace(f,transVar)
laplace(f,var,transVar)

Control Systems Lab 5


SSCASEIT

Description
laplace(f) returns the Laplace Transform of f. By default, the independent variable is t and
transformation variable is s.
laplace(f,transVar) uses the transformation variable transVar instead of s.
laplace(f,var,transVar) uses the independent variable var and the transformation
variable transVar instead of t and s, respectively.

2.13 Symbolic Math Toolbox


Symbolic math command are used in MATLAB M-files right along with your standard
MATLAB statement. The only additional requirement is to declare symbolic variables
before they are used with statement syms x1 x2 … where xi are symbolic variables.

Example 1
syms f(x)
f(x) = x^4-2*x^3+6*x^2-2*x+10
f(-5)

Example 2
syms y1 y2
y1 = x+3; y2 = 3*x;
solve(y1 == y2)

Example 3
syms x y
factor(y^6-x^6)

Example 4
>> syms t
>> f=t^5;
>> laplace(f)

Example 5
>> f=exp(-5*t);
>> F=laplace(f)

Example 6
>> syms w t;
>> f=cos(w/2*t) ;
>> F=laplace(f)

Control Systems Lab 6


SSCASEIT

2.14 Inverse Laplace


F = ilaplace(L) is the inverse Laplace transform of the scalar symbolic object L with default
independent variable s. The default return is a function of t. The inverse Laplace transform
is applied to a function of s and returns a function of t.

Syntax
ilaplace(F)
ilaplace(F,transVar)
ilaplace(F,var,transVar)

Description
ilaplace(F) returns the Inverse Laplace Transform of F. By default, the independent variable
is s and the transformation variable is t. If F does not contain s, ilaplace uses the
function symvar.
ilaplace(F,transVar) uses the transformation variable transVar instead of t.
ilaplace(F,var,transVar) uses the independent variable var and transformation
variable transVar instead of s and t, respectively.

Example 1
Compute the inverse Laplace transform of 1/s^2. By default, the inverse transform is in
terms of t.

syms s
F = 1/s^2;
ilaplace(F)

Example 2
>> a = ilaplace(120/s^6)

Example 3
>> F=1/(s+a)
>> f=ilaplace(F)

Example 4
>>syms s w
>> F=s/(s^2+w^2)
>> f=ilaplace(F) f =cos(w*t)

Control Systems Lab 7


SSCASEIT

Part 3: Introduction to Simulink


Objective:
To gain familiarity with Simulink tool for the MATLAB and develop understanding of
implementing the system model and analysis using this tool.

3.1 Introduction to Simulink


SIMULINK is a tool for simulating dynamic systems. As an extension to MATLAB, SIMULINK
adds many features specific to dynamic systems while retaining all of MATLAB’s general-
purpose functionality. SIMULINK has two phases of use: model definition and model
analysis. A typical session starts by either defining a model or retrieving a previously
defined model, and then proceeds to analysis of that model. These two steps are often
performed iteratively until the model achieves the desired behavior.
To facilitate model definition, SIMULINK adds a new class of windows called block diagram
windows. In these windows, models are created and edited principally by mouse driven
commands. Part of mastering SIMULINK is to become familiar with the manipulation of
model components within these windows. After you define a model, you can analyze it
either by choosing options from the SIMULINK menus or by entering commands in
MATLAB’s command window.

3.2 Constructing a Simple Model


At the MATLAB Command Window prompt, write the following command:

>> simulink

and hit enter. This command displays a browser containing icons for the subsystem blocks
that make up the standard library, called the SIMULINK LIBRARY, as shown in figure – 1
on next page.
Click on File and New in the simulink window and, if required, move the new opened
window to a comfortable position.

Control Systems Lab 8


SSCASEIT

Figure–1

3.3 Simulink Library Browser


The Simulink Library Browser is the library where you find all the blocks you may use in
Simulink. Simulink software includes an extensive library of functions commonly used in
modeling a system. These include:
1. Continuous and discrete dynamics blocks, such as Integration, Transfer functions,
Transport Delay, etc.
2. Math blocks, such as Sum, Product, Add, etc
3. Sources, such as Ramp, Random Generator, Step, etc

Investigate all blocks falling under the Simulink tab only, especially Continuous, Math
Operations, Sinks and Sources.

Control Systems Lab 9


SSCASEIT

Open New Model Window using the Simulink Library browser:


 File > New > Model
Blocks can be copied into the new Untitled Model window by dragging them from the
original location to the new location by holding down the left mouse button.

Example:
Suppose we want to implement the system which generates sine wave using Simulink.
To implement the system we need two blocks.
1. Source which generates sine wave
2. Device to see output
In Simulink step wave falls under category of Sources. Output is seen at oscilloscope in
Sink category. Here is how we implement the system
1. Open library browser. From Sources category select step wave block and drag it
to the model window
2. From Sink category, select scope (oscilloscope) and drag it to the model window.
You get the following window after getting the blocks.

Figure-2
3.4 Wiring Techniques
Use the mouse to wire the inputs and outputs of the different blocks. Inputs are located
on the left side of the blocks, while outputs are located on the right side of the blocks.

Figure-3
3.5 Help Windows
It can be obtained by double-clicking on the block. It can provide detailed information
about the different blocks

Example
Assemble the following diagram in your working window.
 Simulink > Sources > Step \\ Step Input
 Simulink > Math Operations > Sum \\ Summer
 Simulink > Continuous > Transfer Fcn \\ Transfer Function
 Simulink > Continuous > Integrator \\ Integrator
 Simulink > Sinks > Scope \\ Oscilloscope

Control Systems Lab 10


SSCASEIT

Figure – 5

3.6 Procedure
1. Enlarge the blocks, arrange into order, and link the blocks together. Blocks can be
expanded/enlarged by dragging the corner indicators outward with the mouse. To
link the blocks, drag and connect the first block’s output arrow to the input
arrow of the second block using the left mouse button.
2. Double click on the Step, Sum or Transfer Function block and change the
coefficients, if required.
3. Click on File > Save and name your model.
4. Click on Simulation > RUN and observe the trace on the Scope by double-clicking
on it.
5. Ctrl R is the shortcut key to rotate the blocks.
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/
A good link for the tutorials related to simulink can be accessed using the above URL.

3.7 Open-Loop Diagram

Figure-6

Control Systems Lab 11


SSCASEIT

3.8 Closed-Loop Diagram

Figure-7

The above two figures shows Simulation 1 and Simulation 2 for the same system.

Simulation 1
Consider a system with the transfer function same as Integrator. Input to this system is a
step function. In response to this input, the system’s output will be a Ramp as shown
below. Another block, Gain, is attached in between the input and system. This gain will
affect the output. Change its different values to see different responses.

Figure-8

Simulation 2
An advantage associated with this system is that it has faster response. Again change the
values of Gain block to see different responses.

Control Systems Lab 12


SSCASEIT

Figure-9

Control Systems Lab 13


SSCASEIT

Exercise
Q.1 Consider figure 6 and 7 for this question.
1. Find the Step Response of the Transfer Function (Integrator), both for Open and
Closed loop.

Q.2 Consider a block diagram for RC circuit in fig 10. As we know that T=RC, is the charging
time for capacitor.

Figure 10: Block Diagram

Change the value of time constant and draw its response on scope.
i. T=100ms ii. T=200ms iii. T=1s

Q.3 Find Laplace and inverse Laplace transform of following using MATLAB.
f(t) = eat
f(t)=1/sqrt(x)

Q.4 Use MATLAB command to find partial fraction of the following.

___7s2+9s+12__
s(s+7)(s2+10s+100)

Q.5 Consider two polynomial, p(s)=s2+2s+1 and q(s)=s+1. Using MATLAB compute,
1. p(s) * q(s)
2. Roots of p(s) and q(s)
3. p(s)/q(s)

Control Systems Lab 14

You might also like