for partial fulfillment of the award of degree of bachelor
TRANSCRIPT
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
i
CERTIFICATE
This is to certify that the dissertation entitled “Microcontroller Based Automatic Vehicle Lock
Control System of Drunken Driver‟‟ has been carried out by the above group members
For partial fulfillment of the award of degree of
BACHELOR OF SCINCE IN ELECTRICAL AND COMPUTER
ENGINEERING
Specialized in
INDUSTRIAL CONTROL ENGINEERING
At Ethiopian Institute of Technology-Mekelle, during the academic year 2014
Zenachew.M (MSc. In Electrical Power Eng) …………………….
Program coordinator of ECE Signature
Dr:-Ing. Gebremicheal Te-ame, Assistance Professor
Advisor Signature
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
ii
ABSTRACT
Road accidents are very common in today‟s busy life. Thus drunk driving is a major reason
accident in any country all over the world. Most of the people use private vehicles and
sometimes being careless, people may drive in a drunken state. This may lead to hazardous
accidents. To avoid such conditions, we have done the project named as microcontroller based
automatic vehicle lock control of drunken driver as a smart solution to prevent the phenomenon
that enhances safety on roads.
The purpose of this project is to implement an alcohol detector-microcontroller system to reduce
traffic accident cases based on driving under the influence of alcohol.
A breath alcohol detector or better known as a breathalyzer plays a vital role in monitoring
alcohol concentration in a person‟s bloodstream. This project involves the design and
development of various devices such as breathalyzer device and its synchronization with other
device to control an ignition switch so as to assure the safety of the people inside the vehicle.
The hardware modules include the PIC16F877A microcontroller; alcohol sensors, LCD panel
and GSM modem. The software component includes the C programming language and source
code which is implemented PIC microcontroller. Upon assembly, the system is able to detect the
alcohol concentration in a person‟s breath sample and displays the detected amount in terms of
BAC (Blood Alcohol Concentration) percentage on the LCD panel. Based on the concentration
level According to the amount, the system decides whether to enable or disable the ignition
switch circuitry. It sends message through a GSM modem whenever a person is found to be
driving in a drunken state.
Keywords: Microcontroller (PIC16F877A), Alcohol Sensor, Blood Alcohol content, LED, LCD,
relay, buzzer and GSM module
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
iii
ACKNOWLEDGEMENT
First of all, we would like to thank God for his blessing, and we also want to express our deepest
gratitude to our supervisor Dr.-Ing Gebremicheal Te-ame for the unwavering support and
guidance throughout this Project.
Our deepest appreciation also goes out to Electrical & Computer Engineering department who
gave us many needed support, encouragement and help throughout our Project, and our friends
who struggling with us exploring this scope. Not to forget, thanks to our family and fellow
friends who encouraged us.
Finally, thank you to all those involved directly and indirectly helping us out during our design
& simulation which we can„t state out every one of them. A special expression of gratitude is
extended to everyone for their tolerance and patience in doing the Project. We must admit that
they had enriched us in many ways and words alone are not enough to express our gratitude.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
iv
Table of Contents
CERTIFICATE .............................................................................................................................................. i
ABSTRACT .................................................................................................................................................. ii
ACKNOWLEDGEMENT ........................................................................................................................... iii
LIST OF FIGURES .................................................................................................................................... vii
LIST OF TABLES ..................................................................................................................................... viii
LIST OF ACRONYMS ............................................................................................................................. viii
CHAPTER ONE ........................................................................................................................................... 1
INTRODUCTION ........................................................................................................................................ 1
1.1Introduction and Background of The project ....................................................................................... 1
1.2 Microcontrollers .................................................................................................................................. 2
1.3 Other Basic Components .................................................................................................................... 3
1.4 Problem Statement of the project ........................................................................................................ 4
1.5 Objective of the project ....................................................................................................................... 4
1.6 Scope of the project ............................................................................................................................ 4
1.7 Motivation and Significance of the Study ........................................................................................... 5
1.8 Methodology Applied to Overcome the Problem ............................................................................... 6
1.9 Limitation of the Study ....................................................................................................................... 7
1.10 Present Technology on the Automotive Manufacturer ..................................................................... 7
1.11 Organization of the Project ............................................................................................................... 7
CHAPTER TWO .......................................................................................................................................... 8
General Description of an Automatic Lock Control System of Vehicle for Drunken Driver ....................... 8
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
v
2.1 Review on the principal operation of Vehicle Ignition technology system ........................................ 8
2.2 How a Starting System Works .......................................................................................................... 10
2.3 Solenoid Valve .................................................................................................................................. 11
2.4 Vehicle Ignition System for a Drunk Driver That Uses Different Drives ........................................ 12
2.5 Breathe Alcohol Detection and Its Principles ................................................................................... 14
2.6 Alcohol Detection Principle for Breathalyser Applications .............................................................. 17
2.7 General Organization of PIC16F877A Microcontrollers .................................................................. 20
2.8 GSM MODEM.................................................................................................................................. 21
2.9 Hardware Requirements of the project ............................................................................................. 23
2.10 Methodology of the Project............................................................................................................. 24
CHAPTER THREE .................................................................................................................................... 26
INTERFACING OF PIC16F877A WITH EXTERNAL DEVICES .......................................................... 26
3.1 Pin description of PIC16F877A ........................................................................................................ 26
3.1.1 PIC16F877A microcontroller .................................................................................................... 32
3.2 Interfacing of PIC16F877A with other component And Operation of Alcohol Detection ............... 33
CHAPTER FOUR ....................................................................................................................................... 36
DESCRIPTION OF EMBEDDED SYSTEMS AND MICROCONTROLLER ........................................ 36
4.1 Description of C-program for automatic locked control system of vehicle for drunk driver ........... 39
4.2 Software Description of Microcontroller .......................................................................................... 39
CHAPTER FIV ........................................................................................................................................... 44
RESULTS AND DISCUSSION ................................................................................................................. 44
CHAPTER SIX ........................................................................................................................................... 48
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
vi
CONCLUSION AND RECOMMENDATION .......................................................................................... 48
6.1 CONCLUSION ................................................................................................................................. 48
6.2 Future Enhancements (Recommendation) ........................................................................................ 48
REFERENCES ........................................................................................................................................... 49
APPENDEX ................................................................................................................................................ 50
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
vii
LIST OF FIGURES
Figure 1: Block diagram of the system ......................................................................................................... 6
Figure 2: Starting System Diagram of Vehicle ............................................................................................. 9
Figure 3: Internal structure of Solenoid valve ............................................................................................ 12
Figure 4: vehicle ignition system for a drunk driver that uses benzene drive ............................................. 13
Figure 5: vehicle ignition system for a drunk driver that uses dissel drive ................................................. 13
Figure 6: Voltage Regulator Circuit............................................................................................................ 14
Figure 7: Alcohol Sensor, MQ-3................................................................................................................. 15
Figure 8: Pin Description of MQ-3 Sensor ................................................................................................. 16
Figure 9: Power Supply Circuit of PIC16F877A Microcontroller .............................................................. 21
Figure 10: GSM Modem ............................................................................................................................. 22
Figure 11: Hardware Materials of the Project ............................................................................................. 23
Figure 12: System Flowchart ...................................................................................................................... 25
Figure 13: PIC-16F877A ............................................................................................................................ 33
Figure 14: Connection of PIC16F877A microcontroller with other component ....................................... 34
Figure 15 : Developing embedded system .................................................................................................. 36
Figure 16 : Software development .............................................................................................................. 38
Figure 17: Block diagram of microcontroller ............................................................................................ 40
Figure 18: Condition When BAC equal 0.00% to 0.04% ........................................................................... 45
Figure 19: Condition When BAC equal 0.06% to 0.14 .............................................................................. 46
Figure 20: Condition When BAC equal 0.16% to 0.20% ........................................................................... 47
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
viii
LIST OF TABLES
Table 1: Various Cause of Vehicle Accident and their Result in Ethiopia .................................................. 5
Table 2: Step of Ignition Systems ................................................................................................................. 8
Table 3: Short Summery of Sensor Performances ...................................................................................... 17
Table 4: BrAC Vs BAC .............................................................................................................................. 19
Table 5: Pin description of port A ............................................................................................................... 27
Table 6: Pin description of port B ............................................................................................................... 28
Table 7: Port c ............................................................................................................................................. 29
Table 8: Pin Description of Port D & E ...................................................................................................... 30
Table 9: Summary of the Result ................................................................................................................. 44
LIST OF ACRONYMS
PIC ……………………………………………………Peripheral interface control
LED……………………………………………………Light Emitting Diode
LCD……………………………………………………Liquid Crystal Display
GSM…………………………………………………..Global System for Mobile communication
BAC……………………………………………………Blood Alcohol Concentration
AC………………………………………………………Alternating Current
DC ………………………………………………………Direct Current
µC……………………………………………….Microcontroller
µP………………………………………………………..Microprocessor
MCU………………………………………….................Microcontroller unit
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
1
CHAPTER ONE
INTRODUCTION
1.1 Introduction and Background of The project
At present drunken drivers have increased enormously and so, the deaths due to drunken drivers.
The main reason for driving drunk is that the police are not able to check each and every car and
even if they catch any one the police can be easily bribed. So there is a need for an effective
system to check drunken drivers.
In our alcohol detection system the ignition of the fuel is regulated by a sensor circuit. The
sensor circuit is used to detect whether alcohol was consumed by the driver recently which is
used to check whether alcohol is consumed while driving. If the breath sample contains no
alcohol, the driver is given full control to the speed of the vehicle.
There are different types of vehicle accidents which occurred in day to day life time with variety
of causes. Accidents may cause due to many reason it may a break failed system; it may occurred
due to over drunken driver person or due to over speed.Accidents that are due to over drunken
drivers and over speed driving are totally eliminated by applying control mechanism
accordingly. Starting from this point of view we make a system which is installed inside the
vehicle that eradicates the vehicle accident caused due to a drunken driver.
So our project is designed and developed as a system to bring the best solution by avoids such
vehicle accidents happening due to drunker driver. The alcohol concentration sensor MQ-3 that
detects the amount of alcohol taken by the driver accordingly the controller analysis and takes a
decision on the motor of the vehicle if the amount of alcohol detected is greater than the sated
value the motor doesn‟t work. In case the alcohol penetration speed in the blood may varies then
it is difficult to detect at the starting but gradually as the time goes the driver breath with the
correct content of alcohol that he/she have inside but since the circuitry is always active the it
would cutting-off the Fuel supply and induce the alarm & Indicators (display the amount on
LCD), but also it enabling a person who is not drunk to drive the same vehicle exact
concentration of the alcohol from the breath it may increase along the time so, since the detector.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
2
Here we are using embedded controller built around the 8051 family (PIC16F877A) for the
controlling of motor of the vehicle according to the data pattern produced at the input port of the
micro controller to produce the appropriate decision action will be taken. The logic is produced
by the program written in Embedded C language. The software program is written, by using the
MICROC environment. The program written is then converted in hex code after simulation and
burned on to microcontroller using flash micro vision c.
1.2 Microcontrollers
A large number of PIC microcontroller designs are available from microchip. Depending upon
the architecture, memory layout and processing power PIC (peripheral interface controllers) have
been classified as low range, midrange, and high range (Kenneth.J.Ayala, 1890).
The beauty of these devices is their easy availability, low cost and easy programming and
handling. This has made PIC microcontrollers as the apple of hobbyists and students eyes.
We shall be talking about mid-range PIC (PIC16F877) as a kernel in this project to explore the
intended operation. Knowledge gained by learning and exploring one microcontroller is almost
90% applicable on other microcontrollers of the same family. The only difference is in
availability of resources on different chips.
We are using this particular series of PIC microcontroller because:
1. It is very simple yet very powerful to use
2. It can be programmed and reprogrammed numerous times
3. It is small in size while have sufficient input/ output ports
4. It has low current consumption
5. It has on board multichannel analog to digital convertor
6. It has in-built PWM function
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
3
1.3 Other Basic Components
Alcohol Sensor:-
The model of alcohol sensor used is MQ-3 alcohol sensor manufactured by Hanwei
Manufacturers. This model is suitable to be used in developing devices such as alcohol checker
or breathalyzers (M.Fleischer, 2001).
The resistance of the MQ-3 varies with different types of gases at different concentration levels.
Therefore, when using this component, calibration is necessary to determine its proper alarm
point.
Blood Alcohol Concentration (BAC):-
It is necessary to devise a method to create test gas concentrations to mimic various BAC‟s. The
blood alcohol concentration is defined to be the percentage of alcohol, in grams, in 100mL of
blood. Therefore, 0.08% BAC is 80mg of alcohol within 100mL of blood. Since the sensor
detects the presence of alcohol in air, not blood, a relatively constant ratio of 2100:1 was
implemented to create these mock-solutions. This ratio comes from a scientifically agreed upon
notion that the Breath Alcohol Concentration is defined as the amount of alcohol, in grams, in
2100L of air (Xing-Long, 2006).
Motor control (Relay driven circuit):-
When the system detects that the blood alcohol concentration is more than the direction value, if
the driver has the intention to open the car key, automatic locked control system will make the
relay move and cut off the car engine power, which makes car is unable to be started, therefore
effectively prevents the driver from the drunken driving.
LCD display circuit:-
In order to display the alcohol concentration, the automatic locked control System adopts
LMO16L LCD display. The LCD has many advantages, such as low consumption, small
Volume, rich contents displayed, delicate and thin etc. It has been widely used in many kinds of
meters and other low consumption systems. It is integrated with PIC16F877A MCU.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
4
1.4 Problem Statement of the project
The factor of vehicle compactness on the road increased dramatically because of the population
in Ethiopia has been increasing rapidly years by years. Moreover the improvement in Ethiopia
living standard has contributed to the increasing number of vehicle on the road (private vehicle).
These factors are leading to a lot of road accidents. Some of the cases of these road accidents
may happen when there are drunken driver who driving in dangerous condition. At present the
death causes due to the drunken driver have increased radically. Traffic accidents caused by
drunk drivers not only causes the fatalities of life but also a distraction of the vehicle instrument.
However, an effective apparatus for preventing such kinds of accidents has not yet been
developed in our country.
1.5 Objective of the project
The aim and objective this system will to sense the alcohol level of the driver through breath and
control the motor to prevent the driver from such accident:-
1. Prevent the driver from driving if the alcohol level is over the limit.
2. To provides an automatic safety system for cars and other vehicles as well.
3. It prevents material distraction and avoids traffic accidents.
4. It saves the live of passengers.
1.6 Scope of the project
The Proposed System of an Automatic Locked Control System of Vehicle for Drunken Driver
will to assure safety of lives and to prevent material distraction when installed with every vehicle
by maintaining its real time operation. This System not only deals with component monitoring,
does even more than that like sending message to the traffic police station to indicate its status
and take another opportunity to run the activity safely.
Alcohol detection are the vital and of great importance from the perspective of passenger safety
and traffic safety. Impact detection and notification is also one of the lifesaving and critical
information provider system
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
5
1.7 Motivation and Significance of the Study
Now day the popularity of automotive in general and the private vehicle in particular have been
increased rapidly due to economic development and their necessity to human being for various
purposes; such as for transportation of people and goods.
Even though they become very vital in day to day human life as we seen and heard from
different corner of our country from various information sources like radio, television other
information center a hazardous accident is frequently happened on the people and materials due
to various causes; like driving in drunken condition, over speed driving and other braking
problem as shown in the table below during last years in 2007 and 2008 in GC (Road seafty in
Ethiopia, 2011).
Table 1: Various cause of Vehicle Accident and their Result in Ethiopia
Causes of traffic accidents Fatal Serious
Injury
Slight
injury
Property
damage
Total %age
Influence of alcohol or drug 51 7 17 193 268 10
Failure to respect rule 110 129 131 856 1,226 8
Failure to give-way for vehicles 20 65 112 1,507 1,704 11
Failure to give-way for
pedestrians
590 661 728 2,058 4,045 19
Following too closely 39 77 69 161 346 2
Improper overtaking 44 52 78 547 721 5
Improper turning 37 71 98 1,317 1,523 10
Over speeding 426 436 295 852 2,009 13
Failure to respect traffic signs 16 27 11 123 177 1
Driving with fatigue 30 20 20 23 93 1
Driving without attention 10 18 15 9 52 0
Improper parking/moving from
parking
52 62 81 772 967 6
Excess loading 76 135 88 43 342 2
Failure in vehicle 79 73 110 171 433 3
Defective road environment 12 13 19 62 106 1
Pedestrian error 34 164 29 17 244 2
Others 81 81 162 240 564 4
Unidentified 87 65 60 54 266 2 Total 1,802 2,156 2,123 9,005 15,086 100
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
6
Those bad occurrences are the main driving force to do this project of Microcontroller Based
Automatic Vehicle Lock Control System of Drunken Driver by installing this system inside the
vehicle it helps totally to eliminate the accident caused due to drunk driver and has the following
significance.
1. Reduced number of alcohol-related crashes.
2. Reduced number of injuries and fatalities caused by alcohol-related crashes.
3. Reduced damage to property from alcohol-related crashes
4. Frequent accident caused by drunk driver which results human fatalities and material
distraction.
1.8 Methodology Applied to Overcome the Problem
Vehicle accident prevention system includes several parts as follow: PIC 16F876A, alcohol
sensor circuit, alarm System, LCD display and ignition system. The block diagram of this system
is shown in Figure 1. PIC 16F876A is the heart of the system which connect both input and
output of the system. PIC 16F876A required input voltage of 5V in PIC as a voltage supply to
the other circuit.
Figure 1: Block diagram of the system
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
7
1.9 Limitation of the Study
Despite attempting to conduct the project, we had challenges on the following:
1) Lack of enough time
2) Lack some devices in the software
3) Lack of hard ware
1.10 Present Technology on the Automotive Manufacturer
Embedded electronic components are nowadays a prominent part of a car‟s architecture, the
security of Cars have become a main concern for the manufacturers. Nowadays many modern
car manufacturers produce a car which has transmission control unit, engine control unit, airbag
control unit, vehicle to vehicle communication, keyless entry, body controller, object detector as
well as the protection mechanisms by using Electronic Control Units (ECU) to monitoring and
controlling the different subsystems of a car. But the Automatic Locked Control System of
Vehicle for Drunken Driver not widely applied in the world wide vehicle industry in general
especially in our country it is not applied still. So that this leads to increase the traffic accident
.Our contribution to these protection mechanisms: the design and implementation our system is
install on existed car as well as in production new vehicle.
1.11 Organization of the Project
Chapter 1 describes introduction. Chapter 2 deals with the general description of Automatic
Locked Control System of Vehicle for Drunken Driver .Chapter 3 gives emphasis on Interfacing
of PIC16F877A with external devices, chapter 4 explains about description of embedded system
and microcontrollers and chapter 5 contains about the result and discussions obtained from the
project design and simulation. Finally, chapter 6 states the conclusion and some
recommendations forwarded from the project and future work.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
8
CHAPTER TWO
General Description of an Automatic Lock Control System of
Vehicle for Drunken Driver
2.1 Review on the principal operation of Vehicle Ignition technology system
The ignition system of various vehicles possesses various stage but they have some steps in
common the accessories, ignition, starting off and lock positions. As soon as the driver seats the
alcohol circuitry gets power from the car battery then at the first turning of the ignition key radio
and power windows get power from accessory. Then after the ignition stage to make ready the
fuel supply then continues to start the starter motor on which enables the main motor to run when
the required fuel supply was delivered at the ignition state the action taken at each stage is
provided in the table below.
Table 2: Step of Ignition Systems
different internal car
system
Key position
LOCK
ACC
ON
START
light system
some part
on
on
on
on
radio
in most
car off
on
on
on
window system
Off
on
on
on
Full & different oil
sensors
Off
off
on
on
fuel solenoid
valve
Off
off
on
on
starter solenoid Off off off on
The two off positions, off and lock; one turns off the car, and the other allows the key to be
removed from the ignition. When the key is turned to the signals are generated accordingly.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
9
In order to properly service the starting system, you need to understand how it operates. The
starting system has five main components: the ignition switches or start button, a neutral safety
switch (an option on some vehicles), starter relay, solenoid and motor.
Starting system this allows to activating the alcohol detection circuitry, to play the radio, work
the power windows, etc. while the engine is not running. Most ignition switches are mounted on
the steering column. Some switches are actually two separate parts; the lock into which you
insert the key. Once the engine starts, the key-operated switch is turned; a spring in the solenoid
assembly pulls the pinion gear away from the mesh, and the starter motor stops.
Figure 2: Starting System Diagram of Vehicle
Motor starter:-
A starter is an electric motor that turns over or "cranks" the engine to start it.
A starter consists of the very powerful DC electric motor and the starter solenoid that is usually
attached to the motor (see the picture). Inside, a typical starter motor has the electric windings
(coils) attached to the starter motor housing and the armature (the rotating part) that is connected
through the carbon brushes in series with the windings. On the front end of the armature, there is
a small gear that attached to the armature through an overrunning clutch.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
10
Solenoid starter:-
The starter solenoid works as a powerful electric relay - when activated, it closes the electric
circuit and sends the battery power to the starter motor. At the same, the starter solenoid pushes
the starter gear forward to mesh with the engine flywheel. A typical starter solenoid has one
small connector for the control wire (the white connector in the photo) and two large terminals:
one for the positive battery cable and the other for the starter motor.
Battery cables:-
A starter motor requires a very high current to crank the engine, that's why it's connected to the
battery with thick (large gauge) cables (see the diagram). The negative (ground) cable connects
the "-" battery terminal to the engine cylinder block close to the starter. The positive cable
connects the "+" battery terminal to the starter solenoid.
2.2 How a Starting System Works
When you turn the ignition key to the Start position, the battery voltage goes through the starter
control circuit and activates the starter solenoid, which in turn energizes the starter motor. At the
same time, the starter solenoid pushes the starter gear forward to mesh it with the engine
flywheel. The flywheel is attached to the engine crankshaft. The starter motor spins, turning the
engine crankshaft allowing the engine to start.
Natural safety switch: - For safety reasons, the starter motor can only be operated when the
automatic transmission is in Park or Neutral position, or if the car has a manual transmission,
when the clutch pedal is depressed. To accomplish this, there is a Neutral Safety Switch installed
at the automatic transmission shifter mechanism or at the clutch pedal in case of a manual
transmission. When the automatic transmission is not in a Park or Neutral (or when the clutch
pedal is not depressed), the neutral safety switch is open and the starter control circuit is
disconnected.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
11
2.3 Solenoid Valve
Solenoids act as electric to mechanical energy converters, taking an electrical signal and
converting it to work. The operation is based upon the reaction of a moving element, the
armature or plunger, in response to a magnetic field developed by an electrical conductor,
usually a winding. Solenoids can be configured to operate in either Direct Current (DC), or
Alternating Current (AC). Solenoids are electromechanical actuating devices found in many
types of applications.
The solenoid switches is the part of automobile which relays a large electric current to the starter
motor. The system converts electrical energy from the batteries into mechanical energy to turn
the engine over. It is mounted on the starting motor and forms the major component of the
starting system. The coils inside the solenoid are energized by electricity, they create a magnetic
field which attracts and pulls a plunger. Attached to one end of this plunger is a shift lever.
The lever is connected to the drive pinion and clutch assembly of the starter motor. The solenoid
receives a large electric current from the car battery and a small electric current from the ignition
switch.
As the ignition switch is turned, a small electric current is sent to the starter solenoid. The pair of
heavy contacts closes, relaying the large electric current to the starter motor, which in turn sets
the engine in motion. Once the engine starts, the key-operated switch is turned; a spring in the
solenoid assembly pulls the pinion gear away from the mesh, and the starter motor stops.
The starter's pinion is clutched to its driveshaft through an overrunning sprig clutch which allows
the pinion to transmit drive in only single direction. In this manner, drive is transmitted through
the pinion to the flywheel ring gear.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
12
Figure 3: Internal structure of Solenoid valve
2.4 Vehicle Ignition System for a Drunk Driver That Uses Different Drives
Regardless of the driver taken by the vehicle either it is electrical or chemical the controlling
technique of the ignition system applies to both in same way by same controller the trick in
choosing the appropriate position in order to control system.
In case of dissel vehicle we choose to control the solenoid valve which controls the fuel supply
to the main motor this is necessary because if we control the starter motor someone can take or
drink an alcohol or at starting the exhaled alcohol may be very small even the driver can take
more than amount but doesn‟t penetrated to the blood but later it was so, to monitor the status of
the driver every time and take appropriate action we select to control the solenoid valve by
controlling the relay this serves for both dissel and benzene drive vehicle. The relay was
energized according the controller decision if driver consumes an alcohol more than the allowed
value based on the program it doesn‟t energize if not it does.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
13
Figure 4: vehicle ignition system for a drunk driver that uses dissel drive
Figure 5: vehicle ignition system for a drunk driver that uses benzene drive
Voltage Regulator:-
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
14
Obviously the microcontroller and the alcohol sensor uses 5volt DC supply but the battery
supply‟s 12 volt DC therefore this voltage reduced in to suitable amount using the 7805
regulator shown below hence, the distributer continuously feeds to the battery to maintained it
always. Therefore, it should be reduced to a convenient amount of voltage using a regulator the
circuit given below produces an output voltage of the desired amount.
Figure 6: Voltage Regulator Circuit
2.5 Breathe Alcohol Detection and Its Principles
The alcohol sensor used here is MQ-3 is used for alcohol detection. It can detect the presence
and concentration of alcohol. The sensing element used is SnO2.SnO2 behaves as an insulator
but when it is heated it starts behaving as a semiconductor due to the increase in the mobility of
electrons (A.C.Romain, 2010).
When the alcohol molecule fall on the SnO2 surface its resistance decreases and the amount of
current deliver increases. It is a six pin device, with an integrated heating coil. Sensitivity of
SnO2 is greater at higher temperatures. The supply voltage is 5V DC. The output voltage
proportional to the alcohol concentration is an analog voltage and is given to the ADC. The
Sensitive material of MQ-3 gas sensor is SnO2, which have lower conductivity in clean air.
When the target alcohol gas exist, the sensor‟s conductivity is higher along with the gas
concentration rising. It uses simple electronic circuit; Convert change of conductivity to
correspond output signal of gas concentration.MQ-3 gas sensor has high sensitivity to Alcohol,
and has good resistance to disturb of gasoline, smoke and vapor.
The sensor could be used to detect alcohol with different concentration; a breath alcohol ignition
interlock device mechanism which is installed in a vehicle's dashboard. Before the vehicle can be
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
15
started, the driver must breathe into the device. If the analyzed result is over a programmed
predetermined blood alcohol concentration, the vehicle will not start. This device keeps a record
of the activity on the device and is interlocked with the vehicle's electrical system. .
It is with low cost and suitable for different application. Its specifications, features as well as
applications include:-
1) High sensitivity to alcohol (ethanol) and small sensitivity to Benzene.
2) Fast response and High sensitivity
3) Stable and long life
4) Simple drive circuit
Figure 7: Alcohol Sensor, MQ-3
This is an alcohol sensor named MQ-3, which detects ethanol in the air. It is one of the
straightforward gas sensors so it works almost the same way with other gas sensors. It is used as
part of the breathalyzers or breath testers for the detection of ethanol in the human breath.
Basically, it has 6pins, the cover and the body. Even though it has 6 pins, you can use only 4 of
them. Two of them are for the heating system (H) and the other 2 are for connecting power and
ground (A and B).
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
16
Figure 8: Pin Description of MQ-3 Sensor
The sensor needs two voltages sources, heater voltage (VH) and test voltage (VC). VH used to
supply certified working temperature to the sensor, while VC used to detect voltage (VRL) on
load resistance (RL) whom is in series with sensor. The sensor has light polarity, VC needs DC
power. VC and VH could use same power circuit with precondition to assure performance of
sensor. In order to make sensor with better performance, with suitable, RL value is needed.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
17
Table 3: Short Summery of Sensor Performances
Parameter Value Unit
Time taken for sensor to
stabilize
15 to 20 Seconds
Operating temperature Room temperature 25 °C
Resistance in air (typical) 100 kΩ air at room temperature
At normal atmosphere
detected value
0 to 1.18 V V
At Saturated output voltage 4.75 V
Output voltage range 0 to 4.75 V
Main Applications of the sensor:-
1) It is used as part of the breathalyzers or breath testers for the detection of ethanol in the human
breath.
2) They are suitable for alcohol checker, Breath analyzer.
3) Vehicle alcohol detector
4) Portable alcohol detector
2.6 Alcohol Detection Principle for Breathalyser Applications
Over the years, breath testing has become a widely used method for quantitative determination of
the level of intoxication of individuals suspected of driving while under the influence of alcohol.
After recognition of the need for quantitative assessment of intoxication, blood alcohol
concentration was considered as the single most important variable. However concern about the
invasiveness of drawing a blood sample led to the development of the breath test as a non-
invasive means of assessing level of intoxication.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
18
The breath test is an indirect test, but has been considered to be a good estimate of the blood
alcohol concentration because of the assumption that an exhaled breath sample accurately
reflects the alveolar (or deep-lung) air which is in equilibrium with the blood. Many studies have
been performed to quantify the relationship between breath alcohol concentration (BrAC) and
blood alcohol concentration (BAC) with the goal of defining a precise relationship between the
two for accurate non-invasive determination of BAC.
The medical definition for human being is 1g of alcohol in 1 litre of blood corresponds to 1g of
alcohol in 2100 litres of exhaled air which is equal to 0.476 mg/l air. From this we can deduce
different amount of alcohol to blood concentration by varying the alcohol consumption of
individuals. The blood alcohol concentration is defined to be the percentage of alcohol, in grams,
in 100mL of blood. Therefore, 0.08% BAC is 80mg of alcohol within 100mL of blood.
Various countries have various stated low that guides the alcohol consumption of their driver
taking this in to account we have determine our specification which doesn‟t make a great
difference but taking the averaged value. We analyze for the following concentration levels to
find the amount of ethanol needed in each solution: 0.00, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, and
0.20.
To simplify the analysis we organize those concentrations of alcohol in to some interval with
their corresponding generated voltage to demonstrate the effect of each alcohol concentration by
signalling distinct light on the protuse software. For simulation purpose we have used
potentiometer instead of alcohol sensor to show the status of various components for ever
voltage level. This voltage is produced by varying the resistance value of potentiometer (1k ohm
at full reading). The corresponding concentration of alcohol in a breath for the above value is
given below in the table.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
19
Table 4: BrAC Vs BAC
concentration of alcohol in a
breath (
BAC (%) decision of Microcontroller based
on the program
0
0.00%
0.02%
0.04%
0.06%
0.08%
0.10%
0.12%
0.14%
0.16%
0.18%
0.20%
Green light on(at normal condition)
Green light on
Green light on
Yellow light on(warning)
Yellow light on
Yellow light on
Yellow light on
Red light on (under risk)
Red light on
Red light on
Red light on
Notice the concentration of alcohol in a breath is calculated from BAC% .example 0.06% of
BAC means 60mg of alcohol with in 100ml of blood but since the sensor detects the presence of
alcohol in air, not blood, a relatively constant ratio of 2100:1 was implemented to create these
mock-solutions. This ratio comes from a scientifically agreed upon notion that the Breath
Alcohol Concentration is defined as the amount of alcohol, in grams, in 2100L of air.
Hence the 06% in BAC
= gram pre litter in BrAC the rest are
done in same fashion.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
20
2.7 General Organization of PIC16F877A Microcontrollers
The Microcontroller (PIC16F877A) is a low power; high performance CMOS 8-bit micro
controller with 8kbytes of Flash programmable and 256byte of read only memory data
(EEPROM).The on-chip Flash allows the program memory to be reprogrammed in-system or by
a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the PIC16F877A is a powerful microcomputer, which provides a
highly flexible and cost-effective solution to many embedded control applications. By using this
controller the data inputs from the alcohol sensor is passed to the parallel port of the
microcontroller and accordingly the program responds. PIC16F877 have 40-pin with each pin
has been assigned a number of functions.
In a given circuit/application (CH-3, pic16F877A) a pin is usually tied to a specific job, and all
functionality of a pin is usually not required, however you make option to use the specific pin
your own way.
The specific function of a pin is selected by configuring various bits of internal registers. The
number and names of these special function registers (SFRs) vary from device to device as some
devices have limited functionality while others have more. Nevertheless if we are talking about a
function which is present in both devices, its SFR will be same. The selection and settings of
these SFR‟s is the key to successful programming. It is therefore mandatory to go through the
data sheets of the device before starting a project.
Second important thing to know is that the devices with same number of pins are all pin-
compatible. Which means if you design a project for 40 pin PIC microcontroller, and later want
to replace the chip with another 40 pin PIC the pins are all compatible.
Power Supply:-
PIC microcontrollers use TTL logic, and therefore expect a well regulated 5V power supply. The
supply may however range from 3.5V to 5.5V. These microcontrollers require very small amount
of current. Indeed these devices have been labeled as nano-watt technology devices. The logical
levels are also same, a signal from 0 to about 2V is considered as logical „0‟ and a signal from
3.5V to 4.5V is considered as logical „1‟. In order to communicate with devices using higher
logical voltages, consider level conversion.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
21
Figure 9: Power Supply Circuit of PIC16F877A Microcontroller
MCLR, Master Clear On every PIC microcontroller you will find a pin labeled as MCLR. The
MCLR pin when connected to ground, will reset the microcontroller, and keep it in reset state,
till the ground connection is released. After that the microcontroller will have all its RAM reset,
and program execution will begin, just like the system has been just powered on. A 10K pull up
resistor is usually connected with the pin, to keep it high when reset switch is released.
The same pin will also work as program mode pin. When new software is to be downloaded into
the microchip, about 12V are applied to the MCLR pin, by your programming device. This can
be done right in your circuit, or by taking the IC out of circuit and putting it into the IC socket on
your programmer. We shall talk more about this in section on programming. The 10K resistor is
then useful to avoid 12V reaching VCC and therefore to other devices.
2.8 GSM MODEM
A GSM modem is a specialized type of modem which accepts a SIM card, and operates over a
subscription to a mobile operator, just like a mobile phone. When a GSM modem is connected to
a computer, this allows the computer to use the GSM modem to communicate over the mobile
network to send and receive SMS and MMS.
GSM modems can be a quick and efficient way to get started with SMS, because a special
subscription to an SMS service provider is not required. In most parts of the world, GSM
modems are a cost effective solution for receiving SMS messages, because the sender is paying
for the message delivery.
A GSM modem is a wireless modem that works with a GSM wireless network. A wireless
modem behaves like a dial-up modem. The main difference between them is that a dial-up
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
22
modem sends and receives data through a fixed telephone line while a wireless modem sends and
receives data through radio waves. GSM modem requires a SIM card from a wireless carrier in
order to operate.
GSM/GPRS module is used to establish communication between a computer and a GSM-GPRS
system. Global System for Mobile communication (GSM) is an architecture used for mobile
communication in most of the countries. Global Packet Radio Service (GPRS) is an extension of
GSM that enables higher data transmission rate.
Figure 10: GSM Modem
A GSM Modem can be used to build the following applications:-
1. SMS Gateway i.e. to send and receive SMS
2. telemetric i.e. to collect data from remote terminals
3. call-back service for VOIP
4. SMS application, SMS solution
5. automatic reloading of pre-paid account
6. machine to machine communication
7. sending SMS from PC
8. automating business process
9. vehicle tracking with cell broadcast feature or with integrated GPS terminal
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
23
2.9 Hardware Requirements of the project
The overall placement and organization of the intended material to accomplish the desired
system is given below with their brief explanation.
Figure 11: Hardware Materials of the Project
We check the driver weather she/he is drunken or not using the above system inserted inside
vehicle. If the driver is dunked, then alcohol sensor will sense the amount of alcohol consumed
and displays the amount on the LCD. Then the microcontroller takes an action based on pre-
sated amount. There are three states that characterize the driver states; intoxication, slightly
drunk and unconscious. When the driver drives at unconscious mode the GSM modem sends the
desired SMS to the traffic police as soon as the vehicle motor stops.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
24
2.10 Methodology of the Project
Flow chart of the system:-
This flow chart below shows the interconnection of various components or hardware and their
sequential operation when the sensor become active it senses the amount of alcohol taken by the
driver and this data is processed or analysis by the controller then after the controller initiates a
command signal and the other components are activated based on the present data they received
from the microcontroller. Every time, after the data is analyzed by the controller the current
value output in means of BAC percentages will be displayed on the 2 × 16 LCD. If high alcohol
concentration is detected in the provided breath sample, port in the microcontroller will go high
and turn on the desired parameter.
For first condition, LCD will display “intoxication” when the alcohol sensor detected BAC level
from 0.00-0.04 0f BAC in (%). This condition showed that the driver is free from alcohol and
there is no alarm sound from the buzzer. While the ignition system is enable means the river is
conscious and can drive the vehicle on the road safely.
The next condition is slightly drunk with 0.06-0.14 BAC in (%) drunkenness level. This means
the driver has drunk with a little amount of alcohol, but need to be assisted during the driving on
the road. The buzzer is activated to alert the driver and the people in vicinity that the driver is
slightly drunk.
In the last condition, the ignition system is deactivated as the level of BAC become high from 0.
16 -0.20 BAC in (%).The driver is totally unconscious and not safe for driving and the vehicle
stops; as soon as the GSM modem sends a text to traffic police.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
25
System start
MQ-3 alcohol
sensor become
active and senses
Microcontroller
Analyze and decide
the BAC(%)
Of the driver
For BAC(%)
0.06-0.14
Slightly drunk
For BAC(%)
0.00-0.04
intoxicate
Green light onYellow light
on
Relay normal open
Ignition valve
closed fuel supply
stop
Red light onBuzzer on
GSM sends text
to
Police station
For BAC(%)
0.16-0.14
Slightly drunk
Figure 12: System Flowchart
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
26
CHAPTER THREE
INTERFACING OF PIC16F877A WITH EXTERNAL DEVICES
3.1 Pin description of PIC16F877A
The PIC16F877A micro controller is a 40-pin IC. The 11th
and 32th
pins of the controller are Vdd
pin and the 5V dc supplies are given to these pins. The 12th
and 31th
pins of the controller are Vss
pin and are grounded. A 20 MHZ crystal oscillator is connected to 13th
and 14th
pins of the
PIC16F877A micro controller and two 20pf capacitors are connected to ground from 13th
and
14th
pins. The 1st pin is Reset pin.
Special function register:-
RA0-RA5: RA is a bidirectional port. That is, it can be configured as an input or an output. The
number following RA is the bit number (0 to 5). So, we have one 5-bit directional port where
each bit can be configured as Input or Output.
RB0-RB7: RB is a second bidirectional port. It behaves in exactly the same way as RA, except
there are 8 - bits involved.
RC0-RC7 & RD0-RD7: RC & RD are bidirectional ports. They are 8-bit wide pins.
RE0-RE2: 3-bit wide, bidirectional.
VSS and VDD: These are the power supply pins. VDD is the positive supply, and VSS is the
negative supply, or 0V. The maximum supply voltage that you can use is 6V, and the minimum
is 2V.
OSC1/CLK IN And OSC2/CLKOUT: These pins are where we connect an external clock, so
that the microcontroller has some kind of timing.
MCLR: This pin is used to erase the memory locations inside the PIC (i.e. when we want to re-
program it). In normal use it is connected to the positive supply rail.
INT: This is an input pin which can be monitored. If the pin goes high, we can cause the program
to restart, stop or any other single function we desire. We won't be using this one much.
T0CK1: This is another clock input, which operates an internal timer. It operates in isolation to
the main clock. Again, we won't be using this one much either.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
27
Table 5: Pin description of port A
Pin name I/O/P type Description
OSC2/CLKO
OSC2
CLKO
O
O
Oscillator crystal or clock o/p
Oscillator crystal o/p
External clock source o/p
MCLR/VPP
MCLR
VPP
I
P
Master clear (i/p) or programming
voltage (o/p).
Master clear (rest) i/p this pin is
an active low rest to the device.
programming voltage i/p
RA/AN
RA0-RA5
AN0-AN5
VREF-
CVREF
VREF+
T0CKI
CIOUT
SS
C2OUT
I/O
I
I
O
I
I
O
I
O
PORTA is bidirectional I/O port
Digital I/O
Analog i/p 0-5
A/D reference voltage (low)input
Comparator VREF output
A/D reference voltage (high)input
Timer0 external clock input
Comparator o/p
SPI slave select i/p
Comparator2 output
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
28
Table 6: Pin description of port B
Pin name I/O/P Type Description
RB/INT
RB0-RB7
INT
PGM
PGC
PGD
I/O
O
I
I
I/O
Digital I/O.
External interrupt.
Low voltage ICSP programming
enable pin.
In-circuit debugger and ICSP
programming clock.
In-circuit debugger and ICSP
programming data.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
29
Table 7: Port c
Pin name I/O/P Type Description
RC
RC0-RC7
TIOSO
TI0SI
TICKI
CCPI
SCK
SCL
SDI
SDA
SDO
TX
CK
RX
DT
I/O
O
I
I
I/O
I/O
I/O
I/O
I
I/O
O
O
I/O
I/O
PORTC is bidirectional I/O port.
Digital I/O.
Timer1 oscillator output.
Timer1 oscillator input.
Timer1 external clock input.
Capture1 input, comparator1o/p,
PWM1 o/p.
Capture2 input, comparator2 o/p,
PWM2 o/p.
Synchronous serial clock i/o for SPI
mode.
Synchronous serial clock i/o for
C mode. SPI data in.
I2 C data I/O.SPI data out.
USART a synchronous transmit.
USART synchronous clock.
USART asynchronous receive.
USART synchronous data.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
30
Table 8: Pin Description of Port D & E
Pin name
I/O/P Type
Description
RD
RD0-RD7
PSP0-PSP7
RE
RE0-RE2
AN5-AN7
RD
WR
CS
I/O
I/O
I/O
I
I
I
I
PORTD is bidirectional I/O port or
parallel slave port when interfacing
to a microprocessor bus.
Digital I/O.
Parallel slave port data.
PORTE is bidirectional I/O port.
Digital I/O.
Analog input (5-7).
Read control for parallel slave port.
Write control for parallel slave
port.
Chip select control for parallel
Slave port.
In order to enable the microcontroller to operate properly it is necessary to provide:
a) Power Supply
b) Reset Signal
c) Clock Signal
Power supply unit:-
Even though the PIC16 F877A operates at different supply voltages; the circuit, uses a cheap
integrated three-terminal positive regulator, LM7805, provides high-quality voltage stability and
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
31
quite enough current to enable microcontroller and peripheral electronics to operate normally
(enough in this case means 1Amp).
Reset signal:-
In order that the microcontroller can operate properly, a logic one (VCC) must be applied on the
reset pin it explains the connection pin-resistor 10K-VCC. The push-button connecting the reset
pin MCLR to GND is not necessary. However, it is almost always provided because it enables
the microcontroller safe return to normal operating conditions if something goes wrong. By
pushing this button, 0V is brought to the pin, the microcontroller is reset and program execution
starts from the beginning. The 10K resistor is there to allow 0V to be applied to the MCLR pin,
via the push-button, without shorting the 5VDC rail to ground.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
32
Clock signal:-
Even though the microcontroller has a built in oscillator, it cannot operate without external
components which stabilize its operation and determine its frequency (operating speed of the
microcontroller). Depending on which elements are in use as well as their frequencies, the
oscillator can be run in four different modes:
LP -Low Power Crystal;
XT -Crystal / Resonator;
HS -High speed Crystal / Resonator; and
RC -Resistor or Capacitor
3.1.1 PIC16F877A microcontroller
The PIC16F877A provides the following standard features: 14Kbytes or 8k 14 bit-Flash, 368
bytes of RAM, 33 I/O lines, three 16-bit timer/counters,15 interrupt architecture of which 2 of
them are external interrupts; a full duplex serial port, on-chip oscillator and clock circuitry. In
addition, the PIC16F877A is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode stops the CPU while
allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The
Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip
functions until the next hardware reset.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
33
Figure 13: PIC-16F877A
3.2 Interfacing of PIC16F877A with other component And Operation of
Alcohol Detection
At the time of alcohol detection the sensors (MQ-3) that detect the amount of alcohol taken by
the driver is fixed at the certain distance as near as possible to get the maximum sensitivity and
placed on the front side of the driver. As soon as the sensed signal is send to the microcontroller
(PIC16F877A) to analyze accordingly as per the program that signals the appropriate device
based on the controller decision for different alcohol to blood concentration.
There are various states like low, medium & high that associates the green (intoxicated), yellow
(slightly drunk) & red (unconscious) light to indicate the status of the driver. Those signal the
necessary information about the driver to the passengers (people inside the vehicle) the
corresponding alcohol content is displayed numerically on LCD to announce for the driver.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
34
The green light signifies that the driver doesn‟t take an alcohol whereas the yellow card indicates
the driver have taken an alcohol, but doesn‟t mean the target is missed (i.e. it depends on the
amount taking cup of alcohol doesn‟t have the same impact on the thinking of human mind as
many more of cup of alcohol). At the time when the red light is on the buzzer voice to mean the
driver have taken the alcohol which is beyond your tolerance and supply fuel was closed
consequently the main motor stop immediately and the GSM module will be activate at that time
and sends a message to the traffic police.
Figure 14: Connection of PIC16F877A microcontroller with other component
This design was developed using protuse 7 professional software to illustrate the basic
connection of the various component with the PIC16F877A microcontroller to build an
intelligent control system that prevents from being drive in a drunken condition.
LCD display:-
Liquid crystal display (LCD) has material which combines the properties of both liquid and
crystals. They have a temperature range with in which the molecules are almost as mobile as
they would be in a liquid, but are grouped together in an order form similar to crystal. LCD is a
passive component that is it does not make any light but just modifies the light passing through it
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
35
for alphanumeric displays. LCD is exclusively manufactured to be used with microcontrollers,
which means that it cannot be triggered by usual IC circuits.
LCD display in this system will act as an indicator to the driver about the level of drunkenness.
The LCD will display three condition based on BAC sensed by alcohol sensor. The conditions
are „intoxication‟, „slightly drunk‟ and „drunkenness‟ level. Alarm in this system is function to
alert the driver and other people in vicinity about the condition of the BAC level detected by
alcohol sensor.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
36
CHAPTER FOUR
DESCRIPTION OF EMBEDDED SYSTEMS AND
MICROCONTROLLER
A system is something that maintains its existence and functions as a whole through the
interaction of its parts. E.g. Body and Access Control etc. Embedded system is micro controller-
based, software driven, reliable, real-time control system. Microcontrollers and Microprocessors
are widely used in embedded system products. An Embedded product uses a Micro controller to
do one task only. A Printer is an example of embedded system that it is getting the data and
printing it.
Embedded System is a combination of hardware and software used to achieve a single specific
task only, after implementation you can„t use them for another purposes. E.g. you can„t watch
movies using the microprocessor of your microwave oven. Simply we can call any electronics
device that has a computer system embedded inside it an embedded system. Embedded systems
are computer systems that monitor, respond to, or control an external environment. Environment
connected to systems through sensors, actuators and other I/O interfaces. Embedded system must
meet timing & other constraints imposed on it by environment. High end & lower end embedded
systems. High–end embedded system, generally 32, 64 Bit controllers used with OS
(Muhammed Ali Mazidi, 1990).
Figure 15 : Developing embedded system
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
37
Hardware development:-
This includes choosing the right microcontroller unit for our application so that it can satisfy the
requirements of our project.
The criteria for choosing microcontroller are:
1. Number of I/O ports.
2. Serial communication modules.
3. Peripherals like (Timer, ADC, and PWM etc.)
4. Memory requirements.
5. Processing speed required.
6. Power requirements.
Software development:-
1. Writing the required algorithm using assembly or a high level language (almost C).
2. Using a compiler or assembler and a linker.
3. Debugging your code.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
38
Figure 16 : Software development
C Vs. Assembly Languages:-
Using assembly involves learning the used microcontroller„s specific instruction set but results in
the most compact and fastest code.
Using C programming language makes our code portable, which means that you can use it for
another target microcontroller without learning its instruction set; this eases the process of
software development (short time to market) with acceptable quality.
Assembly programs are optimized more than C programs, but to develop more complicated
programs, using C is more practical and also efficient.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
39
4.1 Description of C-program for automatic locked control system of vehicle
for drunk driver
A C-language program is written to interface the LCD with PIC16F877A is written in micro c
software. Initially all the variables and pins are set to zero i.e., initialized, all the required codes
to write this program are in pic16f877A.h header file. The sensor is initialized with variables
potentiometer at port A of pin 2 at RA0. And the port B is the output port assigned for various
LED„s, motor and buzzer. From this port pin 33, 34 and 35 at RB0, RB1 and RB2 are connected
to green LED, yellow LED and red LED respectively and the rest pin 36 and 37 at RB3 and RB4
are connect or control to the motor and buzzer. Again port c & d are set as output ports and are
connect to the GSM and LCD.
The pins of 25, 26 at RC5, RC6 of port C from the controller are connected GSM port of TXD
and RXD. The pins of 19,20,21,22,27 and 28 atRD0,RD1,RD2,RD3,RD4 and RD5 of port D the
controller are connected D4,D5,D6,D7,reset(RS) and enable (E) of the LCD 2X16 display
character.
For the automatic locked control of vehicle for a drunk driver the program execution will be as
follows: The sensor pin goes high and senses alcohol from the driver‟s breath and the
microcontroller received the sensed amount of alcohol in the form of voltage based of this
amount the controller activates (makes high) various output if the sensed amount is less than 1
volt the green LED and relay goes high ;if the sensed amount is greater than 1volt and less than
3volt the yellow LED and relay goes high also if the value is greater than 3volt the red LED,
buzzer and GSM become active (goes high). The GSM modem sends the message to the traffic
police in order take an appropriate action
4.2 Software Description of Microcontroller
Micro-controllers are also being used increasingly as tools for analysis and design of control
systems. The control engineer thus has much more powerful tools available now than in the past.
The purpose of this project work is to present control theory that is relevant to the analysis and
design of Micro-controller system with an emphasis on basic concept and ideas. It is assumed
that a Microcontroller with reasonable software is available for Computations and simulations so
that many tedious details can be left to the Microcontroller.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
40
A microcontroller is a highly integrated single chip, which consists of on chip CPU (Central
Processing Unit), RAM (Random Access Memory), EPROM/PROM/ROM (Erasable
Programmable Read Only Memory), I/O (input/output) –serial and parallel, timers, interrupt
controller. For example, Intel 8051 is 8-bit microcontroller and Intel 8096 is 16-bit
microcontroller.
A Computer on-a-chip is a variation of a microprocessor, which combines the processor core
(CPU), some memory, and I/O (input/output) lines, all on one chip. The computer-on-a-chip is
called the microcomputer whose proper meaning is a computer using a (number of)
microprocessor (s) as its CPUs, while the concept of the microcomputer is known to be a
microcontroller. A microcontroller can be viewed as a set of digital logic circuits integrated on a
single silicon chip. This chip is used for only specific applications.
Figure 17: Block diagram of microcontroller
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
41
Advantages of using a Microcontroller over Microprocessor
A designer will use a Microcontroller to
1. Gather input from various sensors
2. Process this input into a set of actions
3. Use the output mechanisms on the Microcontroller to do something useful
4. RAM and ROM are inbuilt in the MC.
5. Cheap compared to MP.
6. Multi machine control is possible simultaneously.
Examples: 8051, 89C51 (ATMEL), PIC (Microchip), Motorola (Motorola), ARM Processor,
Applications: Cell phones, Computers, Robots, Interfacing to two PC„s.
Types of microcontrollers:
Microcontrollers can be classified on the basis of internal bus width, architecture, memory and
instruction set as 4-bit, 8-bit, 16-bit and 32-bit microcontrollers.
4-bit Microcontrollers: These 4-bit microcontrollers are small size, minimum pin count and low
cost controllers which are widely used for low end applications like LED & LCD display drivers
,portable battery chargers etc.. Their power consumption is also low. The popular 4-bit
controllers are Renasa M34501 which is a 20 pin DIP chip with 4kB of ROM, 256 Bytes of
RAM, 2-Counters and 14 I/O Pins.
8-bit Microcontrollers: These are the most popular and widely used microcontroller‟s .About
55% of all CPUs sold in the world are 8-bit microcontrollers only. The 8-bit microcontroller has
8-bitinternal bus and the ALU performs all the arithmetic and logical operations on a byte
instruction. The well-known 8-bit microcontroller is 8051 which was designed by Intel in the
year 1980 for the use in embedded systems. Other 8-bit microcontrollers are Intel 8031/8052 and
Motorola MC68HC11 and AVR Microcontrollers, Microchip„s PIC Microcontrollers 12C5XX,
16C5X and 16C505 etc...
16-bit Microcontrollers: When the microcontroller performs 16-bit arithmetic and logical
operations at an instruction, the microcontroller is said to be a 16-bit microcontroller. The
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
42
internal bus width of 16-bit microcontroller is of 16-bit. These microcontrollers are having
increased memory size and speed of operation when compared to 8-bit microcontrollers. These
are most suitable for programming in High-level languages like C or C++ .They find applications
in disk drivers, modems, printers, scanners and servomotor control. Examples of 16-bit
microcontrollers are Intel 8096 family and Motorola MC68HC12 and MC68332 families, the
performance and computing capability of 16 bit microcontrollers are enhanced with greater
precision as compared to the 8-bit microcontrollers.
32-Bit Microcontrollers :These microcontrollers used in high-end applications like Automotive
control, communication networks, Robotics, Cell phones ,GPRS & PDAs etc.. For EX: PIC32,
ARM 7, ARM9, SHARP LH79520, ATMEL 32 (AVR), Texas Instrument„s; TMS320,
F2802x/2803x etc.....Some of the popular 32-bit microcontrollers.
Microcontroller development tools:-
To develop an assembly language program we need certain program development tools. An
assembly language program consists of Mnemonics which are nothing but short abbreviated
English instructions given to the controller. The various development tools required for
Microcontroller programming are explained below (Xiang, 2011)
1. Editor: An Editor is a program which allows us to create a file containing the assembly
language statements for the program. Examples of some editors are PC writes WordStar. As we
type the program the editor stores the ACSII codes for the letters and numbers in successive
RAM locations. If any typing mistake is done editor will alert us to correct it. If we leave out a
program statement an editor will let you move everything down and insert a line. After typing
the entire program we have to save the program. This we call it as source file. The next step is to
process the source file with an assembler.
Ex: Sample. Asm
2. Assembler: An Assembler is used to translate the assembly language mnemonics into machine
language (i.e. binary codes). When you run the assembler it reads the source file of your program
from where you have saved it. The assembler generates a file with the extension .hex. This file
consists of hexadecimal values encoding a sequence of data and their starting offset or absolute
address.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
43
3. Compiler: A compiler is a program which converts the high level language program like ―C‖
into binary or machine code. Using high level languages it is easy to manage complex data
structures which are often required for data manipulation. Because of its ease, flexibility and
debug options now a day the compilers have become very popular in the market. Compilers like
Kiel, Ride and IAR workbench are very popular.
4. Debugger/Simulator: A debugger is a program which allows executes the program, and
troubleshoots or debugs it. The debugger allows looking into the contents of registers and
memory locations after the program runs. We can also change the contents of registers and
memory locations and rerun the program. Some debuggers allow stopping the program after each
instruction so that you can check or alter memory and register contents. This is called single step
debug. A debugger also allows setting a breakpoint at any point in the program. If we insert a
break point, the debugger will run the program up to the instruction where the breakpoint is put
and stop the execution (Xiang, 2011).
A simulator is a software program which virtually executes the instructions similar to a
microcontroller and shows the results. This will help in evaluating the results without committing
any errors. By doing so we can detect the possible logic errors
5. Language: The translation process should also report the presence of errors in the source
program.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
44
CHAPTER FIVE
RESULTS AND DISCUSSION
The result of our project was demonstrated by simulation of the designed system using protues 7
professional software supported by the intended program written in c programing language to
meet its target value. For data analysis, a variable resistor (potentiometer) was connected to the
microcontroller as a replacement of the alcohol sensor. This input was varied its value
accordingly in range of 5 V to match the corresponding BAC value.
The analogue input received was quantized into digital signal in microcontroller. The signal was
further processed by the controller to yield its corresponding BAC value. This value was
displayed on the LCD panel. Simultaneously, the various parameters were switched „ON‟
depending on the input given. Hence, the result of the analysis was summarized as in the Table 4
Table 9: Summary of the result
When the sensor detected the BAC from 0.00% until 0.04%, the LCD was displayed B.A.C =
0.00% – 0.04%, and the other parameters are signaled as described in the table above. Except the
green light and relay the rest are deactivated as shown in the figure below.
BAC (%) Green
LED
Yellow
LED
Red
LED
Buzzer Relay(ignition
Switch)
GSM
modem
LCD
displays
Drunkenness
(drivers
status)
0.00-0.04 On Of Of Of Enable Of 0 -1.18V
Intoxicated
0.06-014 Of On Of Of Enable Of 1.23 - 2.35v
Slightly
drunk
0.16-0.20 Of Of On On Disable On 2.38 -4.75v
Unconscious
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
45
Figure 18: Condition When BAC equal 0.00% to 0.04%
When the sensor detected the BAC from 0.06% until 0.14%, the LCD was displayed B.A.C =
0.08% – 0.20%, and the state of the parameters is given on the above table. Except the yellow
light and relay the rest components become deactivate as illustrates in the figure below.
RA0/AN02
RA1/AN13
RA2/AN2/VREF-/CVREF4
RA4/T0CKI/C1OUT6
RA5/AN4/SS/C2OUT7
RE0/AN5/RD8
RE1/AN6/WR9
RE2/AN7/CS10
OSC1/CLKIN13
OSC2/CLKOUT14
RC1/T1OSI/CCP216
RC2/CCP117
RC3/SCK/SCL18
RD0/PSP019
RD1/PSP120
RB7/PGD40
RB6/PGC39
RB538
RB437
RB3/PGM36
RB235
RB134
RB0/INT33
RD7/PSP730
RD6/PSP629
RD5/PSP528
RD4/PSP427
RD3/PSP322
RD2/PSP221
RC7/RX/DT26
RC6/TX/CK25
RC5/SDO24
RC4/SDI/SDA23
RA3/AN3/VREF+5
RC0/T1OSO/T1CKI15
MCLR/Vpp/THV1
U1
PIC16F877A
D7
14
D6
13
D5
12
D4
11
D3
10
D2
9D
18
D0
7
E6
RW
5R
S4
VS
S1
VD
D2
VE
E3
LCD1LM016L
13%
RV1
1k
DC
R1
10k
RV1(3)V=1.18182
D1LED-GREEN
D2LED-YELLOW D3
LED-RED
R2
330
R3
330
R4
330
BUZ1
BUZZERD41N4004
Q1BC183BPR5
12
RL112V
RL1(NC)
D51N4004
Q22N3904
R6
2k
R5(1)V=1.02107e-11
Q1(C)V=12
R6(1)V=8.00333e-11
D3(A)V=0
R5(1)V=1.02107e-11
D4(K)
D5(K) ERROR
TXD3
RXD2
CTS8
RTS7
DSR6
DTR4
DCD1
RI9
P1
COMPIM
RXD
RTS
TXD
CTS
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
46
Figure 19: Condition When BAC equal 0.06% to 0.14%
When the sensor detected the BAC from 0.16% until 0.20%, the LCD was displayed B.A.C =
0.16% – 0.20%, and the other parameters are signaled as described in the table above. Except the
buzzer (alarm) and GSM (sends the required message to the traffic police) the rest components
become deactivate as shown in the figure below.
RA0/AN02
RA1/AN13
RA2/AN2/VREF-/CVREF4
RA4/T0CKI/C1OUT6
RA5/AN4/SS/C2OUT7
RE0/AN5/RD8
RE1/AN6/WR9
RE2/AN7/CS10
OSC1/CLKIN13
OSC2/CLKOUT14
RC1/T1OSI/CCP216
RC2/CCP117
RC3/SCK/SCL18
RD0/PSP019
RD1/PSP120
RB7/PGD40
RB6/PGC39
RB538
RB437
RB3/PGM36
RB235
RB134
RB0/INT33
RD7/PSP730
RD6/PSP629
RD5/PSP528
RD4/PSP427
RD3/PSP322
RD2/PSP221
RC7/RX/DT26
RC6/TX/CK25
RC5/SDO24
RC4/SDI/SDA23
RA3/AN3/VREF+5
RC0/T1OSO/T1CKI15
MCLR/Vpp/THV1
U1
PIC16F877A
D7
14
D6
13
D5
12
D4
11
D3
10
D2
9D
18
D0
7
E6
RW
5R
S4
VS
S1
VD
D2
VE
E3
LCD1LM016L
18%
RV1
1k
DC
R1
10k
RV1(3)V=1.63636
D1LED-GREEN
D2LED-YELLOW D3
LED-RED
R2
330
R3
330
R4
330
BUZ1
BUZZERD41N4004
Q1BC183BPR5
12
RL112V
RL1(NC)
D51N4004
Q22N3904
R6
2k
R5(1)V=1.02107e-11
Q1(C)V=12
R6(1)V=8.00333e-11
D3(A)V=0
R5(1)V=1.02107e-11
D4(K)
D5(K) ERROR
TXD3
RXD2
CTS8
RTS7
DSR6
DTR4
DCD1
RI9
P1
COMPIM
RXD
RTS
TXD
CTS
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
47
Figure 20: Condition When BAC equal 0.16% to 0.20%
The proposed semiconductor breath alcohol detector is cheaper in cost and is as effective as
other types of breath alcohol detector. Furthermore, the system can be easily interfaced to a
microcontroller as the output yield is in voltages. However, it was found that the value of the
concentration becomes saturated for BAC more than 0.20% even though the alcohol
concentration used is more than that value. When power dissipation comes into concern, the
semiconductor sensor model has very low power dissipation although it works with presence of
heat because it only needs low voltage value in the range of 3.3 V to 5 V as its input.
Sensitivity of the sensor is also relatively high compared to the other models. Although the
sensor is capable of detecting other substances and misinterprets it as alcohol, the sensitivity
towards alcohol is much higher and this makes it a very reliable alcohol detecting device.
RA0/AN02
RA1/AN13
RA2/AN2/VREF-/CVREF4
RA4/T0CKI/C1OUT6
RA5/AN4/SS/C2OUT7
RE0/AN5/RD8
RE1/AN6/WR9
RE2/AN7/CS10
OSC1/CLKIN13
OSC2/CLKOUT14
RC1/T1OSI/CCP216
RC2/CCP117
RC3/SCK/SCL18
RD0/PSP019
RD1/PSP120
RB7/PGD40
RB6/PGC39
RB538
RB437
RB3/PGM36
RB235
RB134
RB0/INT33
RD7/PSP730
RD6/PSP629
RD5/PSP528
RD4/PSP427
RD3/PSP322
RD2/PSP221
RC7/RX/DT26
RC6/TX/CK25
RC5/SDO24
RC4/SDI/SDA23
RA3/AN3/VREF+5
RC0/T1OSO/T1CKI15
MCLR/Vpp/THV1
U1
PIC16F877A
D7
14D
613
D5
12D
411
D3
10D
29
D1
8D
07
E6
RW
5R
S4
VS
S1
VD
D2
VE
E3
LCD1LM016L
28%
RV1
1k
DC
R1
10k
RV1(3)V=2.54545
D1LED-GREEN
D2LED-YELLOW D3
LED-RED
R2
330
R3
330
R4
330
BUZ1
BUZZERD41N4004
Q1BC183BPR5
12
RL112V
RL1(NC)
D51N4004
Q22N3904
R6
2k
R5(1)V=2.85386
Q1(C)V=0.901637
R6(1)V=4.95992
D3(A)V=4.84119
R5(1)V=2.85386
D4(K)
D5(K) ERROR
TXD3
RXD2
CTS8
RTS7
DSR6
DTR4
DCD1
RI9
P1
COMPIM
RXD
RTS
TXD
CTS
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
48
CHAPTER SIX
CONCLUSION AND RECOMMENDATION
6.1 CONCLUSION
The project thus gives a system that can detect a certain amount of alcohol present in the
atmosphere inside the vehicle and to a certain range and activates a microcontroller controlled
system that controls the ignition system and the other extra information which acts as an
indicator that enables a person to judge that person has taken alcohol and needs help or any
assistance or not.
The GSM modem sends a message to the traffic police and those who have the authority takes
necessary penalty to drunken driver to prevent from similar situation.
6.2 Future Enhancements (Recommendation)
The system can be further advanced by interfacing a GPS in the system that will inform about
the position of the car; thus provides easy location. The car using alcohol and proximity sensor
can be increased in side for sideways protection and easy alcohol detection. Since the blood
pressure changes due alcohol consumption instead of using alcohol sensor we can monitor the
blood pressure or heart beat by different sensors thus it can lead to a better method. A better
control algorithm like designed by fuzzy logic or neural network can lead to a stable control of
the vehicle. This project can be further enhanced by adding variety of sensor like level, speed,
direction and weight and other sensor to measure to measure and control the necessary parameter
about the vehicle.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
49
REFERENCES
[1] C.Romain, J. (2010). Long term stability of metal oxide-based gas sensors for environmental
applications.
[2] Kenneth.J.Ayala, [. (1890). The PIC16F877A microcontroller architecture programming
and applications, pen ram International. london.
[3] M.Fleischer, S. (2001). Selective gas detection with high temperature operated metal oxides
using catalytic filters, Sensors and Actuators. Tokyo.
[4] Muhammed Ali Mazidi, J. G. (1990). The 8051 Microcontroller and Embedded Systems.
[5] Xiang, X. Z. (2011). The basis of the c51 procedures, Microcomputer principle and the
application of C51 program design. Pearson Education, 189-206.
[6] Xing-Long, Z. (2006). Forensic medical discussion of drunken driving and traffic accidents .
Hon Kong.
[7] Road seafty in Ethiopia. (2011). UNITED NATION ECONOMIC COMMISSION FOR
AFRICA.
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
50
APPENDEX
c- Language Codding
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
// End LCD module connections
char txt1[] = "value";
char txt[45] ; char txt5[] ="%";
unsigned int in1;
volatile unsigned char i=0,j=0;
void main()
TRISA = 0xFF;
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
51
TRISC = 0x00;
TRISB = 0x00;
PORTB.F0=0; PORTB.F1=0; PORTB.F2=0; PORTB.F3=0;
PORTC.F2=0; PORTC.F3=0;
ADCON1 = 0x80;
ADCON0 = 0x81;
trisc.f6=0;
trisc.f7=1;
delay_ms(40);
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,txt1);
uart1_init(9600);
RCSTA.SPEN=1;
RCSTA.CREN=1;
delay_ms(50);
adc_init();
do
in1 = ADC_read(0);
if (in1<250)
float in5;
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
52
in5=(in1*100/1024);
IntToStr(in5,txt);
Lcd_Out(2,1,txt) ; Lcd_Out(2,8,txt5) ;
PORTB.f0=1;
else
PORTB.f0=0;
if (in1>249 && in1<510)
float in5;
in5=(in1*100/1024);
IntToStr(in5,txt);
Lcd_Out(2,1,txt) ; Lcd_Out(2,8,txt5) ;
PORTB.f1=1;
else
PORTB.f1=0;
if (in1>509 && in1<717 )
float in5;
in5=(in1*100/1024);
IntToStr(in5,txt);
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
53
Lcd_Out(2,1,txt) ; Lcd_Out(2,8,txt5) ;
PORTB.f2=1;
PORTB.f3=1;
PORTB.f4=1;
delay_ms(5);
uart1_write_text("at");
uart1_write(0xd);
delay_ms(1000);
uart1_write_text("at+cmgf=1");
uart1_write(0xd);
delay_ms(1000);
UART1_Write_Text("AT+CMGS=");
Delay_ms(40);
UART1_Write(0x22); //”
Delay_ms(40);
UART1_Write_Text("0914197052");
Delay_ms(40);
UART1_Write(0x22); //”
Delay_ms(40);
UART1_Write(0x0D); //
Delay_ms(1000);
UART1_Write(0x22);
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
54
Delay_ms(40);
UART1_Write_Text("the driver is drunk"); //
Delay_ms(40);
UART1_Write(0x22); //”
Delay_ms(40);
UART1_Write(26); //Ctr +Z
Delay_ms(40);
UART1_Write(0x0D); //
delay_ms(25000);
else
PORTB.f2=0;
PORTB.f3=0;
PORTB.f4=0;
while(1);