Design Project Report
Design Project Report
VEHICLES
CERTIFICATE
This is to certify that this report entitled “Attention Based Speed Governor for Electric
Vehicles” submitted by AUGUSTIN JOSE, GOPIKA B, MEENAKSHI SURESH,
MEGHA SANTHOSH to the APJ Abdul Kalam Technological University in partial fulfill-
ment of the requirements for the award of the Degree of Bachelor of Technology in Electrical
and Electronics Engineering is a bonafide record of the design project work carried out by them
under my/our guidance and supervision. This report in any form has not been submitted to
any other University or Institute for any purpose.
As we complete this project, we would like to thank the numerous hands who helped us, wholeheart-
edly. First and foremost, we thank the Almighty, without whose blessings we could have never reached
this far. We express our deepest gratitude to our guide on this project Dr N Mayadevi,Department of
Electrical Engineering for all her help and invaluable advice,support and constant encouragement. We
take this opportunity to express our profound gratitude to our Head Of the Department, Dr P Sreejaya
whose encouragement was a great source of inspiration. We would like to thank all the teachers of the
Department for their help on various areas of this project. We would also like to thank our friends and
family for their continued support and inspiration.
Abstract
This project aims to design and develop an attention based speed governor for electric vehicles. This
project comes up with a design which is simple and can be easily implemented. It analyses the
driver’s facial features and determines whether the driver is paying attention on the road or not. This
system consists of two subsystems: Attention monitoring subsystem and Speed control subsystem.
The attention of the driver is assessed and a numerical value is derived which are checked against
threshold values of speed. If speed is high for low attention, the speed of the vehicle is controlled.
2 Literature Review 10
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Existing System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Detailed Discussion of Two Existing Systems . . . . . . . . . . . . . . . . . . . . 11
2.3.1 Eye Behavior Based Drowsiness System . . . . . . . . . . . . . . . . . . 11
2.3.2 Driver Drowsiness Detection Using Face Expression Recognition . . . . . 12
2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3 Proposed System 13
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Methodology 15
6
5 Design 17
5.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2 Design of Attention Monitoring Program . . . . . . . . . . . . . . . . . . . . . . 17
5.3 Design of entire attention monitoring subsystem . . . . . . . . . . . . . . . . . . 18
5.4 Design of speed control subsystem . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.5 Block Diagram of Designed System . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.6 Components and Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7 Conclusions 44
7.1 Future Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
References 45
7
1 Introduction
The number of accidents occurring on roads are increasing day by day. To overcome this
social issue a solution has been put forward by this design project. Keeping in mind the deplet-
ing sources of fuel, like petrol and diesel, and the upcoming electric vehicles, the solution is
to be implemented in electric vehicles. In the next 10-20 years, electric vehicles will dominate
the automobile industry and petrol and diesel vehicles will be completely eliminated.
In the 21st century, EVs saw a resurgence due to technological developments, and an
increased focus on renewable energy. The power of a vehicle’s electric motor is measured
in kilowatts(kW). Usually, direct current(DC) electricity is fed into a DC/AC inverter where
it is converted to alternating current(AC) electricity and this AC electricity is connected to a
3-phase AC motor.
Most electric vehicles use lithium ion batteries(Li-ions). These batteries have higher en-
ergy density than most other practical batteries.
Charging of an electric car can be carried out at various charging stations, these charging
stations can be installed in both houses and public areas.
Considering the current scenario of the automobile industry, to create a safe environment
on the roads, proper speed limiting precautions are necessary.
1.2 Motivation
• The evolution of electric vehicles in recent years.
1.3 Objective
To design and develop a system that controls the speed of the vehicle by monitoring the
attention of the driver.
• The threshold values of speed for each value of attention is checked against the calcu-
lated value of attention.
• If the attention of the driver is low(eg: he is drowsy) then the speed of the vehicle will
be controlled accordingly.
Chapter 6: This chapter gives a brief overview on the results obtained by testing the com-
pleted product. It also includes the scope of improvement of the designed system according
to the conclusions drawn from the testing.
10
2 Literature Review
2.1 Introduction
Drowsiness detection and speed control technologies are described in the journals re-
ferred. The systems developed figured the advantage of recognizing drowsiness before it
happens and to have the capacity to caution the driver in time. Electronic controller unit
(ECU) used for controlling sub-systems of complex real life applications like automotive ve-
hicles can pose several challenges. In such case, hardware in the loop (HIL) approach for
testing such controllers emulates the external application environment and allows concurrent
development of the electronic controllers. The systems proposed a novel low cost testing
approach.
effective for drowsiness, are extracted and tracked in video sequence frames. The system has
been tested and implemented in a real environment.
In ref [3], an improved Fuzzy PID controller to control the speed of Brushless DC motor
was used. The proposed controller is called proportional-integral-derivative (PID) controller
and Fuzzy proportional-integral-derivative controller. This paper provides an overview of per-
formance conventional PID controller and Fuzzy PID controller. It is difficult to tune the pa-
rameters and get satisfied control characteristics by using normal conventional PID controller.
As the Fuzzy has the ability to satisfied control characteristics and it is easy for computing, In
order to control the BLDC motor, a Fuzzy PID controller is designed as the controller of the
BLDC motor. The experimental results verify that a Fuzzy PID controller has better control
performance than the conventional PID controller. The modeling, control and simulation of
the BLDC motor has been done using the software package MATLAB/SIMULINK.
In ref [4], a case-study of how HIL testing approach was gainfully employed for an elec-
tronic road-speed limiting application was described. The control system uses an electronic
throttle controller as its heart. The HIL system can simulate vehicle dynamics for the end
vehicle as well as road-grade, vehicle load etc. This allowed the rapid development of the
core control algorithm, which minimized vehicle testing time. Another novel feature of this
particular testing was, that the HIL system was implemented on a low cost hardware based
on the target controller to be tested.
Presented at the 2015 12th International Computer Conference on Wavelet Active Media
Technology and Information Processing(ICCWAMTIP) in 2015 [1] exhibits non-intrusive com-
puter vision based ideas has been utilized for the development of a Drowsy Driver Detection
System. The small camera has been used by system that focuses straight towards the face of
the driver and checks the driver’s eyes with a specific end goal to recognize fatigue.
This paper [1] illustrates the process of locating the eyes of driver, and to decide whether
the eyes of driver are open or closed. The system manages utilizing data gained for the image
which is in binary form to locate the face edges, which gets the location where the eyes of
12
a person may exist. If the eyes of the driver are found close for five successive frames, the
proposed system assumes that the driver is nodding off and a signal of warning has been
issued. The camera based drowsiness measures give appreciated contribution.
Presented at the 2011 IEEE International Conference on Signal and Image Processing
Applications(ICSIPA) Proceeding in 2011 [2] exhibits illumination of face with IR LED for
better eye detection. In this paper, unlike conventional drowsiness detection methods, which
are based on the eye states alone, we used facial expressions to detect drowsiness.
There are many challenges involving drowsiness detection systems. Among the important
aspects are: change of intensity due to lighting conditions, the presence of glasses and beard
on the face of the person. In this project, we propose and implement a hardware system
which is based on infrared light and can be used in resolving these problems. In the proposed
method, following the face detection step, the facial components that are more important and
considered as the most effective for drowsiness, are extracted and tracked in video sequence
frames. The system has been tested and implemented in a real environment.
2.4 Conclusion
Literature referred have contributed refinement towards the problems faced on the road
due to the drowsiness of the driver. The proposal has been developed based on its merits and
aimed to overcome the demerits of past solutions.
13
3 Proposed System
3.1 Introduction
The proposed system consists of a camera, microcontroller, speed controller, motor and
a speed sensor. The facial features of the driver is assessed from the images captured. The
program calculates a numerical value for attention and a trigger is sent by the microcontroller
which determines a value of speed for the particular value of attention. The trigger is sent to
the next microcontroller which checks the current speed of the motor which is being measured
by the rotary encoder. The measured speed is checked against a set threshold value and if the
speed is higher than that value it is accordingly controlled.
F IGURE 3.2.1
Block diagram of the project
14
3.3 Working
The attention monitoring subsystem consists of a camera module and a microcontroller.
The user’s attention is converted into a suitable scale and the value produced is checked
against a threshold value and a trigger is sent to the speed control subsystem. The speed
controller subsystem consists of a microcontroller, an electronic speed controller(ESC) and
a rotary encoder coupled with an electric motor as shown in fig 3.2.1. The rotary encoder
measures the speed and the trigger received by the microcontroller decides whether to control
the speed or not. If speed is more than the threshold value, speed control is carried out. Once
the speed equals threshold value, the output frequency of the electronic speed controller is
kept constant. Hence, the speed is limited to that value.
3.4 Conclusion
The main system consists of two subsystems for executing the required actions. Thus, the
system ensures a reliable detection of attention of the driver and the efficient speed control
of the vehicle. The system is to be implemented in an electric vehicle which is the future of
the automobile industry.
15
4 Methodology
F IGURE 4.0.2
Flowchart depicting the working of the project
16
• The image of the driver is captured and the facial features are assessed.
• If the attention is below a threshold value(the numerical value is higher for lower at-
tention) then the speed is limited.
• A trigger is sent to the Electronic speed controller which checks the current speed of the
vehicle and compares it to the threshold value set for that particular attention.
• If the speed is higher than the set threshold value, then it is limited to the threshold
value.
17
5 Design
5.1 Requirements
• Python 3.6.8
• OpenCV
• TensorFlow
• Haarcascades
• Arduino IDE
• The images are converted into grayscale and low level noise reduction algorithms are
applied
• Facial features in the images are compared with the weights in the Haarcascades mod-
ule.
• After the above comparison, a region of interest(ROI) is drawn around the driver’s face.
The number of consecutive frames in which the driver’s eyes remain closed are calculated tak-
ing into account of the frame rate of the camera. The average of these values are calculated
and are tested against a set of trained values. The trained values are calculated using Tensor-
Flow based machine learning program running on a dataset of driver images. The percentage
drowsiness is thus evaluated after the above testing is done.
18
The position of the pupil within the rectangular box drawn around the eye is evaluated.
For a highly attentive driver, the variation in this value from its mean position will have
smooth slope and have periodic characteristics. On the other hand, for a less attentive driver,
this variation will be a have steep slope and non periodic characteristics. This comparison is
done using a pretrained dataset.
By considering the above two values, the percentage attention is generated. The limiting
speed corresponding to this speed is calculated and transmitted to the Arduino using one of
the GPIO pins.
F IGURE 5.5.3
Block diagram of the designed project
20
5.7 Conclusion
• Solution can be easily implemented with the hardware that has been selected.
• The selected solution will help in reducing road accidents due to the carelessness of the
driver.
22
F IGURE 6.1.4
Arduino Uno
ARDUINO UNO
• Microcontroller: ATmega328
• Operating voltage: 5V
• Clock speed:16MHz
24
F IGURE 6.1.5
Raspberry Pi Model 3B
Raspberry PI MODEL 3B
• GPIO: 40 pins
• Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial
Interface (CSI), Display Serial Interface (DSI)
25
F IGURE 6.1.6
VGA Camera Module with USB Connector
• USB Connector
• 30fps
• Resolution : 640x480
26
F IGURE 6.1.7
Lithium Polymer Battery
LiPo Battery
• 11.1V
• 2200mAh
F IGURE 6.1.8
Brushless DC Motor
BRUSHLESS DC MOTOR
• Kv Ratio: 1000Kv
• Poles:14
A brushless DC electric motor (BLDC motor or BL motor), also known as electronically com-
mutated motor (ECM or EC motor) and synchronous DC motors, are synchronous motors
28
powered by direct current (DC) electricity via an inverter or switching power supply which
produces an alternating current (AC) electric current to drive each phase of the motor via a
closed loop controller. The controller provides pulses of current to the motor windings that
control the speed and torque of the motor.
The construction of a brushless motor system is typically similar to a permanent magnet
synchronous motor (PMSM), but can also be a switched reluctance motor, or an induction
(asynchronous) motor [1]
The advantages of a brushless motor over brushed motors are high power-to-weight ra-
tio, high speed, electronic control, and low maintenance. Brushless motors find applications
in such places as computer peripherals (disk drives, printers), hand-held power tools, and
vehicles ranging from model aircraft to automobiles
29
F IGURE 6.1.9
Rotory Encoder
Rotory Encoder
• Operating Voltage : 5V
30
F IGURE 6.1.10
Breadboard
31
F IGURE 6.1.11
Potentiometer
Potentiometer
F IGURE 6.2.12
Final Hardware Implementation
The source codes for Raspberry Pi and Arduino are loaded into the respective devices.
Raspberry Pi is powered by a USB cable and the Arduino is powered by the LiPo battery. The
Raspberry Pi and the Arduino are interfaced by two wire digital connection. The USB camera
is connected to the Raspberry Pi. The BLDC motor and the rotory encoder is mechanically
coupled. The BLDC is connected to the ESU which is powered by the LiPo and its signal
pin is connected to Arduino. The rotory encoder is interfaced to the Arduino using serial
connection. A potentiometer is connected to the Arduino to manually control the speed of the
BLDC motor.
33
30 int count1 = 0;
31 int count2 = 0;
32 int limit = 80;
33 void loop()
34 {
35 x=analogRead(A0);
36 y = map(x, 0, 1023, 0, 180);
37 if(y>=limit)
38 {
39 y=limit;
40 }
41 if(y < limit)
42 {
43 sp = y;
44 }
45 sp = y;
46 s1.write(sp);
47 int buttonState = digitalRead(pushButton);
48 if(buttonState==1)
49 {
50 count2 = 0;
51 count1+=1;
52 limit = limit-(limit*0.1*(count1/5));
53 if(limit<=10)
54 {
55 limit=10;
56 }
57 }
58 if(buttonState<0)
59 {
35
60 count1 = 0;
61 count2 = rpm();
62 }
63 else if(buttonState==0)
64 {
65 count1 = 0;
66 count2+=1;
67 limit = limit+(limit*0.1*(count2/5));
68 if(limit>=80)
69 {
70 limit=80;
71 }
72 }
73 }
74 int rpm()
75 {
76 currentStateCLK = digitalRead(inputCLK);
77 if (currentStateCLK != previousStateCLK)
78 {
79 if (digitalRead(inputDT) != currentStateCLK)
80 {
81 counter --;
82 }
83 else
84 {
85 counter ++;
86 }
87 rps = counter;
88 Serial.println(rps);
89 delay(1000);
36
90 }
91 previousStateCLK = currentStateCLK;
92 return rps;
93 }
24 ear = (A + B) / (2.0 * C)
25 return ear
26 EYE_AR_THRESH = 0.3
27 EYE_AR_CONSEC_FRAMES = 15
28 COUNTER = 0
29 ALARM_ON = False
30 detector = dlib.get_frontal_face_detector()
31 predictor = dlib.shape_predictor(’
shape_predictor_68_face_landmarks.dat’)
32 (lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"
]
33 (rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye
"]
34 threadprint("[INFO] starting video stream thread...")
35 vs = VideoStream("video1.mp4").start()
36 time.sleep(1.0)
37 while True:
38 try:
39 frame = vs.read()
40 frame = imutils.resize(frame, width=450)
41 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
42 rects = detector(gray, 0)
43 for rect in rects:
44 #conn, addr = serv.accept()
45 shape = predictor(gray, rect)
46 shape = face_utils.shape_to_np(shape)
47 leftEye = shape[lStart:lEnd]
48 rightEye = shape[rStart:rEnd]
49 leftEAR = eye_aspect_ratio(leftEye)
50 rightEAR = eye_aspect_ratio(rightEye)
38
The speed.ino program is run in Arduino. The instantaneous resistance of the potentiometer
is read from the analog pins. The pulses generated by the Raspberry Pi is decoded and the
limit of speed is calculated. The ESU is then triggered to decrease the speed until, the speed
become less than the limit.
The server.py program monitors the driver’s face and determines whether the driver is
40
drowsy or not. The weights for detecting facial features are used from a Haarcascades mod-
ule.The function dlib.get_frontal_face_detector() is used to detect all the faces present in the
given image frame. The dlib.shape_predictor() function extracts all the facial features from
the detected faces. The eyes are then mapped and eye contours are drawn. The aspect ratio
of the eye (ear) is calculated in each frame. If the ear value falls below a certain limit for
consecutive frames, the driver is deemed drowsy.
The client.py program runs in the Raspberry Pi. Whenever the driver becomes drowsy, it
sends a signal to the Arduino via the GPIO pins.
41
F IGURE 6.3.13
Finished product
6.4 Testing
The testing of the final product is done in three ways
Test 1. :The accuracy of the drowsiness detection is tested
The Raspberry Pi program is run independently after removing connections to the Ar-
duino. Pre-recorded video files are used instead of real-time video recording. A random set of
videos of attentive and drowsy people are fed to the program and the ability of the program
to classify them is calculated
Test 2 :The manual control of the BLDC is tested using the potentiometer
42
The product is run without connecting the Raspberry Pi. The Arduino, ESU and the BLDC
are powered on using the LiPo. The potentiometer is varied to change the speed of the motor.
Proper working of manual speed control is verified.
Test 3 :The speed limit for different drowsiness is verified
The product is powered on and the driver is made to show varying degree of attention.
The speed of the BLDC is also varied manually. The working of the speed limiter is verified.
• The program was able to detect drowsiness in drivers with a very high level of accuracy.
43
• Below a value of speed, the BLDC was not able to sustain the rotation and the RPM fell
to zero.
• The rotory encoder failed to read speed accurately at very high RPMs
6.6 Conclusion
The tests on the product was done successfully. The test results were closely observed, an-
alyzed and conclusions were made.The issues that arose can be fixed by making slight changes
to the hardware used. The Raspberry Pi used has to be replaced by a better microcontroller
with inbuilt GPU and faster processing speed. BLDC motor with good low speed performance
can be used to tackle the sudden fall to zero speed observed in the current BLDC. Hall effect or
optical rotory encoder can be used to measure very high speeds. The latency problem can be
fixed by using Arduino with faster CPU. The image processing programs can be run in Cloud
servers and high internet connectivity can considerably decrease the latency issue.
44
7 Conclusions
The finished product performed as expected in the tests conducted. The attention of the
driver was successfully monitored and the speed of the BLDC limited as required.
References
[1] Javed Ahmed, Jian-Ping Li, Saeed Ahmed Khan, Riaz Ahmed Shaikh, "Eye be-
haviour based drowsiness Detection System", 12th International Computer Conference
on Wavelet Active Media Technology and Information Processing (ICCWAMTIP), 18-
20 Dec. 2015, Chengdu, China, doi:10.1109/iccwamtip.2015.7493990, pp. 5, 6, 30.
[2] Mohammad Amin Assari, Mohammad Rahmati, "Driver Drowsiness Detection Us-
ing Face Expression Recognition", IEEE International Conference On Signal and Im-
age Processing Applications (ICSIPA), 16-18 Nov. 2011, Kuala Lumpur, Malaysia,
doi:10.1109/icsipa.2011.6144162, pp. 5, 6.
[3] R. Arulmozhiyal, R. Kandiban, "An intelligent speed controller for Brushless DC motor",
7th IEEE Conference on Industrial Electronics and Applications (ICIEA), 18-20 July
2012, Singapore, Singapore, doi:10.1109/iciea.2012.6360690, pp. 5.
[4] Abhijeet S Taksale, Priti Shahane, Vishwas Vaidya, Vivek Deulkar, Goutham Dron-
amraju, "Hardware in the loop for electronic speed limiter", IEEE International
Transportation Electrification Conference (ITEC), 27-29 Aug. 2015, Chennai, India,
doi:10.1109/itec-india.2015.7386899, pp. 6.