Professional Documents
Culture Documents
Embedded Control Systems Lecture 4 - Spring 2018: Knut Åkesson
Embedded Control Systems Lecture 4 - Spring 2018: Knut Åkesson
Embedded Control Systems Lecture 4 - Spring 2018: Knut Åkesson
Knut Åkesson
Modelling of Physcial Systems
Modelica
+ Open standard
+ Supported by many different vendors, including open source
implementations
+ Many existing libraries
+ A plant model in Modelica can be imported into Simulink
- Matlab is often used for the control design
History: The Modelica design effort was initiated in September 1996 by
Hilding Elmqvist from Lund, Sweden.
Simscape
+ Easy integration in the Mathworks tool chain
(Simulink/Stateflow/Simscape)
- Closed implementation
What is Modelica
• Robotics
• Automotive
• Aircrafts
• Satellites
• Power plants
• Systems biology
Declarative language
Equations and mathematical functions allow acausal modeling,
high level specification, increased correctness
Multi-domain modeling
Combine electrical, mechanical, thermodynamic, hydraulic,
biological, control, event, real-time, etc...
Everything is a class
Strongly typed object-oriented language with a general class
concept, Java & MATLAB-like syntax
Visual component programming
Hierarchical system architecture capabilities
Efficient, non-proprietary
Efficiency comparable to C; advanced equation compilation,
e.g. 300 000 equations, ~150 000 lines on standard PC
Differential equations
Causality
Systems
Derivation
Definition Modeling of
Subsystems (manual derivation of
System
Decomposition input/output relations) Implementation Simulation
Proprietary
Code
Block Diagram
Modelica/
Simscape
R1=10 R2=100
sum2
p
n n +1
+1
AC=220
n n
p
G
The following equations are automatically derived from the Modelica model:
Modelica
Graphical Editor Modelica Modelica
Modelica Model Source code
Textual Editor Modelica Model
Frontend Translator
Modeling Flat model Hybrid DAE
Environment Analyzer
"Middle-end"
Sorted equations
Optimizer
Optimized sorted
equations
Backend Code generator
C Code
C Compiler
Executable
Simulation
Angular
Rotational Angle Torque
momentum
Magnetic Magnetic
Magnetic Magnetic flux
potential flux rate
Hydraulic Pressure Volume flow Volume
Heat Temperature Heat flow Heat
Chemical
Chemical Particle flow Particles
potential
+ v v +
pin1 pin2
i i
Pin pin1,pin2;
//A connect equation
//in Modelica: pin1.v = pin2.v;
connect(pin1,pin2);
Corresponds to
pin1.i + pin2.i =0;
Pin pin1,pin2;
//A connect equation
//in Modelica pin1.v = pin2.v;
connect(pin1,pin2);
Corresponds to
pin1.i + pin2.i =0;
v1 = v2 = v3 = ⋯ = vn
More complex system benfit more from taking advantage of the better
structuring and increased possiblity for reusability.
In the project you will use Simscape for modelling the physics and Simulink
to implement the control algorithms.
Next: View Webinar about Physical Modelling with the Simscape Language.
Webinar: Physcial Modeling with the Simscape Language
https://se.mathworks.com/videos/physical-modeling-with-the-simscape-
language-81733.html
Simscape Documentation
https://se.mathworks.com/help/physmod/simscape/