Microcontroller Basede Automatc Vehicle Lock Syste
Microcontroller Basede Automatc Vehicle Lock Syste
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
Specialized in
Advisor Signature
i
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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
ii
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
iii
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Table of Contents
CERTIFICATE .............................................................................................................................................. i
ABSTRACT .................................................................................................................................................. ii
INTRODUCTION ........................................................................................................................................ 1
1.2 Microcontrollers.................................................................................................................................. 2
General Description of an Automatic Lock Control System of Vehicle for Drunken Driver ....................... 8
iv
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
2.1 Review on the principal operation of Vehicle Ignition technology system ........................................ 8
2.4 Vehicle Ignition System for a Drunk Driver That Uses Different Drives ........................................ 12
3.2 Interfacing of PIC16F877A with other component And Operation of Alcohol Detection ............... 33
4.1 Description of C-program for automatic locked control system of vehicle for drunk driver ........... 39
v
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
REFERENCES ........................................................................................................................................... 49
APPENDEX................................................................................................................................................ 50
vi
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
LIST OF FIGURES
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
vii
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
LIST OF TABLES
Table 1: Various Cause of Vehicle Accident and their Result in Ethiopia .................................................. 5
LIST OF ACRONYMS
AC………………………………………………………Alternating Current
DC ………………………………………………………Direct Current
µC……………………………………………….Microcontroller
µP………………………………………………………..Microprocessor
MCU………………………………………….................Microcontroller unit
viii
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER ONE
INTRODUCTION
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.
1
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
2
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
3
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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
4
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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).
5
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
4. Frequent accident caused by drunk driver which results human fatalities and material
distraction.
6
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
7
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER TWO
radio in most on on on
car off
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.
8
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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.
9
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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.
10
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
11
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
12
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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:-
13
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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
14
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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:-
15
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
16
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
17
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
18
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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
19
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
20
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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
21
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
22
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
23
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
24
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
System start
MQ-3 alcohol
sensor become
active and senses
Yellow light
Green light on on
For BAC(%)
Buzzer on 0.16-0.14 Red light on
Slightly drunk
Ignition valve
closed fuel supply
stop
25
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER THREE
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.
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.
26
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
27
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
28
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Table 7: Port c
RC
29
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Digital I/O.
RD0-RD7 I/O
Parallel slave port data.
PSP0-PSP7 I/O
PORTE is bidirectional I/O port.
RE
RE0-RE2 I/O
Digital I/O.
AN5-AN7 I
Analog input (5-7).
RD I
Read control for parallel slave port.
WR I
Write control for parallel slave
CS I
port.
Slave port.
a) Power Supply
b) Reset Signal
c) Clock Signal
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
30
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
31
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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:
XT -Crystal / Resonator;
RC -Resistor or Capacitor
32
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
33
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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
34
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
35
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER FOUR
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).
36
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Hardware development:-
This includes choosing the right microcontroller unit for our application so that it can satisfy the
requirements of our project.
4. Memory requirements.
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.
37
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
38
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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
39
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
40
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Examples: 8051, 89C51 (ATMEL), PIC (Microchip), Motorola (Motorola), ARM Processor,
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
41
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
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.
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.
42
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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.
5. Language: The translation process should also report the presence of errors in the source
program.
43
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER FIVE
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
BAC (%) Green Yellow Red Buzzer Relay(ignition GSM LCD Drunkenness
LED LED LED Switch) modem displays (drivers
status)
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.
44
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
R3
R4
330
330
R2
330 D1 D2
LED-GREEN LED-YELLOW D3
LED-RED
LCD1
LM016L
D3(A)
VDD
VSS
VEE
V=0
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3
4
5
6
7
8
9
10
11
12
13
14
R1
DC
10k
RXD
U1 TXD
RV1 13 33
OSC1/CLKIN RB0/INT RTS
14 34
OSC2/CLKOUT RB1
RV1(3) 35
RB2 CTS
V=1.18182 2 36
13%
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
1k 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A P1
1
DCD
6
DSR
2
RXD
R6(1) 7
RTS
R5(1) V=8.00333e-11 3
TXD
V=1.02107e-11 8
CTS
RL1(NC) 4
DTR
9
RI
D4(K)
D5(K) ERROR
BUZ1
COMPIM
D4 BUZZER
R5(1) 1N4004
V=1.02107e-11 RL1
Q1(C) 12V
V=12
D5
1N4004
Q1
R5 BC183BP
12
R6 Q2
2N3904
2k
45
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
R3
R4
330
330
R2
330 D1 D2
LED-GREEN LED-YELLOW D3
LED-RED
LCD1
LM016L
D3(A)
VDD
VSS
VEE
V=0
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3
4
5
6
7
8
9
10
11
12
13
14
R1
DC
10k
RXD
U1 TXD
RV1 13 33
OSC1/CLKIN RB0/INT RTS
14 34
OSC2/CLKOUT RB1
RV1(3) 35
RB2 CTS
V=1.63636 2 36
18%
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
1k 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A P1
1
DCD
6
DSR
2
RXD
R6(1) 7
RTS
R5(1) V=8.00333e-11 3
TXD
V=1.02107e-11 8
CTS
RL1(NC) 4
DTR
9
RI
D4(K)
D5(K) ERROR
BUZ1
COMPIM
D4 BUZZER
R5(1) 1N4004
V=1.02107e-11 RL1
Q1(C) 12V
V=12
D5
1N4004
Q1
R5 BC183BP
12
R6 Q2
2N3904
2k
46
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
R3
R4
330
330
R2
330 D1 D2
LED-GREEN LED-YELLOW D3
LED-RED
LCD1
LM016L
D3(A)
VDD
VSS
VEE
V=4.84119
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3
4
5
6
7
8
9
10
11
12
13
14
R1
DC
10k
RXD
U1 TXD
RV1 13 33
OSC1/CLKIN RB0/INT RTS
14 34
OSC2/CLKOUT RB1
RV1(3) 35
RB2 CTS
V=2.54545 2 36
28%
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
1k 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A P1
1
DCD
6
DSR
2
RXD
R6(1) 7
RTS
R5(1) V=4.95992 3
TXD
V=2.85386 8
CTS
RL1(NC) 4
DTR
9
RI
D4(K)
D5(K) ERROR
BUZ1
COMPIM
D4 BUZZER
R5(1) 1N4004
V=2.85386 RL1
Q1(C) 12V
V=0.901637
D5
1N4004
Q1
R5 BC183BP
12
R6 Q2
2N3904
2k
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.
47
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
CHAPTER SIX
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.
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.
48
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
REFERENCES
[1] C.Romain, J. (2010). Long term stability of metal oxide-based gas sensors for environmental
applications.
[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.
49
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
APPENDEX
c- Language Codding
void main()
TRISA = 0xFF;
50
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
TRISC = 0x00;
TRISB = 0x00;
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;
51
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
in5=(in1*100/1024);
IntToStr(in5,txt);
Lcd_Out(2,1,txt) ; Lcd_Out(2,8,txt5) ;
PORTB.f0=1;
else{
PORTB.f0=0;
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;
float in5;
in5=(in1*100/1024);
IntToStr(in5,txt);
52
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
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);
53
Microcontroller Based Automatic Vehicle Lock Control System of Drunken Driver
Delay_ms(40);
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);
54