Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin.

Similar presentations


Presentation on theme: "INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin."— Presentation transcript:

1 INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin

2 TABLE OF CONTENTS What Is Simulink? What Is Simulink? Starting Simulink Starting Simulink Simulink Windows Simulink Windows Simulink Library Simulink Library Creating A New Model Creating A New Model Entering Simulink Commands Entering Simulink Commands Connecting Blocks Connecting Blocks Modeling In Simulink Modeling In Simulink Example 1 Example 1 Example 2 Example 2  Creating Subsystems  Simulation Parameters  Running A Simulation Getting Output Getting Output Using Scope Using Scope Further Considerations Further Considerations Ending A Simulink Session Ending A Simulink Session Case Study Case Study References References

3 What Is Simulink Simulink is a graphical method of modeling and simulating a mathematical equation or a system in Matlab. Simulink is a graphical method of modeling and simulating a mathematical equation or a system in Matlab. Simulink is not a stand alone program which means that it could not be run without running Matlab. Simulink is not a stand alone program which means that it could not be run without running Matlab. Whatever variable defined in Matlab can be used in Simulink. Whatever variable defined in Matlab can be used in Simulink.

4 Starting Simulink To start Simulink, you must first start MATLAB. Consult your MATLAB documentation for more information. You can then start Simulink in two ways: Click the Simulink icon on the MATLAB toolbar. Click the Simulink icon on the MATLAB toolbar. Enter the simulink command at the MATLAB prompt. Enter the simulink command at the MATLAB prompt. On Microsoft Windows platforms, starting Simulink displays the Simulink Library Browser

5 Simulink Windows Simulink uses separate windows to display: Simulink uses separate windows to display: a block library browser a block library a model graphical (scope) simulation output These windows are not MATLAB figure windows and cannot be manipulated using HandleGraphics® commands. These windows are not MATLAB figure windows and cannot be manipulated using HandleGraphics® commands.

6 Simulink Library The Library Browser displays a tree-structured view of the Simulink block libraries installed on your system. You can build models by copying blocks from the Library Browser into a model window. The Library Browser displays a tree-structured view of the Simulink block libraries installed on your system. You can build models by copying blocks from the Library Browser into a model window.

7 Sources and Sinks

8 Continuous and Discrete Systems All dynamic systems can be analyzed as continuous or discrete time systems. Simulink allows you to represent these systems using transfer functions, integration blocks, delay blocks etc. All dynamic systems can be analyzed as continuous or discrete time systems. Simulink allows you to represent these systems using transfer functions, integration blocks, delay blocks etc.

9 Simulink Extras Figure 5 contains some advanced linear blocks, available in the “Simulink Extras” ibrary. They contain certain advanced blocks, such as a PID control block, transfer functions with initial conditions, etc. Figure 5 contains some advanced linear blocks, available in the “Simulink Extras” ibrary. They contain certain advanced blocks, such as a PID control block, transfer functions with initial conditions, etc.

10 Non-linear operators

11 Functions and Tables

12 Math Block (Mathematical tools)

13 Signals & Systems Block ( Signals and data transfer) In complicated block diagrams, there may arise the need to transfer data from one portion to another portion of the block. They may be in different subsystems. That signal could be dumped into a GOTO block, which is used to send signals from one subsystem to another. In complicated block diagrams, there may arise the need to transfer data from one portion to another portion of the block. They may be in different subsystems. That signal could be dumped into a GOTO block, which is used to send signals from one subsystem to another. Multiplexing helps us remove clutter due to excessive connectors, and makes matrix (column/row) visualization easier. Multiplexing helps us remove clutter due to excessive connectors, and makes matrix (column/row) visualization easier.

14 Subsystems Block

15 Creating a New Model Click the New button on the Simulink Library Browser’s toolbar (Windows only) or choose New from the library window’s File menu and select Model. You can move the window as you do other windows. Click the New button on the Simulink Library Browser’s toolbar (Windows only) or choose New from the library window’s File menu and select Model. You can move the window as you do other windows. You can build models by copying blocks from the Library Browser into a model window (this procedure is described later in the modeling example ). You can build models by copying blocks from the Library Browser into a model window (this procedure is described later in the modeling example ).

16 Simulink opens a new model window as below.

17 Entering Simulink Commands You run Simulink and work with your model by entering commands. You can enter commands by: You run Simulink and work with your model by entering commands. You can enter commands by: Selecting items from the Simulink menu barSelecting items from the Simulink menu bar Selecting items from a context-sensitive Simulink menu (Windows only)Selecting items from a context-sensitive Simulink menu (Windows only) Clicking buttons on the Simulink toolbar (Windows only) Clicking buttons on the Simulink toolbar (Windows only) Entering commands in the MATLAB command windowEntering commands in the MATLAB command window

18 Using Context-Sensitive Menus to Enter Commands:Using Context-Sensitive Menus to Enter Commands: Simulink displays a context-sensitive menu when you click the right mouse button over a model or block library window. The contents of the menu depend on whether a block is selected. If a block is selected, the menu displays commands that apply only to the selected block. If no block is selected, themenu displays commands that apply to a model or library as a whole.

19 Connecting Blocks To connect blocks, left-click and drag the mouse from the output of one block to the input of another block. The figure below shows the steps involved. To connect blocks, left-click and drag the mouse from the output of one block to the input of another block. The figure below shows the steps involved.

20 Modeling In Simulink Example 1: Modeling Equations Converting Celsius to Fahrenheit: Converting Celsius to Fahrenheit: To model the equation that converts Celsius temperature to Fahrenheit T F = 9/5(T C ) + 32 T F = 9/5(T C ) + 32 First, consider the blocks needed to build the model: First, consider the blocks needed to build the model: A Ramp block to input the temperature signal, from the Sources library A Constant block to define a constant of 32, also from the Sources library A Gain block to multiply the input signal by 9/5, from the Math library A Sum block to add the two quantities, also from the Math library A Scope block to display the output, from the Sinks library

21 Next, gather the blocks into your model window. Next, gather the blocks into your model window. Assign parameter values to the Gain and Constant blocks by opening Assign parameter values to the Gain and Constant blocks by opening (double-clicking) each block and entering the appropriate value. Then, click the Close button to apply the value and close the dialog box. (double-clicking) each block and entering the appropriate value. Then, click the Close button to apply the value and close the dialog box. Now, connect the blocks. Now, connect the blocks.

22 The Ramp block inputs Celsius temperature. Open that block and change the Initial output parameter to 0. The Ramp block inputs Celsius temperature. Open that block and change the Initial output parameter to 0. The Gain block multiplies that temperature by the constant 9/5. The Sum block adds the value 32 to the result and outputs the Fahrenheit temperature. The Gain block multiplies that temperature by the constant 9/5. The Sum block adds the value 32 to the result and outputs the Fahrenheit temperature. Open the Scope block to view the output. Now, choose Start from the Simulation menu to run the simulation. The simulation runs for 10 seconds. Open the Scope block to view the output. Now, choose Start from the Simulation menu to run the simulation. The simulation runs for 10 seconds.

23 Example 2: Modeling A Simple Continuous System To model the differential equation To model the differential equation x′ (t) = – 2x (t) + u (t) where u(t) is a square wave with an amplitude of 1 and a frequency of 1 rad/sec. The Integrator block integrates its input x′ to produce x. Other blocks needed in this model include a Gain block and a Sum block. To generate a square wave, use a Signal Generator block and select the Square Wave form but change the default units to radians/sec. Again, view the output using a Scope block. Gather the blocks and define the gain. Again, view the output using a Scope block. Gather the blocks and define the gain.

24 An important concept in this model is the loop that includes the Sum block, the Integrator block, and the Gain block. In this equation, x is the output of the Integrator block. It is also the input to the blocks that compute x′, on which it is based. This relationship is implemented using a loop. An important concept in this model is the loop that includes the Sum block, the Integrator block, and the Gain block. In this equation, x is the output of the Integrator block. It is also the input to the blocks that compute x′, on which it is based. This relationship is implemented using a loop.

25 The Scope displays x at each time step. For a simulation lasting 10 seconds, the output looks like this:The Scope displays x at each time step. For a simulation lasting 10 seconds, the output looks like this:

26 The equation you modeled in this example can also be expressed as a transfer function. The model uses the Transfer Fcn block, which accepts u as input and outputs x. So, the block implements x/u. If you substitute sx for x′ in the above equation, you get sx = -2x + u Solving for x gives x = u /(s + 2) or, x ⁄ u = 1 ⁄ ( s + 2)

27 The results of this simulation are identical to those of the previous model. The results of this simulation are identical to those of the previous model. The Transfer Fcn block uses parameters to specify the numerator and denominator coefficients. In this case, the numerator is 1 and the denominator is s+2. Specify both terms as vectors of coefficients of successively decreasing powers of s. In this case the numerator is [1] (or just 1) and the denominator is [1 2]. The model now becomes quite simple.

28 Creating Sub System It helps reduce the number of blocks displayed in your model window. It helps reduce the number of blocks displayed in your model window. It allows you to keep functionally related blocks together. It allows you to keep functionally related blocks together. It enables you to establish a hierarchical block diagram, where a Subsystem block is on one layer and the blocks that make up the subsystem are on another. It enables you to establish a hierarchical block diagram, where a Subsystem block is on one layer and the blocks that make up the subsystem are on another.

29 Before - After Before - After Check with model browser in Simulink window Check with model browser in Simulink window Label subsytem Ports Label subsytem Ports

30 Simulation Parameters You can set the simulation parameters for each simulation such as run time or solver option You can set the simulation parameters for each simulation such as run time or solver option

31 Simulation Parameters (Continue) Setting simulation time Setting simulation time Setting solver Setting solver Step Size Solver type

32 Running A Simulation A simulation can be run using 3 ways: A simulation can be run using 3 ways: Clicking the start word on the simulation tab Clicking the start word on the simulation tab Clicking the “play” button on the window Clicking the “play” button on the window Pressing Ctrl+T. Pressing Ctrl+T.

33 When a simulation is running, the status bar displays the status of the simulation, including the current simulation time and the name of the current solver. You can display or hide the status bar by selecting or clearing the Status Bar option on the Simulink View menu.

34 Getting Output You can save scope data into workspace (you can do this with “save to workspace” block in “sinks” catagory) You can save scope data into workspace (you can do this with “save to workspace” block in “sinks” catagory) You can view more than one signal in scope either on the same axis or in the separate axis. You can view more than one signal in scope either on the same axis or in the separate axis. Data can also be exported to the workspace using the scope. Data can also be exported to the workspace using the scope. Parameters

35 Using Scope Setting the number of axes for the scope (Figure 1) Setting the number of axes for the scope (Figure 1) Saving the data to workspace (Figure 2) Saving the data to workspace (Figure 2)

36 Further Considerations This lecture can’t possibly look upon all the blocks. This lecture can’t possibly look upon all the blocks. Another way is to get “help” concerning the block. Another way is to get “help” concerning the block. This can be done by double clicking on the block. A window will appear where a help button is available. This can be done by double clicking on the block. A window will appear where a help button is available. Click on that button to know what is the potential of the block. Click on that button to know what is the potential of the block.

37 Ending A Simulink Session Terminate a Simulink session by closing all Simulink windows. Terminate a Simulink session by closing all Simulink windows. Terminate a MATLAB session by choosing the command below from the File menu: Terminate a MATLAB session by choosing the command below from the File menu: Exit MATLABExit MATLAB

38 References SIMULINK – Model-Based and System-Based Design SIMULINK – Model-Based and System-Based Design Matlab Documentation, The MathWorks. www.mathworks.com http://sts.bwk.tue.n1/7y530/readers/.%5CSimuLinkTutoria l.pdf http://sts.bwk.tue.n1/7y530/readers/.%5CSimuLinkTutoria l.pdf http://sts.bwk.tue.n1/7y530/readers/.%5CSimuLinkTutoria l.pdf http://sts.bwk.tue.n1/7y530/readers/.%5CSimuLinkTutoria l.pdf http://www.eng.warwick.ac.uk/staff/msl/progs/simulinkla b1.pdf http://www.eng.warwick.ac.uk/staff/msl/progs/simulinkla b1.pdf http://www.engin.umich.edu/group/ctm/working/mac/sim ulink_basics/ http://www.engin.umich.edu/group/ctm/working/mac/sim ulink_basics/


Download ppt "INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin."

Similar presentations


Ads by Google