Adaptive Cruise Control With Cloud Connectivity
Adaptive Cruise Control With Cloud Connectivity
List of Tables............................................................................................................iii
Abstract.................................................................................................................... iv
1. Introduction........................................................................................................1
2. Objectives...........................................................................................................2
3. Requirements..................................................................................................... 2
3.1. Hardware required............................................................................................... 2
3.2. Software required................................................................................................ 2
4. Assembly............................................................................................................2
4.1. LCD assembly....................................................................................................... 2
4.2. Ultrasonic assembly............................................................................................. 3
4.3. Push buttons assembly........................................................................................ 4
6. Software Implementation...................................................................................5
7. Working procedure.............................................................................................6
8. ThingSpeak........................................................................................................ 7
9. Program code..................................................................................................... 9
10. Conclusion....................................................................................................11
11. References.................................................................................................... 12
ii
List of Figures
Figure 1: Adaptive cruise control [1]........................................................................ 1
Figure 2: Schematic of LCD connection with Arduino [3].......................................3
Figure 3: Hardware assembly diagram..................................................................... 4
Figure 4: Arduino properties.....................................................................................6
List of Tables
Table 1: HC-SR04 Ultrasonic sensor pin configuration [4]......................................3
Table 2: Pin configuration.........................................................................................5
Abstract
Adaptive cruise control is one of the most useful tools to control the speed for any
vehicle. Any time around the day or night we saw a heavy increase in the traffic
but if we use the Adaptive Cruise Control automation can be implemented to
reduce the speed of the vehicle and can also speed up according to the need of the
host vehicle. As result of these accident major concern for the public.
In this project, we have made use of MATLAB software to develop and implement
an adaptive cruise control system for vehicles that automatically adjusts the speed
to maintain a safe distance from vehicles ahead. The project is based on the
Arduino UNO hardware, which is wired to a 16 x 2 LCD display, push buttons,
and Ultrasonic sensor (HC-SR04). This setup helps to control the speed of the
vehicle and comes up with two modes. The two modes involve Cruise Control
(CC) mode and Adaptive Cruise Control (ACC) mode.
The CC mode helps to maintain the vehicle at a consistent speed set by the user.
The ACC mode sense for the traffic moving ahead and maintain speed accordingly.
If the hardware senses a vehicle before, it automatically slows the vehicle and
adjusts the speed with respect to the traffic. The speed information is also uploaded
on the cloud to support connected vehicles and intelligent transport. ThingSpeak
1. Introduction
Conventional Cruise Control can maintain a steady speed that you set. Adaptive cruise
control (ACC) is an enhancement of conventional cruise control [1]. Adaptive cruise
control (ACC) is a system that assists automobiles in maintaining a safe following
distance and staying under the speed limit on the road. This device automatically changes
a car's speed so that the driver does not have to [2]. This system also allows you to set the
speed, and following distance of your vehicle manually. The user can also activate or
deactivate the system whenever preferred.
1
2. Objectives
The Objective of this project is to use MATLA to develop and implement an adaptive
cruise control system for vehicles with the help of Arduino kit. This automatically adjusts
the vehicle speed while maintaining a safe distance from vehicles ahead. This system also
allows us to set a preferred following distance from the vehicles moving ahead, with the
help of data from ultrasonic sensor. The speed information of the vehicle is also uploaded
on the cloud with the help of ThingSpeak platform. This provides real time data of
vehicle speed and helps to support connected vehicles and intelligent transport.
3. Requirements
The setup required for the project are divided as follows:
4. Assembly
1 Vcc The Vcc pin powers the sensor, typically with +5V
2 Trigger Trigger pin is an Input pin. This pin is kept high for 10us to
initialize measurement by sending US wave.
3 Echo Echo pin is an Output pin. This pin goes high for a period
which will be equal to the time taken for the US wave to
return to the sensor.
One leg of the push button is connected to the 5-volt supply and the other leg is
connected to the Arduino board pins which is also grounded with 10K ohms pull-up
resistor. When the pushbutton is open (unpressed) there is no connection between the
two legs of the pushbutton, so the pin is connected to 5 volts (through the pull-up
resistor) and we read a HIGH. When the button is closed (pressed), it makes a
connection between its two legs, connecting the pin to ground, so that we read a LOW
[5].
6. Software Implementation
The MATLAB version 2021a is used to run the hardware system and the speed data is
uploaded on cloud using ThingSpeak platform. To support Arduino hardware on the
MATLAB, the ‘MATLAB support package for Arduino hardware’ package needs to be
installed. This support package enables you to use MATLAB to interactively
communicate with an Arduino board and it can be downloaded from the MATLAB Add-
Ons. Then the Arduino hardware setup is run to instal the Arduino USB driver and select
the details like port number, board type and libraries (LCD, Ultrasonic), etc.
After completing the setup for the Arduino, type ‘arduino’ in the MATLAB command
window to view the properties of the Arduino board. The MATLAB code for Adaptive
cruise control is developed based on the properties of the Arduino board as shown in the
fig. 4.
Figure 4: Arduino properties
The libraries like ExampleLCD/LCDAddon, and Ultrasonic are used for the LCD display
and Ultrasonic sensor respectively. ThingSpeak functions are included with MATLAB
installation, so we don’t need to ad and download any libraries for it.
7. Working procedure
The working procedure of the hardware involves the following steps.
1. When the program code is run on the Arduino board the LCD display: Speed 0 Km/hr.
2. Increase speed button is pressed to increase the vehicle speed to certain limit. When
the increase speed button is released the speed decreases until 0 Km/hr.
3. Decrease speed button is pressed to decrease the vehicle speed until 0 Km/hr.
4. To start the cruise control mode, the speed is increased to certain limit (say 40
Km/hr) and then the set speed button is pressed once to lock the vehicle speed. In
Cruise control mode the vehicle speed remains constant, and we can also increase or
decrease the speed by pressing the respective buttons.
5. To quit the cruise control mode, press the Cancel button. Then the speed decreases
gradually until 0 Km/hr.
6. Again, the speed of the vehicle is increased and then set speed button is pressed at
certain speed. Then the Adaptive speed button is pressed to enter Adaptive cruise
control mode. During this mode, a model car is used to trigger the distance sensor
and thus the speed decreases. After the model car is removed, the speed increases
gradually until the set speed.
7. The Speed information is automatically recorded into ThingSpeak platform, and the
data is shown in figure which shows plot of speed with respect to time.
8. ThingSpeak
ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize,
and analyze live data streams in the cloud. ThingSpeak has integrated support from
MATLAB allowing ThingSpeak users to analyze and visualize uploaded data using
Matlab [8].
Thus, the syntax is given inside code to write data into thingspeak. In this project code
the syntax is placed inside while loop where the speed gets counted. The pause time is
suggested to maintain 15 seconds since ‘thingspeak free version’ has a limitation to write
data every 15 seconds only. To write the data for every 1 sec we need to buy the license
[9]. The data uploaded into the thingspeak is shown in the fig. 5 below.
Figure 5: Speed data uploaded on ThingSpeak
The above figure shows the data of vehicle speeds on different modes set by the user. The
different modes are as follows,
a. Rest mode- vehicle is at rest (0 km/hr).
b. Increase & Decrease mode- vehicle speed is changed by pressing increase speed and
decrease speed button.
c. Cruise control mode- vehicle speed is remains constant at speed set by the user (24
km/hr).
d. Adaptive Cruise Control mode- vehicle speed remains constant but when the vehicle
senses any other vehicle in front the speed reduces until the way is cleared and the
speed increases until the set speed.
e. Cancel mode- this mode cancels the cruise control mode or adaptive cruise control
mode set by the user and the vehicle speed decreases gradually until 0 km/hr.
9. Program code
The MATLAB code for Adaptive Cruise Control used in the hardware is given below,
%% Variable Creation
input = 0;
cruiseControl = 0;
adaptiveCC = 0;
setspeed = 0;
ACCspeed = 0;
if (Increase_Btn == 1)
input = 1;
break;
elseif (Decrease_Btn > 4)
input = 2;
break;
elseif (SetSpeed_Btn > 4)
CruiseControl = 1;
CCspeed = speed;
break;
elseif (ACC_Btn == 1)
AdaptiveCC = 1;
ACCspeed = speed;
break;
elseif (Cancel_Btn == 1)
CruiseControl = 0;
AdaptiveCC = 0;
ACCspeed = 0;
CCspeed = 0;
break;
else input = 0; break;
end
end
switch input
case speed = speed + 1;
1
if (speed > 0)
case speed = speed - 1;
2
end
otherwise
if(speed > 0 && CruiseControl == 0 && AdaptiveCC == 0)
speed = speed - 1;
elseif(AdaptiveCC == 1)
sensorValue = readDistance(sensor);
if (sensorValue < 0.1 && speed > 0)
speed = speed – 1;
elseif (speed < ACCspeed)
speed = speed + 1;
end
printLCD(lcd, char(""));
end pause(0.5);
end
[2] Hearst Autos Research, What Is Adaptive Cruise Control?, Car and Driver, viewed
26 Jul 2021, <https://www.caranddriver.com/research/a32813983/adaptive-cruise-
control/>.
[3] The MathWorks 2021, Create LCD Add-on, MathWorks, viewed 26 Jul 2021,
<https://in.mathworks.com/help/supportpkg/arduinoio/ug/add-lcd-library.html>.