introdução ao simulink

39
1 Simulink and block diagram 2015 BRAZIL STUDY ABROAD PROGRAM TEXAS A&M UNIVERSITY- UNIVERSITY OF SAO PAULO ELMER ALEXIS GAMBOA PEÑALOZA RODOLPHO VILELA ALVES NEVES MICHEL BESSANI RAFAEL FERNANDO QUIRINO MAGOSSI DEPARTAMENTO DE ENGENHARIA ELÉTRICA USP - SÃO CARLOS 2015

Upload: adson-filipe

Post on 07-Dec-2015

234 views

Category:

Documents


0 download

DESCRIPTION

Introdução Ao Simulink USP

TRANSCRIPT

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

3

Simulink and block diagramSimulink’s interface

4

Simulink and block diagramSimulink’s interface

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

7

Simple RC circuit exemple

8

Simple RC circuit example

RC

u

RC

xx 1

1'

To create the first equation, you can use:

9

Simple RC circuit example

To use the integrator with external initial

condition, give a double click on integrator

block.

10

Simple RC circuit example

To create the second equation you can use

R

u

R

xy

1

11

Simple RC circuit example

Before you run your simulation, it’s necessary set theconfigurations in simulink.

12

Simple RC circuit example

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);

16

Simple RC circuit example

You got the following function:

>> G

G =

0.001 s

-------

s + 1

17

Simple RC circuit example

Create a transfer function using

on simulink the transfer fcn block.

18

Simple RC circuit example

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

21

Simple pendulum example

Vector notation

buxfx

u

mlxsen

l

g

x

x

21

2

10

1xy

22

Simple pendulum example

1xy

22122 xml

bxsen

l

g

ml

ux

1x

23

Simple pendulum example

1xy

22122 xml

bxsen

l

g

ml

ux

1x

24

Simple pendulum example

1xy

22122 xml

bxsen

l

g

ml

ux

1x

u 2ml

u

2ml

u

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.

31

Simple pendulum example

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

34

Simulink and block diagramTransfer Fcn

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.

39

[1] Matlab Product Help.

[2] Matlab Demystified. A Self-Teaching Guide, David McMahon, McGraw Hill.

[3] Matlab: An Introduction with Applications, Amos Gilat, Fourth Edition, JOHN WILEY & SONS.

References