Introduction to Simulink

Mariusz Janiak p. 331 -3, 71 320 26 44

c 2015 Mariusz Janiak

All Rights Reserved Contents

1 Introduction

2 Essentials

3 Continuous systems

4 Hardware-in-the-Loop (HIL) Simulation Introduction

Simulink is a block diagram environment for multidomain simulation and Model-Based Design. It supports simulation, automatic code generation, and continuous test and verification of embedded systems.1 Graphical editor Customizable block libraries Solvers for modeling and simulating dynamic systems Integrated with Matlab Web page www.mathworks.com

1 The MathWorks, Inc. Introduction

Simulink capabilities Building the model (hierarchical subsystems) Simulating the model Analyzing simulation results Managing projects Connecting to hardware Introduction

Alternatives to Simulink Xcos (www..org/en/scilab/features/xcos) OpenModelica (www..org) MapleSim (www.maplesoft.com/products/maplesim) Wolfram SystemModeler (www.wolfram.com/system-modeler) Introduction

Model based design with Simulink Modeling and simulation Multidomain dynamic systems Nonlinear systems Continuous-, Discrete-time, Multi-rate systems Plant and controller design Rapidly model what-if scenarios Communicate design ideas Select/Optimize control architecture and parameters Implementation Automatic code generation Rapid prototyping for HIL, SIL Verification and validation Essentials

Working with Simulink Launching Simulink Library Browser Finding Blocks Getting Help Context sensitive help Simulink documentation Demo Working with a simple model Changing block parameters Labeling blocks and signals Running a simulation Defining parameters with MATLAB variables Saving/opening a model Essentials

How Simulink works Engine provides variable- and fixed-step ODE solvers Block diagram representation of dynamic systems Blocks define “governing” equations Signals are propagated between blocks over time Solvers Fixed-step: ode1, ode2, ode3, ode4, ode5, ode8 Variable-step: ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb Essentials

Subsystems Reduce blocks displayed in a model window Keep functionally related block together Establish hierarchical block diagram Creating Context menu → Create subsystem Subsystem ports Exploring subsystems Undo subsystem Essentials

Model Referencing Reuse models as blocks in other models Include one model in another by using a Model block Organize large models hierarchically, similar to using subsystems Advantages Modular development Inclusion by reference Incremental loading Accelerated simulation Incremental code generation Independent configuration sets Continuous systems

System x0(t) = 3x(t) + u(t) Time-domain representation using integrator block Frequency-domain representation using transfer function block

sX (s) = 3X (s) + U(s)

(s − 3)X (s) = U(s) X (s) 1 G(s) = = U(s) (s − 3) Hardware-in-the-Loop (HIL) Simulation

Hardware-in-the-loop (HIL) simulation is a technique for validating your control algorithm, running on an intended target controller, by creating a virtual real-time environment that represents your physical system to control. HIL helps to test the behavior of your control algorithms without physical prototypes.2

2 The MathWorks, Inc. Hardware-in-the-Loop (HIL) Simulation

Where is HIL simulation used?

1 When testing your control algorithm on the real physical system is costly or dangerous 2 Aerospace and defense: Flight simulators and flight dynamic control, where it is too complex to test the control algorithm on the actual aircraft 3 Automotive: Vehicle dynamics and controls, where it is impractical to test the functionality on the road in the initial phases 4 Industrial automation: Controller-plant testing, when stopping the production or assembly line to test control algorithms involves a huge amount of resources and business loss Hardware-in-the-Loop (HIL) Simulation Hardware-in-the-Loop (HIL) Simulation

How does HIL simulation work? 1 Create and simulate a virtual real-time implementation of physical components such as a plant, sensors, and actuators on a real-time target computer. 2 Run the control algorithm on an embedded controller and run the plant or environment model in real time on a target computer connected to the controller. The embedded controller interacts with the plant model simulation through various I/O channels. 3 Refine software representations of your components and gradually replace parts of the system environment with the actual hardware components. Hardware-in-the-Loop (HIL) Simulation The End

Thank you for your kind attention.