Alcohol Detector Using 8051 MCU
Alcohol Detector Using 8051 MCU
BACHELOR OF ENGINEERING
Of Anna University
September 2015
1
PSG COLLEGE OF TECHNOLOGY
(Autonomous Institution)
V Ganesh (13L217)
M Gokularam(13L218)
P.S.Guru Balajee(13L219)
BACHELOR OF ENGINEERING
ELECTRONIC AND COMMUNICATION ENGINEERING
Of Anna University
September 2015
……………………………….. ………………………………
Dr. S. Subha Rani
Faculty guide Head of the Department
2
ACKNOWLEDGEMENT
I am indebted to Dr. S. SUBHA RANI, Professor and Head of the Department of Electronics
and Communication Engineering, for her continued support and motivation.
I would like to express my gratitude to my technical report guide Dr.D. Sivaraj and
Mr.K.Rajasekar, Department of Electronics and Communication Engineering, for their
constant motivation, direction and guidance throughout the entire course of our technical
report.
I thank all the staff members of the Department of Electronics and Communication
Engineering for their support.
Last but not the least I thank the Almighty and my family members who have been a guiding
light in all our endeavours.
3
Table of Contents
Objective and need for the Project......................................................................6
Objective of Project...................................................................................... 6
Project overview............................................................................................. 7
Block Diagram............................................................................................. 7
Circuit Schematic and Explanation..................................................................8
Flowchart and C program.................................................................................9
Simulation Results...................................................................................... 16
Hardware Implementation...........................................................................17
Conclusion................................................................................................... 18
Future Scope................................................................................................ 18
Reference..................................................................................................... 18
LIST OF FIGURES
4
ABSTRACT
This project report deals with the design and testing of alcohol detector
with the 8051 series of ATMEL’s microcontrollers. This project uses the 8051
variant AT89S52 (8052). The program for configuring the microcontroller was
written in Keil microvision 3 IDE, designed for ATMEL 8051 series
microcontrollers.
5
CHAPTER I
Objective and need for the Project
Many accidents happen in this fast moving day to day world. And one of
the main reasons for these accidents are drunken driving. Due to this very
reason, even innocent people are affected too. So a constant check is needed in
this issue by the government to strictly avoid drinking during driving. And for
this we need a device to detect the presence of alcohol in human without and
interference of environment.
Objective of Project
The objective of the project is to design a fool proof alcohol detector to
detect the presence of alcohol in human breath. It also needs to provide the
numerical value of the alcohol content to know the extent of alcohol
consumption. For this digital devices such as microcontrollers are used to
achieve high accuracy and speed for instantaneous detection.
CHAPTER II
6
Project overview
Block Diagram
7
Figure 2.Schematic of the alcohol detector done in Proteus ISIS simulator
The figure above shows the circuit schematic of the alcohol detector in
Proteus Simulation software. Here we can see the regular connections such as
the crystal oscillator connected to pin 18, 19. Here as mentioned above, instead
of using the sensor, for the purpose of demonstration, we have used a
potentiometer. And it is given to a ADC. The ADC is also supplied with the
required clock frequency with the RC network. Then the converted data is taken
and given to the controller via port 2.
Now the processes are done in the microcontroller and the data to be
displayed are given to the LCD display via port 1. Then the additional data to be
given to the LCD display such as write, enable, etc. are given via some of the
pins of port 3.
CHAPTER III
8
Flowchart and C program
The above flowchart shows the main procedure to get the final result. That is,
we first blow on the sensor, then the amount of alcohol is calculated and the
result is given according to the threshold value.
This flowchart depicted above shows the signal conditioning and display
unit in an outline. In signal conditioning, the alcohol vapour concentration is
given to the sensor and it produces a resistance change. This resistance change
9
in turn produces a voltage change corresponding to it, since it is a passive
sensor. Now the voltage is converted by ADC and given to the microcontroller.
This flow chart describes the working of the LCD. Here when powered
ON, the LCD is initialised. That is the function sets are sent in one by one and
each digits are displayed one by one according to the clock cycle. After
displaying the digits, it clears the whole display and waits for the next set of
data to display. Due to high clock frequency, we observe the digits as stable
ones.
void main()
{
//Initialise lcd
rs=0;
rw=0;
en=1;
delay(1500);
//clear display and move to home
//------------------------------
P1=0x01;
en=0;
11
delay(1500);
en=1;
P1=0x03;
en=0;
delay(1500);
en=1;
//-------------------------------
//------------------------------
while(1)
{
rd=1;
wr=1;
while(intr);
wr=0;
rd=0;
adc=P2;
if(adc<127)
{
rs=0;
P1=0x85;//set cursor to 6th position on first line
en=0;
delay(1500);
en=1;
delay(1500);
for(i=0;i<7;i++)
13
{
rs=1;
P1=normal[i];
en=0;
delay(1500);
en=1;
}
}
if(adc>127)
{
rs=0;
P1=0x85;
en=0;
delay(1500);
en=1;
delay(1500);
for(i=0;i<7;i++)
{
rs=1;
P1=drunk[i];
en=0;
delay(1500);
en=1;
}
}
h=adc/100; //split the adc decimal value into
individual
t=(adc%100)/10; // digits(hundreds,tens and ones place
values)
o=adc%10; //(255 -> h=2,t=5,o=5)
14
rs=1;//ascii value of zero is 0x30, add h to 0x30 to
get
P1=0x30+h;//the corresponding ascii value of h
en=0;
delay(1500);
en=1;
rs=1;
P1=0x30+t;
en=0;
delay(1500);
en=1;
rs=1;
P1=0x30+o;
en=0;
delay(1500);
en=1;
}
}
CHAPTER IV
Simulation and Hardware implementation
Simulation Results
15
Figure 6. Simulation showing drunk output
The figures shown above is the simulation of the alcohol detector circuit
in Proteus Simulation software. We can clearly observe the working of the
device in both the test conditions. The first figure displays the output when the
condition is DRUNK and the second image shows the output when the
condition is NORMAL. The following content shows the hardware
implementation.
16
Hardware Implementation
Conclusion
From this report it can be seen that implementation and realisation of
alcohol detector is a challenging, yet a vital one. It gives us a wide idea about
the field of coding in embedded systems. It also helps us to realise the
architecture of 8051. On realisation, it justifies that simulation and the working
is the same. So the design of alcohol detector at its simplest is conveyed in all
possible ways. Similar works can also be done with such technical knowledge.
17
Future Scope
Alcohol detector designed in this project is the simplest one compares to
the present day equipment. The future scope for this alcohol detector can be
extended to various degrees. They are
Camera
A camera can be interfaced with this device to immediately capture the
face of the person who is drunk. It gives us an advantage to get more details
about the accust.
GPS
GPS can be interfaced with this device to trace the exact location of the
crime. It gives us more details and also easy for us to track the device if lost or
in theft.
Printer
A thermal printer interfaced with this device can be of immense use to
immediately print the fine receipt like bus ticket issuer.
Card Swiper
An attached card swiper can be used to pay the fine on the spot for time
saving. It also gives extra accounting purpose.
Reference
1. The 8051 microcontroller – Architecture, Programming and applications
– Kenneth J. Ayala
2. The 8051 microcontroller and embedded systems – Muhammad Ali
Mazidi and Janice Gillespie Mazidi
3. Architecture and Programming of 8051 microcontrollers –
Mikroelektronika.
4. ATMEL’s AT89S52 hardware description datasheets.
18