Intro to Simulink Modified by Gary Balas 20 Feb 2011 Copyright 2005-8, Andy Packard. This work is licensed under.

Slides:



Advertisements
Similar presentations
Example Project and Numerical Integration Computational Neuroscience 03 Lecture 11.
Advertisements

Formal Computational Skills
Chapter 6 Differential Equations
1 1 Mechanical Design and Production Dept, Faculty of Engineering, Zagazig University, Egypt. Mechanical Design and Production Dept, Faculty of Engineering,
Getting started with Simulink An introductory tutorial ES205 Analysis and Design of Engineering Systems Rose-Hulman Institute of Technology © R. Layton.
Ordinary Differential Equations
Computer Science 1000 LOGO I. LOGO a computer programming language, typically used for education an old language (1967) the basics are simple: move a.
SIMULINK Dr. Samir Al-Amer. SIMULINK SIMULINK is a power simulation program that comes with MATLAB Used to simulate wide range of dynamical systems To.
HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Simulink ® From Simulink® 7 Getting Started Guide.
Command Console Tutorial BCIS 3680 Enterprise Programming.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Numerical Solution of Ordinary Differential Equation
Solving ODEs UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
In the previous two sections, we focused on finding solutions to differential equations. However, most differential equations cannot be solved explicitly.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
Lecture 35 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Numerical Integration UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Sistem Kontrol I Kuliah II : Transformasi Laplace Imron Rosyadi, ST 1.
Simulink ® Interface Course 13 Active-HDL Interfaces.
Erin Catto Blizzard Entertainment Numerical Integration.
EE3561_Unit 8Al-Dhaifallah14351 EE 3561 : Computational Methods Unit 8 Solution of Ordinary Differential Equations Lesson 3: Midpoint and Heun’s Predictor.
Simulink ® Interface Course 13 Active-HDL Interfaces.
Simulink SubSystems and Masking April 22, Copyright , Andy Packard. This work is licensed under the.
Control Theory Lab 4 Modeling of Physical-SİMULİNK.
1 Extend is a simulation tool to create models quickly, with all the blocks you need and without even having to type an equation. You can use a series.
ECEN/MAE 3723 – Systems I MATLAB Lecture 2. Lecture Overview What is Simulink? How to use Simulink  Getting Start with Simulink  Building a model Example.
Regensburg, 24. – Introduction to Simulink Pavel Karban University of West Bohemia, Faculty of Electrical Engineering, Department of Theory.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 12.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
Introduction to Matlab Module #9 Page 1 Introduction to Matlab Module #9 – Simulink Topics 1.Simulink Textbook Reading Assignments Practice Problems.
Numerical Differentiation UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under.
THE LAPLACE TRANSFORM LEARNING GOALS Definition
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
SIMULINK-Tutorial 1 Class ECES-304 Presented by : Shubham Bhat.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
EE3417 – Introduction to Simulink
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Basics of Matlab UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Lecture 6: Time Response 1.Time response determination Review of differential equation approach Introduce transfer function approach 2.MATLAB commands.
Announcements Read Chapters 11 and 12 (sections 12.1 to 12.3)
Intro to Simulink April 15, Copyright , Andy Packard. This work is licensed under the Creative Commons.
Simulink Simulink is a graphical extension to MATLAB for modeling and simulation of systems. In Simulink, systems are drawn on screen as block diagrams.
INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin.
Simulink by Dr. Amin Danial Asham. References  MATLAB Help  Telemark University College - Department of Electrical Engineering, Information Technology.
Dr. Mujahed AlDhaifallah ( Term 342)
Simulink  ? 1 Simulink  ( Simu lation and Link ) is an extension of Matlab Offers modeling, simulation, and analysis of dynamical systems; i.e., a system.
ECE 576 – Power System Dynamics and Stability Prof. Tom Overbye Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Controlling Program Flow with Decision Structures.
MATLAB and SimulinkLecture 21 To days Outline Introduction to Simulink Block diagrams Building models Exercises on today’s topics.
Topics 1 Specific topics to be covered are: Discrete-time signals Z-transforms Sampling and reconstruction Aliasing and anti-aliasing filters Sampled-data.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Introduction to CMex E177 April 25, Copyright 2005, Andy Packard. This work is licensed under the Creative.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Getting started with Simulink
Getting started with Simulink An introductory tutorial.
ECEN/MAE 3723 – Systems I MATLAB Lecture 2.
ECE 576 – Power System Dynamics and Stability
Local Gain Analysis of Nonlinear Systems
Getting Started With Simulink
Numerical Analysis Lecture 37.
Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
CHAPTER 59 TRANSISTOR EQUIVALENT CIRCUITS AND MODELS
Presentation transcript:

Intro to Simulink Modified by Gary Balas 20 Feb 2011 Copyright , Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

What is Simulink? First perspective –Ordinary Differential Equation (ODE) solver –Differential equations described by block diagrams –Graphical interface to create/modify block diagrams There’s more, but we will probably not have time to cover –Hybrid systems –…–…

What is Simulink?

ODE theory Consider an input/output system, with m inputs, q outputs, and governed by a set of n, first-order, coupled differential equations Here, f 1 is a function that takes in 1+n+m arguments, and returns 1 value. Similar for f 2, … and h 1, h 2, …

ODE theory Look at the first n equations At each time t, the –current value of t –current value of x 1, x 2, … –current value of u 1, u 2,… dictate the current value of the rate-of-change of x i. So, an initial value of x, x(t 0 ) = x 0, and the value of u(t) for t≥t 0 yield the solution x(t) for t≥t 0. Unless the form of the functions f i is particularly simple, solving for x must be done numerically. These are called the state equations, and x is called the state.

Output Equations Look at the rest of the equations At each time t, the –current value of t –current value of x 1, x 2, … –current value of u 1, u 2,… dictates the current value of y i. So, these equations are quite simple, just how the outputs y (at time t) are defined as functions of the state (x) and input (u) at time t. Back to the state equations, where the action is…

Numerical Solution of ODEs Simulink solves the state equations using numerical integration techniques, such as 4 th and 5 th order Runge-Kutta formulae. You can learn more about numerical integration by taking Math We will not discuss this important topic in this class. However, to understand in a very crude manner how ODE solvers work, we will revisit the forward Euler method of approximate solution. Write the state equations in concise form

Numerical Solution of ODEs Taylor's expansion on a time-dependent function x, ignoring the higher order terms, gives an approximation formula Roughly, the ``smaller'' δ is, the better is the approximation. Euler's method propagates a solution by repeatedly using this approximation for a fixed δ,called the stepsize. Writing out the first 4 time steps (ie., t=0, δ, 2δ, 3δ, 4δ) gives and so on. An approximate solution can be quickly propagated by calling the subroutine for f once each timestep. Using the state equation

Numerical Solution of ODEs Once the approximate solution, x, is computed, computing the output, y simply involves evaluating the function h In Runge-Kutta methods, more sophisticated approximations are made, resulting in –more computations (e.g., 4 evaluations of f for every time step), –much greater solution accuracy. In effect, more terms of the Taylor series are used, involving matrices of partial derivatives, and even their derivatives, but without actually requiring explicit knowledge of these derivatives of the function f

“direct feedthrough” in Output Equations In general, the output equations are of the form If, in fact, h does not have explicit u dependence, then the system is said to “have no direct feedthrough from u to y” Note: no direct feedthrough does not mean that u doesn’t affect y. It is still true that u drives x in the state equations, and the values of x define the values of y.

ODE notation Recall, for shorthand, we write the state and output equations as State equations Output equations

General Form of a Continuous-Time block Input: u (vector valued) Output: y (vector valued) Internal State: x (vector valued) Governing relationship between these signals is of the form Each block “knows” –the functions f and h which define its behavior, and –at all times, the current value of its internal state x Initial value is specified by user. Implicitly, all blocks have time as an input.

Sources and Sinks Source: a block with no inputs, only outputs –Typical example: fixed “waveform” signal Sink: a block with no outputs, only inputs –Specific examples are blocks that represent data-logging (blocks that capture signals, but don’t “pass” anything on to another block)

Evolving a solution: Psuedo-code Current time: t Loop through blocks, determine output of each block –This uses the current time, and internal state x and output function h associated with the block. Using diagram, determine input to each block –The diagram dictates how the inputs to blocks are combinations of outputs of blocks. If the outputs are already known, then the inputs are determinable Using governing equations, determine for each block –This uses the current time, and internal state x and state function f associated with the block. Advance time, to t+δ –Use numerical integration formula (Euler, Backwards Euler, Runge- Kutta, etc) to advance one time-step Update internal state x for each block. Repeat.

Simulink Library The Simulink Library has folders of prebuilt blocks that have well-defined behaviors. We will primarily use 6 Libraries –Continuous –Math Operations –Signal Routing –Sinks –Sources –User-defined Functions

Continuous Library One commonly used block in continuous-time library is the Integrator. The appearance and equations of the block are Equivalently hence the name. The user specifies the value of x(0) by double-clicking on the icon, and entering value in dialog box.

Continuous Library - Integrator Double click

Running Simulink from Command line/function The sim command can be used to run a simulation from the command line, or inside a function, e.g., >> sim(‘ModelName’,TimeSpan,Options) The simset command sets options for the simulation. Two useful properties when sim is invoked in a function are SrcWorkspace: The workspace where dialog box entries are evaluated Default: ‘base’. Other options include ‘current’ and ‘parent’ DstWorkspace: The workspace where to assign variables defined in model Default is ‘current’. Other options are ‘base’ and ‘parent’ function [arg1,arg2] = analyzesim(ModelName)... Opt = simset(); % set options sim(ModelName,TSpan,Opt);...

Simple Examples Build two simple examples using –Step Function (from Source) –Integrator (from Continuous) –Scope (from Sink) The files are e177model1.mdl and e177model2.mdl Be sure to create a variable named mygain in the workspace before running model2 – recall this is what is entered in the dialog box of the Gain block. A more complicated example is from ME132. For illustrative purposes, the files are given. The setup and model files are –setupAW132.m –exampleAW132.m Run the setup file, then run the simulations. Be sure to try changing the Antiwindup gain, as well as the gain on the measurement noise.

Simple Example – Step/Int/Gain/Scope Build two simple examples using –Step Function (from Source) –Integrator (from Continuous) –Scope (from Sink)