1© 2017 The MathWorks, Inc.
Physical System Modelling with MATLAB/Simulink
Vasco Lenzi
Application Engineer
MathWorks Bern
2
Setting the Expectations
▪ I will be solving an engineering problem using Simulink&Simscape.
▪ I’ll try to show you how theory and industry workflows mix
▪ Please fill out the lecture feedback survey! Three questions, one minute,
no email asked ;)
3
Key takeaways
▪ Physical System Modelling is the process of understanding, formalizing and
deploying a real system inside a simulation framework
▪ Working with virtual models allows you to:
– Explore design possibilities
– Optimize system performance
– Simulate critical situation and verify control software
– Enable model-based control algorithm
▪ Use the right tool for the right task
4
5
6
Common Concerns when Innovating
Do we know the “thing” works when we turn it on?
Have we validated malfunctions and safety?
How big are the risks of returns?
Projects concerning complex and big
Outcome uncertain, issues found at the end
Risks from delays and quality issues
7
Digital Transformation of the Industry: is everywhere
– Higher flexibility given by small batches production
with the economies of scale
– Higher speed from prototyping to mass production
using innovative technologies
– Increased productivity thanks to lower set-up time
and reduced downtimes
– Improved quality and scrap reduction thanks to
real time production monitoring through sensors
– Higher competitiveness of products thanks to
additional functionalities enabled by Internet Of
Things
Buzzwords:
Industry 4.0
IIoT (Industrial Internet of Things)
8
Key Enabler: Mechatronics
Combination of mechanical-, computer-,
telecommunications-, systems- and control
engineering with electronics
9
Key Enabler: Digital Twin
▪ A digital replica of physical assets,
that can be used for various purposes.
▪ Integrate machine learning and analytics
to create living digital simulation models
that continuously learn and update
themselves
10
Hydro-Québec Models Wind Power Plant
Performance
ChallengePlan the integration of new wind farms into the power system,
predict power output, and ensure safe, reliable operation
SolutionUse MathWorks products to simulate individual wind
turbines and wind farms and to generate C code for
multiprocessor simulation of entire power systems
Results▪ Simulation speed increased to real time
▪ Equipment needs accurately predicted
▪ Dynamic simulations enabled
“Accurate modeling is essential not only for
planning investments but also to detect
situations that can cause an outage. With
MathWorks tools, we can simulate power
electronics, mechanics, and control systems
in one environment, and our models
respond like the turbines we have in the
field.”
Richard Gagnon
Hydro-QuébecLink to user story
Turbines on a wind farm.
11
Source:wikipedia.org
12
Lockheed Martin Simulates Orion Spacecraft Missions
Using a Multidomain Power System Model
ChallengeSimulate the Orion spacecraft’s power system to
validate the design, test fault conditions, and verify
system performance
SolutionUse Simulink and Simscape Power Systems to
model solar arrays, batteries, and the complete
system and to run simulations for a variety of mission
profiles
Results▪ Development time cut by two-thirds
▪ Library of reusable components established
▪ Low-level coding minimized
“With Simscape Power Systems we created an integrated power
system model that connects electrical and thermal domains, so
we get the whole picture during our mission-level simulations. If
we need to model the motors that turn the solar arrays, we have
the capability to integrate those mechanical components, too.”
- Hector Hernandez, Lockheed Martin
Link to user story
NASA’s Orion spacecraft.
© Reishauer AG
Oliver Stamm
Folie 13Workflow: The elements
Examples of configured CAD Models
© Reishauer AG
Oliver Stamm
Folie 14Solution: Virtual machine of different Systems
Current systemVirtual prototype: better trajectories, faster,
less moving mass, cheaper
© Reishauer AG
Oliver Stamm
Folie 15Technology: Output
Simulation Data Inspector: View of results during one cycle
Belt tensions [N] Axis positions [mm] Deviation stiff vs. Elastic [mm]
16© 2017 The MathWorks, Inc.
Physical Modelling within MATLAB & Simulink
17
▪ Purpose: Explore design or physical parameters
▪ Requirements:
– Physics of system are well-known
– System-level equations can be derived and implemented
Data-DrivenFirst Principles
Programming
Block Diagram
Modeling Language
Symbolic Methods
Modeling Approaches
18
Modeling Approaches
▪ Purpose: Explore design or physical parameters
▪ Requirements:
– Physics of system are well-known
– Component-level models exist or can be created
Data-DrivenFirst Principles
Physical NetworksProgramming
Block Diagram
Modeling Language
Symbolic Methods
19
Modeling Approaches
▪ Purpose: Model an existing design (real or virtual)
▪ Requirements:
– Relevant set of measured data is available
– Design and physical parameters will not be changed
Data-DrivenFirst Principles
Physical NetworksProgramming
Block Diagram
Modeling Language
Symbolic Methods
Neural Networks
System Identification
Statistical Methods
MeasuredModel
20
Demystifying Deep Learning
ETH Zürich, ML Room E12
Wednesday, October 17 – 16:15-18:00
More Information and Free Registration:
https://bit.ly/2PpmZTR
MATLAB Academic Tour
21
Case study – Ball-on-WheelRapid Control Prototyping
22
Simscape Products
▪ MATLAB and Simulink provide
foundation for technical computing
and algorithm development
▪ Simscape platform
– Simulation engine and custom diagnostics
– Foundation libraries in many domains
– Language for defining custom blocks
▪ Simscape add-on libraries
23
Model-Based Design
How big should the motor be?
What’s the impact on the controller?
How does my controller structure
should look like?
Requirements Verification and Validation
What model fidelity is good enough? Am I using
the right techniques?
INTEGRATION
IMPLEMENTATION
DESIGN
TE
ST
AN
D V
ER
IFIC
AT
ION
RESEARCH REQUIREMENTS
24
Model-Based Design
One of the key industrial
verification methodology:
INTEGRATION
IMPLEMENTATION
DESIGN
TE
ST
AN
D V
ER
IFIC
AT
ION
RESEARCH REQUIREMENTS
“in-the-loop” workflows
25
Algorithm Plant Model
Does algorithm
perform well on
actual device
with true
latencies?
Harness
Code
In-the-loop verification methodologiesHardware-in-the-Loop: “HIL”
Code
Real-Time Machine
eg “Speedgoat”Production embedded target
26
ChallengeEvaluate design concepts and parameter values for construction
equipment before building physical prototypes
SolutionUse Simulink, Simscape, and Simulink Real-Time to model
hydraulic, mechanical, and engine systems and perform real-
time, operator-in-the-loop simulations
Results▪ Number of prototypes reduced
▪ Issues in the field resolved faster
▪ Controller tuned in simulation
Volvo Construction Equipment Streamlines Product
Development with a Real-Time, Human-in-the-Loop
Simulator
Volvo Construction Equipment’s real-time, human-in-
the-loop simulator.
Link to user story
“It was technically impossible for us to
build a full-scale hydraulic system model
to run in real time without Simulink,
Simscape, and Simulink Real-Time. Our
simulator enables us to test new
concepts for construction equipment,
tune parameters, reduce lead times, and
minimize issues in the field.”
Jae Yong Lee
Volvo Construction Equipment
27
Hardware Support for Project-Based Learning
▪ Supported target hardware
– Arduino® Uno, Mega 2560,
– LEGO® MINDSTORMS®
– Raspberry Pi Model B, B+, 2, and 3
– BeagleBone Black
– Samsung Galaxy Android Devices
– Apple iPhone and iPad
– Microsoft Kinect
– …
Hardware for Project Based Learning
Hardware Support
28
Free MathWorks Online training @ ETH Zürich
Link
29
Writing algorithm for embedded targets
Graphical programming
Coding languages
Sig
nal
Pro
cessin
g
Co
ntr
ol
Sta
te M
ach
ine, L
og
ic
Industry Best Practices Modeling a plant
First principles
Data driven
Transfer Functions
Simulink
Simscape Language
Symbolic Math
Simscape Multibody (CAD models)
Simscape
System IdentificationNeural Network
StateflowSimulink
C/C++-code in Simulink
MATLAB
30
Key takeaways
▪ Physical System Modelling is the process of understanding, formalizing and
deploying a real system inside a simulation framework
▪ Working with virtual models allows you to:
– Explore design possibilities
– Optimize system performance
– Simulate critical situation and verify control software
– Enable model-based control algorithm
▪ Use the right tool for the right task
31© 2017 The MathWorks, Inc.
Appendix: Useful Links and Resources
MathWorks @ ETHZ
32
Internet of Things / Cloud
▪ MATLAB Online & Drive
▪ Thingspeak
33
ODEs vs DAEs and Algebraic Loops
▪ Simulink is great for ODEs…..
▪ ….but most physical systems have algebraic constraints
▪ And in Simulink models, algebraic constraints cause algebraic loops
▪ The system become a DAE (Differential Algebraic Equation)
▪ Be careful in dealing with algebraic loops!
34
How to handle algebraic loops
https://www.mathworks.com/help/releases/R2017b/simulin
k/ug/algebraic-loops.html#bsxw0e2-1
Guy on Simulink: Why you should never break a continuous algebraic loop with a Memory block
35
Simulink Units
▪ Specify physical units for Simulink signals
and bus elements
▪ Identify unit mismatches at the component interfaces
▪ Automatically convert units
▪ Enforce consistency by restricting the unit system
Specify, visualize, and check consistency
of units on interfaces
Modeling and Simulation