simulink basics for engineering applications
TRANSCRIPT
![Page 1: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/1.jpg)
Simulink Basics for Engineering Applications
Ashok Krishnamurthy and Siddharth Samsi
SC 09 Education Program, Saturday 11/14/09
![Page 2: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/2.jpg)
Basic concepts• Simulink provides a graphical user interface (GUI) for
building models as block diagrams, using click-and-drag mouse operations.
• Why use Simulink?– You can draw the models as you would with pencil and
paper.– Designs are hierarchical, so that levels of details can be
hidden or made explicit.– Simulations are interactive, so you can change parameters
“on the fly”.– Simulink includes a comprehensive block library of sinks,
sources, linear and nonlinear components, and connectors.– C code or executables can be generated from a Simulink
model by using Real-Time Workshop.
![Page 3: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/3.jpg)
• Stateflow• Simulink Performance Tools• Sateflow Coder• Real-time Workshop• Real-time Workshop Embedded Coder• Real-time Workshop ADA Coder• Real-time Windows Target
Associated Products - 1
RTW
Stateflow
![Page 4: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/4.jpg)
• xPC Target• xPC Targetbox• xPC Target Embedded Option• Simulink Report Generator• Requirements Management Interface• Virtual Reality• SimMechanics• Embedded Target MPC555
Associated Products - 2 xPC Targetbox
VirtualReality
![Page 5: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/5.jpg)
• Aerospace• CDMA Reference• Communications• Dials and Gauges• DSP• Fixed Point • Nonlinear Control Design• Power Systems
Simulink Blocksets
DSP
Fixed Point
A blockset is a library of blocks
![Page 6: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/6.jpg)
A Typical Simulink Model
• Includes Sources, Systems and Sinks.
Sources Systems Sinks
Random SignalsFunction Generators
From MATLAB WorkspaceFrom Disk Files
Interconnectionof
Linear and Nonlinearblocks
DisplaysScopes
FFT ScopesTo MATLAB Workspace
To Disk Files
![Page 7: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/7.jpg)
A Typical Simulink ModelA typical Simulink model includes Source, System and Sink.
![Page 8: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/8.jpg)
Block Choices in Simulink
![Page 9: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/9.jpg)
More Block Choices
Math
TableLook-up
SignalRouting
![Page 10: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/10.jpg)
Yet More Simulink Blocks
Ports andSubsystems
Dis-continuous
User-definedfunctions
![Page 11: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/11.jpg)
Now, let’s build a simple model!This model plots the sign of the input signal.
![Page 12: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/12.jpg)
Example -- Step 1Step1: Start Simulink and choose New then Model from the File menu.
![Page 13: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/13.jpg)
Example -- Step 2Step2: Copy the needed blocks by using Drag and Drop.
![Page 14: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/14.jpg)
Example -- Step 3Step3: Complete the connection.
• Move the mouse to the location of output port of the source block.• Hold down the mouse button and move the cursor to the input port of the destination block.• Release the mouse button.
![Page 15: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/15.jpg)
Example -- Step 4Step4: Set the block parameters.
Double click a block to open its block parameters.
![Page 16: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/16.jpg)
Example -- Step 5Step5: Setup the simulation parameters.
Start time
Stop time
Solver type
![Page 17: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/17.jpg)
Example -- Step 6Step6: Start simulation.
![Page 18: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/18.jpg)
Need help?
Double click a block to bring up the left window
Click ‘help’ to bring up the help window
![Page 19: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/19.jpg)
Manipulating blocks
Select a corner and drag to resize a block
Rotating a block
Single click on the block label to change block name
![Page 20: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/20.jpg)
Labels and Annotations
Double click a line to add line label
Double click an empty area to add annotation
![Page 21: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/21.jpg)
Moving a line segmentStep1: Position the pointer on the
segment you want to move.Step2: Press and hold down the left
mouse button.
Step3: Drag the pointer to the desired location. Step4: Release the mouse button.
![Page 22: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/22.jpg)
Dividing a line into segments
Step1: Select the line.
Step2: Position the pointer on the line where you want the vertex.
Step3: While holding down the Shift key, press and hold down the mouse button.
Step4: Drag the pointer to the desired location.
Step5: Release the mouse button and the Shift key.
![Page 23: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/23.jpg)
Dividing a line into segments
Step1: Position the pointer on thevertex, then press and hold down
the mouse button.
Step2: Drag the pointer to the desired location.
Step3: Release the mouse button.
![Page 24: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/24.jpg)
Inserting a block in a line
Step1: Position the pointer over the block and press the left mouse
button.
Step2: Drag the block over the line in which you want to insert the
block.
Step3: Release the mouse button todrop the block on the line.
![Page 25: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/25.jpg)
Example 2: Revisit van der Pol’s equation• Recall that the equation is
d2x/dt2 - µ(1-x2)dx/dt + x = 0• Convert to first order ODEs using
dy1/dt = y2
dy2/dt=µ(1-y12)y2-y1
where y1 = x, and y2 = dx/dt• In Simulink, start with two integrator blocks, one for y1,
another for y2.• Then use Sum, Product and Gain blocks to create dy1/dt
and dy2/dt as inputs to the integrator blocks.
![Page 26: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/26.jpg)
Simulink model of van der Pol
![Page 27: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/27.jpg)
Example 3: Leaky Integrator• An ideal integrator is described by the equation
dy/dt = x(t),where y(t) is the output and x(t) is the input.
• A leaky integrator is described by the equationdy/dt = x(t) – µy(t), µ > 0
• The solution, for x(t) = Ku(t), isy(t) = (K/µ) (1 – e-µt)u(t)
• If we want the steady state output for a constant input to be thesame constant, we can add a gain term of µ at the output.
yo(t) = µy(t)
![Page 28: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/28.jpg)
Simulink model for leaky integrator
![Page 29: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/29.jpg)
Output of leaky integratorInput Output
µ= 0.1K = 1
µ= 0.9K = 4
µ= 0.1K = 4
![Page 30: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/30.jpg)
Subsystems
Subsystems can hide the complexity of the subsystems from the user, which can make your model clearer. There are two ways to create Subsystems.•You can create a Subsystem by adding the Subsystem block from Signals & Systems. Then you can edit the Subsystem by doubling clicking the Subsystem block.•You can create create the subsystem by grouping blocks from an existing system.
![Page 31: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/31.jpg)
Leaky integrator subsystem1. Use the mouse to select the blocks 2. Choose Create Subsystem from the Edit menu
3. This replaces theselected blocks with a Subsystem block.
![Page 32: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/32.jpg)
Using the leaky integrator subsystem
• You can now use the leaky integrator subsystem like any other block
• Double clicking the subsystemopens the subsystem and shows the blocks inside
![Page 33: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/33.jpg)
Example 4: Envelope Detection using Leaky Integrator
Source
Absolutevalue
LeakyIntegrator Mux
![Page 34: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/34.jpg)
Stepped Sine Wave
100 Hz sinewave
BlowupAround 5sec
![Page 35: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/35.jpg)
Results for mu =1 for Leaky Integrator
SteppedSine wave
After absolutevalue
After leakyintegrator
Envelope detectoroutput
![Page 36: Simulink Basics for Engineering Applications](https://reader031.vdocuments.mx/reader031/viewer/2022021306/620742bc49d709492c2f9d0c/html5/thumbnails/36.jpg)
Comparing Results for different mu values
Mu = 1
Mu = 5
Mu = 10