360 likes | 560 Views
MATLAB Tutorials. Session VII Introduction to SIMULINK. Rajeev Madazhy Email: rmadaz1@lsu.edu Dept of Mechanical Engineering LSU. Last Session…. Engineering Applications using MATLAB…. Solving non linear differential equations Algorithm analysis for four bar linkage problem
E N D
MATLAB Tutorials Session VII Introduction to SIMULINK Rajeev Madazhy Email: rmadaz1@lsu.edu Dept of Mechanical Engineering LSU
Last Session…. • Engineering Applications using MATLAB…. • Solving non linear differential equations • Algorithm analysis for four bar linkage problem • Other mechanical problems
Session VII Outline…. • Introduction to Simulink • Solving simple problems using Simulink
Simulink….. • Simulink is a program that runs as a companion to MATLAB • Simulink provides a graphical user interface (GUI) that is used in building block diagrams, performing simulations, as well as analyzing results of dynamic systems. • In Simulink, models are hierarchical so that you can view a system at a high level, then double click on blocks by using the mouse to go down through the design levels.
Getting started….. Lets get started with a simple example of simulating a sin wave. To open Simulink open the MATLAB command window first. Click on the icon which is present in the toolbar in the command window of MATLAB. Alternatively you can also enter the command Simulink to open the graphics library of simulink
General list of libraries…. Source type blocks produce input signals.The Sine Wave block is a source type block Sink type blocks provide a place for output. The scope block is a sink type block. Linear type blocks perform a linear transformation. The Integrator is a linear type block. Connection type blocks are involved with formingvector signals, the Mux block is an example.
Adding a block from the library….. To open a block library, double click on the associated library icon in the Simulink block library window. After opening the Sources library, the Sources library window opens, as shown
Adding a block from the library….. • To add the first block to the diagram, point the mouse at the Sine Wave block in the Sources library window and press the left button. • Create a new model window by clicking on to the new icon at the toolbar. • Without releasing the left mouse button, drag the mouse to the new model window and release the mouse button.
Pulling the selected blocks…. Pull in the following blocks for our simulation from the following libraries. Block From Library Sine wave sources integrator Linear Mux connections Scope sinks
Inputs and outputs…. In general the inputs to a block are on the left a > symbol points into the block. In addition, outputs are generally on to the right, a > symbol out of the block. To add a connection, use the mouse to position the pointer over the output port of the block. During this time the pointer changes to cross hairs .
Cont… The completed connection should look like this…. Adding a branch line….This is required when you have an output which needs to be connected to two separate blocks
Cont… To complete the connections, add a line from the output of the integrator block to the input port of the mux block. When you are done it should look similar to the following. Labels can be added to lines to further annotate your model. To create a signal label, double click on a line segment and type the label at the insertion point.
Final model…. Save the model as example1.mdl
Giving model parameters….. The sine wave block Double click on the sine wave block and examine the data fields. Sine wave block parameters: Amplitude = 1 Frequency (rad/sec) = 0.25*2*pi Phase(rad) = 0 Sample time = 0
Integrator Block…. Integrator block parameters: External reset = None Initial Conditions = 0 Limit Output = Not checked Show saturation point = Not checked Show state port = Not checked Absolute tolerance = auto
Simulation parameters…. Go to simulation => parameters in the model window toolbar Enter the following values
Run the simulation…. To view the results of the simulation, double click on the scope block.
Cont…. To better fit the display in the scope window, click on the ‘Fit View’ button . The scope window should similar to the following.
Example 2…. The next example would be to simulate the dynamics of second order system. Given that: Obtain the velocity and displacement response
Building the model…. The same procedure is applied as being shown in the first example. Pull all the necessary blocks from the library browser. The blocks required is as follows: BlocksNumber Integrator 2 Sum 1 Scope 3 Step I/P 1 Gain 3
Gain parameters- 1st Gain block Similarly give the gains for the second and the third one as shown in the model window.
Output from Scope3…. Scope3 shows the displacement response for the second order system.
References…. MATLAB website (http://www.mathworks.com) has a comprehensive list of examples and references to SIMULINK. There are several books which cater to this area. One of the good references is listed below: Mastering Simulink 4James B. Dabney & Thomas L. Harman ISBN 0-13-017085-2
Looking back…. This completes the MATLAB Tutorial. Sessions 1 to 7 covered almost all areas of applications of MATLAB. Specialized areas of MATLAB are using the toolboxes. These are a collection of m-files that are specific to the area of application.