You are on page 1of 58

A

Mini Project Report


On
“MICROCONTROLLER BASED AUTOMATIC ENGINE
LOCKING SYSTEM FOR DRUNKEN DRIVERS”
Submitted in partial fulfillment of requirements
For the award of the Degree of

BACHELOR OF TECHNOLOGY
IN
ELECTRONICS & COMMUNICATION ENGINEERING
By

B.VINEETHA (11RQ1A0486)

Under the Guidance of


Mr. MD.MUSTAQ AHMED
[M.Tech]
Asst. Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

MINA INSTITUTE OF ENGINEERING & TECHNOLOGY FOR WOMEN


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)

Ramachandragudem, Miryalguda, Nalgonda (Dist), T.G.

2015
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

MINA INSTITUTE OF ENGINEERING & TECHNOLOGY FOR WOMEN


(Approved by AICTE, New Delhi, Affiliated to JNTUH, Hyderabad)

Ramachandragudem, Miryalguda, Nalgonda (Dist), T.G. 2015

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.

Internal Guide Head of the Department

Mr. MD.MUSTAQ AHMED Mr. MD.MUSTAQ AHMED


[M.Tech] [M.Tech]

Asst. Professor Asst. Professor

External Examiner Principal

Mr. PANDU RANGA REDDY


ACKNOWLEDGEMENT

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 am extremely grateful to our respected Principal, Mr. PANDU RANGA


REDDY for fostering an excellent academic climate in our institution. I also express my
sincere gratitude to our respected Head of the Department Prof. Mr. MD. MUSTAQ
AHMED for his encouragement, overall guidance in viewing this project a good asset
and effort in bringing out this project.

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

I do here by declare that the mini project work titled by “MICROCONTROLLER

BASED AUTOMATIC ENGINE LOCKING SYSTEM FOR DRUNKEN

DRIVERS” submitted by me to the JNTU in partial fulfillment of the requirement for the

award of bachelor of technology in Electronics & Communication Engineering is my

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 DRIVER’S STATE 46
FROM THE DRIVING BEHAVIOR
8 CONCLUSION 47

9 BIBILOGRAPHY 47
LIST OF FIGURES

SNO FIGURE PAGE NO

1. BLOCK DIAGRAM OF MICROCONTROLLER BASED 5


AUTOMATIC ENGINE LOCKING SYSTEM FOR
DRUNKEN DRIVERS
2. SCHEMATIC CIRCUIT DIAGRAM 7
3. PIN DIAGRAM OF MICROCONTROLLER 10
4. BLOCK DIAGRAM OF MICROCONTROLLER 11
5. CONNECTIONS OF OSCILLATOR 14
6. MQ-3 ALCOHOL DETECTION SENSOR 15
7. BUZZER 16
8. BLOCK DIAGRAM OF BUZZER DRIVER CIRCUIT 17
9. HALF-WAVE RECTIFIER 18
10. HALF-WAVE RECTIFICATION 19
11. FULL-WAVE RECTIFIER 19
12. FULL-WAVE RECTIFICATION 20
13. WIRING UP A REGULATOR IC 21
14. LCD DISPLAY 21
15. MOTOR 22
16. BLOCK DIAGRAM OF LM324 OP-AMP 23
17. RESISTORS 24
18. CAPACITORS 24
19. SYSTEM CONFIGURATION 44
20. DETECTION USING FACIAL MONITORING SYSTEM 45
21. DETECTION USING THE DRIVER’S STATE FROM 46
THE DRIVING BEHAVIOR
LIST OF TABLES

SNO TABLE PAGE NO

1. PORT PIN’S DESCRIPTION 13

2. REGULATOR VOLTAGE REPRESENTATION 20


1. INTRODUCTION

1.1 INTRODUCTION TO EMBEDDED SYSTEMS:

1.1.1 EMBEDDED SYSTEMS:

An Embedded System is a combination of computer hardware and software, and


perhaps additional mechanical or other parts, designed to perform a specific function. An
embedded system is a microcontroller-based, software driven, reliable, real-time control
system, autonomous, or human or network interactive, operating on diverse physical
variables and in diverse environments and sold into a competitive and cost conscious
market.

An embedded system is not a computer system that is used primarily for


processing, not a software system on PC or UNIX, not a traditional business or scientific
application. High-end embedded & lower end embedded systems. High-end embedded
system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital
Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit
Controllers used with an minimal operating systems and hardware layout designed for the
specific purpose.

1.1.2 CHARACTERISTICS OF EMBEDDED SYSTEMS:

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

1.1.3 CLASSIFICATION OF EMBEDDED SYSTEMS:

REAL TIME SYSTEMS (RTS):

 RTS is one which has to respond to events within a specified deadline.


 A right answer after the dead line is a wrong answer.
RTS CLASSIFICATION:

1. Hard Real Time Systems.


2. Soft Real Time System.
1. HARD REAL TIME SYSTEM:
 Hard real-time systems have very narrow response time.

 Example: Nuclear power system, Cardiac pacemaker.

2. SOFT REAL TIME SYSTEM:


 Soft real-time systems have reduced constrains on "lateness" but still must operate very quickly
and repeatable.
 Example: Railway reservation system – takes a few extra seconds the data remains valid.

1.1.4 APPLICATIONS OF EMBEDDED SYSTEMS:

1) Military and aerospace embedded software applications.


2) C o mmunic a tio n Ap p lic a tio ns .
3) I nd us tr ia l a uto ma tio n a nd p r o c e s s c o ntr o l s o ftwa r e .
4) Mastering the complexity of applications.
5) Reduction of product design time.
6) Real time processing of ever increasing amounts of data.
7) Intelligent, autonomous sensors.
1.2 INTRODUCTION TO MICROCONTROLLER BASED

AUTOMATIC ENGINE LOCKING SYSTEM FOR

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

2.1 BLOCK DIAGRAM OF MICROCONTROLLER BASED


AUTOMATIC ENGINE LOCKING SYSTEM WHEN DRUNKEN
DRIVERS:

Power
supply

Buzzer
AT89S52
Alcohol
Detection MICRO LM324 Motors
SENSORS CONTROL
LER

Fig 2.1: Block diagram of Microcontroller based automatic engine locking system for drunken
drivers

2.2 BLOCK DIAGRAM DESCRIPTION:

The following hardware and software is used in this system. Detailed explanations
of these components follow in the later sections.
2.2.1 HARDWARE COMPONENTS:

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.

2.2.2 SOFTWARE COMPONENTS:

1. Keil software.
2. Keil software programming.
3. SCHEMATIC CIRCUIT DIAGRAM

Fig 3: Schematic circuit diagram


4. HARDWARE COMPONENTS DESCRIPTION

4.1 POWER SUPPLY:

Power supply is a supply of electrical power. A device or system that supplies


electrical or other types of energy to an output load or group of loads is called a power
supply unit or PSU. The term is most commonly applied to electrical energy supplies,
less often to mechanical ones, and rarely to others.

A power supply may include a power distribution system as well as primary or


secondary sources of energy such as:

 Chemical fuel cells and other forms of energy storage systems.


 Solar power and batteries.
 Generators or alternators.
A brief description:
 Transformer-steps down high voltage AC mains to low voltage AC
 Rectifier-converts AC to DC, but the DC output is varying.

4.2 MICROCONTROLLER AT89S52:

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:

Compatib le with MCS®- 51 Products :

 8K Bytes of In- System Programmable (ISP) Flash Memory -


Endura nce : 10,000 Write/Era se Cycles.
 4.0V to 5.5V Operating Range.
 Fully Static Operatio n: 0 Hz to 33 MHz.
 Three- bit Interna l RAM.
 32 Programmab le I/O Line s.
 Three 16- bit Time r/C o unter s.
 Eight Interr up t Sources.
 Full Duple x UART Seria l Channe l.
 Low- power Idle and Power- down Modes.
 Interr up t Recover y from Power- down Mode.
 Watchdog Time r.
 Dual Data Pointer .
 Power- off Flag.
 Fast Progra mmin g Time.
 leve l Progra m Memory Lock.
 Flexib le ISP Programming (Byte and Page Mode).
 Green (Pb/Halid e-free) Packaging Option.
4.2.2 PIN DIAGRAM:

Fig 4.1: Pin diagram of microcontroller


4.2.3 BLOCK DIAGRAM:

Fig 4.2: Block diagram of micro controller


4.2.4 PIN DESCRIPTION:

VCC: Supply volta ge.

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.
Port Pin Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

P3.6 WR (external data memory Write strobe)

P3.7 RD (external data memory read strobe)

Table 4.1: Port pin’s de s criptio n

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.
Note, however, that if lock bit 1 is programmed, EA 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:

Output from the inverting oscillator amplifier.

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.

Fig 4.3: Connections of oscillator


4.3 ALCOHOL DETECTION SENSOR:

The alcohol detector sensor used in our project is MQ-3 Sensor.

Fig 4.4: MQ-3 alcohol detection sensor

The features and applications of the alcohol sensor are as follows:


4.3.1 DESCRIPTION:

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:

 High sensitivity to alcohol and small sensitivity to benzene.


 Fast response and high sensitivity.
 Stable and long life.
4.3.3 APPLICATIONS:

 They are suitable for alcohol checker, breath analyzer.


4.4 BUZZER:

Fig 4.5: Buzzer

4.4.1 FEATURES:

• These high reliability electromagnetic buzzers are applicable to automobile equipment.


• Compact, pin terminal type electromagnetic buzzer with 2048Hz output.
• Pin type terminal construction enables direct mounting onto printed circuit boards.
4.4.2 APPLICATIONS:

 Clocks, travel watches, keyboards, toys, various alarms of automobile equipment.

4.5 BUZZER DRIVER CIRCUIT:

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 microcontroller’s 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.
4.5.1 BLOCK DIAGRAM OF BUZZER DRIVER CIRCUIT:

CONTROLLER

DRIVER BUZZER
PIN
CIRCUIT

Fig 4.6: Block diagram of buzzer driver 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 purpose of a rectifier is to convert an AC waveform into a DC waveform.


There are two different rectification circuits, known as 'half-wave' and 'full-wave'
rectifiers. Both use components called diodes to convert AC into DC.

4.7.1 HALF-WAVE RECTIFIER:

The half-wave rectifier is the simplest type of rectifier since it only uses one
diode, as shown in figure 1.

Fig 4.7: Half-wave rectifier

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.

4.7.2 FULL-WAVE RECTIFIER:

The circuit in figure 3 addresses the second of these problems since at no time is
the output voltage 0V.

Fig 4.9: Full-wave rectifier


Fig 4.10: Full-wave rectification

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.

4.8.1 THE 78XX SERIES OF REGULATORS:

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.

Type Number Regulation voltage Maximum current Minimum voltage

7805 +5V 1A +7V

7812 +12V 1A +14.5V

Table 4.2: Regulator voltage representation


If you are using a regulator after the smoothing block of the power supply, then
you shouldn't need to worry about the ripple voltage, since the whole point of using a
regulator is to get a stable, accurate, known voltage for your circuits.

Fig 4.11: Wiring up a regulator IC

4.9 LCD:

Fig 4.12: LCD display

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 speed of a DC motor is directly proportional to the supply voltage, so if we


reduce the supply voltage from 12 Volts to 6 Volts, the motor will run at half the speed.
How can this be achieved when the battery is fixed at 12 Volts. The speed controller
works by varying the average voltage sent to the motor. It could do this by simply
adjusting the voltage sent to the motor, but this is quite inefficient to do. A better way is
to switch the motor’s supply on and off very quickly. If the switching is fast enough, the
motor doesn’t notice it, it only notices the average effect.

Fig 4.13: Motor

4.11 LM324 OP-AMP:

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.

Fig 4.14: Block diagram of LM324 op-amp.


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:

A capacitor or condenser is a passive electronic component consisting of a pair


of conductors separated by a dielectric. When a voltage potential difference exists
between the conductors, an electric field is present in the dielectric.

Fig 4.13: Capacitors.


5. SOFTWARE COMPONENTS DESCRIPTION

5.1 KEIL SOFTWARE:

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.
STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL AND
HOW TO COMPILE IT:

1. Install the Keil Software in the PC in any of the drives.


2. After installation, an icon will be created with the name “Keil uVision3”. Just
drag this icon onto the desktop so that it becomes easy whenever you try to write
programs in keil.
3. Double click on this icon to start the keil compiler.
4. A page opens with different options in it showing the project workspace at the
leftmost corner side, output window in the bottom and an ash colored space for
the program to be written.
5. Now to start using the keil, click on the option “project”.
6. A small window opens showing the options like new project, import project, open
project etc. Click on “New project”.
7. A small window with the title bar “Create new project” opens. The window asks
the user to give the project name with which it should be created and the
destination location.
8. The project can be created in any of the drives available. You can create a new
folder and then a new file or can create directly a new file.
9. After the file is saved in the given destination location, a window opens where a
list of vendors will be displayed and you have to select the device for the target
you have created.
10. The most widely used vendor is Atmel. So click on Atmel and now the family of
microcontrollers manufactured by Atmel opens. You can select any one of the
microcontrollers according to the requirement.
11. When you click on any one of the microcontrollers, the features of that particular
microcontroller will be displayed on the right side of the page. The most
appropriate microcontroller with which most of the projects can be implemented
is the AT89C51. Click on this microcontroller and have a look at its features.
Now click on “OK” to select this microcontroller.
12. A small window opens asking whether to copy the startup code into the file you
have created just now. Just click on “No” to proceed further.
13. Now you can see the TARGET and SOURCE GROUP created in the project
workspace.
14. Now click on “File” and in that “New”. A new page opens and you can start
writing program in it.
15. After the program is completed, save it with any name but with the .asm
extension. Save the program in the file you have created earlier.
16. You can notice that after you save the program, the predefined keywords will be
highlighted in bold letters.
17. Now add this file to the target by giving a right click on the source group. A list of
options open and in that select “Add files to the source group”. Check for this file
where you have saved and add it.
18. Right click on the target and select the first option “Options for target”. A window
opens with different options like device, target, output etc. First click on “target”.
19. Since the set frequency of the microcontroller is 11.0592 MHz to interface with
the PC, just enter this frequency value in the Xtal (MHz) text area and put a tick
on the Use on-chip ROM. This is because the program what we write here in the
keil will later be dumped into the microcontroller and will be stored in the inbuilt
20. present in the same window. The hex file can be created in any of the drives. You
can change the folder by clicking on “Select folder for Objects”.
21. ggg
22. Now add this file to the target by giving a right click on the source group. A list of
options open and in that select “Add files to the source group”. Check for this file
where you have saved and add it.
23. Right click on the target and select the first option “Options for target”. A window
opens with different options like device, target, output etc. First click on “target”.
24. Since the set frequency of the microcontroller is 11.0592 MHz to interface with
the PC, just enter this frequency value in the Xtal (MHz) text area and put a tick
on the Use on-chip ROM. This is because the program what we write here in the
keil will later be dumped into the microcontroller and will be stored in the inbuilt
ROM in the microcontroller.
25. Now click the option “Output” and give any name to the hex file to be created in
the “Name of executable” text area and put a tick to the “Create HEX file” option
present in the same window. The hex file can be created in any of the drives. You
can change the folder by clicking on “Select folder for Objects”.
26. Now to check whether the program you have written is errorless or not, click on
the icon exactly below the “Open file” icon which is nothing but Build Target
icon. You can even use the shortcut key F7 to compile the program written.
27. To check for the output, there are several windows like serial window, memory
window, project window etc. The icon with the letter “d” indicates the debug
mode.
28. Click on this icon and now click on the option “View” and select the appropriate
window to check for the output.
29. After this is done, click the icon “debug” again to come out of the debug mode.
30. The hex file created as shown earlier will be dumped into the microcontroller with
the help of software called Proload.
5.2 KEIL SOFTWARE PROGRAMING PROCEDURE:

How to write Embedded C Program in Keil Software.

Procedure Steps:

The procedure steps of keil software are as following:


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:

Next select New Project from Project Tab.


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:

In this slide see the selected port i.e, PORT-1.

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_cmd(unsigned char);

void delay(unsigned int);

void lcd_msg(unsigned char *);

void lcd_data(unsigned char);

void dis_data(unsigned char);

void dis_cmd(unsigned char);

void lcd_ini();

void main()

lcd_ini();

smoke=1;

buzzer=1;

mp1=1;

mn1=0;

lcd_ini();
dis_cmd(0x80);

lcd_msg(" DRUNK DRIVE");

dis_cmd(0xc0);

lcd_msg(" BASED");

delay(100);

dis_cmd(0x01);

dis_cmd(0x80);

lcd_msg(" ENGINE LOCK");

dis_cmd(0xc0);

lcd_msg(" SYSTEM ");

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);

lcd_msg(" BUZZER ON ");

delay(50);

dis_cmd(0x01);

}
else

smoke=1;

buzzer=1;

mp1=1;

mn1=0;

dis_cmd(0x80);

lcd_msg(" NO ALOCHOL");

dis_cmd(0xc0);

lcd_msg(" BUZZER OFF");

delay(50);

dis_cmd(0x01);

void delay(unsigned int ms)

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);

void dis_cmd(unsigned char cmd_value)

unsigned char cmd_value1;

cmd_value1 = (cmd_value & 0xF0);

lcd_cmd(cmd_value1);

cmd_value1 = ((cmd_value<<4) & 0xF0);

lcd_cmd(cmd_value1);

void dis_data(unsigned char data_value)

unsigned char data_value1;

data_value1=(data_value&0xF0);

lcd_data(data_value1);

data_value1=((data_value<<4)&0xF0);

lcd_data(data_value1);

Void lcd_cmd(unsigned char cmdout)

lcdport=cmdout;

rs=0;
//rw=0;

en=1;

delay(1);

en=0;

void lcd_data(unsigned char dataout)

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.

7.3 FUTURE ENHANCEMENT:

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.

7.3.1 DETECTION USING FACIAL MONITORING SYSTEM:

Fig 7.2: Detection using facial monitoring system


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 DRIVER’S STATE FROM THE


DRIVING BEHAVIOR:

Fig 7.3: Detection of the driver’s state from the driving behavior

By constantly monitoring the operational behavior of the vehicle (e.g. sensing if


the vehicle is drifting out of its driving lane), the system can identify signs of
inattentiveness or distraction in the driver. When the system detects such behavior, voice
and message alerts are issued via the navigation system. The seatbelt alert mechanism is
also activated, tightening around the driver to gain immediate attention.
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.

This is a developed design to efficiently check drunken driving. By implementing


this design a safe car journey is possible decreasing the accident rate due to drinking. By
implementing this design, drunken drivers can be controlled so are the accidents due to
drunken driving. Government must enforce laws to install such circuit in every car and
must regulate all car companies to preinstall such mechanisms while manufacturing the
car itself. If this is achieved the deaths due to drunken drivers can be brought to minimum
level. In this type of system, future scope can be safely landing of car aside without
disturbing other vehicles.
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

You might also like