0% found this document useful (0 votes)
53 views

V' 1/m (F (T) - B V) : Creating The Model

This document describes how to create a Simulink model to simulate the response of a truck pulling a trailer. The model represents the system using a differential equation that relates the velocity and acceleration of the truck. The document explains how to construct the model blocks to represent the integration of acceleration to get velocity, damping force proportional to velocity, summation of forces, and calculation of acceleration from the net force. It also provides instructions for simulating the step response and sinusoidal response of the modeled system.

Uploaded by

Jorge Choque
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

V' 1/m (F (T) - B V) : Creating The Model

This document describes how to create a Simulink model to simulate the response of a truck pulling a trailer. The model represents the system using a differential equation that relates the velocity and acceleration of the truck. The document explains how to construct the model blocks to represent the integration of acceleration to get velocity, damping force proportional to velocity, summation of forces, and calculation of acceleration from the net force. It also provides instructions for simulating the step response and sinusoidal response of the modeled system.

Uploaded by

Jorge Choque
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

In Simulink it is very straightforward to represent a physical system or a model.

In
general, a dynamic system can be constructed from just basic physical laws. We will
demonstrate through an example.

In this example we will again consider a truck pulling a trailer. This example problem
can be modeled as a sliding block where the friction acts as a velocity dependant force,
with a coefficient B.

The governing equation gathered from the free body diagram is:

f(t) - m v' - b v = 0

which can be rearranged to find an expression for x".

v' = 1/m [ f(t) - b v ]

CREATING THE MODEL

To begin the construction of the Simulink model, we must first start Simulink and open a
new model window. To start Simulink, type simulink at the MATLAB prompt, or click
on the icon.

To start a new model in Simulink, click File on the Simulink Library Browser window's tool
bar, click on New and then click on Model or equivalently type Ctrl+N.
CONSTRUCTING THE DERIVATIVE RELATIONS

A first order system is one that is governed by a differential equation that consists of
only a variable and its first derivative. The first step in creating a model of this system is
to create the relation between the velocity and its first derivative, which is acceleration.
Since velocity is the integral of acceleration, place an integrator block in the model. In
the Simulink Library Browser expand Simulink. Then single-click on Continuous. Then drag
an Integrator block into the Simulink model.
The input of this integrator is v' and the output is v. Add lines coming in and out of the
integrator and label them by double clicking on them and typing in the text box. Also
label the integrator by double clicking on its name and changing it.

CONSTRUCTING THE DAMPING FORCE

Now construct the signal representing the damping force. The damping force is v
multiplied by the damping constant. We can pull v from the output of the Integration
from v' to v block. The Simulink equivalent to multiplication is the Gain block. From the
Simulink Library Browser window add a Gain block by expanding Simulink and then
clicking on Math Operations and then dragging the Gain block into the model.
The number inside the triangle indicates the gain of the Gain block. To change the gain
of this Gain block from 1 to b, right click on the Gain block and click on Gain parameters...
A new window labeled Block Parameters: Gain will pop up. Change the value in the field
for Gain from 1 to b.
Clicking OK will return you to the Simulink Model window.

The input of the Gain block is currently on the left side. To make the line connection
simpler, we would like the input of the Gain block to be on the right. To flip a Gain
block, right click on the block and select Format and select Flip block.
Also it may be useful to relabel this Gain block Damping Coefficient. Do so by clicking
on the title and typing in the text box that opens.

In order to multiply v with the Damping Coefficient to calculate the damping force, we
need to drag a line from the input of the Damping Coefficient to the line marked v. Be
sure it connects to the line with the small rectangle as shown.
The damping force is now the output of the Damping Coefficient block. Drag a line out
of the output and label it Damping Force.

SUMMING OF FORCES

The governing equation shows that two forces sum to form the total force on the body --
one external force and the Damping Force created above. Summation uses the Sum
block. From the Simulink Library Browser window, expand Simulink and click on Math
Operations and then scroll down in the right column to find Sum. Drag the Sum block into
the model.
The default Sum block has two positive inputs. This system has one positive input and
one negative input. To change the polarity of an input, right click on the Sum block and
select Sum parameters.... A new window titled Block Parameters: Sum will open up. In the
field marked List of signs change the value from |++ to |+-.

Selecting OK will return you to the model.


It is useful to name the Sum block. To turn on the naming of the Sum block, right click
on the block and select Format and then select Show name. Change the name by clicking
on it and typing in the text box.

Now the name of the Sum block is in the way of one of the input terminals. To flip the
name to the top of the block, right click on the block and select Format and select Flip
name.
Now to connect the Damping Force to the negative input terminal of the Sum block,
drag the end of the arrow labeled Damping Force to a negative input of the Sum block.

The second input of our Sum block is reserved for the external force. Different analyses
of this system use different sources for the applied force. Simply draw a line out of the
positive input of the Sum block and label it External Forces. Later on, the output of a
source will attach to this arrow.
The output of the Sum block is the Sum of all of the forces acting on the system. Draw
a line out of the input and label it Sum of All Forces.

CREATING V'

From Newton's Law, the Sum of All Forces is equal to mv'. So dividing the sum of all
forces results in v'. To multiply the Sum of All Forces by 1/m, add a Gain block with
value 1/m.
Change the value of the Gain block from 1 to 1/m.

The block is too small to display the value of the gain. Enlarge the block slightly by
clicking on it and dragging the corner rectangles. Also it is beneficial to rename this
Gain block Division by m.
Now connect the line labeled Sum of All Forces to the input of Division by m, and
connect the line marked v' to the output of Division by m.

Save the model by selecting File in the toolbar of the model and selecting Save as....

The finished Simulink model can be downloaded here: first.mdl

The model is now complete and ready for running.

RUNNING THE MODEL

Many useful analyses of the model can be done using Simulink. Before the model can
be run, values for the variables used in the model must be defined. We will use the
same values used in the Transfer Function and State Space Model sections of this first
order example problem. Enter the following values into the MATLAB window prompt.
Note: Simulink reads variable values directly from MATLAB commands.

>> m = 20000;

>> b = 500;
SIMULATING THE STEP RESPONSE

Once the model has been created in MATLAB it is easy to simulate the response to a
step input. In order to simulate the step response you need to add a source to provide
the external force, and you need a sink to view the response of the system. In the
Simulink Library Browser window, expand Simulink and click on Sources and then drag the

Stepsource from the right column into the model. Connect the tail of the arrow
labeled External Forces to the Step source output.

To monitor the value of x add a scope sink. Go to the Simulink Library Browser window,

expand Simulink, click on Sinks, and then drag the Scope sink from the right column
into the model. Connect the head of the arrow labeled x to the Scope sink.
The default parameters for the Step source are a Step time of 1, an Initial value of 0, a
Final value of 1, and a Sample time of 0. To change the parameters of the Step source,
right click on the Step source and select Step parameters.... In the Block Parameters: Step
window that opens up, change the parameters to whatever is desired. We will use the
same values as used in the Transfer Function and State Space Model sections of this
example problem. To find the response to a step input of magnitude 20,000N with the
step starting at time t=0, change the parameters to the following: a Step time of 0, an
Initial value of 0, a Final value of 20000, and a Sample time of 0.
To run the simulation, click Simulation in the tool bar and select Start, or equivalently hit
Ctrl+T on the keyboard, or click the button on the tool bar.

To view the output of the Scope sink which is monitoring the value of x, double click on
the Scope in the model. The following plot of the step response will appear in a new
window.

To autoscale the plot, click on the button.

As you can see, the autoscale function did not pick an appropriate set of axes for this
plot. The default Simulation time is set at 10 seconds, which is not long enough to
display important features of the response. To change the Simulation time, click on
Simulation on the model toolbar, and select Simulation parameters. In the Simulation
Parameters: First window that pops up, change the Stop time to 250 seconds.
Running the simulation again and selecting autoscale yields the following plot of the
step response.
SINUSOIDAL RESPONSE

To find the sinusoidal response of a model, the source should be either a signal
generator source or a sine wave source, and the sink should be a scope. Before adding
any new source, first delete any existing source by clicking on it and hitting delete on
your keyboard.

The sine wave source allows a bias input which enables one to find the sinusoidal
response about a nonzero speed, which is more appropriate for a truck. To add a sine
wave source, expand Simulink in the Simulink Library Browser window and select Sources

and then drag the Sine Wave source into the model and connect its output to the tail
of the arrow labeled External Forces. Add the Scope using the same method
prescribed from above when finding the Step Response.

To set the signal output of the Sine Wave source, double click on the Sine Wave
icon. To model the response of the truck to a constant throttle input of 10,000N which
has a sinusoidal variation of +/-5000N with a frequency of 0.05Hz, change the values as
shown below.
Be sure the values for the variables m, and b have been defined in the MATLAB
Command Window. Once the input, the output, and all of the variables have been
defined, the model can be run.

To run the simulation, click Simulation in the tool bar and select Start, or equivalently hit
Ctrl+T on the keyboard, or click the button on the tool bar. Make sure your Simulation
time is set to 250 seconds.

To view the output of the Scope sink which is monitoring the value of v, double click on
the Scope in the model and click autoscale. The following plot of the sinusoidal
response will appear in a new window.
The response really hasn't reached a steady state. The simulation time is still too
short. Also the curve appears to be jagged because the step size is too big.

To observe the steady state response more clearly, change the simulation time to 400
seconds and change the step size to approximately 1/20th of the period of the sine
wave. In this case the period is 20 seconds, so the step size should be 1 second.

To change the step size of the simulation, click Simulation in the model tool bar and
select Simulation parameters.... Alternately you can press Ctrl+E to bring up the Simulation
Parameters window. Change the Max step size to 1.
Running the simulation again and autoscaling yields to following plot.

To look more closely at the steady state response, zoom in to the time period between
300 and 400 seconds by using the zoom x button , and between 18 and 22 m/s by
using the zoom y buttom .
OBTAINING THE MATLAB MODEL

MATLAB can extract the matricies of a state space representation of a Simulink model
by using the linmod command.

The syntax for the linmod function is:

>> [ A, B, C, D ] = linmod('system')

where A, B, C, and D are from the standard vector-matrix form of a state space model
and system is the name of the Simulink model.

In order to use the linmod command with a Simulink system, the sources and sinks
need to be changed. To delete any existing sources and sinks, simply click on them
and hit the delete key on your keyboard.

The correct source to run linmod is the subsystem input. To insert this source, go to
the Simulink Library Browser window, expand Simulink, click on Sources, and find the
source In1 and drag it into the system.
The correct sink to run linmod is the subsystem input. To insert this sink, go to the
Simulink Library Browser window, expand Simulink, click on Sinks, and find the sink Out1
and drag it into the system.
Be sure the values for the variables m, and b have been defined in the MATLAB
Command Window. Once the input, the output, and all of the variables have been
defined, the MATLAB model can be obtained.

In the case of our tutorial:

>> [ A, B, C, D ] = linmod('first')

This defines A, B, C, and D as matricies that define a state space model in standard
vector-matrix form and outputs the following:

A =

-0.0250

B =

5.0000e-005

C =

1.0000

D =

You might also like