introdução ao simulink
DESCRIPTION
Introdução Ao Simulink USPTRANSCRIPT
1
Simulink and block diagram
2 0 1 5 B R A Z I L S T U DY A B R O A D P R O G R A M
T E X A S A & M U N I V E R S I T Y - U N I V E R S I T Y O F S A O PA U L O
E L M E R A L E X I S G A M B O A P E Ñ A LO Z A
R O D O L P H O V I L E L A A LV E S N E V E S
M I C H E L B E S S A N I
R A FA E L F E R N A N D O Q U I R I N O M A G O S S I
D E PA R TA M E N TO D E E N G E N H A R I A E L É T R I C A U S P - S Ã O C A R L O S
2 0 1 5
2
Simulink and block diagram
Matlab has a tool called Simulink. Simulink allows you to create block diagram, modelling, model analysis and construction functions.
To access Simulink, type:
>> simulink
5
Simple RC circuit example
iu
Sensor
idtC
vc
1
C
i
dt
dvc
R
vui c
cvx 1
dt
dvx c1'
RC
u
RC
xx 1
1'
R
u
R
xy
1
RC
vu
dt
dv cc
iy
If then
6
Simple RC circuit exemple
This is the simulink library. You can type what you want. For example:
Gain
Sum
Integrator
9
Simple RC circuit example
To use the integrator with external initial
condition, give a double click on integrator
block.
11
Simple RC circuit example
Before you run your simulation, it’s necessary set theconfigurations in simulink.
13
Simple RC circuit example
%parameters of a RC circuitclear all;close all ;clc;
% constantsR = 1000;C = 1000e-6;alpha = 1;
Create and run a script using the program below before of runthe simulation
14
Simple RC circuit example
To get the linear model, use the blocks in
and out on the diagram.
Open a new script on matlab and
use this program to create the
linear model.
[A,B,C,D] = linmod(‘rc_circuit’);
15
Simple RC circuit example
Now, it’s possible get the transfer function of
the system.
Use the tf command on matlab with the
matrices A,B,C,D
[num,den] = ss2tf(A,B,C,D);G = tf(num,den);
19
Simple RC circuit example
To simulate the transfer function use the step and scope on simulink.
Run and give a double click on scope to see the response.
20
Hand’s on (simple pendulum example)
State space representation
1xy
22122 xml
bxsen
l
g
ml
ux
1x
2
1
x
xx
1x
2x
cTu
y
25
Simple pendulum example
1xy
22122 xml
bxsen
l
g
ml
ux
1x
22122 xml
bxsen
l
g
ml
ux
u 2ml
u
2x
1xsen1x
2x
1xsenl
g
22x
ml
b
26
Simple pendulum example
1xsen
22x
ml
b
u 2ml
u
1xsenl
g
2x2x
2x
1x
1xy
22122 xml
bxsen
l
g
ml
ux
1x
27
Simple pendulum example
1xsen
22x
ml
b
u
2ml
u
1xsenl
g2x
2x
2x
1x
1xy
22122 xml
bxsen
l
g
ml
ux
1x
2x
2x
28
Simple pendulum example
1xsen
22x
ml
b
u
2ml
u
1xsenl
g2x
2x
2x
1x
1xy
22122 xml
bxsen
l
g
ml
ux
1x
2x
2x
29
Simple pendulum example
1xsen
22x
ml
b
u2ml
u
1xsenl
g 2x
2x
2x
1x
1xy
22122 xml
bxsen
l
g
ml
ux
1x
2x
2x
30
Simple pendulum example
Before you run your simulation, it’s necessary set theconfigurations in simulink.
32
Simple pendulum example
%parameters of simple pendulum clear all;close all ;clc;
% constantsl=0.5;m=10;g=9.81;b=4.5;%initial conditionsx20= 0; %initial acelerationx10=30*pi/180; %initial position in rad
Create a script using this program
33
Hands on plus!1. Using the function [A,B,C,D]=linmod('SYS') to extract the continuous-time linear state-space model of the
nonlinear pendulum;
Pendulum System
u y
2. Compare the linear system found in step 1 with the nonlinear system built.
Pendulum System
u y
35
RC circuit transfer function
iu
Sensor
)(1
)( sisC
sRisu
)()(
sysi
)(si )(sy)(su)(sG
Kirchhoff
)(1
)( suRCs
Cssi
1
RCs
CssG
36
RC circuit transfer function to time
iu
Sensor
1
)()(
)(
RCs
CssG
su
sysK
)(1
)( suRCs
Cssy
)(1
)( suRCs
C
Rsy
RCs
CRRsy
1
1)(
2
RC
t
eCR
tR
ty
2
)()(
0t
)(si )(sy)(su)(sG
37
Hands on!
)(si )(sy)(su
1. Built the transfer function of the RC circuit using Simulink:
R=1000 (ohm); C=0.001 (F); alpha=10;;
2. Simulate the step responses.
1RCs
Cs
a)
b)
cvsy )()(su
RCs1
1
38
Hands on!
Newton
Kirchhoff
+
-
JBtiK at
eaaaa
a KviRdt
diL
J=3.2284E-6; B=3.5077E-6; Kt=Ke=0.0274; Ra=4; La=2.75E-6;
1. Find the state space representation of the D.C motor whit output
a
a
vu
ix
x
x
3
2
1
2. Build the block diagram using Simulink.
3. Simulate the step response to get: x1, x2 ,x3.