0% found this document useful (0 votes)
88 views17 pages

Adaptive Cruise Control With Cloud Connectivity

This document describes the development of an adaptive cruise control system using an Arduino Uno, ultrasonic sensor, LCD display, and push buttons. The system can operate in two modes: cruise control mode to maintain a set speed, and adaptive cruise control mode to automatically adjust speed based on sensed traffic. The speed information is uploaded to ThingSpeak for connected vehicle applications. Key components are assembled including connecting the LCD, ultrasonic sensor, and push buttons to the Arduino. Software is implemented in MATLAB to control the Arduino board and implement the adaptive cruise control functionality.

Uploaded by

tejash patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views17 pages

Adaptive Cruise Control With Cloud Connectivity

This document describes the development of an adaptive cruise control system using an Arduino Uno, ultrasonic sensor, LCD display, and push buttons. The system can operate in two modes: cruise control mode to maintain a set speed, and adaptive cruise control mode to automatically adjust speed based on sensed traffic. The speed information is uploaded to ThingSpeak for connected vehicle applications. Key components are assembled including connecting the LCD, ultrasonic sensor, and push buttons to the Arduino. Software is implemented in MATLAB to control the Arduino board and implement the adaptive cruise control functionality.

Uploaded by

tejash patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Table of Contents

List of Figures.......................................................................................................... iii

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

5. Hardware assembly diagram..............................................................................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.

Figure 1: Adaptive cruise control [1]

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:

3.1. Hardware required


1. Arduino Uno board.
2. Ultrasonic sensor (HC-SR04).
3. 16x2 LCD display.
4. 16 pins male strip connector.
5. Bread board.
6. Push buttons.
7. Jump cables (Male-Male).
8. 10K ohm pull-up resistors.
9. 10K ohm potentiometer
10. USB cable (Arduino board to System)
11. A PC or Laptop with MATLAB software.

3.2. Software required


1. MATLAB Software (Version 2018 or above).
2. MATLAB Supporting Package for Arduino Hardware.
3. ThingSpeak (Online IoT platform).

4. Assembly

4.1. LCD assembly


The Assembly process begins with the LCD displays, where in some case the LCD
doesn’t comes with male connector, so we have soldered 16 pins male strip connector
to the LCD. The soldered LCD setup is then placed in the breadboard and then the
pins are wired to the Arduino UNO board. The Arduino UNO uses four data pins, a
register select pin, and a enable pin, and input of 5V is provided to LCD from the
Arduino UNO board. A potentiometer is also connected to control the brightness of
the LCD display which is powered and grounded with the Arduino. The schematic for
the wiring the pins is shown in the below fig. 2.
Figure 2: Schematic of LCD connection with Arduino [3]

4.2. Ultrasonic assembly


The HC-SR04 Ultrasonic sensor is a sensor used for detecting the distance to an
object using sonar. This sensor is a four-pin module, whose pin names are Vcc,
Trigger, Echo and Ground respectively. It has a measuring range of 2-80 cm and
accuracy of 3mm [4]. Both the Trigger and Echo pins are connected to the digital pins
(i.e., 12 and 10 respectively) of the Arduino UNO board. The pin configuration of an
Ultrasonic sensor is given in the below table 1.

Pin Pin Description


Number Name

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.

4 Ground This pin is connected to the Ground of the system.

Table 1: HC-SR04 Ultrasonic sensor pin configuration [4]


4.3. Push buttons assembly
The pushbutton is a component that connects two points in a circuit when you press
it. The hardware uses five push buttons for increase speed, decrease speed, set speed,
adaptive speed, and cancel button. The Increase speed, adaptive speed, and cancel
button are connected to the digital pins of the Arduino UNO board. The decrease
speed and set speed are connected to the analog pins of the Arduino board.

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].

5. Hardware assembly diagram


The Hardware assembly diagram is given in the below figure 3. The assembly consists of
the following parts Arduino Uno x 1, button x 5, ultrasonic sensor x 1, 16x2 LCD display
x 1, potentiometer x 1, pull-up resistor x 5, and bread board x 1.

Figure 3: Hardware assembly diagram


No. LCD Pin Arduino Pin
1. 1 (VSS) Ground
2. 2 (VDD) 5V
3. 3 (V0) Mid pin on potentiometer
4. 4 (RS) D7
5. 5 (R/W) Ground
6. 6 (E) D6
7. 11 (DB4) D5 (PWM)
8. 12 (DB5) D4
9. 13 (DB6) D3 (PWM)
10. 14 (DB7) D2
11. 15 (LED+) 5V
12. 16 (LED-) Ground
Ultrasonic sensor pin Arduino pin
13. VSS 5V
14. Trig D12
15. Echo D10
16. Gnd Ground
Push Button Arduino pin
17. Increase button D13
18. Decrease button A2
19. Set speed button A1
20. Adaptive speed button D9
21. Cancel button D11

Table 2: Pin configuration

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.

For LCD the following syntax are used [3],


 To create the LCD object:
lcd=addon(a,'ExampleLCD/LCDAddon','RegisterSelectPin','D7','EnablePin','D6','Da
taPins',{'D5','D4','D3','D2'});
 Initialize the LCD: initializeLCD(lcd);
 To print on the LCD: printLCD(lcd,'Hello World!');

For Ultrasonic the following syntax are used [6],


 To create Ultrasonic sensor object:
ultrasonicObj = ultrasonic(arduinoObj,triggerPin,echoPin)
 To measure the distance of object: Distance= readDistance(ultrasonicObj)

For ThingSpeak the following syntax are used [7],


 To write data to ThingSpeak from MATLAB 2021a:
thingSpeakWrite( channelID , data ,'WriteKey',' channel write API key ', ' Fields',1)
 To read data from ThingSpeak into MATLAB 2021a:
thingSpeakRead(channelID, data ,'ReadKey',' channel read API key ')

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].

To upload data into ThnigSpeak follow the steps given below,

1. Open ‘thingspeak’ on your browser.


2. Login or create an account.
3. Open My Channel.
4. Click on New Channel.
5. Enter the details and select the number of fields required.
6. Click on Save Channel.
7. Inside your channel select ‘API Keys’ to get the read and write API keys.
8. Enter the below syntax into your MATLAB command window,
>> thingSpeakWrite( channelID , data ,'WriteKey',' channel write API key ')
9. This command collects the data from your MATLAB and writes into the
ThingSpeak platform, where the data is displayed in ‘Field 1 chart’ in real time.
10. To read the data recorded with respect to time in ThingSpeak into the MATLAB,
enter the following code into the command window,
>>[data, time]=thingSpeakRead(channelID, data ,'ReadKey',' channel read API key ')

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,

%% Arduino Setup a=arduino('COM3','uno','Libraries',


{'ultrasonic','ExampleLCD/LCDAddOn'},'ForceBuild On',true);
lcd=addon(a,"ExampleLCD/LCDAddon",'RegisterSelectPin','D7','EnablePin','D6','DataPi
ns',{'D5','D4','D3','D2'});
initializeLCD(lcd);
sensor = ultrasonic(a,'D12','D10');
speed = 0;
printLCD(lcd, char("Speed: " + speed + " km/h"));
disp('Press Ctrl+C to terminate the loop');

%% Variable Creation
input = 0;
cruiseControl = 0;
adaptiveCC = 0;
setspeed = 0;
ACCspeed = 0;

%% Continuous loop to increase/decrease count and different mode setup


while true
while true
Increase_Btn = readDigitalPin(a, 'D13');
Decrease_Btn = readVoltage(a, 'A2');
SetSpeed_Btn = readVoltage(a, 'A1');
ACC_Btn = readDigitalPin(a, 'D9');
Cancel_Btn = readDigitalPin(a, 'D11');

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

printLCD(lcd, char("Speed: " + speed + " km/h"));


pause(0.5);
thingSpeakWrite(1456476,counter,'WriteKey','7C91K8U7GLUZPA6Q','Fields',1);
end
10. Conclusion
The Adaptive Cruise Control system decreases the stress of long-distance travel by
minimizing the time taken to use the accelerator. Thus, it helps to avoid accidents due to
collision by the sensing the object before colliding and reducing the speed. This system
can be modified to display a red light or a “brake now” phrase on the dashboard to
indicate any obstacle on the pathway. This system also helps to collect speed data from
cars and upload it into the cloud. The data collected from number of cars can be used in
Interactive Cruise Control which helps in intelligent transportation and traffic control.
The ACC system forms the basis of the future of car intelligence.
11. References
[1] Adaptive Cruise Control, MyCarDoesWhat, viewed 26 Jul 2021,
<https://mycardoeswhat.org/deeper-learning/adaptive-cruise-control/ >.

[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>.

[4] Components101 2017, HC-SR04 Ultrasonic Sensor, Components101, viewed 26


Jul 2021, <https://components101.com/sensors/ultrasonic-sensor-working-pinout-
datasheet>.

[5] Arduino 2021, Pushbutton, Arduino, viewed 27 Jul 2021,


<https://www.arduino.cc/en/tutorial/pushbutton>.

[6] The MathWorks 2021, ultrasonic, MathWorks, viewed 26 Jul 2021,


<https://in.mathworks.com/help/supportpkg/arduinoio/ref/arduinoio.ultrasonic.htm
l?searchHighlight=ultrasonic&s_tid=srchtitle>.

[7] The MathWorks 2021, thingSpeakWrite, MathWorks, viewed 26 Jul 2021,


<https://in.mathworks.com/help/supportpkg/arduinoio/ref/arduinoio.ultrasonic.htm
l?searchHighlight=ultrasonic&s_tid=srchtitle>.

[8] ThingSpeak for IOT Projects, ThingSpeak, viewed 27 Jul 2021,


<https://thingspeak.com/>.

[9] ThingSpeak™ Licensing FAQ, ThingSpeak, viewed 27 Jul 2021,


<https://thingspeak.com/>.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy