Example: Bus Suspension Modeling in Simulink
Physical setup
Building the model
Open-loop response
Extracting the Model
Implementing Full State Feedback
Closed-loop response
Physical setup
Designing an automatic suspension system for a bus turns out to be an
interesting control problem. When the suspension system is designed,
a 1/4 bus
model (one of the four wheels) is used to simplify the problem to a
one dimensional spring-damper system. A diagram of this system is
shown below:

Where:
* body mass (m1) = 2500 kg,
* suspension mass (m2) = 320 kg,
* spring constant of suspension system(k1) = 80,000 N/m,
* spring constant of wheel and tire(k2) = 500,000 N/m,
* damping constant of suspension system(b1) = 350 Ns/m.
* damping constant of wheel and tire(b2) = 15,020 Ns/m.
* control force (u) = force from the controller we are going to
design.
Design requirements:
A good bus suspension system should have satisfactory road holding
ability, while still providing comfort when riding over bumps and
holes in the road. When the bus is experiencing any road disturbance (i.e.
pot holes, cracks, and uneven pavement),the bus body should not have large
oscillations, and the oscillations should dissipate quickly. Since the
distance X1-W is very difficult to measure, and the deformation of
the tire (X2-W) is negligible, we will use the distance
X1-X2 instead of X1-W as the output in our problem. Keep in
mind that this is an estimation.
The road disturbance (W) in this problem will be simulated by a
step input. This step could represent the bus coming out of a
pothole. We want to design a feedback controller so that the output
(X1-X2) has an overshoot less than 5% and a settling time shorter
than 5 seconds. For example, when the bus runs onto a 10 cm high step, the
bus body will oscillate within a range of +/- 5 mm and return to a smooth
ride within 5 seconds.
Building the Model
This system will be modeled by summing the forces acting on both
masses (body and suspension) and integrating the accelerations of each
mass twice to give velocities and positions. Newton's law will be
applied to each mass. Open Simulink and open a new model window.
First, we will model the integrals of the accelerations of the masses.
- Insert an Integrator block (from the Linear block library) and draw
lines to and from its input and output terminals.
- Label the input
line "a1" (for acceleration) and the output line "v1" (for velocity)
To add such a label, double click in the empty space just above the
line.
- Insert another Integrator block connected to the output of the
first.
- Draw a line from its output and label it "x1" (for position).
- Insert a second pair of Integrators below the first with lines labeled
"a2", "v2", and "x2".
Next, we will start to model Newton's law. Newton's law for each of
these masses can be expressed as:
These equations can be represented with gain blocks (for 1/M1
and 1/M2) and two summation blocks.
- Insert two Gain blocks, (from the
Linear block library) one attached to the inputs of each of the
integrator pairs.
- Edit the gain block corresponding to M1 by
double-clicking it and changing its value to "1/m1".
- Change the label
of this Gain block to "Mass 1" by clicking on the word "Gain"
underneath the block.
- Similarly, edit the other Gain's value to "1/m2"
and it's label to "Mass 2". (You may want to resize the gain blocks
to view the contents. To do this, single click on the block to
highlight it, and drag one of the corners to the desired size.)
There are three forces acting on M1 (one spring, one damper,
and the input, u) and five forces acting on M2 (two
springs, two dampers, and the input, u).
- Insert two Sum blocks
(from the Linear block library), one attached by a line to each of the
Gain blocks.
- Edit the signs of the Sum block corresponding to
M1 to "+--" to represent the three forces (two of which will be
negative)
- Edit the signs of the other Sum block to "++-++" to
represent the five forces, one of which will be negative.
Now, we will add in the forces acting on each mass. First, we will
add in the force from Spring 1. This force is equal to a constant,
k1 times the difference X1-X2.
- Insert a sum block after the upper pair of integrators.
- Edit its signs to "+-" and connect the "x1" signal to the positive
input and the "x2" signal to the negative input.
- Draw a line leading
from the output of the Sum block.
- Insert a Gain block above the "Mass1" block.
- Flip it left-to-right by single-clicking on it and
selecting Flip Block from the Format menu (or hit Ctrl-F).
- Edit the
value of this gain to "k1" and label the block "Spring 1".
- Tap a line
off the output of the last Sum block and connect it to the input of
this gain block.
- Connect the output of this gain block (the spring
force) to the second input of the Mass 1 Sum block.
This input should
be negative since the Spring 1 pulls down on Mass 1 when X1 >
X2.
- Tap a line off the spring force line and connect it to the
second input of the Mass 2 Sum block. This input is positive since
Spring 1 pulls up on Mass 2.
Now, we will add in the force from Damper 1. This force is equal to
b1 times V1-V2.
- Insert a sum block below the Mass 1's
first integrator.
- Flip it left-to-right, and edit it's signs to "+-".
- Tap a line off the "v1" line and connect it to the positive
input of this Sum block.
- Tap a line off the "v2" line and connect it
to the negative input of this Sum block.
- Insert a Gain block to the
left of this Sum block and flip it left-to-right.
- Edit it's value to
"b1" and label it "Damper 1".
- Connect the output of the new Sum block
to the input of this gain block.
- Connect the output of this gain
block (the damper force) to the third input of the Mass 1 Sum block.
This input is negative, similar to Spring 1's force on Mass 1.
- Tap a
line off Damper 1's force line and connect it to the first input
(which is positive) of Mass 2's Sum block.
Now we will add in the force from Spring 2. This force acts only on
Mass 2, but depends on the ground profile, W. Spring 2's force
is equal to X2-W.
- Insert a Step block in the lower left area
of your model window. Label it "W".
- Edit it's Step Time to "0" and
it's Final Value to "0". (We will assume a flat road surface for
now).
- Insert a Sum block to the right of the W Step block
and edit its signs to "-+".
- Connect the output of the Step block to
the positive input of this Sum block.
- Tap a line off the "x2" signal
and connect it to the negative input of the new Sum block.
- Insert a
Gain block to the right of this Sum block and connect the Sum's output
to the new Gain's input.
- Change the value of the gain to "k2" and
label it "Spring 2".
- Connect the output of this block (Spring 2's
force) to the fourth input of Mass 2's Sum block. This force adds in
in the positive sense.
Next, we will add in the force from Damper 2. This force is equal to
b2 times V2-d/dt(W). Since there is no existing
signal representing the derivative of W we will need to
generate this signal.
- Insert a Derivative
block (from the Linear block library) to the right of the W
step block.
- Tap a line of the Step's output and connect it to the
input of the Derivative block.
- Insert a Sum block after the
Derivative block and edit it's signs to "+-".
- Connect the
Derivative's output to the positive input of the new Sum block.
- Tap a
line off the "v2" line and connect it to the negative input of this
Sum block.
- Connect the output of this Sum block (Damper 2's force) to
the fifth input of Mass 2's Sum block. This force also adds in with
positive sign.
The last force in the input U acting between the two masses.
- Insert a Step block in the upper left of the model window.
- Connect it's output to the remaining input of Mass 1's Sum block (with
positive sign).
- Tap a line off this signal and connect it to the
remaining input of Mass 2's Sum block (with negative sign).
- Edit this
Step block's Step Time to "0" and leave its Final Value "1".
- Label this Step block "U".
- Finally, to view the output (X1-X2)
insert a Scope connected to the output of the rightmost Sum block.
You can download a model file for the complete system here.
Open-loop response
To simulate this system, first, an appropriate simulation time must be
set. Select Parameters from the Simulation menu and enter "50" in
the Stop Time field. 50 seconds is long enough to view the open-loop
response.
The physical parameters must now be set. Run the following commands
at the MATLAB prompt:
m1=2500;
m2=320;
k1=80000;
k2=500000;
b1 = 350;
b2 = 15020;
Run the simulation (Ctrl-t or Start on the Simulation menu). When the
simulation is finished, double-click on the scope and hit its
autoscale button. You should see the following output.
Extracting a Linear Model into MATLAB
A linear model of the system (in state space or transfer function
form) can be extracted from a Simulink model into MATLAB. This is
done through the use of In and Out Connection blocks and the MATLAB
function linmod. We will extract only the
model from the input U to the output X1-X2.
- First, replace the U Step block with an In Connection
Block.
- Also, replace the Scope block with an Out Connection Block.
(These blocks
can be found in the Connections block library). This defines the
input and output of the system for the extraction process.
Save your file as "suspmod.mdl" (select
Save As from the File menu). MATLAB will extract the linear model
from the saved model file, not from the open model window. At the
MATLAB prompt, enter the following commands:
[A,B,C,D]=linmod('suspmodel')
[num,den]=ss2tf(A,B,C,D)
You should see the following output, providing both state-space
and transfer function models of the system.
A =
1.0e+003 *
0 0 0 0.0010
0 0 0.0010 0
0.2500 -1.8125 -0.0480 0.0011
-0.0320 0.0320 0.0001 -0.0001
B =
0
0
-0.0031
0.0004
C =
1 -1 0 0
D =
0
num =
0 0.0000 0.0035 0.0188 0.6250
den =
1.0e+004 *
0.0001 0.0048 0.1851 0.1721 5.0000
To verify the model extraction, we will generate an open-loop step
response of the extracted transfer function in MATLAB. Enter the
following command in MATLAB.
step(num,den);
You should see the following plot which is equivalent to the Scope's
output.
Implementing Full State Feedback
In the Bus Suspension
Control State Space example a full-state feedback controller
was designed feeding back the following five states:
The controller used the following feedback gain matrix:
To implement this in Simulink,
we
will contain the open-loop system from earlier in this page in a
Subsystem block.
- Create a new model window.
- Drag a Subsystem block from the Connections block
library into your new model window.
- Double click on this block. You will see a blank window representing
the contents of the subsystem (which is currently empty).
- Open your previously saved model of the Bus Suspension system, suspmod.mdl.
- Select Select All from the Edit
menu (or Ctrl-A), and select Copy from the Edit menu (or Ctrl-C).
- Select the blank subsystem window from your new model and select Paste
from the Edit menu (or Ctrl-V). You should see your original system
in this new subsystem window (you may need to use the scroll bars to
center on it).
- Label the In Connection block "U", and the Out
Connection block "y1".
- Replace the W Step block with an In
Connection block and label this block "W".
Now we will generate the other state outputs from the subsystem.
- Insert an Out block below the "y1" block and label it "d/dt(y1)", Tap
a line off the line leading into the Damper 1 gain block
(V1-V2) and connect it to the d/dt(y1) Out block.
- Insert
another Out block below the "d/dt(y1)" Out block and label it "x1".
- Tap a line off the "x1" line and connect it to this Out block.
- Insert
another Out block below the "x1" Out block and label it "d/dt(x1)".
- Tap a line off the "v1" line and connect it to this Out block.
The final, extra, state needs to be generated, which is the integral
of Y1.
- Insert an Integrator block above the "y1" Out block and
connect its input with a line tapped of the input to the "y1" Out
block.
- Insert an Out block, label it "int(y1)", and connect it to the
output of the new integrator.
Since the state outputs will be used to form a vector, it is important
that they be numbered in the right order.
- Edit the "x1" Out block and
change its Port Number to "1".
- Similarly, change the "d/dt(x1)" Out
block's port number to "2", "y1" Out's port number to "3", "d/dt(y1)"
Out's port number to "4", and "int(y1)" Out's port number to
"5".
- The In blocks should be numbered such that "U" is "1" and "W" is
"2". Some of these numbers may already be correct.
- Close the Subsystem window. You should now see input and output
terminals on the Subsystem block.
- Name this block "Suspension Model".
- You should resize this block so that you can read all of the labels.
To do this, highlight it by single-clicking on it and drag one of the
highlighted corners to the right size. Notice that the model has two
inputs and five outputs. Each input and output is a scalar signal in
this model.
Now, we will build a full-state feedback controller around the
plant model. First, we need to create a vector signal out of the five
scalar outputs in order to multiply by the feedback gain matrix
K.
- Insert a Mux block (from the Connections block library) to
the right of the Suspension Model block. The Mux takes multiple
inputs and combines them into a vector signal. By default, the Mux
has three inputs.
- Edit the Mux block and change the Number of Inputs
to "5".
- Resize the Mux so that it is the same height as the
Suspension Model block.
- Connect each of the Suspension Model's
outputs to the Mux's inputs in order.
Now, we will close the loop.
- Insert a Matrix Gain block (from the
Linear block library) below the Suspension Model block.
- Flip the
Matrix Gain left-to-right and edit its value to "K".
- Insert a Sum block to the left of the Suspension Model block.
- Edit its signs to "+-".
- Connect the output of the Matrix Gain to the negative input of the Sum
block.
- Connect the output of the Sum block to the "U" input of the
Suspension Model.
- Insert a Step block and connect it to the positive input of
the Sum block.
- Label the step block "r" and edit its Step Time to "0"
and its Final Value to "0" (we are commanding the bust to stay level).
- Insert a Step block and connect it to the "W" input of the Suspension
Model.
- Edit its Step Time to "0" and its Final Value to "-.1" (we are
now assuming a 10cm deep pothole).
- Insert a Scope block and tap a
line off the "y1" output of the Suspension Model and connect it to the
Scope.
You can download our version of the closed-loop system here.
Closed-loop response
To simulate this system, first, an appropriate simulation time must be
set. Select Parameters from the Simulation menu and enter "2" in the
Stop Time field. The design requirements included a settling time of
less than 5 sec, and the system actually settles in 2 sec.
The physical parameters must now be set. Run the following commands
at the MATLAB prompt:
m1=2500;
m2=320;
k1=80000;
k2=500000;
b1 = 350;
b2 = 15020;
The last step is to assign values to the feedback gain matrix K. Execute the following command at the MATLAB prompt.
K= [ 0 2.3e6 5e8 0 8e6 ];
Run the simulation (Ctrl-t or Start on the Simulation menu). When the
simulation is finished, double-click on the scope and hit its
autoscale button. You should see the following output.
- Simulink Examples
-
Cruise Control |
Motor Speed |
Motor Position |
Bus Suspension |
Inverted Pendulum |
Pitch Controller |
Ball and Beam
- Bus Suspension Examples
-
Modeling |
PID |
Root Locus |
Frequency Response |
State Space |
Digital Control |
Simulink
- Tutorials
-
MATLAB Basics |
MATLAB Modeling |
PID |
Root Locus |
Frequency Response |
State Space |
Digital Control |
Simulink Basics |
Simulink Modeling |
Examples
