Presentation is loading. Please wait.

Presentation is loading. Please wait.

HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat.

Similar presentations


Presentation on theme: "HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat."— Presentation transcript:

1 HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat

2 HossamTalaat - MATLAB Course - KSU - 21/1/24 2 What is Simulink? It becomes a standard in many universities. It becomes a standard in many universities. Simulink is an interactive environment for modeling, simulating and analyzing dynamic systems. Simulink is an interactive environment for modeling, simulating and analyzing dynamic systems. It uses graphical user interface of block diagram representation instead of differential and difference equations. It uses graphical user interface of block diagram representation instead of differential and difference equations. A Simulink model consists of blocks (representing elementary dynamic systems) interconnected by lines (time-domain signals). A Simulink model consists of blocks (representing elementary dynamic systems) interconnected by lines (time-domain signals).

3 HossamTalaat - MATLAB Course - KSU - 21/1/24 3 Capabilities of Simulink It Simulates Linear and nonlinear systems. It Simulates Linear and nonlinear systems. It Simulates continuous, discrete and hybrid systems. It Simulates continuous, discrete and hybrid systems. It has a powerful “What if” exploration capability. It has a powerful “What if” exploration capability.

4 HossamTalaat - MATLAB Course - KSU - 21/1/24 4 How to Simulate a Dynamic System Phase I: Create a model of the system to be simulated using Simulink’s model editor, blocks library and click and drag mouse operations. Phase I: Create a model of the system to be simulated using Simulink’s model editor, blocks library and click and drag mouse operations. Phase II: Use Simulink’s ODE solvers to simulate the behavior of the system for a specified time span. Phase II: Use Simulink’s ODE solvers to simulate the behavior of the system for a specified time span.

5 HossamTalaat - MATLAB Course - KSU - 21/1/24 5 Phase I: Creating a model To open Simulink click on the Simulink icon on the MATLAB toolbar. To open Simulink click on the Simulink icon on the MATLAB toolbar. To open a new model click on the corresponding icon on the Simulink toolbar. To open a new model click on the corresponding icon on the Simulink toolbar. To introduce blocks in your model, choose the block from the library, click on it and drag it in your model. To introduce blocks in your model, choose the block from the library, click on it and drag it in your model. Interconnect the output of a block to the input of the required block by a line using mouse. Interconnect the output of a block to the input of the required block by a line using mouse. Double-click each block to set its parameters. Double-click each block to set its parameters.

6 HossamTalaat - MATLAB Course - KSU - 21/1/24 6 Model 0: How to Build a New Model Procedure How to insert a Block? How to insert a Block? How to set the block parameters? How to set the block parameters? How to interconnect between blocks? How to interconnect between blocks? How to add text? How to add text?

7 HossamTalaat - MATLAB Course - KSU - 21/1/24 7

8 8 Simulink block libraries Simulink provides a library browser that allows you to select blocks from libraries of standard blocks: Sources - blocks that generate signals Sources - blocks that generate signals Sinks - display or output blocks. Sinks - display or output blocks. Discrete - discrete-time components blocks. Discrete - discrete-time components blocks. Continuous - linear continuous-time blocks. Continuous - linear continuous-time blocks. Math - general mathematical functions blocks. Math - general mathematical functions blocks.

9 HossamTalaat - MATLAB Course - KSU - 21/1/24 9 Simulink block libraries (cont.) Functions & Tables - general functions and look- up table operations. Functions & Tables - general functions and look- up table operations. Nonlinear - blocks that describe nonlinear functions. Nonlinear - blocks that describe nonlinear functions. Signal & Systems - blocks that allow multiplexing, demultiplexing, create subsystems and perform similar functions. Signal & Systems - blocks that allow multiplexing, demultiplexing, create subsystems and perform similar functions. Blocksets and Toolboxes - the Extras block library of specialized blocks. Blocksets and Toolboxes - the Extras block library of specialized blocks. Demos - useful MATLAB and Simulink demos. Demos - useful MATLAB and Simulink demos.

10 HossamTalaat - MATLAB Course - KSU - 21/1/24 10 Model 1: Sources and Sinks Procedure Run the model using different waveforms. Run the model using different waveforms. Run the model using different waveforms. Run the model using different waveforms. Open/close the manual switch to check the effect of noise. Open/close the manual switch to check the effect of noise. Open/close the manual switch to check the effect of noise. Open/close the manual switch to check the effect of noise. Check the workspace for y1. Check the workspace for y1. Check the workspace for y1. Check the workspace for y1. Check the file model1.mat under matlab/simulink folder. Check the file model1.mat under matlab/simulink folder. Check the file model1.mat under matlab/simulink folder. Check the file model1.mat under matlab/simulink folder.

11 HossamTalaat - MATLAB Course - KSU - 21/1/24 11 New Blocks in Model 1 BlockGroupDescription Signal generator Uniform random number To workspace Scope To file Sum Manual switch SourcesSourcesSinkSinkSinkMathNonlinear Generate various waveforms Generate uniformly distributed random numbers Write data to a variable in the workspace Display signals generated during a simulation Write data to a file Generate the sum of the inputs Switch between two inputs

12 HossamTalaat - MATLAB Course - KSU - 21/1/24 12 Model 2: Scopes and Graphs Procedure Run the model using different values of w (freq. of y in rad/s), put w= 50, 100, 150, and 250. Run the model using different values of w (freq. of y in rad/s), put w= 50, 100, 150, and 250. For each value sketch the graphs obtained in the 4 fixed scopes. For each value sketch the graphs obtained in the 4 fixed scopes. How to use a floating scope? How to use a floating scope? How to control the graph settings? How to control the graph settings?

13 HossamTalaat - MATLAB Course - KSU - 21/1/24 13 New Blocks in Model 2 BlockGroupDescription Sine wave XY Graph MuxSourcesSinkSignals Generate a sine wave Display an x-y plot of signals using a MATLAB figure window Combine several input lines into a vector line.

14 HossamTalaat - MATLAB Course - KSU - 21/1/24 14 Phase II: Solving the Dynamic Model (Simulation)  The Simulink block diagram model depicts a time-dependent mathematical relationship between Inputs, States, and Outputs in the form of a set of Ordinary Differential Equations “ODE”.  In this phase Simulink successively solves the ODE to compute the states and the outputs of the system at intervals from the simulation start time to the stop time.  To set the parameters of the simulation select simulation from Simulink’s toolbar, then select simulation parameters. Ir. Mihaela BUTUNOIU Ghent University MATLAB and Simulink Tutorial 2002

15 HossamTalaat - MATLAB Course - KSU - 21/1/24 15 Solver Pane In the solver tab you have to set:  Start Time (default is zero) and Stop time.  Solver options : fixed/variable step, discrete/continuous.  Step size: it is the length of time between successive calculation. If you select variable step this may produce more accurate results without sacrificing execution speed. You have to select:  Max, min and initial step size (the default is auto).  Relative and absolute tolerance to control the accuracy of the solution (the default is auto).  Output options: to control the simulation output. If you need more points use Refine output with refine factor>1.

16 HossamTalaat - MATLAB Course - KSU - 21/1/24 16 Model 3: Continuous Blocks Procedure How to set the transfer function? How to set the transfer function? Run the model. Run the model. Verify the output of each block in the combined graph. Verify the output of each block in the combined graph.

17 HossamTalaat - MATLAB Course - KSU - 21/1/24 17 New Blocks in Model 3 BlockGroupDescription RampDerivativeIntegrator Transfer Fcn Transport delay SourcesContinuousContinuousContinuousContinuous Generate a ramp signal Output the time derivative of the input. Integrate the input. Implement a linear transfer function. Delay the input by a given amount of time.

18 HossamTalaat - MATLAB Course - KSU - 21/1/24 18 Model 4: Transient response of a second order system Procedure Set the damping coefficient “zeta” by double clicking the transfer function, let zeta=0.2, 0.4, 0.6, 1,5. Set the damping coefficient “zeta” by double clicking the transfer function, let zeta=0.2, 0.4, 0.6, 1,5. For each value specify if the response is underdamped, critical damped, or overdamped. For each value specify if the response is underdamped, critical damped, or overdamped.

19 HossamTalaat - MATLAB Course - KSU - 21/1/24 19 Step-by-Step Model Construction Design of a First order L.P.F. Theoretical Background

20 HossamTalaat - MATLAB Course - KSU - 21/1/24 20 Required Construct a Simulink Model that describes the dynamic performance of a L.P.F. Construct a Simulink Model that describes the dynamic performance of a L.P.F. Use an original low frequency signal x with a noise high frequency signal y: Use an original low frequency signal x with a noise high frequency signal y: x=100 sin(120 t) y= 10 sin(4000 t).

21 HossamTalaat - MATLAB Course - KSU - 21/1/24 21 Step I Insert a “sine wave” input from Sources. Insert a “sine wave” input from Sources. Copy it to have another one. Copy it to have another one. Double click each one to adjust its parameters (Amplitude and Freq.). Double click each one to adjust its parameters (Amplitude and Freq.). Edit the Block name. Edit the Block name. Right-click to adjust foreground color. Right-click to adjust foreground color.

22 HossamTalaat - MATLAB Course - KSU - 21/1/24 22 Step II Insert a “scope” from Sinks. Insert a “scope” from Sinks. Double click it then select parameters icon to set “no. of axes” = 2. Double click it then select parameters icon to set “no. of axes” = 2. Use mouse to connect each of the sine wave outputs to one of the scope inputs. Use mouse to connect each of the sine wave outputs to one of the scope inputs. Name the two signals. Name the two signals.

23 HossamTalaat - MATLAB Course - KSU - 21/1/24 23 Step III Use the icon on toolbar to start simulation. Use the icon on toolbar to start simulation. Double-click the scope to check the signals. Double-click the scope to check the signals. If the obtained plots are not as expected select simulation parameters and adjust the stop time (say 0.05), the max step (say 0.00001), the min and initial steps (say 0.000001) and relative accurracy (say 1e- 6). If the obtained plots are not as expected select simulation parameters and adjust the stop time (say 0.05), the max step (say 0.00001), the min and initial steps (say 0.000001) and relative accurracy (say 1e- 6).

24 HossamTalaat - MATLAB Course - KSU - 21/1/24 24 Step IV Insert a “sum” from Math. Insert a “sum” from Math. Connect the output of each sine to on of the sum inputs. Connect the output of each sine to on of the sum inputs. Connect the output of sum to a scope. Connect the output of sum to a scope. Start simulation and verify if the plot is as expected.. Start simulation and verify if the plot is as expected..

25 HossamTalaat - MATLAB Course - KSU - 21/1/24 25 Step V Insert a transfer function ”T.F.” from continuous. Insert a transfer function ”T.F.” from continuous. Set its parameters such that the numerator =1 and denominator = 0.00001 s +1. Set its parameters such that the numerator =1 and denominator = 0.00001 s +1. Name it L.P.F Name it L.P.F Connect the output of sum to the input of the T.F. Connect the output of sum to the input of the T.F.

26 HossamTalaat - MATLAB Course - KSU - 21/1/24 26 Step VI Insert a scope and name it “filtered signal”. Insert a scope and name it “filtered signal”. Connect the output of T.F. to the scope input. Connect the output of T.F. to the scope input. Start simulation then verify the obtained plot. Start simulation then verify the obtained plot. Change the time constant to 0.0001,.001 and.01 and comment. Change the time constant to 0.0001,.001 and.01 and comment.

27 HossamTalaat - MATLAB Course - KSU - 21/1/24 27 Step VII Insert a scope and name it “filtered signal”. Insert a scope and name it “filtered signal”. Connect the output of T.F. to the scope input. Connect the output of T.F. to the scope input. Start simulation then verify the obtained plot. Start simulation then verify the obtained plot. Change the time constant to 0.0001,.001 and.01 and comment. Change the time constant to 0.0001,.001 and.01 and comment.

28 HossamTalaat - MATLAB Course - KSU - 21/1/24 28 Step VIII Insert a scope with 2 inputs to compare the filtered and unfiltered signals. Insert a scope with 2 inputs to compare the filtered and unfiltered signals.

29 HossamTalaat - MATLAB Course - KSU - 21/1/24 29 End of tutorial


Download ppt "HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat."

Similar presentations


Ads by Google