Project
Control Engineering
Complex engineering problem
Model the cruise control system
Secton (B
Name: Reg no.
Asad irshad UET/SCET-17F-ME-074
Submitted to:
Engr. Ahsan rafiue
SWEDISH COLLEGE OF ENGINEERING AND
TECHNNOLOGY, WAH CANTT
Model the cruise control system? Modelling should include.
Physical setup: Automatic cruise control is an excellent example of a feedback control system found in many
modern vehicles. The purpose of the cruise control system is to maintain a constant vehicle speed despite
external disturbances, such as changes in wind or road grade. This is accomplished by measuring the vehicle
speed, comparing it to the desired or reference speed, and automatically adjusting the throttle according to a control
law.
We consider here a simple model of the vehicle dynamics, shown in the free-body diagram (FBD) above. The vehicle,
of mass m, is acted on by a control force, u. The force u represents the force generated at the road/tire interface. For
this simplified model we will assume that we can control this force directly and will neglect the dynamics of the
powertrain, tires, etc., that go into generating the force. The resistive forces, Bv, due to rolling resistance and wind
drag, are assumed to vary linearly with the vehicle velocity, v, and act in the direction opposite the vehicle's motion.
System eiuatons:
With these assumptions we are left with a first-order mass-damper system. Summing forces in the x-direction and
applying Newton's 2nd law, we arrive at the following system equation:
Since we are interested in controlling the speed of the vehicle, the output equation is chosen as follows
System parameters:
For this example, let's assume that the parameters of the system are:
(m) Vehicle mass 1000 kg
(b) Damping coefficient 50 N.s/m
State-space model:
First-order systems have only a single energy storage mode, in this case the kinetic energy of the car, and therefore
only one state variable is needed, the velocity. The state-space representation is therefore:
We enter this state-space model into MATLAB using the following commands.
m = 1000;
b = 50;
A = -b/m;
B = 1/m;
C = 1;
D = 0;
cruise_ss = ss (A,B,C,D);
Transfer functon model:
Taking the Laplace transform of the governing differential equation and assuming zero initial conditions, we find the
transfer function of the cruise control system to be:
We enter the transfer function model into MATLAB using the following commands:
s = tf ('s');
P_cruise = 1/ (m*s+b);
Matlab simulaton:
Using Newton's 2nd law, the governing equation for this system becomes:
Where u is the force generated between the road/tire interfaces and can be controlled directly. For this example, let's
assume that
m = 1000 kg
b = 50 N.sec/m
u = 500 N
(uilding the model:
This system will be modeled by summing the forces acting on the mass and integrating the acceleration to give the
velocity. Open Simulink and open a new model window. First, we will model the integral of acceleration.
Insert an Integrator block (from the Continuous library) and draw lines to and from its input and output
terminals.
Label the input line "vdot" and the output line "v" as shown below. To add such a label, double click in the
empty space just above the line.
Since the acceleration (dv/dt) is equal to the sum of the forces divided by mass, we will divide the incoming signal by
the mass.
Insert a Gain block (from the Math Operations library) connected to the Integrator block input line and draw a
line leading to the input of the Gain block.
Edit the Gain block by double-clicking on it and change its value to "1/m".
Change the label of the Gain block to "inertia" by clicking on the word "Gain" underneath the block.
Now, we will add in the forces which are represented in Equation (1). First, we will add in the damping force.
Attach a Sum block (from the Math Operations library) to the line leading to the inertia Gain block.
Change the signs of the Sum block to "+-".
Insert a Gain block below the Inertia block, select it by single-clicking on it, and select Flip Block from
the Rotate & Flip menu (or type Ctrl-I) to flip it left-to-right.
Set the block's value to "b" and rename this block to "damping".
Tap a line (hold Ctrl while drawing) off the Integrator block's output and connect it to the input of the
damping Gain block.
Draw a line from the damping Gain block output to the negative input of the Sum Block.
The second force acting on the mass is the control input, u. We will apply a step input.
Insert a Step block (from the Sources library) and connect it with a line to the positive input of the Sum
Block.
To view the output velocity, insert a Scope block (from the Sinks library) connected to the output of the
Integrator.
The physical parameters must now be set. Run the following commands at the MATLAB prompt:
m=1000;
b=50;
u=500;
Run the simulation (hit Ctrl-T or select Run from the Simulation menu). When the simulation is finished you should
see the following output.
Extractng a Linear Model into MATLA(:
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.
Replace the Step Block and Scope Block with an In Connection Block and an Out Connection Block, respectively
(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 "ccmodel.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 ('ccmodel')
[numden]=ss2tf (A, B ,C ,D)
You should see the following output, providing both state-space and transfer function models of the system.
A =
-0.0500
B =
1.0000e-003
C =
1
D =
0
num =
0 0.0010
den =
1.0
0.0500
To verify the model extraction, we will generate an open-loop step response of the extracted transfer function in
MATLAB. We will multiply the numerator by 500 to simulate a step input of 500N. Enter the following command in
MATLAB. Step (500*num, den);
You should see the following plot which is equivalent to the Scope's output.
Implementng PI control:
In the cruise control example a PI controller was designed with KP=800 and Ki=40 to give the desired response. We
will implement this in Simulink by first containing 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 Cruise Control system, ccmodel.mdl.
a. Select All from the Edit menu (or Ctrl-A), and select Copy from the Edit menu (or Ctrl-C).
b. 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. Close this window.
c. You should now see input and output terminals on the Subsystem block. Name this block "plant model".
Now, we will build a PI controller around the plant model. First, we will feed back the plant output.
• Draw a line extending from the plant output.
• Insert a Sum block and assign "+-" to its inputs.
• Tap a line of the output line and draw it to the negative input of the Sum block
The output of the Sum block will provide the error signal. From this, we will generate proportional and integral
components.
• Insert an integrator after the summer and connect them with a line.
• Insert and connect a gain block after the integrator to provide the integral gain.
• Label this integrator Ki and assign it a value of Ki.
• Insert a new Gain block and connect it with a line tapped off the output of the Sum block.
• Label this gain KP and assign it a value of KP.
You can download our version of the closed-loop system here.
In this example, we constructed a PI controller from fundamental blocks. As an alternative, we could have used a
Transfer Function block (from the Linear block library) to implement this in one step, as shown below.
Closed-loop response:
To simulate this system, first, an appropriate simulation time must be set. Select Parameters from the Simulation
menu and enter "10" in the Stop Time field. The design requirements included a rise time of less than 5 sec, so we
simulate for 10 sec to view the output. The physical parameters must now be set. Run the following commands at the
MATLAB prompt:
m=1000;
b=50;
u=10;
KP=800;
Ki=40;
Run the simulation (Ctrl-t or Start on the Simulation menu). When the simulation is finished, double-click on the scope
and hit its auto scale button. You should see the following output.