Automatic Cruise Control

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

University of Engineering and Technology Taxila

Department of Electronic Engineering

Control System Case Study


CRUISE CONTROL SYSTEM
Submitted to:
Dr. Hammad Zaki
Submitted by:
I. Rehman Abbas (19-ENC-15)
II. Muhammad Waqas (19-ENC-16)
III. Nouman Afzal (19-ENC-30)

Dated:19-06-20222
1
Table of Contents
1. Automatic Cruise Control ...................................................................................................................... 3
I. Abstract ............................................................................................................................................. 3
II. Introduction ...................................................................................................................................... 3
III. Literature Review .......................................................................................................................... 4
2. Applications In Real Life ........................................................................................................................ 5
3. Modeling ............................................................................................................................................... 5
I. Mathematical Modeling.................................................................................................................... 5
II. State Space Model ............................................................................................................................ 6
4. Analysis ................................................................................................................................................. 7
III. Open Loop Step Response ............................................................................................................ 8
IV. Open Loop Poles And Zeros .......................................................................................................... 8
5. PID Design ........................................................................................................................................... 10
I. Overview Of PID .............................................................................................................................. 10
II. Propertionl Control ......................................................................................................................... 11
III. PI Controller ................................................................................................................................ 15
IV. PID Controller .............................................................................................................................. 17
V. Root Locus ....................................................................................................................................... 20
VI. Proportional control.................................................................................................................... 20
6. Lag Controller ...................................................................................................................................... 25
7. State space Equations(Models)........................................................................................................... 29
I. Control Design using Pole placement ............................................................................................. 29
II. System Reference_input ................................................................................................................. 32
8. Simulink Model ................................................................................................................................... 33
I. Controller Design ................................................................................................................................ 35
II. Implementation of PI control ......................................................................................................... 37
III. Closed-loop response.................................................................................................................. 39
9. Conclusion ........................................................................................................................................... 41
10. Reference’s ......................................................................................................................................... 41

2
1. Automatic Cruise Control
I. Abstract
This report deals with simulation of car system having cruise control in it present. The basic
purpose of cruise control is to keep the velocity of a moving car constant.So, the driver in the
car moves at desired speed but when it activates the cruise control by pushing the button,the
car moves at constant speed. The report also includes the design of autonomous cruise control
(ACC) which was implemented on a car system using PID controller. An important feature of
the autonomous cruise control system is its ability to keeps a competent inter-vehicle gap
based on the speed of host vehicle and headway. There are three major inputs to the ACC
system i.e speed of host vehicle read from Memory unit, headway time set by driver, and actual
gap measured by the Radar scanner. The system is been adapted with the velocity control at
urban environments avoids lighten possible accidents. This paper deals with the mathematical
modelling, analysis, and design of the controller performing actions on the longitudinal control
of a car system to execute stop-and-go manoeuvres.

Keywords: Car System, Cruise Control, PID controller

II. Introduction
Science has traditionally been concerned with describing nature using mathematical symbols and
equations. Applied mathematicians have traditionally been studying the sort of equations of
interest to scientists. More recently, engineers have come onto the scene with the aim of
manipulating or controlling various processes. They introduce (additional) control variables and
adjustable parameters to the mathematical models. In this way, they go beyond the traditions of
science and mathematics, yet use the tools of science and mathematics and, indeed, provide
challenges for the next generation of mathematicians and scientists [1].

[1] S. Moon, I. Moon, and K. Yi, “Design, tuning and evaluation of a full range adaptive cruise
control system with collision avoidance,” Control Eng. Pract., vol. 17, pp. 44 K. M. Passino,
“Biomimicry of bacterial foraging for distributed optimization,” IEEE Control Systems Magazine,
vol. 22, no. 3, pp. 52-67, 2002.

3
Autonomous control system is one of the advanced car systems in modern era. It becomes so
popular that almost in all the automobiles, it becomes a vital and common feature in nowadays.
Instead of frequently checking out the speedometer and adjusting pressure, Autonomous control
system takes over the control the speed of the car by maintaining the constant speed set by the
driver. Therefore, this system can help in reducing driver’s tiredness in driving a long road trip.

The process of autonomous cruise control works in such a way that firstly the driver sets the desired
speed by turning on the cruise control in such a way desired speed is attained. Secondly, as long
as the processing unit receives input signal, it responds to output i.e actuator. The actuator at last
adjusts the position of accelerator by using controller.The car attained the desired speed but the
actuator continuously monitored the actual speed by using sensor and send it into processing unit.
The process of transmitting the current speed of the car continues to the processor to maintaining
the desired speed, as long as the cruise control is engaged.For example, if we take an example of
car which works on the principle of cruise control. Firstly, we will look on the free body diagram
and will look at the forces acting on the car. Mass of car is 𝑚,u is force acted on car. This force is
between road and tyre. 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.

III. Literature Review

In the next few years, the way we use cars will radically change. According to the book
Reinventing the Automobile: Personal Urban Mobility for the 21st Century (Mitchell et al., 2010),
a paradigm shift is necessary to change the ways we look at cars. The developments during the
recent century results in the way cars are used at present. From the beginning of the 20th century,
the car was invented as a motorized coach without horses. But now today from that starting point,
the car has developed a lot. Hundreds of new features added which makes its importance a bit
higher then other technology. But for more development in it,to make the car fit the needs of the
user in the 21st century, we cannot depends on the cars as they are now today. To add an important
feature is for example the way cars are controlled. Until now, cars were manually driven by their
drivers, , just like the coachmen a century ago. Now the centre of attention is that a driver who is

4
in charge and takes decisions on its own changes, to a car which is capable of executing tasks on
its own. A slow, steady transition is necessary and likely towards this new, 21st-century car and
it does not take place suddenly. Noticeable is that this transformation has already started. At
present, different stakeholders finding the best possibilities, all in their own field of expertise. For
car manufacturers for example, driver comfort and safety are very important goals. Keeping this
in mind, car manufacturers are designing new systems that are capable of performing driving tasks
in place of the driver. An example of such a new system designed to assist the driver is Autonomus
Cruise Control (ACC). ACC is an expansion of the common cruise control

2. Applications In Real Life


In cars, ships, airplanes etc.

3. Modeling
I. Mathematical Modeling
Summing the forces of one direction and using Newton’s Second Law:

𝐹 = 𝑚𝑎

𝑢 − 𝑏 ∗ 𝑣 = 𝑚𝑎

𝑢 = 𝑚𝑎 + 𝑏 ∗ 𝑣

Using Laplace Transformation:


𝐹(𝑠) = 𝐿{𝑓(𝑡) = ∫ 𝑓(𝑡)𝑒 −𝑠𝑡 𝑑𝑡


0

5
𝑑
𝐿{ } = 𝑠𝑌(𝑠) − 𝑌(0)
𝑑𝑡

𝑑𝑣
𝑢(𝑡) = 𝑚 +𝑏∗𝑣 ℎ𝑒𝑟𝑒 𝑣(0) = 0
𝑑𝑡

Here we used integration technique to convert time domain into frequency technique:

𝑑𝑣
𝑢(𝑠) = 𝐿{𝑢(𝑡)} = {𝑚 + 𝑏 ∗ 𝑣}
𝑑𝑡

𝑢(𝑠) = 𝑚[𝑠 ∗ 𝑣(𝑠) − 𝑣(0)] + 𝑏 ∗ 𝑣(𝑠)

𝑢(𝑠) = 𝑚 ∗ 𝑠 ∗ 𝑣(𝑠) + 𝑏 ∗ 𝑣(𝑠)

𝑢(𝑠) = 𝑣(𝑠)[𝑚 ∗ 𝑠 + 𝑏]

So the open loop transfer function of Cruise control will be:

𝑣(𝑠) 1 𝑚
𝑃(𝑠) = = [( )/𝑁]
𝑢(𝑠) 𝑚 ∗ 𝑠 + 𝑏 𝑠

II. State Space Model


We entered state space model in matlab using following piece of code. For that firstly we defined
system parameters which are following.

Assumed parameters mass of vehicle 1000 kilo grams ,damping coefficients 50N.s/m and
reference speed of our system is 10 milli per second

And matlab code is;

6
Now we entered the transfer function into matlab using following code;

4. Analysis
Assumed system parameters are following.

Assumed parameters mass of vehicle 1000 kilo grams ,damping coefficients 50N.s/m and
reference speed of our system is 10 milli per second

Next, we will we define the specification criteria of compensator. For example, we define that
when car engine gives a force of 500N the reaches a maximum velocity of 10m/s. For a car to gain
such speed 5 seconds of time are sufficient. So, 10% overshoot and 2% steady state error in
velocity are sufficient. So, by keeping this specification we defined some parameters as following.

Performance Specifications:

Risetime less than 5 s ,Overshoot less than 10% ,SS error less than 2%

For this specification we developed a system with open loop response without feedback to
unit step input of force of 500N will be;

7
III. Open Loop Step Response

Step Response Output:

From the open loop step response we saw that there is no overshoot and our system reached the
desired steady state speed of 10 m/s. Here rise time is too much slow therefore we need to design
a feedback controller that speeds up the response significantly without negatively effecting the
other dynamic performance matrixes.

IV. Open Loop Poles And Zeros


P-Z map of open loop system code
8
Output:

As shown in p-z map there is only one pole and that is present in left half of the plane and our
system is stable and does not oscillate and also pole is real and negative so we cannot change the
system parameters to change the response of the system. So we must need to design a controller
part which alters is poles and zeros of closed loop system to made the desired performance
specifications.

9
5. PID Design
System model and parameters:

Transfer function of the cruise control system is given below;

𝑣(𝑠) 1 𝑚
𝑃(𝑠) = = [( )/𝑁]
𝑢(𝑠) 𝑚 ∗ 𝑠 + 𝑏 𝑠

Assumed parametres;

Assumed parameters mass of vehicle 1000 kilo grams ,damping coefficients 50N.s/m and
reference speed of our system is 10 milli per second

Performance Specifications:

Risetime less than 5 s ,Overshoot less than 10% ,SS error less than 2%

Overview of PID controller:

Block diagram of typical unity feedback system is given below.

I. Overview Of PID

Transfer function of our PID controller is given below.

𝐾𝑖 𝐾𝑑 𝑠 2 + 𝐾𝑝 𝑠 + 𝐾𝑖
𝐶(𝑠) = 𝐾𝑝 + + 𝐾𝑑 𝑠 =
𝑠 𝑠

Now we will define a PID controller using following code in matlab;

10
Output:

x=

s^2 + s + 1

-----------

Continuous-time transfer function.

II. Propertionl Control


To design a controller we find the open loop transfer function with proportional control added.

By replacing unity feedback with proportional controller the transfer function becomes.

𝑌(𝑠) 𝑃(𝑠). 𝐶(𝑠) 𝐾𝑝


𝑇(𝑠) = = =
𝑅(𝑠) 1 + 𝑃(𝑠). 𝐶(𝑠) 𝑚𝑠 + 𝑏 + 𝐾𝑝

From the theory of proportional controller we know that 𝐾𝑝 decrease the rise time so this is
desirable in this case.

Matlab code:

11
Output:

Closed loop Transfer Function of proportional controller:

W=

100

------------

1000 s + 150

12
Continuous-time transfer function.

In matlab, we use feedback command to simplify the block diagram reduction of the closed loop
system.

In the graph we see that both steady state error and rise time cannot satisfied our required design
criteria.so we need to increase the proportional gain kp to reduce the rise time and steady state
error by increasing kp value from 100 to 5000 to achieve desired design specifications.

Code:

13
Output:

However, this reaction is unrealistic since, due to engine and drivetrain power constraints, a true
cruise control system can't adjust the vehicle's speed from 0 to 10 m/s in less than 0.5 seconds.

14
In this example, the answer is to choose a smaller proportional gain Kp, which will result in a
tolerable rise time, and to use an integral controller to reduce the steady-state error.

III. PI Controller
Closed loop transfer function is given as

𝑌(𝑠) 𝑃(𝑠). 𝐶(𝑠) 𝐾𝑝 + 𝑘𝑖


𝑇(𝑠) = = =
𝑅(𝑠) 1 + 𝑃(𝑠). 𝐶(𝑠) 𝑚𝑠 + (𝑏 + 𝐾𝑝 )𝑠 + 𝑘𝑖
2

As we know that, when we add integral controller to any system,it will decrease the steady state
error.

Assume values

𝐾𝑝 = 600

𝑘𝑖 = 1

And we check the reponse:

Code:

15
Output:

For desired output, we adjusted both proportional and integral gain to attain specific response.

We check our system for the following values:

16
We check our system at 𝐾𝑝 𝑣𝑎𝑙𝑢𝑒 800 and 𝑘𝑖 value 40

We achieved our desired response by adjusting the values of proportional and integral controller.

IV. PID Controller


Closed loop transfer function for PID controller

𝑌(𝑠) 𝑃(𝑠). 𝐶(𝑠) 𝑘𝑑 𝑠 2 +𝐾𝑝 𝑠 + 𝑘𝑖


𝑇(𝑠) = = =
𝑅(𝑠) 1 + 𝑃(𝑠). 𝐶(𝑠) (𝑚 + 𝑘𝑑 )𝑠 2 + (𝑏 + 𝐾𝑝 )𝑠 + 𝑘𝑖

Assume values

𝐾𝑝 = 𝑘𝑖 = 𝑘𝑑 = 1

17
Code:

%%% PId controller design


clear all
close all
clc
mass = 1000;
damping_coeff = 50;
reffrence_inp = 10;
s = tf('s');
P_cruise = 1/(mass*s + damping_coeff);
Kp = 1;
Ki = 1;
Kd = 1;
D = pid(Kp,Ki,Kd);
W = feedback(D*P_cruise,1);
t = 0:0.1:20;
step(reffrence_inp*W,t)
axis([0 20 0 10])
xlabel('\bf\fontsize{20}Time(second)')
ylabel('\bf\fontsize{20}amplitude')
title('\bf\fontsize{30}PId control Step Response)')

Output:

18
To achieve desired response ,we tuned our controller by giving different values

%%% PId controller design


clear all
close all
clc
mass = 1000;
damping_coeff = 50;
reffrence_inp = 10;
s = tf('s');
P_cruise = 1/(mass*s + damping_coeff);
Kp = 800;
Ki = 40;
Kd = 1;
D = pid(Kp,Ki,Kd);
W = feedback(D*P_cruise,1);
t = 0:0.1:20;
step(reffrence_inp*W,t)

19
axis([0 20 0 10])
xlabel('\bf\fontsize{20}Time(second)')
ylabel('\bf\fontsize{20}amplitude')
title('\bf\fontsize{30}PId control Step Response)')

output

V. Root Locus
Transfer function of the cruise control system is given below;

𝑣(𝑠) 1 𝑚
𝑃(𝑠) = = [( )/𝑁]
𝑢(𝑠) 𝑚 ∗ 𝑠 + 𝑏 𝑠

Assumed parameters mass of vehicle 1000 kilo grams ,damping coefficients 50N.s/m and
reference speed of our system is 10 milli per second

Performance Specifications:

Risetime less than 5 s ,Overshoot less than 10% ,SS error less than 2%

VI. Proportional control


As we know that root locus tells us about the location of all possible closed loop poles. So we will
only use proportional controller to design root locus. The closed loop transfer function then
becomes;

20
𝑌(𝑠) 𝑃(𝑠). 𝐶(𝑠) 𝐾𝑝
𝑇(𝑠) = = =
𝑅(𝑠) 1 + 𝑃(𝑠). 𝐶(𝑠) 𝑚𝑠 + (𝑏 + 𝐾𝑝

Now we will find the damping ratio and natural frequency as shown below;

1.8
𝑤𝑛 ≥
𝑇𝑟

𝑙𝑛2 𝑀𝑝
𝜁=√ 2
𝜋 + 𝑙𝑛2 𝑀𝑝

where

𝑤𝑛 = Natural Frequency [rad\s]

𝜁= Damping Ratio

Tr = Rise time [s]

Mp = Maximum Overshoot

A rising time of fewer than 5 seconds is one of our design criteria. The natural frequency must be
bigger than 0.36, according to the first equation. The damping ratio must be more than 0.6,
according to the second equation, because the maximum overshoot must be less than 10%.

Matlab Code to Plot Root Locus:

21
Output:

In our graph dotted line in angle indicates the location of constant damping ratio,our damping ratio
is greater than 0.6 in between these lines and less than 0.6 outside the dotted lines and in the graph
semi lips show the location of Wn. And Wn is greater than 0.36 outside the semi lips and smaller

22
than 0.36 inside the dotted lines. We can then find the gaain to place the closed loop poles in the
desired region by employing the rlocfind command. Also code explains this. Figure shows this.

Know we add code [Kp,poles]=rlocfind(P_cruise) into command window choose a specific loop
gain.

Now we see the output in command window;

selected_point =

-0.4201 + 0.0037i

Kp =

370.1608

23
poles =

-0.4202

The values which showed in command window may not be same but have same order or
magnitude. The gain for the compensator can be set to this value, and the closed-loop step response
can be constructed as follows.

Matlab Code of Closed Loop Step Response:

Output:

24
The rise time and overshoot criteria have been met with the gain Kp you just selected; nonetheless,
a steady-state error of more than 10% remains.

6. Lag Controller
As we know that we used a lag controller in our system to reduce the steady state error.Lag
controller transfer function is given below:

𝑠 + 𝑧0
𝐶(𝑠) =
𝑠 + 𝑝0

The closed loop transfer function without Kpbecomes :

𝑌(𝑠) 𝑠 + 𝑧0
= 2
𝑅(𝑠) 𝑚𝑠 + (𝑏 + 𝑚𝑝0 )𝑠 + 𝑏𝑝0

Then closed loop transfer function with Kp becomes:

𝑌(𝑠) 𝐾𝑝 𝑠 + 𝐾𝑝 𝑧0
=
𝑈(𝑠) 𝑚𝑠 2 + (𝑏 + 𝐾𝑝 + 𝑚𝑝0 )𝑠 + (𝑏𝑝0 + 𝐾𝑝 𝑧0 )

From study of Lag or Phase-Lag Compensator using Root-Locus we know that we need to place
poles and zeros of our controller close to each other. It states that steady state error will be reduced
𝑧
up to a factor 𝑝0 For these reasons we assume the following values.
0

25
Zo1= 0.3;

Po1 = 0.03;

Root-Locus Matlab Code:

Output:

26
Also we can choose a new loop gain.Enter the code [Kp,poles]=rlocfind(C_lag*P_cruise) into the
command window then figure becomes.

selected_point =

-0.3931 - 0.0000i

Kp =

1.3379e+03

poles =

27
-1.0248

-0.3931

A new closed loop step response can be gained using following code in Matlab,

close all

clear all

clc

Output:

28
As we can see that system steady error reduced upto zero. The overshoot is due to addition of zeros
to lag controller. Till now we we have achieved all the requirements needed us so we need not to
change anything further.

7. State space Equations(Models)


The equation of motions in state space form as follows:

−𝑏 1
[𝑣̇ ] = [ ] [𝑣] + [ ] [𝑢]
𝑚 𝑚

𝑦 = [1][𝑣]

Self Assumptions:

Assumed parameters mass of vehicle 1000 kilo grams ,damping coefficients 50N.s/m and
reference speed of our system is 10 milli per second where y=v is the system velocity output

System Requirements:

Risetime less than 5 s ,Overshoot less than 10% ,SS error less than 2%

I. Control Design using Pole placement


The schematic of full state system feedback is shown below.

29
Where,

where

K = state-feedback gain matrix

u = r - K.x = r - K.v = control input

As we know that we can use the pole place method to achieve the desired response. we can find
the poles of closed loop system from characteristic equation. The intended output can be obtained
if the poles of the system can be placed in the desired location by developing an appropriate control
matrix (K). now we need to watch that where we have to place poles in system.We only have one
pole to insert because our [sI-(A-B*K)] matrix is 1x1.Set the pole to -1.5. (arbitrary). The
MATLAB command put will be used to find the control matrix K, just as it was in the State-Space
Tutorial. Create a new m-file and run the commands below. The control matrix and step response
shown below should be obtained by running the m-file in the MATLAB command window.

30
Matlab Code for Linear Simulation:

Output:

Now rise time is compensated but we have to reduce steady state error.

31
II. System Reference_input
Now to reduce the steady state error we used a technique called as Nbar in Matlab. The matlab
code is written below,

Output:

32
As shown in the figure steady state error has eliminated,rise time is less than 5% and overshoot is
almost zero. So our all the requirements are fulfilled.

8. Simulink Model
We made a Simulink model using following blocks

• Step
• Sum
• Integrator
• Inertia
• Damping
• Scope

Model picture:

We used these values in Matlab.

close all

clear all

33
clc

%%% simulink modeling

m = 1000;

b = 50;

u = 500;

Model results:

34
From the above results we would like to improve the response of our cruise control system.

Simulink

I. Controller Design
Extracting a linear model into matlab;

A linear model of the system can be brought from simulink into matlab by using inp1 out1 and
matlab function linmod. Then we changed scope and step block with an inp1 and out1 blocks, so
that now it will indicates the input and output in the process of extraction.

Matlab will open the saved model file by extracting a linear model. At the MATLAB prompt, Use
following commands:

35
We use open –loop step response of extracted transfer function to check the model extraction in
matlab. For this purpose we multiply num by 500 to stimulate a step input of 500N.Use following
commands:

Output

36
II. Implementation of PI control
A PI controller was designed with and to give the appropriate response on the Cruise Control. In
Simulink, we will start by putting the open-loop system into a Subsystem block.

Make a brand-new model window.

Into your new model window, drag a Subsystem block from the Ports & Subsystems library.

Double-click this block to activate it. The contents of the subsystem will be displayed in a blank
window.

Open the previously saved model ccmodel.slx of the cruise control system.

Select All from the Edit menu, and then Copy from the Edit menu.

Choose Paste from the Edit menu and paste the blank subsystem window from your new model.
In this new subsystem window, original system window should be closed.

The Subsystem block should now have input and output terminals. This block should be called
"plant model."

Now, we make a PI controller for the plant model, By giving feed back to the plant output.

Make a line that extends from the plant's output.ThenInsert a Sum block and label its inputs as "+-
."

37
Tap a line from the output line and draw it to the Sum block's negative input.

From the output of the sum block which will provide error signal me make proportional and
integral controllers.

After the Sum block, insert an Integrator block and connect them with a line.To provide the integral
gain, insert and connect a Gain block after the Integrator block.

Name this Integrator "Ki" and give it the value "Ki."Insert a new Gain block and connect it to a
line tapped off the Sum block's output.Mark this gain "Kp" and give it the value "Kp."

We make proportional and integral controllers, adding both and apply their sum to plant.

Connect the outputs of the two Gain blocks to the Sum block inputs by inserting a Sum block
between the Ki block and the plant model and then connect their output to the plant block's input.

At last at step input we will check output with scope block.

Attach a Step block to the feedback Sum block's free input and Connect a Scope block to the plant's
output.

Set the Step Time to "0" and the Step Distance to "0" by double-clicking the Step block.

An alternate can be done to make PI controller by using transfer function technique.

Output:

38
III. Closed-loop response
A proper simulation time must be required to stimulate the system. From the Simulation menu,
choose parameters and enter "10" in the stop time field. Because the design specifications called
for a rise time of less than 5 seconds, we run the simulation for 10 seconds to see how it turned
out. Physical parameters must now be defined. At the MATLAB prompt, enter the following
commands:

Code:

Run the simulation we will see the following output.

39
SimScape Model:

Out put

40
9. Conclusion
Cruise control is system used in cars or vehicles to maintain a specific speed. In this report we
developed a controller for cruise control. For this purpose first we found transfer function of open
loop system. Then we used state space model for open loop system and done coding in matlab.
Then we draw the open loop poles and zeros in matlab. After that we made proportional,
proportional integral and proportional integral derivative control in matlab. Then we found step
response of closed loop system and made root locous. After that we made model in Simulink and
checked it.

10. Reference’s
Control tutorials for Matlab: Example: Modeling a cruise control system.
http://www.engin.umich.edu/group/ctm/examples/cruise/cc.html

D. Swaroop and R. Huandra, “Intelligent cruise control design based on a traffic flow specification,” Vehicle
Syst. Dyn., vol. 30, pp. 319– 344,Nov. 1998 .

https://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&section=SystemModeling

https://youtu.be/zWuwjCuDAEc

41

You might also like