Session 3 Introduction to SIMULINK

Similar documents
Experiment 6 SIMULINK

Experiment 8 SIMULINK

Experiment 3. Getting Start with Simulink

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Objectives. Simulink Basics

Introduction to Simulink. The Use of Mathematic Simulations in Electrical Engineering

SIMULINK A Tutorial by Tom Nguyen

SIGNALS AND LINEAR SYSTEMS LABORATORY EELE

Lecture 10: Simulink. What is Simulink?

Introduction to Matlab Simulink. Control Systems

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

BME 5742 Bio-Systems Modeling and Control

[ MATLAB ] [ Resources ] PART TWO: SIMULINK

Simulink Basics Tutorial

MATLAB AND SIMULINK. Modeling Dynamic Systems J. ABELL

Simulink Basics Tutorial

ME422 Mechanical Control Systems Matlab/Simulink Hints and Tips

The Mathcad Workspace 7

Note 10 Introduction to MATLAB & SIMULINK

Introduction to Simulink

UNIT 5. Simulink. 1. Introduction

ELEC ENG 4CL4 CONTROL SYSTEM DESIGN

Guide to WB Annotations

Introduction to Simulink

Introduction to Simulink

MATLAB Project: Getting Started with MATLAB

Introduction to the MATLAB SIMULINK Program

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Exploring the Workspace

ChemSense Studio Client Version 3.0.7

Systems & Control Lab.-Manual

Controlling the Drawing Display

Appendix A. HINTS WHEN USING EXCEL w

TI-SmartView Emulator Software for the TI-84 Plus Family (Windows and Macintosh )

SIMULINK Tutorial. Select File-New-Model from the menu bar of this window. The following window should now appear.

Photoshop / Editing paths

Introduction to LabVIEW

Microsoft Word 2010 Tutorial

Introduction to Scientific Computing with Matlab

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Process Automation CHEM-E7140

Introduction to Simulink

SOUND BROWSER SYSTEM PROTOTYPES SOUND FILE WINDOW. Click to update the list when files or directories have been added or removed by other programs.

L E S S O N 2 Background

A Guide to Processing Photos into 3D Models Using Agisoft PhotoScan

LEARNING TO PROGRAM WITH MATLAB. Building GUI Tools. Wiley. University of Notre Dame. Craig S. Lent Department of Electrical Engineering

the Simulation of Dynamics Using Simulink

StudioPrompter Tutorials. Prepare before you start the Tutorials. Opening and importing text files. Using the Control Bar. Using Dual Monitors

Drawing Tools. Drawing a Rectangle

The Photoshop Workspace

Using MATLAB, SIMULINK and Control System Toolbox

Introduction to Word 2010

AutoCAD 2009 User InterfaceChapter1:

Adobe Illustrator CS5 Part 2: Vector Graphic Effects

Using Arrays and Vectors to Make Graphs In Mathcad Charles Nippert

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Radial Diameter Dimension. Contents

Working with Spectrum Tabs, Plots, and Charts

SystemVue 2011 Fundamentals (version ) LAB EXERCISE 1. SystemVue Basics

Computer Aided Design (CAD) Lecture 10. Introduction to Simulink (3) Dr.Eng. Basem ElHalawany

Grade 8 FSA Mathematics Practice Test Guide

An Introduction to Using Simulink

COPYRIGHTED MATERIAL PHOTOSHOP WORKSPACE. Interface Overview 3. Menus 15. The Toolbox 29. Palettes 61. Presets and Preferences 83 WEB TASKS

CECOS University Department of Electrical Engineering. Wave Propagation and Antennas LAB # 1

VIMED JWEB Manual. Victorian Stroke Telemedicine. Version: 1.0. Created by: Grant Stephens. Page 1 of 17

Introduction to Excel 2013

Create ruler guides. Create a ruler guide

To learn more about the Milestones window choose: Help Help Topics Select the Index tab and type in the feature. For Example toolbox.

Learning Microsoft Word By Greg Bowden. Chapter 10. Drawing Tools. Guided Computer Tutorials

GIMP WEB 2.0 BADGES. GIMP is all about IT (Images and Text) OPEN GIMP

USER GUIDE DESIGN LAYOUTS

Microsoft Word 2016 by Prapaporn Techa-angkoon adapted into English by Dr. Prakarn Unachak

Xyron Wishblade Software Manual (PC)

Computer Project: Getting Started with MATLAB

Maple Quick Start. Maplesoft, a division of Waterloo Maple Inc.

ActivLearning. Training Series. addendum

VIEWZ 1.3 USER MANUAL

Table of Contents. Introduction.*.. 7. Part /: Getting Started With MATLAB 5. Chapter 1: Introducing MATLAB and Its Many Uses 7

Creating a Basic Chart in Excel 2007

Dive Into Visual C# 2008 Express

Texas School for the Blind and Visually Impaired. Using The Drawing Tools in Microsoft Word 2007 for Tactile Graphic Production

MATLAB The first steps. Edited by Péter Vass

Getting Started With XPresReview

3 TUTORIAL. In This Chapter. Figure 1-0. Table 1-0. Listing 1-0.

Homework Assignment 9 LabVIEW tutorial

Lehigh University Library & Technology Services

It is a good idea to practice View Control tools for 5 minutes at the start of every 3D session, before doing any other work.

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

ENVI Classic Tutorial: Introduction to ENVI Classic 2

Working with Graphics and Text

MICROSOFT OFFICE. Courseware: Exam: Sample Only EXCEL 2016 CORE. Certification Guide

Piping & Instrumentation Diagrams

Getting Started With Excel

MatDeck User Manual. Contents

Adobe Illustrator CS Design Professional GETTING STARTED WITH ILLUSTRATOR

Spreadsheets Microsoft Office Button Ribbon

Introduction to Mathcad

Chapter 25 Editing Windows. Chapter Table of Contents

Welcome to MicroStation

Appendix B: Creating and Analyzing a Simple Model in Abaqus/CAE

Transcription:

Session 3 Introduction to SIMULINK Brian Daku Department of Electrical Engineering University of Saskatchewan email: daku@engr.usask.ca EE 290 Brian Daku

Outline This section covers some basic concepts needed to use SIMULINK, such as: SIMULINK Basics SIMULINK Libraries Building Models Simulating Models Documenting Models Interfacing to the Workspace Vectors and Matrices in SIMULINK Other Useful Blocks EE 290 Introduction to SIMULINK Page 3-1 Brian Daku

What is SIMULINK SIMULINK is an interactive graphical environment for building and simulating system models. Some of the defining features of this tool are: It is an extension of MATLAB and thus is tightly integrated with MATLAB and the toolboxes. Models can easily be built using block diagrams. Continuous, discrete and hybrid systems can be modeled and simulated. Finite wordlength implementations. Nonlinear modeling and simulation. Asynchronous (non-uniform steps) simulation. EE 290 Introduction to SIMULINK Page 3-2 Brian Daku

Basic SIMULINK Operation First a block diagram model of system is built using the SIMULINK model window. Then the SIMULINK engine is used to step the system through time by computing the block outputs and propagating the signals to the next blocks. The engine accomplishes this using MATLAB s differential equation and difference equation solvers, whenever required. SIMULINK can also use MATLAB s workspace for system parameters, signal input and signal output. EE 290 Introduction to SIMULINK Page 3-3 Brian Daku

Starting SIMULINK Start SIMULINK using the icon or by typing simulink in the command window Select the new model icon to open this model window EE 290 Introduction to SIMULINK Page 3-4 Brian Daku

SIMULINK Library Browser Block Name Search Block Description Left click and drag Blocksets Libraries Blocks -Left click on a library to view the blocks in the browser -Right click on a library and select to open a new window -Left click on a block for a block description in the window -Right click on a block to access a menu of items EE 290 Introduction to SIMULINK Page 3-5 Brian Daku

General SIMULINK Libraries SIMULINK has general set of blocks contained in eight libraries. Continuous: Blocks for continuous systems. These are implemented with differential equations. Discrete: Functions & Tables: Math: Nonlinear: Signals & Systems: Sinks: Sources: Blocks for implementing discrete systems. These are implemented with difference equations. Blocks for implementing functions, lookup tables and S-functions. Arithmetic, logic and trigonometric functions. Limiters, quantizers and switches. Blocks to interface, manipulate and observe signals. Blocks to observe system output signals. Blocks to generate system inputs. EE 290 Introduction to SIMULINK Page 3-6 Brian Daku

General Form for a SIMULINK Model Sources System Sinks Deterministic Waveforms Random Waveforms Clocks From Workspace From File Interconnected Linear and Nonlinear Blocks s Displays Spectrum s To Workspace To File EE 290 Introduction to SIMULINK Page 3-7 Brian Daku

Building a Simple Model Sine Wave Sine Wave 1. Left click and drag sine wave block to model window. Location: Simulink->Sources 2. Left click and drag scope block to model window. Location: Simulink->Sinks Sine Wave Sine Wave output port, the pointer 3. Move mouse over sine wave becomes a cross. Left click and drag the dashed line. 4. Drag the dashed line to the input port of the scope block. The pointer becomes a double cross, release to connect. EE 290 Introduction to SIMULINK Page 3-8 Brian Daku

Inserting Blocks into a Model Sine Wave Sine Wave 1 1 1. Select the block with the left mouse button and drag the block over the line. 2. Release the left mouse button to to automatically connect The block is located in the Simulink->Math library. This method of block insertion will only work for blocks with a single input and single output. For blocks with multiple inputs or outputs you must remove the line, place the block and then add new lines. EE 290 Introduction to SIMULINK Page 3-9 Brian Daku

Copying Blocks 1 1 Sine Wave Sine Wave 1. Right click on the scope block and hold the button down. Drag the mouse, placing the dashed image at the desired location. Alternate methods to copy blocks are: 2. Release the right mouse button to automatically place the scope. Edit menu or right click on a block and release. Standard hot keys for copy and paste, Ctrl-C and Ctrl-V. Multiple blocks can be copied, at the same time, by first selecting all of the blocks. EE 290 Introduction to SIMULINK Page 3-10 Brian Daku

Working with Connecting Lines 1 1 Sine Wave Sine Wave 1. To create a branch line, right click on the line and drag the dashed line. 2. At the scope, when the cursor becomes a double cross, release the right mouse button. Left clicking on a line and dragging it reroutes the line segment. Shift and left click on a line to create a breakpoint. Left click on the breakpoint (turns into a circle) and drag to move the breakpoint. Left clicking on a line will display all the breakpoints. EE 290 Introduction to SIMULINK Page 3-11 Brian Daku

Moving Connected Blocks To move a block without breaking line connections drag it using the left mouse button. Use the following approach to move the block, when you want to break the connections. 1 Sine Wave Sine Wave 1 1. To move the connected gain block to the other branch, hold down the shift key, left click and drag the dashed box. 2. Release the left mouse button to place the gain block on the on the other branch. You can connect the separated line using the left mouse button. EE 290 Introduction to SIMULINK Page 3-12 Brian Daku

Deleting and Selecting Delete a block by selecting the block and pressing the Delete or Backspace key. You can also use Cut or Clear from the Edit menu or by right-clicking on the block. Similarly, you can delete a signal line. If you want to move, copy or delete a group of blocks, you must first select the multiple blocks. This can be done using two methods: 1. Hold the shift key down while left-clicking on each block of interest. 2. Left-click and hold the mouse button near the blocks. Drag the dotted bounding box that appears to enclose all of the desired blocks. Release the mouse and all the blocks are selected. EE 290 Introduction to SIMULINK Page 3-13 Brian Daku

Combining Signals Two signals can be simultaneously displayed on a scope by combining them into a vector. A Mux block from the Signals & Systems library can be used to combine scalar signals into vectors. Sine Wave Sine Wave 1 1 2 1. Add the Mux block to the left model to produce the model on the right. To identify the vector signals in the model on the the right, Wide Nonscalar Lines and Signal Dimensions have been selected from the Format menu. EE 290 Introduction to SIMULINK Page 3-14 Brian Daku

Setting Block Parameters Sine Wave Sine Wave 1 2 Double left click block -K- 2 Block parameters can be any MATLAB function (eg. sqrt(4)). Right clicking on the block can also be used to display the block parameter box using the displayed menu. EE 290 Introduction to SIMULINK Page 3-15 Brian Daku

Running the Simulation Start the simulation by selecting the play icon -Display the scopes by double clicking on the scope icons. -Automatically scale the scope by selecting the binocular icon. EE 290 Introduction to SIMULINK Page 3-16 Brian Daku

Block Diagram Zoom You can control the size of your model in the window using the following methods: Select the menu item View->Zoom in to increase the model size. OR use the hot key r to zoom in. Select the menu item View->Zoom out to decrease the model size. OR use the hot key v to zoom out. If you want to fit the model to the window size, press the space bar. EE 290 Introduction to SIMULINK Page 3-17 Brian Daku

Modifying Block Graphics Resizing Blocks Left click on the block to select the block. Left click and drag any of the corners to resize the block. Coloring Blocks Right click on a block to display a menu. Select Foreground color or Background color and choose your color. The Foreground color modification changes the block color and all output signal lines. This feature can be used to make complex models easier to read. Drop Shadow Right click on a block, select Format and then Hide drop shadow. EE 290 Introduction to SIMULINK Page 3-18 Brian Daku

Block Orientation Blocks can be flipped using Ctrl-I or Flip Block in the Format menu or rotated using Ctrl-R or Rotate Block. Sine Wave Sine Wave K K 1 1 Original Rotated Block Sine Wave K 1 Repositioned Block EE 290 Introduction to SIMULINK Page 3-19 Brian Daku

Annotating Models Double left-click anywhere in model window to open textbox and type in the text. To reposition the text box just left-click on the box and drag (the box has to be unselected first). You can edit the text by double left-clicking on the text box. Right-click on text box to change the size, font or alignment of the text. Sine Wave This is a basic model. K 1 EE 290 Introduction to SIMULINK Page 3-20 Brian Daku

Labeling Signals To label a signal, double left-click on the signal line and a text box will appear, then type in the label name. This text box is attached to the signal line, you can reposition it on the line. But you can t move it away from the line. You can also use a GUI to add a label. Select the signal line, and right click (or the Edit menu), select Signal Properties to see the GUI. Here you can also link to an HTML document. SignalA SignalA Sine Wave K SignalB 1 EE 290 Introduction to SIMULINK Page 3-21 Brian Daku

Propagating Signal Labels Signal labels can be propagated through virtual blocks (ones that do not change the signal). Label the signal with a <, Edit Update Diagram. then select the menu item You could also go to Signal Properties and enter < or turn Show Propagated Signals on. Note that the title of the display is given the signal name. SignalA SignalA Sine Wave K SignalB <SignalA, SignalB> 1 EE 290 Introduction to SIMULINK Page 3-22 Brian Daku

Input from Workspace The From Workspace block in the Simulink Sources library can be used to input signals into SIMULINK. From Workspace The input can take the standard form of two dimensional matrix with time and data value columns or a structure. Parameters and Dialog Box Data An expression that evaluates to an array or a structure containing an array EE 290 Introduction to SIMULINK of simulation times and corresponding Page 3 - signal 23 values. For example, Brian Daku suppose

Output to Workspace The To Workspace block in the Simulink Sinks library can be used to output SIMULINK signals to the workspace. To Workspace The output can bein another savedexample, as an all parameters array are of asdata defined in values, the first example or as except a that the Limit data points to last is 3. In this case, only the last three sample structure, with or without points collected the are written timeto the information. workspace. If the simulation stop time is 100, data corresponds to times 99.0, 99.5, and 100.0 seconds (three points). The signals Data Type go to the A To Workspace workspace block can when save input the of any simulation real or complex data is paused type to the Support MATLAB workspace. or ends. Parameters and Dialog Box Variable name EE 290 Introduction to SIMULINK The name of the array that holds Pagethe 3 -data. 24 Brian Daku

Block Parameters from the Workspace Block parameters can be defined as variables in the workspace or they can be mathematical expressions that are evaluated in the workspace. If a variable used in SIMULINK is undefined in the workspace, an error message will appear. In the following gain block examples, variable A must be defined in the workspace. A sqrt(a) EE 290 Introduction to SIMULINK Page 3-25 Brian Daku

Vectors, Matrices and SIMULINK In SIMULINK signals and block parameters can be 1-D vectors and the default operations are element-by-element. SIMULINK can also work with matrices. It can tell the difference between row and column vectors. Blocks can be configured to treat the parameters as matrices. Note, in SIMULINK a vector is a one-dimensional (1-D) array of values, an ordered list that has no row or column orientation. There is no MATLAB equivalent for a 1-D Simulink vector and most blocks treat a 1-D vector as a column vector. Row vectors, column vectors and matrices are referred to as two-dimensional (2-D) arrays. EE 290 Introduction to SIMULINK Page 3-26 Brian Daku

Fcn: Function Blocks This block implements simple functions. Simulink Functions & Tables library. Input is referred to as u and it can be a vector. Output is always a scalar. C language expressions, ie sin(u[1]) + cos(u[2]) MATLAB Fcn: This block is used to call MATLAB functions. Simulink Functions & Tables library. The function must return a single output, which can be a vector. The specified function is applied to the input, or u can be used, ie mean, sin(u((1)) + cos(u(2)) Slow, since MATLAB parser is called. EE 290 Introduction to SIMULINK Page 3-27 Brian Daku

Block The scope block can be customized for your viewing pleasure. The Binoculars icon Autoscales the plot. Right-clicking on a graph, you can manually set the axes. The Magnifying glasses are used to zoom, zoom in x direction and zoom in y direction. General scope properties can be set by selecting the Properties icon. Number of axes (one for each input port). Time range, tick labels, sampling. Data history tab allows you to set the amount of data saved and you can output the scope data to the workspace. Use the Save Current Axes Settings icon to save your changes. EE 290 Introduction to SIMULINK Page 3-28 Brian Daku

Floating and Display Blocks When debugging complicated models, connecting a scope to each signal line can be time consuming. This problem is addressed with floating devices. The and Display blocks can be configured as floating devices using a setting in their parameter dialog box. A floating block has no input ports, it displays any selected signal in the model. To select a signal just left click on the signal line. A floating scope has a blue frame around the axes. Multiple floating devices in a model display the same signals. EE 290 Introduction to SIMULINK Page 3-29 Brian Daku

Signals for Floating Devices In SIMULINK, the buffers that store signal data are, by default, reused to save memory. Thus the signals are local variables. For floating devices, since there are no connections to signal lines, local variables are not useful. Thus you have to stop SIMULINK from reusing the buffer for that floating variable. This can be done in one of two ways: For all signals, disable (set to Off) the Signal storage reuse item in the Advanced tab of the Simulation Parameters box. For specific signals, right-click on the signal line and select Signal properties, then select the item Simulink Global (Test Point). EE 290 Introduction to SIMULINK Page 3-30 Brian Daku

Printing a Model Printing a Block Diagram Selecting the menu item File Print displays this print dialog When you select either the Current system and belowor All systems option, box (only a portion is shown here). two check boxes become enabled. In this figure, All systems is selected. Selecting the Look Under Mask Dialog check box prints the contents of masked subsystems when encountered at or below the level of the current block. When printing all systems, the top-level system is considered the current block so Simulink looks under any masked blocks encountered. You can design your own background frame for printing models using the frame editor, by typing frameedit at the MATLAB prompt. Selecting the Expand Unique Library Links check box prints the contents of library blocks when those blocks are systems. Only one copy is printed regardless of how many copies of the block are contained in the model. For more information about libraries, see Libraries on page 4-77. Type doc frameedit to view a help file. The print log lists the blocks and systems printed. To print the print log, select the Include Print Log check box. EE 290 Introduction Selecting to SIMULINK the Frame check box prints Page a title 3 block - 31 frame on each diagram. Brian Daku

Summary This section covered the basic mechanics for building, documenting and simulating SIMULINK models. It should be more apparent that MATLAB is an integral part of using SIMULINK, since the workspace can be used for signal input and output and for defining block parameters. It should be noted that SIMULINK has a special way of viewing 1-D vectors, which does not fit into typical linear algebra definitions. EE 290 Introduction to SIMULINK Page 3-32 Brian Daku