introduction to simulink (1)

36
Introduction to Simulink K. Craig 1 Introduction to Simulink Physical & Mathematical Modeling Engineering Measurement Engineering Analysis & Computing Engineering Discovery P h y s i c s M a th e m a t ic s Social Science Hands-On Minds-On Technical Communications Teamwork Professionalism Engineering System Investigation Process Engineering System Design Process Mechanical Engineering Electrical & Computer Engineering Civil & Environmental Engineering Biomedical Engineering Selection of Engineering Materials Processes to Make Products

Upload: memo-love

Post on 08-Aug-2015

53 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Introduction to simulink (1)

Introduction to Simulink K. Craig 1

Introduction to Simulink

Physical &

Mathematical

Modeling

Engineering

Measurement

Engineering

Analysis &

Computing

Engineering

Discovery

Physics

Mathem

atics

So

cia

l S

cie

nce

Hands-On Minds-On

Technical

Communications

Teamwork Professionalism

Engineering System Investigation Process

Engineering System Design Process

Mechanical

Engineering

Electrical &

Computer

Engineering

Civil &

Environmental

Engineering

Biomedical

Engineering

Se

lectio

n o

f E

ng

ine

erin

g M

ate

ria

ls Pro

ce

sse

s to

Ma

ke

Pro

du

cts

Page 2: Introduction to simulink (1)

Introduction to Simulink K. Craig 2

What is a System?

• A system is an assemblage of components or elements

intended to act together to accomplish an objective.

• The view of a system as a set of interconnected elements is

what has been called the “systems approach” to problem

solving.

• The behavior of a system is specified by its input-output

relation, which is a description – usually mathematical – of

how the output is affected by the input.

• There are two types of systems: static and dynamic.

• Engineering dynamic systems can be small-scale and

large-scale.

Page 3: Introduction to simulink (1)

Introduction to Simulink K. Craig 3

What is a Block Diagram?

• Block Diagram

– A block diagram of a system is a pictorial

representation of the functions performed by each

component and of the flow of signals. It describes a

set of relationships that hold simultaneously.

– A block diagram contains information concerning

dynamic behavior, but it does not include any

information on the physical construction of the

system.

– Many dissimilar and unrelated systems can be

represented by the same block diagram.

– A block diagram of a given system is not unique.

Page 4: Introduction to simulink (1)

Introduction to Simulink K. Craig 4

Electro-Pneumatic Transducer:

An Engineering System

Note the three methods of

engineering communication:

picture, schematic, & block

diagram!

Page 5: Introduction to simulink (1)

Introduction to Simulink K. Craig 5

Temperature Feedback

Control System:

A Larger-Scale

Engineering System

Page 6: Introduction to simulink (1)

Introduction to Simulink K. Craig 6

What is Simulink?

• Simulink is an extension to MatLab that allows engineers to

rapidly and accurately build computer models of dynamic

physical systems using block diagram notation.

– linear and nonlinear systems

– continuous-time and discrete-time components

– graphical animations are possible

• Previously, a block diagram of the dynamic system

mathematical model was created and then the block

diagram was translated into a programming language.

• In Simulink, the computer program is the block diagram and

this eliminates the risk that the computer program may not

accurately implement the block diagram.

Page 7: Introduction to simulink (1)

Introduction to Simulink K. Craig 7

Engineering System Investigation Process

Physical

System

System

Measurement

Measurement

Analysis

Physical

Model

Mathematical

Model

Parameter

Identification

Mathematical

Analysis

Comparison:

Predicted vs.

Measured

Design

Changes

Is The

Comparison

Adequate ?

NO

YES

START HERE

Focus

of

Our Attention Here

Simulink uses the

Mathematical Model

represented in Block

Diagram form and

predicts the dynamic

response (solves the

equations) of the

physical model (not

the actual physical

system).

Page 8: Introduction to simulink (1)

Introduction to Simulink K. Craig 8

F ma

Ma Bv Kx F(t)

Ma Bv Kx F(t)

1a ( Bv Kx F(t))

M

• Rigid support

• Pure and ideal spring

• Pure and ideal viscous damper

• One degree-of-freedom motion; x direction

• Rigid attached mass

• System is vertical; g acts down in +x direction

Physical System Simplifying Assumptions

Mathematical Model

Page 9: Introduction to simulink (1)

Introduction to Simulink K. Craig 9

Simulink Block Diagram1/s means

integration

in Simulink

Gain Block

multiplies the input

by the gain value

To Workspace

Block sends

selected output

to workspace

for plotting,

analysis, etc.

Page 10: Introduction to simulink (1)

Introduction to Simulink K. Craig 10

• Numerical Integration

– Rectangle Approximation

• Assumes the function has a constant value within each interval

• Break the interval into a number of pieces of equal width, T

• Evaluate the function at x, the start of each piece, i.e., f(x)

• Calculate the area of a rectangle for each piece

– Area = T • f(x)

• Add up the areas of all the rectangles

T

f(x)

Page 11: Introduction to simulink (1)

Introduction to Simulink K. Craig 11

– Trapezoid Approximation

• Assumes the function may change linearly within each interval

• Break the interval into a number of pieces of equal width, T

• Evaluate the function at x1, the start of each piece, i.e., f(x1)

• Evaluate the function at x2, the end of each piece, i.e., f(x2)

• Calculate the area of a box with a linearly sloping top for each

piece

– Area = T • ½ [f(x1) + f(x2)]

• Add up the areas of all the boxes

f(x1)

f(x2)

T

Page 12: Introduction to simulink (1)

Introduction to Simulink K. Craig 12

• Inputs to a Dynamic System

– Engineers typically use two inputs to evaluate dynamic

systems: a step input and a sinusoidal input.

– By a step input of any variable, we will always mean a

situation where the system is at rest at time t = 0 and we

instantly change the input quantity, from wherever it was

just before t = 0, by a given amount, either positive or

negative, and then keep the input constant at this new

value forever. This leads to a transient response called

the step response of the system.

– When the input to the system is a sine wave, the steady-

state response of the system, after all the transients have

died away, is called the frequency response of the system.

– These two input types lead to the two views of dynamic

system response: time response and frequency response.

Page 13: Introduction to simulink (1)

Introduction to Simulink K. Craig 13

Step Response

blue mass is placed on mass

M at t = 0 and left there

Page 14: Introduction to simulink (1)

Introduction to Simulink K. Craig 14

Why is Simulink Important?

• The potential productivity improvement and cost savings

realized from the block diagram approach to programming

is dramatic.

• There are two principal strategies for Simulink employment.

– Rapid Prototyping

• This is the application of productivity tools to develop

working prototypes in the minimum amount of time.

Here we optimize for development speed, rather than

execution speed or memory use. A hierarchy of

physical models is used in this phase. Physical

system design and control design are optimized

simultaneously.

Page 15: Introduction to simulink (1)

Introduction to Simulink K. Craig 15

– Rapid Application Development

• Here the final computer program is the Simulink

model or is derived from the Simulink model

through automatic C-code generation.

Page 16: Introduction to simulink (1)

Introduction to Simulink K. Craig 16

MatLab Desktop

Command WindowCurrent Directory / Workspace

Command History

Simulink Icon

Page 17: Introduction to simulink (1)

Introduction to Simulink K. Craig 17

Page 18: Introduction to simulink (1)

Introduction to Simulink K. Craig 18

File → New → Model

Page 19: Introduction to simulink (1)

Introduction to Simulink K. Craig 19

Simulink Block Diagram Manipulations

Page 20: Introduction to simulink (1)

Introduction to Simulink K. Craig 20

• Some Simulink Block Diagram Suggestions

– Careful arrangements of blocks and signal lines can

make relationships easier to follow.

– Naming blocks and signal lines and adding

annotations to the model can make the purpose of the

model elements easier to understand.

– The Best Way to ensure that your Simulink Block

Diagram accurately represents your mathematical

model equations is to write your mathematical model

equations directly from the Simulink Block Diagram

and then compare your result to the actual equations.

This will uncover any errors before you start to use

your block diagram to investigate model behavior.

Page 21: Introduction to simulink (1)

Introduction to Simulink K. Craig 21

F ma

Ma Bv Kx F(t)

dv dxa v

dt dt

Ma Bv Kx F(t)

1a ( Bv Kx F(t))

M

Spring-Mass System Mathematical Model

a v v x

a v

v x

Page 22: Introduction to simulink (1)

Introduction to Simulink K. Craig 22

Initial Conditions

a v v x

Page 23: Introduction to simulink (1)

Introduction to Simulink K. Craig 23

1a ( Bv Kx F(t))

M

Page 24: Introduction to simulink (1)

Introduction to Simulink K. Craig 24

1a ( Bv Kx F(t))

M

Page 25: Introduction to simulink (1)

Introduction to Simulink K. Craig 25

1a ( Bv Kx F(t))

M

Page 26: Introduction to simulink (1)

Introduction to Simulink K. Craig 26

1a ( Bv Kx F(t))

M

Page 27: Introduction to simulink (1)

Introduction to Simulink K. Craig 27

1a ( Bv Kx F(t))

M

Page 28: Introduction to simulink (1)

Introduction to Simulink K. Craig 28

1a ( Bv Kx F(t))

M

Page 29: Introduction to simulink (1)

Introduction to Simulink K. Craig 29

1a ( Bv Kx F(t))

M

Page 30: Introduction to simulink (1)

Introduction to Simulink K. Craig 30

1a ( Bv Kx F(t))

M

Page 31: Introduction to simulink (1)

Introduction to Simulink K. Craig 31

Simulation → Configuration Parameters → Solver

Page 32: Introduction to simulink (1)

Introduction to Simulink K. Craig 32

Simulation → Configuration Parameters → Data Import/Export

Page 33: Introduction to simulink (1)

Introduction to Simulink K. Craig 33

M-File for Parameters

Start

Simulation

Page 34: Introduction to simulink (1)

Introduction to Simulink K. Craig 34

Page 35: Introduction to simulink (1)

Introduction to Simulink K. Craig 35

Page 36: Introduction to simulink (1)

Introduction to Simulink K. Craig 36