You are on page 1of 12

Dynamic System Modeling Using MATLAB and Simulink

MIE397B: DYNAMIC SYSTEM MODELING, ANALYSIS, AND SIMULATION


Fall Semester, 2007
Prof. Robert Gao

Problem Statement:
The time-varying response of suspension system in an automobile can be analyzed through a
simplified modeled as a spring-mass-damper system. Using the state-variable notations, derive
the governing equations of the system and its response to an input function that simulates various
types of road conditions. The response of the vehicle can be used to model a variety of
suspension settings.

Assumptions:

Only vertical displacement of the car is considered (no roll or pitch);


The springs and dampers are assumed to be mass-less;
The tire has no mass or dampening properties associated with it.
The input on the cars wheel can be modeled as the sum of two step functions, the first
function stepping down in the hole and the second function stepping out of the hole.

Figure 1: Illustration of the problem statement

MIE397B

Page 1 of 12

Fall 2007

Given Parameters:

Cars vertical displacement: hole depth = 0.15 m.


Input function: step function initially starting at a vertical displacement of 0m, dropping
to -0.15 m level after a horizontal displacement of 450 m, and then stepping back up to 0
m after 1 m.
The cars tires are 0.305 m in diameter.
The car is traveling at a speed of 20 m/s.

Solution Approach:
This model only takes into consideration vertical displacement and the all axle movements of the
car will be modeled as having equal amplitude and occurring concurrently, to eliminate the need
for calculating pitch and roll of the vehicle. The state variables are first identified. Next,
governing equations that describe the systems dynamic behavior are set up, based on the freebody diagram (FBD) of the car suspension system.

Governing Equation:
mcar &y&1 + c y&1 + k ( y1 y 2 ) = 0
Note: the gravitational force is cancelled out by the
initial displacement of the springs.
Figure 2: FBD of the suspension system

State Variable:
1. y1 , displacement of car body (from the governing equation)
cy&1 k ( y1 y 2 )
&y&1 =
mcar
Input:

y2 : Displacement of tire (from the problem statement)


t < hstart
0

y1 = 0.15 m hstart t < hend


0
t hend

hstart and hend correspond to the time instants at which the tire starts entering the hole and
comes out of it.

MIE397B

Page 2 of 12

Fall 2007

Simulink Model:
1) Open Simulink
Open Matlab, and type Simulink in the command window (MATLAB is case sensitive).
From the menu, select file->new->model.

Suspension Model Setup.

Figure 3: Flow chart of the system model

Step 1: Input Position

MIE397B

The effect of the wheel going down into the pothole is simulated by adding two step
functions, step1 and step2 through the summation block.
Double click on Step1 block.
Change the step time to hstart, the initial value to 0, and the final value to -holedepth.
Set sample time to 0.001s for example.
Select OK.
Double click on the second Step2 Function block.
Change the step time to hend, the initial value to 0, and the final value to holedepth.
Set sample time to the same value 0.001s.
Select OK.
Double Click on the existing labels to change to Step1 and Step2.
Page 3 of 12

Fall 2007

Step

Step1

Figure 4: Input Step functions

Step 2: Integrator blocks.


These blocks will allow the conversion of acceleration to velocity and velocity to
displacement in the model.
1
s

1
s

Integrator

Integrator1

The Integrator blocks are located in the Simulink Library Browser under the Continuous
folder.
- Blocks are inserted by dragging them into the model.

Connect the first integrators output arrow to the input of the second integrator.
- This is done by clicking on the output arrow of the first integrator and dragging
a wire to the input of the second integrator. Double Click on the connecting
wires and label as velocity.

Step 3: Spring Force

MIE397B

Both the spring and dampening forces depend on relative motion.


Introduce a summation block; click on it and change list of signs to |-+.
Connect the output of the first summation block to the (-) input port.
Draw a wire from the output of the Integrator1 block and join it to the (+) port of
the new summation block.

Page 4 of 12

Fall 2007

Velocity

Step1
Integrator

Integrator1
Position

Step2

Figure 5: System for calculation of relative displacement

Introduce a Gain block from the Simulink Library Browser from the Math Operations
section. The gain block is dragged from the library browser into the model.
Double Click on the Gain block and set gain value as stiffness k.
Connect the output of the new summation block to the input of the Gain block.
Label the Gain block as Stiffness so the output is the spring force.

1
s

k
Step1

Integrator

1
s
Integrator1

Stiffness
Position

Step2

Figure 6: System for calculation of spring force

Step 4: Damping Force


Introduce a Gain block from the Simulink Library Browser.
Double click on it and change the gain value to damping constant c.
Click on the gain block and press the Ctrl key and repeatedly press the R key so the
block rotates to the desired orientation.
Label the block as damping constant.
Draw a wire from the output of the first integration block and connect to the input of
damping constant block.
Introduce a summation block and change the list of signs to |--.
Connect the output of the Stiffness block and the Damping constant block to the ports of
the new summation block. The block will sum the spring and damping forces and
generate the total force acting on the car mass.
MIE397B

Page 5 of 12

Fall 2007

Velocity

Spring
Force

s
Integrator1

Integrator

Stiffness

Step1

Damping
Constant

Position

Damping Force
Step2

Figure 7: System for summation of damping and spring forces

Step 5: Calculation of acceleration and completion of model.

Acceleration
Velocity

Spring
Force
k
Step1

Stiffness

1
s

1
s

1/m
Mass

Scope

Integrator1

Integrator
c

Damping
Constant
Step2

Position

Damping Force
disp.mat
To File

Figure 8: Complete system for calculation of displacement of the car body.

Drag and introduce a gain block.


Double click and set the gain value to 1/m.
Label the block as mass.
Connect the ouput of the summation block in the last step to the input of the Mass block.
This introduces the force acting on the car body.
The output of the mass block is acceleration. So draw a wire from the output of the block
and connect to the input of the first Integration block. Label the wire as Acceleration.

Step 6: Visual Display Output


Go to the Simulink library browser and simulink and then on Sink folder.
Drag a scope to the workspace.
MIE397B

Page 6 of 12

Fall 2007

Press control and click and draw a wire from the position output of the second
integrator block. Connect to the input of the scope.
Double click on the scope and click on the Parameters tab and then click the Data
History tab on the pop-up window.
Set the Limit Data Points to option to 100000 (or any number of your choice,
default is 5000).

Step 7: Generation of data file

Go to the Simulink library browser and then to the Sink folder.


Drag the To file block to the workspace. This creates a .mat file and stores the time and
the displacement data as an array.
Draw a wire from the position output and connect to the input port of the To file block.
Double click and change the name of the file and the name of the array variable.
Repeat the same for the summed displacement input.

Step 8:
Go to the Simulation tab of the workspace.
Go to the Configuration parameters option.
Set the start time to 0 and the stop time to 100s (for e.g.)
Under the Solver Options heading, set type to fixed step and solver to ODE5
Dormand Prince for example.
Set fixed step size to 0.001s (usually a small time step compared to the natural period of
the system).

Congratulations! The Simulink model is now complete.

input_disp.mat

To File1

Step

Stiffness

Spring
Force

1/m

Mass

Velocity

1
s

Acceleration

Velocity

Scope

Integrator1

Integrator
Damping
Constant

1
s

c
Position

Damping Force

Step1

disp.mat

To File

MIE397B

Page 7 of 12

Fall 2007

MATLAB File
This program defines parameters, executes the simulation for the given parameters,

and the plot results.


% Simulink Model of a Simplified Automobile Suspension
% % denotes comments
%
% Created by Abhijit Ganguli, September 2007.
%
% This program sets up variables, simulates response of the
% cars suspension when hitting a pothole, and plots the results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define present working directory
% (the directory where your Simulink model is saved)
cd g:\simulink\
% Define pothole size in the simulation
clear all; % clears workspace
m = 1000; % Mass of car (kg)
k = 1000; % Stiffness of spring (N/m)
c = 100; % Damping parameter (Ns/m)
V = 20; % Velocity of car (m/s)
holedepth=0.15; % Depth of hole (m)
hole_width=1; % Width of hole (m)
holestart = 450;
hstart =holestart/V; % Time at which the tire enters the hole
hend = (holestart+hole_width)/V; %% Time at which the tire comes out of the hole
% Run Simulink
% sim('filename') runs the Simulink model defined in the file filename
sim('suspension_model1');
load disp1.mat; % Load the displacement results file
load input_disp.mat; %Load the input data file
% Plot Results
% the command figure(n) define which figure to put the results.
figure(1);
% The command subplot(m,n,p) allows for multiple graphs
% to be plotted in the same figure where the figure is
% divided into a m x n matrix where the current plot is
% placed in the position defined by p.
subplot(2,1,1);
% plot(x) plots the variable x.
% Plot the input stimulus
plot(input_disp(1,: ),input_disp(2,:));
% Plot the system response
subplot(2,1,2);
plot(disp1(1,:),disp1(2,:));

MIE397B

Page 8 of 12

Fall 2007

2) Results
Varying dampening coefficient c

- When the dampening coefficient is increased, the amount of reverberation that


occurs in the system is decreased.
9 Parameters: k=500, c=10.
This figure shows how a lack of dampening would result in an
uncomfortable ride.
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

0.01
0.005
0
-0.005
-0.01

9 Parameters: k=500, c=100.


This system shows improved damping characteristics
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

-3

x 10

-5

MIE397B

Page 9 of 12

Fall 2007

9 Parameters: k=500, c=1000.


This large dampening leads to hardly any reverberations and
small displacement.
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

-3

x 10

0
-1
-2
-3

Varying Spring Constant k

- Varying the spring constant k affects the frequency of the system response.
9 Parameters: k=50, c=100.
Due to the small spring constant, the system does not respond
swiftly to external excitation.
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

-3

x 10

-1

-2

MIE397B

Page 10 of 12

Fall 2007

- Parameters: k=500, c=100.


9 The increased spring stiffness results in higher frequency vibrations of
greater magnitude.
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

-3

x 10

-5

- Parameters: k=5000, c=100.


9 On the other extreme: this highly stiff spring responds very quickly at the
cost of excessive changes in vertical travel for the passenger in the car.
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

0.02
0.01
0
-0.01
-0.02

MIE397B

Page 11 of 12

Fall 2007

Optimal Solution: Lower displacement and minimal reverberation


9 Parameters: k=500 c=3000
0
-0.05
-0.1
-0.15
-0.2

10

20

30

40

50

60

70

80

90

100

10

20

30

40

50

60

70

80

90

100

-3

x 10

-0.5

-1

-1.5

Matlab Example for trajectory tracking of a projectile


% Program to track the trajectory of a projectile
clear all;
% Clears variables in the workspace
% Launch velocity of the projectile (m/s)
V=20;
alpha=45*pi/180; % Angle of launch
g = 9.8;
% Gravitational Acceleration (m/s^2)
vx=V*cos(alpha); % Horizontal velocity of projectile
vy=V*sin(alpha); % Initial Vertical velocity of projectile
tof = 2*V*sin(alpha)/g; % Time of flight
t=[0:0.001:tof];
% Time instants
ux=vx*t;
% Horizontal Displacement
uy=vy*t-0.5*g*t.^2; % Vertical displacement
figure(1)
plot(t,ux,'c');
hold on;
plot(t,uy,'c--');

MIE397B

Page 12 of 12

Fall 2007

You might also like