Professional Documents
Culture Documents
❖ Introduction
❖ Cruise Control
❖ Motor Speed
❖ Motor Position
❖ Suspension
❖ Inverted Pendulum
❖ Aircraft Pitch
1
Introduction
❖ Simulink Modeling
❖ Simulink Control
2
Introduction
❖ Simulink Modeling
▪ Models are represented graphically in Simulink as block diagrams.
▪ A wide array of blocks are available to the user in provided libraries for
representing various phenomena and models in a range of formats.
3
Introduction
❖ Simulink Modeling
▪ Train system
❖ Simulink Modeling
▪ Free-body diagram and Newton's second law
5
Introduction
❖ Simulink Modeling
▪ Free-body diagram and Newton's second law
➢ Applying Newton's second law in the horizontal direction based on the above free-
body diagrams leads to the following governing equations for the train system.
6
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
7
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
8
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ These Gain blocks should contain 1/M for each of the masses
9
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ The outputs of these gain blocks are the accelerations of each of the masses (the
train engine and car).
10
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ Drag a total of four Integrator blocks from the Continuous library into your model,
two for each of our two accelerations.
11
Introduction
12
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ Now, drag two Scopes from the Sinks library into your model and connect them to
the outputs of these integrators. Label them "x1" and "x2".
13
Introduction
14
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
15
Introduction
16
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ The first force acting on mass 1 is just the input force, F. Drag a Signal Generator
block from the Sources library and connect it to the uppermost input of the
corresponding Sum block. Label this signal as "F".
17
Introduction
18
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ The next force acting on mass 1 is the rolling resistance force. Recall that this force
is modeled as follows.
19
Introduction
20
Introduction
❖ Simulink Modeling
▪ Constructing the Simulink model
➢ The last force acting on mass 1 is the spring force. Recall that this force is equal to
the following.
21
Introduction
22
Introduction
23
Introduction
24
Introduction
25
Introduction
26
Introduction
❖ Simulink Modeling
▪ Running the model
➢ Before running the model, we need to assign numerical values to each of the
variables used in the model. For the train system, we will employ the following
values.
27
Introduction
❖ Simulink Modeling
▪ Running the model
28
Introduction
❖ Simulink Modeling
▪ Running the model
➢ Execute your m-file in the MATLAB command window to define these values.
Simulink will recognize these MATLAB variables for use in the model.
29
Introduction
30
Introduction
❖ Simulink Modeling
▪ Running the model
➢ The last step before running the simulation is to select an appropriate simulation
time.
➢ Select Model Configuration Parameters from the Simulation menu at the top of the
model window and change the Stop Time field to "1000".
31
Introduction
32
Introduction
❖ Simulink Modeling
❖ Simulink Control
33
Introduction
❖ Simulink Control
▪ The open-loop plant model
➢ Recall the Simulink model of the toy train system derived in the Introduction:
Simulink Modeling page and pictured below.
34
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ In order to make our Simulink model more understandable, we will first save the
train model into its own subsystem block.
35
Introduction
36
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ Next select all of the blocks in your model (Ctrl A) and select Create Subsystem from
Selection after right-clicking on the model window.
37
Introduction
38
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ Now we can add a controller to our system.
39
Introduction
40
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ Next add a Sum block from the Math Operations library.
41
Introduction
42
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ Next add a Signal Builder block from the Sources library to represent the velocity
commanded to the train.
43
Introduction
44
Introduction
❖ Simulink Control
▪ Implementing a PID controller in Simulink
➢ Also add a Scope block from the Sinks library and use it to replace the Out1 block for the
train's velocity. Relabeling the blocks, your model will appear as follows.
45
Introduction
46
Introduction
❖ Simulink Control
▪ Running the closed-loop model
➢ For the train system, we will employ the following values.
47
Introduction
❖ Simulink Control
▪ Running the closed-loop model
➢ Create a new m-file and enter the following commands.
48
Introduction
❖ Simulink Control
▪ Running the closed-loop model
➢ Execute your m-file in the MATLAB command window to define these values.
49
Introduction
❖ Simulink Control
▪ Extracting a model into MATLAB
50
Introduction
❖ Simulink Control
▪ Extracting a model into MATLAB
➢ We can now extract the model by opening the Linear Analysis Tool.
Select
51
Introduction
❖ Simulink Control
▪ Extracting a model into MATLAB
➢ The Linear Analysis Tool window should now appear as shown below.
52
Introduction
❖ Simulink Control
▪ Extracting a model into MATLAB
➢ Having extracted this model, we can now employ all of the facilities that MATLAB offers for
controller design. For example, let us employ the following commands to generate and
analyze the closed-loop system reflecting the Simulink model created above.
53
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ We can launch interactive tools to tune our controller from within Simulink.
54
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ The first thing that needs to be done is to identify the controller block that is to be tuned.
55
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Before we proceed to tune our controller, we must first identify the inputs and outputs of
the closed-loop system we wish to analyze.
56
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Now that we have identified the block to tune and our input and output signals, we can
now commence with tuning the controller.
57
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Clicking the Tuning Methods button, we will choose the design plots we wish to employ for
designing our controller.
58
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢
59
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢
60
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Then we specify the input and output signals within the New Step to plot window as
shown below.
61
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Then click the Plot button. From the resulting closed-loop step response we can see that
the response is stable, but with some steady-state error.
62
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ Recall that adding integral control is one way to reduce the steady-state error of a closed-
loop system. In this case, adding an integrator via the controller will make the system type
1, where type 1 systems can track step references with zero steady-state error. Recall the
following form of a PI controller.
63
Introduction
❖ Simulink Control
▪ Controller design within Simulink
64
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ The resulting closed-loop step response plot is shown below demonstrating that the train
engine is brought to rest smoothly and with zero steady-state error for a constant speed
command.
65
Introduction
❖ Simulink Control
▪ Controller design within Simulink
➢ The control gains that have been chosen can then be applied to the Simulink model by
clicking the Update Blocks button within the CONTROL SYSTEM tab as shown above. The
simulation can then be run with this newly tuned controller. Clicking on the Scope block for
the train engine's velocity will produce a plot like the one shown below.
66