0% found this document useful (0 votes)
40 views

23MTRN08I Lec 8 - Modelling Using Simulink PDF

The document discusses modeling and simulation techniques in Simulink including designing model architecture, managing design data, designing model behavior, configuring signals and parameters, and configuring inputs and visualizations. Specific techniques covered include component-based modeling, subsystems, custom libraries, data stores, data storage using dictionaries, conditional logic, signals, sample times, and providing input data.

Uploaded by

Aya Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

23MTRN08I Lec 8 - Modelling Using Simulink PDF

The document discusses modeling and simulation techniques in Simulink including designing model architecture, managing design data, designing model behavior, configuring signals and parameters, and configuring inputs and visualizations. Specific techniques covered include component-based modeling, subsystems, custom libraries, data stores, data storage using dictionaries, conditional logic, signals, sample times, and providing input data.

Uploaded by

Aya Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

[23MTRN08I]

Modelling & Simulation

Modelling using Simulink

Data in this lecture is obtained from MATLAB Documentation


Contents
➢Design Model Architecture
➢Manage Design Data
➢Design Model Behavior
➢Configure Signals, States, and Parameters
➢Configure Inputs and Visualizations

Modelling and Simulation 2


DESIGN MODEL ARCHITECTURE
Create independent components to share
between models or teams, reduce visual
complexity with model hierarchy

Modelling and Simulation 3


Design Model Architecture
• Component-Based Modeling
– Learn when to use different types of model components
• Subsystems
– Group blocks into functional subsystems, create model
hierarchy
• Custom Libraries
– Reusable libraries of blocks and subsystems
• Model References
– Reuse models as blocks in other models
• Data Stores
– Define global values for multiple signals at different
levels of a model

Modelling and Simulation 4


Component-Based Modeling
• Enables efficient and robust system development.
• Facilitates collaboration.
• Improves verification workflows.
• Large-scale systems typically use a combination of
Simulink® model components.

Modelling and Simulation 5


Subsystems
• As a model increases in size and complexity, you can
simplify it by grouping blocks into subsystems. A
subsystem is a set of blocks that you group into a single
Subsystem block.

Using subsystems:
• Establishes a hierarchical block diagram, where a
Subsystem block is on one layer and the blocks that make
up the subsystem are on another.
• Keeps functionally related blocks together.
• Helps reduce the number of blocks displayed in your
model window.
• Establishes an interface with inputs and outputs..
Modelling and Simulation 6
Subsystems
• When you make a copy of a subsystem, that copy is
independent of the source subsystem.
• To reuse the contents of a subsystem across a model or
across models, consider referenced subsystems,
referenced models, or subsystems linked to a block in a
custom library.
• A subsystem can be virtual or nonvirtual. A virtual
subsystem provides graphical hierarchy in a model. A
nonvirtual subsystem provides graphical hierarchy and
executes as a unit within a model.

Modelling and Simulation 7


Custom Libraries
• A block library is a collection of blocks that you can use in
a Simulink model. You can create instances of blocks from
built-in Simulink libraries, and you can make custom
libraries for instances of blocks that you create.
• You can access the built-in libraries from the Simulink
Library Browser. However, you cannot modify these
libraries.
• To enable others to create custom blocks, you can create
your own block library and add it to the Library Browser.
• Creating your own libraries is a useful componentization
technique for:
– Providing frequently used, and seldom changed, modeling
utilities
– Reusing components in a model or in multiple models

Modelling and Simulation 8


Data Stores
• Define global values for multiple signals at
different levels of a model
• A large model can require individual signals to
route to many separate blocks in different
locations in the diagram. You can configure a
data store to allow access to signal data from
anywhere in a model, similar to a global variable
in a computer program.
• However, as with global variables, data stores
can reduce model transparency and make model
verification more difficult.
Modelling and Simulation 9
MANAGE DESIGN DATA
Assign variable values using model workspace,
symbols, data objects, and data classes

Modelling and Simulation 10


Data Storage
Model Workspace:
• Place variables and objects that a model uses in a
workspace that only the model can access.

Objects and Variables


• Model data are objects and variables that you create in
workspaces such as the base workspace or a data
dictionary. Choose a technique to permanently store
that data.

Modelling and Simulation 11


Data Storage
Dictionary:
• A data dictionary is a persistent repository of data that
are relevant to your model.
• The dictionary stores design data, which define
parameters and signals, and include data that define
the behavior of the model.
• Use a data dictionary to store external data for a model.
• The dictionary does not store simulation data
• Store Data in Dictionary Programmatically

Modelling and Simulation 12


DESIGN MODEL BEHAVIOR
Modeling techniques for specific functionality
and applications

Modelling and Simulation 13


Design Model Behavior
• Conditionally / Logical conditionally Executed
Subsystems and Models: Control when a subsystem or
model is executed

Modelling and Simulation 14


Design Model Behavior
• Simulink Functions: Create functions accessible in
Simulink models
• Event Functions: Customize default model Initialize and
terminate methods
• Messages: Establish message-based communication
between Simulink model components
• Schedule Model Components: Create export-function,
rate-based models, and partitions to schedule model
for code generation

Modelling and Simulation 15


Design Model Behavior
• Multicore Processor Targets: Model concurrent
execution for systems designed for deployment on a
multicore or FPGA system

Modelling and Simulation 16


CONFIGURE SIGNALS, STATES &
PARAMETERS
You can configure the behavior of a model by
adjusting settings for block parameters, signals,
states, and the entire model.

Modelling and Simulation 17


Configure Signals, States &
Parameters
You can use these settings to:
• Control mathematical model behavior.
• Simulate system behavior on computer
hardware.
• Control the rate of block execution and the
numerical accuracy of simulation.
• Simulate different initial conditions.

Modelling and Simulation 18


Blocks parameters & properties
Adjust the parameters and properties of blocks to:
• Experiment with parameter values as you design a
model.
• Match simulation results with measured data by
estimating parameter values.
• Design an efficient control algorithm by optimizing
parameter values.
• Document blocks and customize appearance.

Modelling and Simulation 19


Signals
• Signals transmit data between two blocks in a
simulation.
• The data could be the calculated output of a block, or
simply a message.
• The value of signals are calculated at all points during
the simulation time.
• You can display the signal data and properties during
and after simulation, see the real-time values on a block
diagram, or you can log the values as variables in the
workspace.
• Also, you can export the signals to a file or to
a workspace to investigate further.
Modelling and Simulation 20
Sample Time
• Control block execution rates, assign discrete, continuous,
or hybrid sample time
• For many engineering applications, you need to control
the rate of block execution.
• Simulink provides this capability by allowing you to
specify an explicit SampleTime parameter in the block
dialog or at the command line.
• Blocks that do not have a SampleTime parameter have an
implicit sample time. You cannot specify implicit sample
times. Simulink determines them based upon the context
of the block in the system. The Integrator block is an
example of a block that has an implicit sample time.
Simulink automatically sets its sample time to 0.
Modelling and Simulation 21
CONFIGURE INPUTS AND
VISUALIZATIONS
Provide signal data and decide how to visualize its simulation

Before simulating a model, define the external interfaces for


the model, including input and output signals. Input signals
load data into the model for simulation, while output signals
allow you to record simulation results.

Modelling and Simulation 22


Configure Inputs & Visualizations
• Provide signal data and decide how to visualize its
simulation
• Before simulating a model, define the external
interfaces for the model, including input and output
signals. Input signals load data into the model for
simulation, while output signals allow you to record
simulation results.
• Provide Signal Data for Simulation: Identify model signal
data requirements and load input signal data.
• Decide How to Visualize Simulation Data: Choose the
right visualization technique for each modeling and
simulation task.
Modelling and Simulation 23
Signal Data for Simulation
• A Simulink® model performs algorithms on input signal
data and produces output signals. The model defines
what input data to use at the start of simulation and
what output to capture at the end of simulation. As you
create and simulate your model, you:

➢Identify Model Signal Data Requirements

➢Load Input Signal Data

➢Log Output Signal Data


Modelling and Simulation 24
Identify Model Signal Data
Requirements
• To use system-generated signal data, use source blocks
such as a Sine Wave block. Source blocks do not require
the use of a variable or external data source. If you
cannot configure source blocks to meet your modeling
requirements, then supply the signal data.
• As you determine your signal data requirements,
identify the:
• Blocks (including subsystems and Model blocks) that
you need to provide data for — Design interfaces for
blocks and for model components, including data types
of signals.

Modelling and Simulation 25


Identify Model Signal Data
Requirements
• Range characteristics of signals, such as sample time,
dimensions, and data type.
• Storage location for data for each input signal —
Determine where to store signal data: in workspace
variables, a MAT-file, or an external data file such as an
Microsoft® Excel® spreadsheet.
• Create a list of equation variables and constant
coefficients, and then determine the coefficient values
from published sources or by performing experiments
on the system.

Modelling and Simulation 26


Load Input Signal Data
You can use various sources for input signal data for simulating a
model:

➢ Use existing data from a file, such as a spreadsheet.

➢ Write a MATLAB script to define variables for the signal data. For
example, you can create Dataset format data that you can use
with all the signal loading techniques.

➢ Use data logged from a previous simulation.

Modelling and Simulation 27


Load Input Signal Data
You can use several different approaches to load data into a model,
including:

❖ Source blocks — Add a source block, such Sine Wave block, to


generate signals to input to another block.

❖ From File block — Read data from a MAT-file, outputting the data
as a signal.

❖ From Spreadsheet block — Read data from Microsoft Excel


spreadsheets or CSV spreadsheets, outputting the data as one or
more signals.

Modelling and Simulation 28


Log Output Signal Data
• You can save signal values to the MATLAB
workspace or to a MAT-file during simulation for
later retrieval and postprocessing.
• Saving simulation data is also known as logging
or exporting simulation data.
• Saving simulation data in Dataset format
simplifies postprocessing by providing a
common format for the results of various
logging techniques. Simulink provides tools for
converting data logged in other formats to
Dataset format.
Modelling and Simulation 29
Visualize Simulation Data
• Visualizing simulation data throughout the modeling
process helps you understand and tune model
behavior.
• Simulink® offers several complementary visualization
tools you can use throughout the modeling process.
• Some visualization tools also offer the ability to save
simulation data.
• Visualization tools:
➢Simulation Data Inspector .
➢Scope block, Floating Scope block, and Scope Viewer.
➢Dashboard blocks.
➢Port value displays.
➢Custom MATLAB® visualization.
Modelling and Simulation 30
Simulation Data Inspector
• Viewing signals during simulation
• Logging, importing, and exporting data
• Configurable subplot layouts and visualization
settings
• Viewing data using multiple visualization options,
including maps and XY plots
• Post-processing and data analysis using
comparisons with tolerance values
• Saving plots and data to share or archive results

Modelling and Simulation 31


Simulation Data Inspector

Modelling and Simulation 32


Scope Blocks and Viewer
• Viewing signals during simulation, including
rapid accelerator simulations.
• Simple connection and accessibility for
lightweight debugging.
• Signal visualization without logging.
• Optional signal logging.
• Starting simulations from the visualization
interface using playback controls.
• Oscilloscope measurements, including
cursors and triggers.
Modelling and Simulation 33
Scope Viewer

Modelling and Simulation 34


Dashboard Blocks
• The Dashboard library includes control blocks you can
use to tune variables and parameters in your model and
visualization blocks you can use to view signal data. Use
Dashboard blocks to view instantaneous signal data and
build an interactive interface for your model.

Modelling and Simulation 35


Dashboard Blocks

Modelling and Simulation 36


Port Value Displays
• You can enable port value displays to view a signal value
at a given time point. Port value displays can
supplement existing visualizations while prototyping
and debugging models.
• For example, you can view signal values on port value
displays as you step through a simulation while
visualizing the temporal behavior using a Scope block.
• You can also use port value displays on their own to
support debugging without adding any blocks to your
model or logging data.

Modelling and Simulation 37


Port Value Displays
• To display a signal value, right-click the signal and
select Show Value Label of Selected Port
• When inspecting signal data by displaying the
value on the port, consider using simulation pacing
or stepping through the simulation.

Modelling and Simulation 38


Custom MATLAB Visualizations
• When you log simulation data to the workspace or a
file, you can write MATLAB code and scripts to create
custom visualizations.
• You can log signals, outputs, and states in a model, and
you can also enable data logging for signals connected
to Scope Viewers, Floating Scope blocks
and Scope blocks

Modelling and Simulation 39


References
• For more information please refer to MATLAB
Documentation from the installed version or online
documentation through:
https://www.mathworks.com/help/?s_tid=gn_supp

Modelling and Simulation 40

You might also like