HossamTalaat - MATLAB Course - KSU HossamTalaat - MATLAB Course - KSU - 21/1/24 - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU IEEE Student Branch - College of Engineering - KSU Getting started with Getting started with Simulink Simulink By By Prof. Hossam Talaat Prof. Hossam Talaat
29
Embed
HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
What is Simulink?What is Simulink? It becomes a standard in many It becomes a standard in many
universities.universities. Simulink is an interactive environment Simulink is an interactive environment
for modeling, simulating and analyzing for modeling, simulating and analyzing dynamic systems.dynamic systems.
It uses graphical user interface of block It uses graphical user interface of block diagram representation instead of diagram representation instead of differential and difference equations.differential and difference equations.
A Simulink model consists of A Simulink model consists of blocks blocks (representing elementary dynamic systems) (representing elementary dynamic systems) interconnected by interconnected by lines lines (time-domain (time-domain signals).signals).
How to Simulate a Dynamic How to Simulate a Dynamic SystemSystem
Phase I: Create a model of the system to Phase I: Create a model of the system to be simulated using Simulink’s model be simulated using Simulink’s model editor, blocks library and click and drag editor, blocks library and click and drag mouse operations. mouse operations.
Phase II: Use Simulink’s ODE solvers to Phase II: Use Simulink’s ODE solvers to simulate the behavior of the system for a simulate the behavior of the system for a specified time span.specified time span.
Phase I: Creating a modelPhase I: Creating a model To open Simulink click on the Simulink icon on the To open Simulink click on the Simulink icon on the
MATLAB toolbar.MATLAB toolbar. To open a new model click on the corresponding To open a new model click on the corresponding
icon on the Simulink toolbar.icon on the Simulink toolbar. To introduce blocks in your model, choose the To introduce blocks in your model, choose the
block from the library, click on it and drag it in block from the library, click on it and drag it in your model.your model.
Interconnect the output of a block to the input of Interconnect the output of a block to the input of the required block by a line using mouse.the required block by a line using mouse.
Double-click each block to set its parameters.Double-click each block to set its parameters.
Model 0: How to Build a New ModelModel 0: How to Build a New Model
ProcedureProcedure 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?
Simulink provides a library browser that allows Simulink provides a library browser that allows you to select blocks from libraries of standard you to select blocks from libraries of standard blocks:blocks:
SourcesSources - blocks that generate signals - blocks that generate signals SinksSinks - display or output blocks. - display or output blocks. DiscreteDiscrete - discrete-time components blocks. - discrete-time components blocks. ContinuousContinuous - linear continuous-time blocks. - linear continuous-time blocks. MathMath - general mathematical functions blocks. - general mathematical functions blocks.
Functions & TablesFunctions & Tables - general functions and look-up - general functions and look-up table operations.table operations.
NonlinearNonlinear - blocks that describe nonlinear functions. - blocks that describe nonlinear functions. Signal & SystemsSignal & Systems - blocks that allow multiplexing, - blocks that allow multiplexing,
demultiplexing, create subsystems and perform demultiplexing, create subsystems and perform similar functions.similar functions.
Blocksets and ToolboxesBlocksets and Toolboxes - the Extras block library - the Extras block library of specialized blocks.of specialized blocks.
DemosDemos - useful MATLAB and Simulink demos. - useful MATLAB and Simulink demos.
Model 1: Sources and SinksModel 1: Sources and Sinks
ProcedureProcedure Run the model using different Run the model using different
waveforms.waveforms. Open/close the manual switch to Open/close the manual switch to
check the effect of noise.check the effect of noise. Check the workspace for y1.Check the workspace for y1. Check the file model1.mat under Check the file model1.mat under
Phase II: Solving the Dynamic Model Phase II: Solving the Dynamic Model (Simulation)(Simulation)
The Simulink block diagram model depicts a The Simulink block diagram model depicts a time-dependent mathematical relationship time-dependent mathematical relationship between Inputs, States, and Outputs in the form between Inputs, States, and Outputs in the form of a set of Ordinary Differential Equations of a set of Ordinary Differential Equations “ODE”.“ODE”.
In this phase Simulink successively solves the In this phase Simulink successively solves the ODE to compute the states and the outputs of ODE to compute the states and the outputs of the system at intervals from the simulation the system at intervals from the simulation start start timetime to the to the stop timestop time..
To set the parameters of the simulation select To set the parameters of the simulation select simulationsimulation from Simulink’s toolbar, then select from Simulink’s toolbar, then select simulation parameterssimulation parameters. .
Ir. Mihaela BUTUNOIU Ghent University MATLAB and Simulink Tutorial 2002
In the solver tab you have to set: In the solver tab you have to set: Start TimeStart Time (default is zero) and (default is zero) and Stop timeStop time.. Solver optionsSolver options : fixed/variable step, discrete/continuous. : fixed/variable step, discrete/continuous. Step size: Step size: it isit is the length of time between successive the length of time between successive
calculation. If you select calculation. If you select variable stepvariable step this may produce this may produce more accurate results without sacrificing execution more accurate results without sacrificing execution speed. You have to select:speed. You have to select: Max, min and initial step size (the default is auto).Max, min and initial step size (the default is auto). Relative and absolute tolerance to control the accuracy of the Relative and absolute tolerance to control the accuracy of the
solution (the default is auto).solution (the default is auto). Output options: Output options: to control the simulation output. If you to control the simulation output. If you
need more points use need more points use Refine output Refine output withwith refine factor>1. refine factor>1.
Model 3: Continuous BlocksModel 3: Continuous Blocks
ProcedureProcedure 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 Verify the output of each block in the
Model 4: Transient response of a Model 4: Transient response of a second order systemsecond order system
ProcedureProcedure Set the damping coefficient “zeta” by Set the damping coefficient “zeta” by
double clicking the transfer function, double clicking the transfer function, let zeta=0.2, 0.4, 0.6, 1,5.let zeta=0.2, 0.4, 0.6, 1,5.
For each value specify if the For each value specify if the response is underdamped, critical response is underdamped, critical damped, or overdamped.damped, or overdamped.
Construct a Simulink Model that Construct a Simulink Model that describes the dynamic performance describes the dynamic performance of a L.P.F.of a L.P.F.
Use an original low frequency signal Use an original low frequency signal x with a noise high frequency signal x with a noise high frequency signal y:y:
Insert a “scope” from Sinks. Insert a “scope” from Sinks. Double click it then select Double click it then select
parameters icon to set “no. of parameters icon to set “no. of axes” = 2.axes” = 2.
Use mouse to connect each Use mouse to connect each of the sine wave outputs to of the sine wave outputs to one of the scope inputs.one of the scope inputs.
Use the icon on toolbar to start simulation. Use the icon on toolbar to start simulation. Double-click the scope to check the Double-click the scope to check the
signals.signals. If the obtained plots are not as expected If the obtained plots are not as expected
select simulation parameters and adjust select simulation parameters and adjust the stop time (say 0.05), the max step (say the stop time (say 0.05), the max step (say 0.00001), the min and initial steps (say 0.00001), the min and initial steps (say 0.000001) and relative accurracy (say 1e-0.000001) and relative accurracy (say 1e-6).6).
Insert a transfer function Insert a transfer function ”T.F.” from continuous. ”T.F.” from continuous.
Set its parameters such Set its parameters such that the numerator =1 that the numerator =1 and denominator = and denominator = 0.00001 s +1.0.00001 s +1.
Name it L.P.FName it L.P.F Connect the output of Connect the output of
sum to the input of the sum to the input of the T.F.T.F.
Insert a scope Insert a scope with 2 inputs with 2 inputs to compare to compare the filtered the filtered and unfiltered and unfiltered signals . signals .