58
1 SIMULINK INTRODUCTION Sadaf Anjum

Simulink Presentation

Embed Size (px)

Citation preview

Page 1: Simulink Presentation

1

SIMULINK INTRODUCTION

Sadaf Anjum

Page 2: Simulink Presentation

2

Lecture Overview

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 3: Simulink Presentation

3

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems Useful Information System Identification

Page 4: Simulink Presentation

4

Simulink

Is a software package for modeling, simulating, and analyzing dynamic systems.

Supports linear and nonlinear systems, modeled in continuous time, sample time, or a hybrid of the two.

For modeling, it provides a graphical user interface (GUI) for building models as block diagrams (using click-and-drag mouse operations)

You can simulate, analyze the output results, explore, revise your models.

Page 5: Simulink Presentation

5

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 6: Simulink Presentation

6

Start a Simulink Session

Page 7: Simulink Presentation

7

Start a Simulink Session

Page 8: Simulink Presentation

8

Simulink Library Browser

Page 9: Simulink Presentation

9

Create a New Model

Page 10: Simulink Presentation

10

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 11: Simulink Presentation

11

Building a Model

Simulink Block Diagram – clear model of a dynamic system

Each block represents an elementary dynamic system that produces an output (either continuous or discrete output)

Lines represent connections of block inputs to block outputs

u(Input)

x(states)

y(Output)

Page 12: Simulink Presentation

12

Continue…

The following steps will guide you to construct a system/model:

STEP 1: Creating Blocks

STEP 2: Making connections

STEP 3: Set Parameters

STEP 4: Running Simulation

Page 13: Simulink Presentation

13

Continue…

Step 1: Creating Blocks

Click-Drag-Drop the Sine Wave block to Workspace Window

This is the Sine Wave block is

from the Sources library

Sources library

Save this model

Page 14: Simulink Presentation

14

Continue…

Step 1: Creating Blocks

These arefrom the Sinks

library

The Gain block isfrom the

Math library

The Mux block is from the Signals &Systems library

Page 15: Simulink Presentation

15

Continue…

Step 2: Making connectionsTo make connection: left-click while holding down control key (on keyboard) and drag from source port to a destination port

A connected Model

Page 16: Simulink Presentation

16

Continue…

Gain value = 5

Name the output parameter as “out1”

Double click the Gain block to set the parameter for the Gain block

Step 3: Set Parameters

Page 17: Simulink Presentation

17

Continue…

Page 18: Simulink Presentation

18

Continue…

View output via Scope block

Double click on Scope block to display output of the scopeNote: Scope block is similar to oscilloscope!

Output of the scope

Yellow: Input sine wavePurple: Output (sine wave with gain of 5

To fit graph to frame

Page 19: Simulink Presentation

19

Continue…

Three outputs show here

View output (workspace)

You can plot the output using the plot function

Page 20: Simulink Presentation

20

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 21: Simulink Presentation

21

Example 1:Differential Equations Example of a dynamic system:

1x Bx Kx f t

M

The Mathematical model of the system is describe by:

12 2

2x x x f t

Lets M=2kg; B = 2 Ns/m; K=2 N/m

Page 22: Simulink Presentation

22

Unit Step Input

Continue…

Use Simulink to simulate the step response of the system, i.e.

STEP 1: Creating Blocks

12 2

2x x x f t

f(t), N

1

0 Time, s

Select BLOCK set Location in Simulink Library

Step Sources

Sum Math Operation

Gain Math Operation

Integrator Continuous

Scope & To Workspace Sinks

Page 23: Simulink Presentation

23

Continue…

Page 24: Simulink Presentation

24

Continue…

Page 25: Simulink Presentation

25

Continue…

Page 26: Simulink Presentation

26

Continue…

12 2

2x x x f t

12 2

2x x x f t

STEP 2: Making connections

Page 27: Simulink Presentation

27

Continue…Step 4 Run SimulationStep Response for system example

Output from Scope block Plot system response

Page 28: Simulink Presentation

28

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 29: Simulink Presentation

29

Example 2: Transfer Function Use the system example and simulate the

response using transfer function approach

12 2

2x x x f t

2

( ) 1

( ) 2 2 2

X s

F s s s

The transfer function of the equation (assume all initial conditions =0)

Page 30: Simulink Presentation

30

Continue…

STEP 1: Creating Blocks

Select BLOCK set Location in Simulink Library

Step Sources

Transfer Function Continuous

Scope & To Workspace Sinks

Page 31: Simulink Presentation

31

Continue…

Page 32: Simulink Presentation

32

Continue… STEP 2: Making

connections

2

( ) 1

( ) 2 2 2

X s

F s s s

Page 33: Simulink Presentation

33

Continue…

Step 3 set parameters

Page 34: Simulink Presentation

34

Continue…

Step 4 Run Simulation

Output from Scope blockPlot system response

Page 35: Simulink Presentation

35

Topics

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 36: Simulink Presentation

36

Creating Subsystems

Subsystem – similar to “Subroutine” Advantage of Subsystems:

Reduce the number of blocks display on the main window (i.e. simplify the model)

Group related blocks together (i.e. More organized)

Can create a hierarchical block diagram (i.e. you can create subsystems within a subsystem )

Easy to check for mistakes and to explore different parameters

Page 37: Simulink Presentation

37

Continue…

Create Subsystem using model in Example 1STEP 1: Creating Blocks (Main window)

Page 38: Simulink Presentation

38

Continue…

Page 39: Simulink Presentation

39

Continue…

STEP 2: Double click Subsystem block and create a model in the Subsystem block

Page 40: Simulink Presentation

40

Continue…

STEP 3: Making connections (Main window)

Page 41: Simulink Presentation

41

Continue…

STEP 4: Set Parameter (Main window)STEP 5: Running SimulationThen view output response

Output from Scope block

Page 42: Simulink Presentation

42

TOPICS

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System Modeling example System Identification

Page 43: Simulink Presentation

43

System modeling Example.

Moment of inertia of the rotor (J) = 3.2284E-6 kg.m^2/s^2

Damping ratio of the mechanical system (b) = 3.5077E-6 Nms

Electromotive force constant (K=Ke=Kt) = 0.0274 Nm/Amp

Electric resistance (R) = 4 ohm Electric inductance (L) =

2.75E-6 H Input (V): Source Voltage

Output (theta): position of shaft

Page 44: Simulink Presentation

44

Continue…

Page 45: Simulink Presentation

45

Continue…

Page 46: Simulink Presentation

46

Continue…

Page 47: Simulink Presentation

47

Continue…

Page 48: Simulink Presentation

48

Continue…

Page 49: Simulink Presentation

49

What is Simulink? How to use Simulink

Getting Start with Simulink Building a model

Example 1 (Differential Equations ) Example 2 (Transfer Function) Creating Subsystems System modeling example System Identification

Page 50: Simulink Presentation

50

System Identification

Page 51: Simulink Presentation

51

Continue…

Page 52: Simulink Presentation

52

Coninue…

Page 53: Simulink Presentation

53

Continue…

Page 54: Simulink Presentation

54

Continue…

Page 55: Simulink Presentation

55

Continue…

Page 56: Simulink Presentation

56

Continue…

Page 57: Simulink Presentation

57

Continue…

This is the identified model of the unknown system.

Page 58: Simulink Presentation

58

THANK YOU…