Lab2 Control System

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 43

‫الجمهورية اليمنية‬

‫جامعة صنعاء – كلية الهندسة‬


‫قسم الهندسة الكهربائية‬
‫مستوى رابع‬

‫‪LAB 2‬‬
‫‪Control System Using MATLAB‬‬
LAB 2
Transfer Functions & Step
Response
The Laplace Transform
The Laplace transform is a mathematical operation that takes an
equation from being a function of time, t, to being a function of the
Laplace variable, s

L [ f (t )]   f (t )e dt  F ( s )
 st
0

Some mathematical operations become much simpler in the


.Laplace domain We will never solve this integral, will use tables
.Item No f(t) F(s)

.1 δ(t) t 1
1 1
.2 )t(1
t s
1
.3 t t s2
1
.5 e -at
s+a
ω
.5 sin (ωt)
s 2 + ω2
s
.6 cos (ωt)
s 2 + ω2

Table of Laplace pairs


In MATLAB

:For example
The Laplace of the following equation in MATLAB

f(t)= sin(t)

;Syms t
f=sin(t)
Laplace(f)
:exercise
Find the Laplace of the following equation in MATLAB

f(x)= 2x + cos(2x)
Open Loop Control system
An open-loop control system takes input under the
consideration and doesn’t react on the feedback to obtain the
output. This is why it is also called a non-feedback control
.system
Closed Loop Control system
A closed loop system is also referred as a feedback control system. These
systems record the output instead of input and modify it according to the
need. It generates preferred condition of the output as compared to the
.original one. It doesn’t encounter any external or internal disturbances
Transfer Function
Often it is desired to remain in the Laplace domain for analysis and
manipulation
The transfer function G(s) of a system is an alternative model to the
differential equation and is defined as the ratio of the Laplace transform of
the output Y(s) to the Laplace transform of the input U(s) assuming zero
initial conditions
L [output ] Y (s)
G ( s)  
L [input ] init cond 0 U ( s )
BLOCK DIAGRAMS

Y (s)
G
is(often
s )  drawn as a block diagram
U ( s)
U(s) Y(s)
G(s)

where U(s), Y(s) are signals and G(s) is a system


Mathematically, Y(s) = G(s)U(s)
In the time domain, need a convolution integral
Useful for visualizing complex systems

R + Em Y
- C(s) G(s) P(s)

Ym
H(s)

here each block is a transfer function and the arrows


represent signal flow
IN MATLAB
:To input a Transfer Function in Matlab
Method(1): transfer function representation (TF)
S=tf(‘s’) .)a(
Full equation
:For example
=G(s)

In Matlab: s=tf(‘s’)
G=(10*s)/(s^2+25*s+100)
IN MATLAB
.)b(
tf([numerator],[denominator])
coefficients
:For example
=G(s)

In Matlab: G=tf([10 0],[1 25 100])


;Or num=[10 0]
;den=[1 25 100]
G=tf(num,den)
IN MATLAB
Method(2): Zero – Pole - Gain representation (zpk)
)(Zpk
Zero pole gain

:for example
=G(s)

In Matlab: G=zpk([3,4],[0,-2,-10,-15],100)
tf(G)
IN MATLAB
Method(3): state Space representation (SS)
for example: State Space to Transfer Function

:Matlab Function
ss2tf(A,B,C,D)=]n,d[
mySys=tf(n,d)
IN MATLAB

;D=0
EXERCISE
Find the transfer function of the system with state space representation
ANSWER
;A=[1 0; -2 1] >>
;B=[1;0]>>
;C=[3 -2]>>
;D=0>>
ss2tf(A,B,C,D)=]n,d[>>
T=tf(n,d)>>
The T.F of this form
=G(s)

:In MATLAB
num=[1 1]
den=conv([1 1 2 1],[1 2])
tf(num,den)
FINDING ZEROS & POLES
:Finding zeros and poles of the T.F
:Poles are the roots for the denominator of transfer functions

:In MATLAB
pole(T.F) for finding poles
zero(T.F) for finding zeros

Or: roots(numerator) for finding poles


roots(denominator) for finding zeros
:To plot the zeros and poles

:In MATLAB
pzmap(T.F)
:Exercise
In MATLAB, find and plot the zeros and poles for the
:following transfer function
=G(s)
Answer
:In MATLAB
;n=[1 2 1] >>
;d=[4 1 2 1] >>
T=tf(n,d) >>
z= zero(T) >>
p=pole(T) >>
pzmap(T) >>
3D Plot
”MATLAB Function: “plot3(x,y,z)

;x=linspace(0,2*pi,20) >>
;y=sin(x) >>
;z=x >>
plot3(x,y,z,’linewidth’,3) >>
xlabel(‘x-axis’) >>
ylabel(‘y-axis’) >>
zlabel(‘z-axis’) >>
title(‘3D-plotting’) >>
3D Plot
Bar Graph

”MATLAB Function: “bar(y)

;y=[4 3 2; 3 2 4; 8 5 3; 9 3 1] >>
;bar(y) >>
Or >>bar3(y)
Bar Graph: bar(y)
Bar Graph: bar3(y)
Control Plot
Simulation of Linear systems to different inputs

”impulse”, “step” and “lsim“ -

You can simulate the LTI systems to inputs like impulse, step and other
standard inputs and see the plot of the response in the figure window.
MATLAB command ‘impulse’ calculates the unit impulse response of the
.system, ‘step’ calculates the unit step response of the system
:To obtain an impulse response

T=tf([2 5 1],[1 2 3]) >>


impulse(T)>>
To obtain a step response type

T=tf([2 5 1],[1 2 3]) >>


step(T)>>
Exercise

=For the Transfer function of G(s)

.Plot the step response for the system


Answer
Simulink
Basic Elements
There are two major classes of items in Simulink: blocks and lines. Blocks are used to
generate, modify, combine, output, and display signals. Lines are used to transfer signals
. from one block to another

Blocks
:There are several general classes of blocks within the Simulink library
Sources: used to generate various signals
Sinks: used to output or display signals
Continuous: continuous-time system elements (transfer functions, state-
space models, PID controllers, etc.)
Discrete: linear, discrete-time system elements (discrete transfer functions,
discrete state-space models, etc.)
Math Operations: contains many common math operations (gain, sum,
product, absolute value, etc.)
Ports & Subsystems: contains useful blocks to build a system
The block shown below has an unused input terminal on the left and an unused output
. terminal on the right

.Lines transmit signals in the direction indicated by the arrow


Simple Example

The simple model consists of three blocks: Step, Transfer Function, and
Scope. The Step is a Source block from which a step input signal
originates. This signal is transferred through the line in the direction
indicated by the arrow to the Transfer Function continuous block. The
Transfer Function block modifies its input signal and outputs a new signal
on a line to the Scope. The Scope is a Sink block used to display a signal
much like an oscilloscope.
Modifying Blocks

A block can be modified by double-


clicking on it. For example, if you
double-click on the Transfer Function.

you will see the following dialog box.


: For example, to change the denominator to

Enter the following into the denominator


field: [1 2 4]

and hit the close button, the model


window will change to the following,
The simulation should
run very quickly and the
scope window will
.appear as shown below
Homework

Find the T.F, zeros, poles and then plot the zeros, poles using
Matlab command and then plot impulse response using Simulink
:for the following system

10
X(s) + Em Y(s)
- 𝑠+ 4

20
The End

You might also like