Section 6.12 Use of simulink with control

Introduction

Simulink is a powerful tool within the MATLAB suite for modelling and simulating system behaviour, especially where the interconnections are complicated and/or there are non-linear components. Being a visual environment, it is straightforward to see how different components relate to each other and thus to construct models representing complex systems.

It is  not the purpose of this section to give an introductory or detailed tutorial to simulink which are available on 'onramp'. Rather the purpose here is to give examples of focused case studies which illustrate some simple scenarios that are directly relevant to a modelling, dynamics and control undergraduate course. It is hoped that, for someone already competent in the use of MATLAB, these simple examples will be enough for students to make progress with any basic requirements. The livescript files all have more detailed explanation of the context, tasks and programming.

We have added these files to the control101 toolbox, but the draft versions are also available separately in the following folder.  If accessing files from the toolbox, it would be quicker and easier to use the short cuts available by using one of the commands:

>> doc Control101 Toolbox   (short cuts open in a different window)

>> help control101  (short cuts appear in command window)

A. Simple introduction - open-loop and closed-loop

The first resource uses the app environment. In essence it is delivered like a virtual laboratory - the file is named myfirstimulink_control101.mlapp and the initial interface looks like the image here

When running this app, two other files are opened automatically: i) the manual which gives detailed step-by-step instructions and ii) a simulink file containing the components required for the tasks. The idea is to introduce students gently to the concept of constructing the block diagrams within the simulink window, while not exposing them too much to data entry and simulation; the app handles these details in the background. The tasks encourage the user to become familiar with a limited toolset and also the important concept of how data is returned to the workspace for further processing and precise plotting.

B. Introductory examples

The livescript intro_to_simulink_for_system_behaviour.mlx  is a brief introduction to the use of simulink to model systems with some simple components. More importantly, it shows how integration with MATLAB code can make running the simulink file very efficient to allow systematic investigations for a range of parameter values. In essence:

This livescript file makes use of the following paired files which can be accessed through the livescript with supporting explanation or separately if desired. In summary, you can simply run the script file to run the simulation (assuming all files are visible on your MATLAB path).

simulink_openloop_model_control101_script.m

C. Heating system example

Heating systems are common examples in control courses and indeed there are examples of this  already in the toolbox (e.g. see section 6.8). The purpose of this illustration heating_system_simulink_control101_toolbox.mlx is simply to show how using simulink allows the easy inclusion of non-linear, or other, components which are not so simple to enter into MATLAB code. The code here introduces two forms of non-linearity, that is delay and dead-zones when switching sign. For simplicity and illustration, all 3 scenarios are within the same simulink file and simulink simply handles these as parallel but independent simulations. The results are collected together into a single scope for comparison.

This example has all the numerical parameters predefined within the simulink model and thus no supporting script file is needed to provide any numerical values.

Heating_System_control101.slx 

D. Hydraulic system example

Systems of tanks are also common in control courses and in the toolbox (e.g. see section 6.8), but again, simulink offers the opportunity to consider different arrangements of tanks and to manage the interconnections without having to manipulate into a single large state-space model for simulation in MATLAB, as well as the chance to add non-linear components ass required. The resource  hydraulic_system_simulink_control101_toolbox.mlx focuses on comparing parallel and series arrangements of tanks (separate simulink file for each arrangement). The required parameter values definition, simulation and plotting is handled within the code sections of the livescript.

The simulink files are:

E. Car suspension example

The livescript car_suspension_simulink_control101_toolbox.mlx introduces a car suspension scenario where the car drives over a ramp in the road at different speeds. The livescript gives a concise overview of the modelling and scenario and shows the associated simulink diagram to capture this scenario. It also illustrates common sources and sinks that can be used for importing and exporting data, both visually and into the MATLAB workspace. Specifically, here the source allows for non-simple input signals (e.g. not a constant) which are needed to capture the road profile. It also shows how deviation variables can be defined  within the model and corrected to absolute values for plotting.  All the simulation variables and model data are defined within a script for convenience as illustrated in the sections of the livescript.

The simulink file is:

car_suspension_control101.mlx

F. Position system example

The livescript file position_system_simulink_control101_toolbox.mlx is a brief introduction to the use of simulink to model and simulate a simple position system which uses a DC motor to move a lever. More importantly, it shows how integration with MATLAB code can make running the simulink file very efficient to allow systematic investigations for a range of parameter values and specifically in this case, the impact of the inclusion of non-linear components which are harder to handle in simple MATLAB code. This livescript file defines the required parameters and runs the simulations within sections. Users can edit the code in the sections to modify the parameters and other choices. It makes use of the following 3 simulink files:

G. Submersible example

The livescript file submersible_simulink_control101_toolbox.mlx is a brief introduction to the use of simulink to model and simulate a simple autonomous underwater vehicle.  Here the modelling equations take a form that might lend itself to a standard state-space model, apart from the fact there are some non-linear elements. Simulink allows a simple and transparent implementation of the state dependencies with these nonlinear components, using transfer function blocks and lines as shown in the two simulink files:

nonlinear_position_control.mlapp nonlinear_position_system_control101_manual .mlx non_linear_Position_System_control101.slx

H. Position control systems and non linear behaviours

This resource provides an interactive app file (MATLAB virtual laboratory) which demonstrates core learning outcomes linked to nonlinear bahviour. First, investigate the dynamics of position control system based on a DC servo and then consilder the impact of different nonlinear components in the system such as:  measurement noise, input saturation, backlash and parameter uncertainty. Users can also change core parameters to perform compare and contrast simulations with different assumptions. The manual and app also give guidance on the underlying scenario and how to use the simulink files directly.

I Behaviour of a nonlinear tank level system

This resource provides an interactive app file (MATLAB virtual laboratory) which demonstrates how the dynamics of tank exhibit non-linear behaviour in the open-loop; this is solely available within the livescript manual file. The focus is mostly on a simple non-linear impact: the nonlinear dependence of the flow rate through a restriction on pressure difference. The simulation also investigates the impacts of changes in input flow and blockages in the output pipe both of which cause a movement away from the linearisation point. The manual and app give guidance on the underlying scenario and how to use the simulink files directly.

nonlinear_tank_behaviour_control101.mlapp nonlinear_tank_system_simulink_control101_manual.mlx non_linear_tank_system_control101.slx   (MATLAB 2024) non_linear_tank_system_control101_2023.slx  

J Nonlinear tank level system and PI control

This resource provides an interactive app file (MATLAB virtual laboratory) which demonstrates two core learning outcomes. First, how the dynamics of tank exhibit non-linear behaviour in the open-loop; this is solely available within the livescript manual file. Secondly, it introduces feedback and a number of other external and non-linear impacts such as measurement noise, input saturation, anti-windup, disturbances and parameter uncertainty. Users can also change core parameters to perform compare and contrast simulations with different assumptions. The manual and app also give guidance on the underlying scenario and how to use the simulink files directly.

nonlinear_tank_control_control101.mlapp nonlinear_tank_system_simulink_control101_manual.mlx non_linear_tank_system_fbk_control101.slx   (MATLAB 2024) non_linear_tank_system_fbk_control101_2023.slx  


K Conical tank behaviour and control

This resource provides two interactive app files (MATLAB virtual laboratory) which demonstrate core learning outcomes linked to nonlinear behaviours (one file does open-loop and the second does closed-loop). Specifically the focus is on a conical tank. This has nonlinearities due to both the outflow depending on pressure difference and also, the variation in cross sectional area with depth. Users are able to observe and understand the limitations of linear models by investigations on this app. It also includes realistic effects such as:  measurement noise, input saturation, and windup. Users can also change some of the tank parameters to perform compare and contrast simulations with different assumptions. The manual and app also give guidance on the underlying scenario and how to use the simulink files directly.

conical_tank_behaviour_control101.mlapp  conical_tank_control_control101.mlapp conical_tank_system_simulink_control101_manual.mlx conical_tank_system_behaviour_control101_2023.slx

conical_tank_system_control101_2023.slx