Professional Documents
Culture Documents
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS & COMMUNICATION ENGINEERING
By
B.VINEETHA (11RQ1A0486)
2015
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
MINA INSTITUTE OF ENGINEERING & TECHNOLOGY FOR WOMEN
(Approved by AICTE, New Delhi, Affiliated to JNTUH,
Hyderabad)
CERTIFICATE
This is to certify that the dissertation entitled MICROCONTROLLER BASED
AUTOMATIC ENGINE LOCKING SYSTEM FOR DRUNKEN DRIVERS that
is being submitted by B.VINEETHA (11RQ1A0486) in partial fulfillment for the award
of the Degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS &
COMMUNICATION ENGINEERING from Jawaharlal Nehru Technological
University, Hyderabad. This is a bonafide work done by her under my guidance and
supervision from October 2014 to November 2014.
The satisfaction that accompanies the successful completion of any task would be
incomplete without the mention of the people who made it possible and whose constant
guidance and encouragement crown all the efforts success.
I would like to convey thanks to our Project guide at college Prof. Mr. MD.
MUSTAQ AHMED for his guidance, encouragement, co-operation and kindness during
the entire duration of the course and academics.
I am deeply indebted to our Project trainer Mr. VENKAT GAUD of Kit Tech
Solutions for regular guidance and constant encouragement and we are extremely
grateful to him for his valuable suggestions and unflinching co-operation throughout
project work.
Last but not the least we also thank our friends and family members for helping us
in completing the project.
B.VINEETHA (11RQ1A0486)
DECLARATION
DRIVERS submitted by me to the JNTU in partial fulfillment of the requirement for the
original work. The analysis, design and implementation of this project have been done by
me and my batch mates and it has not submitted anywhere else for the award of the
degree.
Date:
Place: Miryalguda
B.VINEETHA (11RQ1A0486)
ABSTRACT
Most of these days, we hear lot of accidents due to drunken driving. Drunken
drivers will not be in stable condition and so the rash driving is the inconvenience for
other road users and also question of life and death for the drunken driver and for others.
In this project, we are developing an Auto Lock System. The input for the system
is from Detection Sensors either from Alcohol Breath or any other mechanism. The
controller keeps looking for the output from these sensors. If there are any traces of
Alcohol above the set limit, then the system will lock the Engine.
As vehicle automobiles are beyond the scope of this project, we are simulating the
process by activating the relay.
CONTENTS
LIST OF FIGURES i
LIST OF TABLES ii
1 INTRODUCTION 1
1.1 INTRODUCTION TO EMBEDDED SYSTEMS 1
1.1.1 EMBEDDED SYSTEMS 1
1.1.2 CHARACTERISTICS OF EMBEDDED SYSTEMS 1
1.1.3 CLASSIFICATION OF EMBEDDED SYSTEMS 2
1.1.4 APPLICATIONS OF EMBEDDED SYSTEMS 3
1.2 INTRODUCTION TO MICROCONTROLLER BASED 4
AUTOMATIC ENGINE LOCKING SYSTEM FOR
DRUNKEN DRIVERS
2 BLOCK DIAGRAM 5
2.1 BLOCK DIAGRAM OF MICROCONTROLLER BASED 5
AUTOMATIC ENGINE LOCKING SYSTEM FOR
DRUNKEN DRIVERS
2.2 BLOCK DIAGRAM DESCRIPTION 5
2.2.1 HARDWARE COMPONENTS 6
2.2.2 SOFTWARE COMPONENTS 6
3 SCHEMATIC CIRCUIT DIAGRAM 7
4 HARDWARE COMPONENTS DESCRIPTION 8
4.1 POWER SUPPLY 8
4.2 MICROCONTROLLER AT89S52 8
4.2.1 FEATURES 9
4.2.2 PIN DIAGRAM 10
4.2.3 BLOCK DIAGRAM 11
4.2.4 PIN DESCRIPTION 12
4.3 ALCOHOL DETECTION SENSOR 15
4.3.1 DESCRIPTION 15
4.3.2 FEATURES 15
4.3.3 APPLICATIONS 15
4.4 BUZZER 16
4.4.1 FEATURES 16
4.4.2 APLLICATIONS 16
4.5 BUZZER DRIVER CIRCUIT 16
4.5.1 BLOCK DIAGRAM OF BUZZER DRIVER 17
CIRCUIT
4.6 TRANSFORMER 17
4.7 RECTIFIER 18
4.7.1 HALF WAVE RECTIFIER 18
4.7.2 FULL WAVE RECTIFIER 19
4.8 REGULATOR 20
4.8.1 THE 78XX SERIES OF REGULATORS 20
4.9 LCD 21
4.10 MOTORS 22
4.11 LM324 OP-AMP 22
4.11.1 FEATURES 23
4.12 RESISTORS 24
4.13 CAPACITORS 24
5 SOFTWARE COMPONENTS DESCRIPTION 25
5.1 KEIL SOFTWARE 25
5.2 KEIL SOFTWARE PROGRAMMING PROCEDURE 27
6 SOURCE CODE 39
7 FEATURES 44
7.1 ADVANTAGES 44
7.2 APPLICATIONS 44
7.3 FUTURE ENHANCEMENT 45
7.3.1 DETECTION USING FACIAL MONITORING 45
SYSTEM
7.3.2 DETECTION USING THE DRIVERS STATE 46
FROM THE DRIVING BEHAVIOR
8 CONCLUSION 47
9 BIBILOGRAPHY 47
LIST OF FIGURES
LIST OF TABLES
An embedded system is any computer system hidden inside a product other than a
computer.
Embedded systems have a microprocessor/ microcontroller and a memory. Some
have a serial port or a network connection. They usually do not have keyboards,
screens or disk drives.
They will encounter a number of difficulties when writing embedded system
software in addition to those we encounter when we write applications.
Throughput: Our system may need to handle a lot of data in a short
period of time.
Response: Our system may need to react to events quickly.
Testability: Setting up equipment to test embedded software can be
difficult.
Debugability: Without a screen or a keyboard, finding out what the
software is doing wrong (other than not working) is a troublesome
problem.
Reliability: Embedded systems must be able to handle any situation
without human intervention.
Memory space: Memory is limited on embedded systems, and you must
make the software and the data fit into whatever memory exists.
Program installation: You will need special tools to get your software
into embedded systems.
Power consumption: Portable systems must run on battery power, and the
software in these systems must conserve power.
Processor hogs: Computing that requires large amounts of CPU time can
complicate the response problem.
Cost: Reducing the cost of the hardware is a concern in many embedded
system projects; software often operates on hardware that is barely
adequate for the job.
RTS CLASSIFICATION:
1. Hard Real Time Systems.
2. Soft Real Time System.
DRUNKEN DRIVERS:
Most of these days, we hear lot of accidents due to drunken driving. Drunken
drivers will not be in stable condition and so the rash driving is the inconvenience for
other road users and also question of life and death for the drunken driver and for others.
The system uses a compact circuitry built around Flash version of AT89S52
microcontroller with a non-volatile memory capable of retaining the password data for
over ten years. Programs are developed in embedded C. ISP is used to dump the code
into the microcontroller.
The main purpose behind this project is Drunken driving detection. Now-a-
days, many accidents are happening because of the alcohol consumption of the driver or
the person who is driving the vehicle. Thus drunk driving is a major reason of accidents
in almost all countries all over the world. Alcohol Detector in Car project is designed for
the safety of the people seating inside the car. This project should be fitted / installed
inside the vehicle.
2. BLOCK DIAGRAM
Power
supply
Buzzer
AT89S52
Alcohol
Detection MICRO LM324 Motors
SENSORS CONTROL
LER
1. Power supply.
2. Microcontroller AT89S52.
3. Alcohol detection sensor.
4. Buzzer.
5. Buzzer Driver circuit.
6. Transformer.
7. Rectifier.
8. Regulator.
9. LCD.
10. Engine/Motors.
11. LM324 op-amp.
12. Resistors.
13. Capacitors.
1. Keil software.
2. Keil software programming.
Microcontrollers are "embedded" inside some other device. They can control
the features or actions of the product. Another name for a microcontroller is "embedded
controller. Microcontrollers are dedicated to one task and run one specific program. The
program is stored in ROM (read-only memory) and generally does not change.
Microcontrollers are often low-power devices. A microcontroller has a dedicated input
device and has a small LED or LCD display for output. A microcontroller also takes input
from the device it is controlling and controls the device by sending signals to different
components in the device.
4.2.1 FEATURES:
GND: Ground.
PORT 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high impedance inputs. Port 0 may also be configured to be the multiplexed low order
address/data bus during accesses to external program and data memory. In this mode P0
has internal pull-ups.
PORT 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are
pulled high by the internal pull-ups and can be used as inputs.
PORT 2:
Port 2 is a 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that
are externally being pulled low will source current During accesses to external data
memory that uses (IIL) because of the internal pull-ups.
PORT 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (IIL) because of the pull-ups.
RESET:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during
Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and may be used for external timing or clocking purposes.
EA / VPP:
External Access Enable must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
EA
Note, however, that if lock bit 1 is programmed, will be internally latched on reset.
EA
should be strapped to VCC for internal program executions.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:
OSCILLATOR CHARACTERISTICS:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in Figure3.3.
Either a quartz crystal or ceramic resonator may be used.
To drive the device from an external clock source, XTAL2 should be left
unconnected while XTAL1 is driven as shown in Figure.
This alcohol sensor is suitable for detecting alcohol concentration on your breath,
just like your common breathalyzer. It has a high sensitivity and fast response time.
Sensor provides an analog resistive output based on alcohol concentration. The drive
circuit is very simple, all it needs is one resistor. A simple interface could be a 0-3.3V
ADC.
4.3.2 FEATURES:
4.4 BUZZER:
Fig 4.5: Buzzer
4.4.1 FEATURES:
Digital systems and microcontroller pins lack sufficient current to drive the
circuits like relays, buzzer circuits etc. While these circuits require around 10milli amps
to be operated, the microcontrollers pin can provide a maximum of 1-2milli amps
current. For this reason, a driver such as a power transistor is placed in between the
microcontroller and the buzzer circuit.
The input to the base of the transistor is applied from the microcontroller port pin
P1.0. The transistor will be switched on when the base to emitter voltage is greater than
0.7V (cut-in voltage). Thus when the voltage applied to the pin P1.0 is high i.e., P1.0=1
(>0.7V), the transistor will be switched on and thus the buzzer will be ON.
4.6 TRANSFORMER:
A suitable ready-built mains power supply unit, such as those used to control
model trains, will include a transformer. I wouldn't recommend building your own due to
the safety
Considerations when dealing with mains voltages if such a unit does not
incorporate smoothing, rectification, and regulation, then you will need to build these
blocks as described in part 1 of this series. If the unit does not have a fuse or a cut-out on
the output of the transformer, you will also need to add a fuse of an appropriate rating.
This fuse is in addition to the mains fuse in the unit's plug and is needed to protect the
low voltage winding of the transformer and any circuits you connect to it. Although we
won't be building the transformer block of our 5V regulated power supply, it is interesting
to know how it works.
4.7 RECTIFIER:
The half-wave rectifier is the simplest type of rectifier since it only uses one
diode, as shown in figure 1.
Figure 2 shows the AC input waveform to this circuit and the resulting output. As
you can see, when the AC input is positive, the diode is forward-biased and lets the
current through.
Fig 4.8: Half-wave rectification
While the output of the half-wave rectifier is DC (it is all positive), it would not
be suitable as a power supply for a circuit.
The circuit in figure 3 addresses the second of these problems since at no time is
the output voltage 0V.
When the AC input is positive, diodes A and B are forward-biased, while diodes C
and D are reverse-biased. When the AC input is negative, the opposite is true - diodes C
and D are forward-biased, while diodes A and B are reverse-biased.
4.8 REGULATOR:
While there are many circuits that will tolerate a smoothed power supply, some
must have a completely regular supply with no ripple voltage.
There are many types of regulator IC and each type will have different pin-outs
and will need to be connected up slightly differently. Therefore, this article will only
look at one of the common ranges of regulator, the 78xx series.
4.9 LCD:
LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. These modules are preferred over seven
segments and other multi segment LEDs. The reasons being: LCDs are economical;
easily programmable; have no limitation of displaying special & even custom characters
(unlike in seven segments).
A 16x2 LCD means it can display 16 characters per line and there are 2 such
lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two
registers, namely, Command and Data.
4.10 MOTORS:
The LM324 series are low-cost, quad op-amps with true differential inputs. They
have several distinct advantages over standard operational amplifier types in single
supply applications. The quad amplifier can operate at supply voltages as low as 3.0 V or
as high as 32 V with quiescent currents about one-fifth of those associated with the
MC1741 (on a per amplifier basis). The common mode input range includes the negative
supply, thereby eliminating the necessity for external biasing components in many
applications. The output voltage range also includes the negative power supply voltage.
4.11.1 FEATURES:
Short circuited protected outputs.
True differential input stage.
Single supply operation: 3V to 32(LM224, LM324, LM324A).
Low input bias currents: 100 nA maximum (LM324A).
Four amplifiers per package.
Internally compensated.
Common mode range extends to negative supply.
4.12 RESISTORS:
A resistor is a two-terminal electronic component designed to oppose an
electric current by producing a voltage drop between its terminals in proportion to the
current, that is, in accordance with Ohm's law:
V = IR
Fig 4.15:Resistors
4.13 CAPACITORS:
Keil compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which
is to be dumped into the microcontroller for further processing. Keil compiler also
supports C language code.
Procedure Steps:
Step-1:
Install Keil MicroVision-2 in your PC, Then after Click on that Keil UVision-2
icon. After opening the window go to toolbar and select Project Tab then close previous
project.
Step-2:
Step 3:
Then it will open Create New Project window. Select the path where you want
to save project and edit project name.
Step-4:
Next it opens Select Device for Target window, It shows list of companies and
here you can select the device manufacturer company.
Step-5:
For an example, for your project purpose you can select the chip as 89c51/52
from Atmel Group. Next Click OK Button, it appears empty window here you can
observe left side a small window i.e, Project Window. Next create a new file
Step-6:
From the Main tool bar Menu select File Tab and go to New, then it will open a
window, there you can edit the program.
Step-7:
Here you can edit the program as which language will you prefer either Assembly
or C.
Step-8:
After
editing the program
save the file with
extension as .c or
.asm, if you write
a program in
Assembly Language
save as .asm or
if you write a
program in C
Language save as
.c in the selected
path. Take an
example and save
the file as test.c.
Step-9:
Then after saving the file, compile the program. For compilation go to project
window select source group and right click on that and go to Add files to Group.
Step-10:
Here it will ask which file has to Add. For an example here you can add test.c
as you saved before.
Step-11:
After adding the file, again go to Project Window and right click on your c file
then select Build target for compilation. If there is any Errors or Warnings in your
program you can check in Output Window that is shown bottom of the Keil window.
Step-12:
Here in this step you can observe the output window for errors and warnings.
Step-13:
If you
make any mistake
in your program
you can check in
this slide for
which error and
where the error is
by clicking on that
error.
Step-14:
After compilation then next go to Debug Session. In Tool Bar menu go to
Debug tab and select Start/Stop Debug Session.
Step-15:
Here a simple program for Leds Blinking. LEDS are connected to PORT-1. you
can observe the output in that port.
Step-16:
To see the Ports and other Peripheral Features go to main toolbar menu and select
peripherals.
Step-17:
Step-18:
Start to trace the program in sequence manner i.e, step by step execution and
observe the output in port window.
Step-19:
After completion of Debug Session Create an Hex file for Burning the Processor.
Here to create an Hex file go to project window and right click on Target next select
Option for Target.
Step-20:
It appears one window; here in target tab modify the crystal frequency as you
connected to your microcontroller.
Step-21:
Next go to Output tab. In that Output tab click on Create HEX File and then
click OK.
Step-22:
Finally Once again compile your program. The Created Hex File will appear in
your path folder.
6. SOURCE CODE
#include<reg52.h>
#define lcdport P2
sbit rs=P2^0;
sbit en=P2^1;
sbit buzzer=P3^7;
sbit smoke=P1^7;
sbit mp1=P1^0;
sbit mn1=P1^1;
void lcd_ini();
void main()
lcd_ini();
smoke=1;
buzzer=1;
mp1=1;
mn1=0;
lcd_ini();
dis_cmd(0x80);
dis_cmd(0xc0);
lcd_msg(" BASED");
delay(100);
dis_cmd(0x01);
dis_cmd(0x80);
dis_cmd(0xc0);
delay(100);
dis_cmd(0x01);
while(1)
{
if(smoke==0)
buzzer=0;
mp1=mn1=0;
dis_cmd(0x80);
lcd_msg("ALOCHOL DETECTED");
dis_cmd(0xc0);
delay(50);
dis_cmd(0x01);
else
smoke=1;
buzzer=1;
mp1=1;
mn1=0;
dis_cmd(0x80);
lcd_msg(" NO ALOCHOL");
dis_cmd(0xc0);
delay(50);
dis_cmd(0x01);
}
}
int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1275;j++);
void lcd_ini()
dis_cmd(0x02);
dis_cmd(0x28);
dis_cmd(0x0C);
dis_cmd(0x06);
dis_cmd(0x80);
lcd_cmd(cmd_value1);
lcd_cmd(cmd_value1);
data_value1=(data_value&0xF0);
lcd_data(data_value1);
data_value1=((data_value<<4)&0xF0);
lcd_data(data_value1);
lcdport=cmdout;
rs=0;
//rw=0;
en=1;
delay(1);
en=0;
lcdport=dataout;
rs=1;
//rw=0;
en=1;
delay(1);
en=0;
}
void lcd_msg(unsigned char *ptr2)
while(*ptr2)
dis_data(*ptr2);
delay(10);
ptr2++;
7. FEATURES
7.1 ADVANTAGES:
Low cost.
Automated operation.
Low Power consumption.
It provides an automatic safety system for cars and other vehicles as well.
7.2 APPLICATIONS:
System configuration:
Fig 7.1: System configuration
1) Alcohol Detector project can be used in the various vehicles for detecting whether
the driver has consumed alcohol or not.
2) This project can also be used in various companies or organization to detect alcohol
consumption of employees.
1) We can implement GSM technology to inform the relatives or owners of the vehicle
about the alcohol consumption.
2) We can implement GPS technology to find out the location of the vehicle.
A camera is mounted on the instrument cluster facing the driver to monitor the
driver's face. The system is calibrated to monitor the driver's state of consciousness
through the blinking of the eyes. When the system detects signs of drowsiness, a voice
and message alert is triggered via the navigation system. Additionally, a seat-belt
mechanism is activated which tightens around the driver to gain his or her immediate
attention.
7.3.2 DETECTION OF THE DRIVERS STATE FROM THE
DRIVING BEHAVIOR:
Fig 7.3: Detection of the drivers state from the driving behavior
8. CONCLUSION
In this project we have developed a real time model that can automatically lock
the engine when a drunken driver tries to drive a car. Now-a-days car accidents are
mostly seen. By fitting this alcohol sensor into the car, we can save guard the life of the
driver and also the remaining passengers. It is very simple application. The life time of
the project is high. It has low or zero maintenance cost and of course low power
consumption.
9. BIBILOGRAPHY:
1. www.wikipedia.org
2. www.atmel.com
3. Passive Alcohol Sensors Tested in 3 States of Youth Alcohol Enforcement-
NHSA(1996)
4. Muhammad Ali Mazidi,Janice Gillispie Mazidi The 8051 Microcontroller and
Embedded Systems Using Assembly and C-2nd-ed
5. http://www.atmel.com/Images/doc1919.pdf
6. Infrared sensors: detectors, electronics, and signal processing
7. Practical Aspects of Embedded System Design Using Microcontrollers