Modeling a First Order System in Simulink

Free Body Diagram and System Equation
Building System Model
System Response to Step/Pulse Inputs
Additional Examples


The idea behind these tutorials is that you can view them in one window while running Simulink in another window.  Do not confuse the windows, icons, and menus in the tutorials for your actual Simulink windows.  Most images in these tutorials are not live - they simply display what you should see in your own Simulink windows.  All Simulink operations should be done in your Simulink windows.


Free Body Diagram and System Equation

To demonstrate how Simulink can be used to investigate a real-world system, we will look at a simplified, first-order model of the motion of a car.  If we assume the car to be travelling on a flat road, then the horizontal forces on the car can be represented by:

In this diagram:

Writing Newton's Second Law for the horizontal direction thus gives:

For our system, we will assume that:

M = 1000 kg  (a Dodge Neon has a mass of about 1100 kg)
b = 40 N*sec/m

Building System Model

This system will be modeled in Simulink by using the system equation derived above.   This equation indicates that the car's acceleration (dv/dt) is equal to the sum of the forces acting on the car (F-bv) divided by the car's mass:

To model this equation, we begin by inserting a Sum block and a Gain block (both found in the Math subfolder of the Simulink folder in the Library Browser) into a new model window. The Sum block represents adding together the forces and the Gain block symbolizes dividing by the mass. Connecting the blocks with a line gives the following in the model window:

Next, we modify these blocks to properly represent our system.  The Sum block needs to add the motor force (F) and subtract the damping force (bv).  Thus, we double-click on this block and change the second "+" in the "List of signs" box into a "-".  The Sum Block Parameters window should now look like:

We also modify the Gain block so that it divides by the car's mass.  Double-click on the block and change the Gain to 1/1000 (dividing by 1000 is the same as multiplying by 1/1000).

To keep our block diagram organized and easy to understand, we next add labels to the signals and blocks we have included so far.  A signal is labeled by double-clicking on its line and entering the desired description into the text box that appears.  These labels can be moved by dragging the text boxes to their desired location on the lines.  A block is labeled by clicking on the text underneath it and editing the description. 

Draw lines to the open input terminals of the Sum block and open output terminal of the Gain block and label the signals and blocks in the model so that they look like:

To relate the car's acceleration (v_dot in the Simulink model) to its velocity-dependent damping force, we will integrate the v_dot signal.  Place an Integrator block (from the Continuous subfolder) in the model (you do not need to change its parameters), and draw and label the velocity signal so that the model looks like:

To obtain the damping force from the velocity, we need to branch the velocity signal and multiply it by the damping coefficient (b).  Branching the velocity signal is done by clicking the right mouse button anywhere on its line (or hold down CTRL and use the left mouse button) and dragging away a new signal.  A Gain block is then used to multiply the velocity by the damping coefficient.  Add this block to the model (from the Math subfolder) and flip it to so that it outputs to the left by clicking on Format then Flip Block (the Gain block must be selected in the model window when this is done).  Finally, edit the Gain block's parameters so that its gain equals the damping coefficient of the system (40 N*sec/m).  These additions to the model should cause it to look like:

Note that the block diagram is now set up with input F (engine force) and output v (car velocity). 

System Response to Step/Pulse Inputs

Step Input

To be able to successfully simulate the system, we need to specify an applied input, F.  Let us assume the car is initially at rest, and that the engine applies a step input of F = 400 N at t = 0.  This is approximately equivalent to the car's driver quickly pushing down and holding the gas pedal in a steady position starting from a stoplight.  Insert a Step block from the Sources subfolder into the model, and also add a Scope block from the Sinks subfolder to monitor the system's velocity, v.  The Simulink model window should now look like:

The Step block must be modified to correctly represent our system.  Double-click on it, and change the Step Time to 0 and the Final Value to 400.  The Initial Value can be left as 0, since the F step input starts from 0 at t = 0.  The Sample Time should remain 0 so that the Step block's input is monitored continuously during simulation.

Next, run a simulation of the system (by clicking the "Start/Pause Simulation" button or selecting Simulation, Start).   Once the simulation has finished, double-click on the Scope block to view the velocity response to the step input.  Clicking on the "Autoscale" button (looks like a pair of binoculars) in the Scope window will produce the following graph:

Note that this graph does not appear to show the velocity approaching a steady-state value, as we would expect for the first-order response to a step input.  This result is due to the settling time of the system being greater than the 10 seconds the simulation was run.  To observe the system reaching steady-state, click Simulation, Parameters in the model window, and change the Stop Time to 150 seconds.  Now, re-run the simulation and note the difference in the velocity graph:

From this graph, we observe that the system has a steady-state velocity of about 10 m/s (about 22 mph), and a time constant of about 25 seconds.  Let's check these results with our original equation.  For a step input of F = 400 N, the system equation is:

Setting dv/dt = 0 gives a steady-state velocity of 10 m/s, a result which agrees with the velocity graph above.  Next, we find the time constant of the system using the characteristic equation, which is:

Solving this gives the characteristic root, s = -0.04, and thus the time constant is indeed 25 seconds (tau = -1/s), as we predicted using the graph.

Pulse Input

Now, we consider the response of the system if a pulse, instead of a step, input is applied.  This is approximately equivalent to the car's driver pressing and holding the gas pedal in a constant position for a specified period of time, and then releasing the pedal.  To model a pulse input using Simulink, insert another Step block and a Sum block in the system as shown:

The parameters for the original "Step" block can be left as they were before.   Modify the "Step1" block parameters to the following:

Step Time = 100
Initial Value = 0
Final Value = -400

These settings enable the "Step1" block to cancel out the input from the "Step" block starting at t = 100.

To monitor the input of the system, F, we insert another scope into the model window as shown below:

Modify the simulation time (found by going to Simulation, then Parameters) to 200 seconds, then run the simulation.  After autoscaling the scopes recording the F and v signals, you should see graphs that look like:

                  

A couple of important features of the system are visible from comparing the input and output plots above.  First of all, as we stated previously, the time constant of the system is 25 seconds.  Thus, the time it will take for the system to reach steady-state (the settling time) should be about 100 seconds (4 * time constant).  At t = 100 seconds in the simulation, the system is within 2% of its steady-state response to the original step input of 400 N.  When F is instantaneously reduced to 0 at t = 100 seconds, it takes the system another 100 seconds (until t = 200 seconds) to respond to this new input.  Also, notice that the steady-state response of the system to an input of F = 0 is v = 0.  Physically, this means that if the driver of the car drops the accelerator while moving at any speed, the car will eventually come to rest.

Additional Examples

Variations of the mass-damper problem we have been studying can be found by following the links below:

First Order System:  Ramp Response
First Order System:  Linearizing System Equation
First Order System:  System Identification

Author:  RDM
Updated: 5/18/00