![Page 1: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/1.jpg)
1© 2015 The MathWorks, Inc.
Introduction to Simulink & Stateflow
Jonathan Agg
![Page 2: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/2.jpg)
2
![Page 3: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/3.jpg)
4
Topics we will address this session
▪ Why model a system?
▪ Why use Simulink?
▪ Getting to grips with the basics of Simulink and Stateflow through a worked
example
![Page 4: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/4.jpg)
6
Why model a system?
![Page 5: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/5.jpg)
7
Modelling & Simulation
gives you insight
![Page 6: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/6.jpg)
8
Image credit: McLaren
Image credit: Peter Gronemann | Wikipedia
![Page 7: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/7.jpg)
11
MODEL
Integrate
Create
Import
SIMULATE
Test
Optimize
ConfigureAnalyze and
Document
DEPLOY
Integrate Into
Other Environments
Share Models
Test Controller
![Page 8: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/8.jpg)
12
Why use
Simulink?
![Page 9: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/9.jpg)
13
Model Based Design with Simulink
▪ Modelling and simulation
– Multidomain Dynamic Systems
– Nonlinear Systems
– Continuous-time, Discrete-time, Multi-Rate systems
▪ Plant and Controller Design
– Select/optimise control architecture and parameters
– Rapidly model “what-if” scenarios
– Communicate design ideas
– Embody performance specifications
▪ Implementation
– Automatic code generation
▪ Embedded systems, FPGAs, GPUs
– Rapid prototyping for HIL, SIL, PIL
– Verification and validation
![Page 10: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/10.jpg)
14
Optimise System-Level Performance
▪ Simulating plant and controller in one environment allows you to optimize
system-level performance.
– Automate tuning process using optimization algorithms
– Accelerate process using parallel computing
Plant
+u y
Controller
s1 s2
s3
System
Actu
ato
rs
Sen
so
rs
![Page 11: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/11.jpg)
15
Plant
Specification
Detect Integration Issues Earlier
Plant
+u y
Controller
s1 s2
s3
▪ Controls engineers and domain specialists can work together to detect integration issues in simulation– Convert plant models to C code for hardware-in-the-loop tests
– Share models with other internal users
– Share models with external users while protecting IP
System
Actu
ato
rs
Sen
so
rs
![Page 12: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/12.jpg)
16
Modelling Approaches
Data-Driven ModellingFirst Principles Modelling
Statistics and Machine
Learning Toolbox
Simscape SystemIdentification
ToolboxSimulink
Design Optimization
Simulink
MATLAB
Tools for Modelling Dynamic Systems
![Page 13: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/13.jpg)
18
Using Simulink &
Stateflow
![Page 14: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/14.jpg)
19
Model-Based Design Application
▪ Rotate a camera to track an object
▪ Computer vision application
▪ Closed-loop motor control
+ +
![Page 15: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/15.jpg)
21
![Page 16: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/16.jpg)
22
What questions do we want to answer?
▪ Can I get the closed loop response I need?
▪ What current will my motor draw during operation?
▪ Does my system still work if component values change?
▪ What if…?
![Page 17: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/17.jpg)
23
Steps in the process
1. Model the motor
2. Model the speed controller
3. Refine the motor model using measured data
4. Model the supervisory logic
5. Validate and integrate the image processing algorithm
6. Deploy the control model to hardware
At each stage: Simulate the model
![Page 18: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/18.jpg)
26
Steps in the process
✓ Model the motor
✓ Model the speed controller
3. Refine the motor model using measured data
4. Model the supervisory logic
5. Validate and integrate the image processing algorithm
6. Deploy the control model to hardware
At each stage: Simulate the model
![Page 19: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/19.jpg)
27
Parameter Estimation
![Page 20: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/20.jpg)
28
Steps in the process
✓ Model the motor
✓ Model the speed controller
✓ Refine the motor model using measured data
4. Model the supervisory logic
5. Validate and integrate the image processing algorithm
6. Deploy the control model to hardware
At each stage: Simulate the model
![Page 21: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/21.jpg)
30
Stateflow Overview
▪ Extend Simulink with a design environment for developing state machines
and flow charts
▪ Design systems containing control, supervisory, and mode logic
▪ Describe logic in a natural and understandable form with deterministic
execution semantics
![Page 22: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/22.jpg)
31
What are State Machines?
▪ Represent an algorithm or process▪ Represent reactive systems that have states or
modes
▪ States change based on defined conditions
and events
What are Flow Charts?
E.g. Fault Management
![Page 23: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/23.jpg)
33
Modelling the system with Simulink and Stateflow
![Page 24: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/24.jpg)
34
Next steps in the process
✓ Model the motor
✓ Model the speed controller
✓ Refine the motor model using measured data
✓ Model the supervisory logic
5. Validate and integrate the image processing algorithm
6. Deploy the control model to hardware
✓ Simulate the model
Visit the
Demo
Stations!
![Page 25: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/25.jpg)
35
Conclusions
▪ Modelling and simulation gives you insight to make smarter decisions,
earlier
▪ Simulink allows you to model the complete system in a single environment
▪ Accelerate your simulation work with the power of MATLAB
![Page 26: Introduction to Simulink & Stateflow - MathWorks · Modelling and simulation gives you insight to make smarter decisions, earlier Simulink allows you to model the complete system](https://reader030.vdocuments.site/reader030/viewer/2022040204/5ecebceb31c6980988752358/html5/thumbnails/26.jpg)
36
Solar Impulse Develops Advanced
Solar-Powered Airplane
• Key design decisions
made early
• Vital pilot training
enabled
• Models reused and
shared throughout
development
“Simulations with MATLAB and Simulink were essential to assessing
feasibility and evaluating broad design tradeoffs as well as making
detailed design decisions—like the size of control surfaces and the
vertical tail—that directly affect aircraft dynamics and handling
qualities.”
–Ralph Paul, Solar Impulse