0% found this document useful (0 votes)
15 views

Alcohol Detector Using Pic16f877a and MQ-3 Sensor

This document describes the design of an over speed and alcohol detection system for vehicles. It aims to reduce accidents by limiting vehicle speed when exceeded and alerting authorities if the driver is drunk. The system uses sensors to check speed and alcohol levels and sends alerts by Zigbee if thresholds are crossed.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Alcohol Detector Using Pic16f877a and MQ-3 Sensor

This document describes the design of an over speed and alcohol detection system for vehicles. It aims to reduce accidents by limiting vehicle speed when exceeded and alerting authorities if the driver is drunk. The system uses sensors to check speed and alcohol levels and sends alerts by Zigbee if thresholds are crossed.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Over Speed and Alcohol Detection System for Vehicles

Submitted in partial fulfillment of the requirements

For the award of the degree

Bachelor of Science

in

Electrical & Computer Engineering

with specialization in

Instrumentation and Industrial Control Engineering with

Computer Engineering Stream

by

Emebet Mekuria RET/516/04

Sofonias Sintayehu RET/1399/04

Tewodros Berihun RET/1526/04


Walelegn Nakachew RET/1588/04
Yohannes Kassaye RET/1675/04

under the guidance of

Dr. N. Ram Kumar

Department of Electrical & Computer Engineering

Arba Minch Institute of Technology, Arba Minch University

June 2016

i
CERTIFICATE
This is to certify that the present work entitled Over Speed and Alcohol Detection
System for Vehicles is a bona fide record of work done by

Emebet Mekuria RET/516/04

Sofonias Sintayehu RET/1399/04

Tewodros Berihun RET/1526/04

Walelgn Nakachew RET/1588/04

Yohannes Kassaye RET/1675/04

submitted as a partial fulfillment of the requirements for the award of the


degree
Bachelor of Science
in
Electrical & Computer Engineering
with specialisation in
Instrumentation and Industrial control Engineering with Computer
Engineering Stream

from
Arba Minch University

Dr.N. Ram Kumar (Mr. Eyasu Dilla)


(Main Advisor) (H.O.D.)

Date: Jun 02, 2016


Place: Department of Electrical & Computer Engineering,
Arba Minch Institute of Technology, Arba Minch University

ii
ACKNOWLEDGEMENT
First of all, we would like to thank God for his blessing and our family for their encouragement,
and we also want to express our deepest gratitude to our Advisors Dr.N. Ram Kumar and Dr.
Yadav for their unwavering support and guidance throughout this project. We also want to thank
Mr. Hilemariam for his friendly and selfless assistance. Our deepest appreciation also goes out to
Mr. Henok Ali for his material support. Next to this we want to extend our heartfelt gratitude to
Mr. Lelisa Adeba for his continuous help and excellent suggestions.

Finally, we want to thank Electrical and Computer Engineering department members who gave us
many needed support, encouragement and help throughout our project.

iii
ABSTRACT
The main aim of this project is to design a system for implementing an efficient over speed and
alcohol detection system for vehicles that will be useful to reduce car accidents.
Now a days, car accident reaches in an alarming rate. Accident occurs due to many reasons. From
those, most of accidents happen due to over speed and drunken driver problem. There are laws to
punish over speed and drunken drivers but this rules and regulations cannot have any system that
can reveal the speed status of the car and the driver alcoholic condition. So, there is a need of an
effective system to limit the speed of the vehicles and check the drunken drivers. These system
works when the vehicle moves beyond the allowed speed, it retrieve to a desired speed and when
the vehicle driven by a drunken person then the system automatically send a message to the nearest
traffic police station. Therefore the project members will design and implement the prototype of
this system.

iv
LIST OF TABLES

Table 1-Zigbee and other wireless technologies ........................................................................... 21

v
LIST OF FIGURES

Figure 1-MQ3 Alcohol sensor ...................................................................................................... 14


Figure 2-Working principle of MQ3 alcohol sensor..................................................................... 15
Figure 3-TCS 3103 Color sensor .................................................................................................. 16
Figure 4-Dc motor......................................................................................................................... 17
Figure 5-L293D Motor driver ....................................................................................................... 18
Figure 6-PIC16F877A Microcontroller ........................................................................................ 18
Figure 7-16× 2 LCD Display ....................................................................................................... 19
Figure 8-Zigbee Module ............................................................................................................... 22
Figure 9-RS232 connector ............................................................................................................ 23
Figure 10-Overall system design .................................................................................................. 23
Figure 11-Motor driver circuit ...................................................................................................... 25
Figure 12-Level convertor ............................................................................................................ 26
Figure 13-A string of 10 bit data................................................................................................... 29
Figure 14-Software architecture ................................................................................................... 30
Figure 15-System over view ......................................................................................................... 30
Figure 16-GUI (Graphical user interface)..................................................................................... 31
Figure 17-Data base architecture .................................................................................................. 31
Figure 18-Flow chart..................................................................................................................... 32
Figure 19-Overall simulation ........................................................................................................ 33
Figure 20-Simulated result of alcohol sensor ............................................................................... 34
Figure 21-PWM for 120 Kph ........................................................................................................ 34
Figure 22-PWM for 80 Kph .......................................................................................................... 35
Figure 23-PWM for 60 Kph .......................................................................................................... 35
Figure 24-PWM for over speed .................................................................................................... 35
Figure 25-Hardware connection ................................................................................................... 36

vi
ABBREVIATIONS

PIC……………………………………………………………Programmable interfacing mobile


SDC…………………………………………………………..Smart Display &Control
RF…………………………………………………………….Radio frequency
FM……………………………………………………………Frequency Modulation
BAC…………………………………………………………..Blood alcohol content
RGB…………………………………………………………..Red Green Black
VOR………………………………………………………….Out voltage of red
VOG………………………………………………………… Out voltage of green
VOB ………………………………...……………………….Out voltage of blue
DC............................................................................................Direct Current
IC..............................................................................................Integrated Circuit
CMOS.........................................................................Complementary Metal-oxide Semiconductor
EEPROM.......................................................Electrical erasable programmable read only memory
ICD............................................................................................In-circuit debug
A/D...........................................................................................Analog to digital
SPI............................................................................................Serial Peripheral Interface
USART.....................................................................UniversalAsynchronous Receiver Transmitter
PWM........................................................................................Pulse with modulation
LCD..........................................................................................Liquid Crystal Display
WSN.........................................................................................Wireless Sensor Network
FFDs.........................................................................................Full Function Devices
RFDs........................................................................................Reduced Function Devices
UART.......................................................................Universal Asynchronous Reviver Transmitter
TTL...........................................................................................Transistor Transistor Logic
MCU..........................................................................................microcontroller controller unit
SMPS.........................................................................................switched-mode power supply
LED...........................................................................................light emitting diode
Tx and Rx..................................................................................Transmitter and Receiver
GUI............................................................................................graphical user interfa

vii
TABLE OF CONTENTS
CERTIFICATE ........................................................................................................................................... ii
ACKNOWLEDGEMENT ......................................................................................................................... iii
ABSTRACT ................................................................................................................................................ iv
LIST OF TABLES ...................................................................................................................................... v
LIST OF FIGURES ................................................................................................................................... vi
ABBREVIATIONS ................................................................................................................................... vii
CHAPTER 1 .............................................................................................................................................. 10
INTRODUCTION..................................................................................................................................... 10
1.1 Introduction ................................................................................................................................... 10
1.2 Problem statement ........................................................................................................................ 10
1.3 Project objective ............................................................................................................................ 10
1.4 Scope of the project ....................................................................................................................... 10
CHAPTER 2 .............................................................................................................................................. 12
LITERATURE REVIEW ........................................................................................................................ 12
2.1 Work review .................................................................................................................................. 12
2.2 Component review ........................................................................................................................ 14
2.2.1 Alcohol sensor (MQ-3) ...................................................................................................... 14
2.2.2 Color sensor (TCS3103).................................................................................................... 16
2.2.3 DC Motor ........................................................................................................................... 17
2.2.4 Motor Driver ..................................................................................................................... 17
2.2.5 Microcontroller ................................................................................................................. 18
2.2.6 LCD display ....................................................................................................................... 19
CHAPTER 3 .............................................................................................................................................. 20
METHODOLOGY ................................................................................................................................... 20
3.1 Introduction ................................................................................................................................... 20
3.2 Communication unit ..................................................................................................................... 20
3.2.1 Wireless Sensor Network.................................................................................................. 20
3.2.2 RS 232 Connector.............................................................................................................. 22
3.3 Overall system design ................................................................................................................... 23
3.4 Electronic hardware ..................................................................................................................... 24
3.5 Materials ........................................................................................................................................ 26

8
3.6 Software design ............................................................................................................................. 27
3.7 Computer software ....................................................................................................................... 29
3.8 Software Architecture................................................................................................................... 32
CHAPTER 4 .............................................................................................................................................. 33
RESULTS AND DISCUSSION ............................................................................................................... 33
4.1 Result.............................................................................................................................................. 33
4.2 Discussion....................................................................................................................................... 36
CHAPTER 5 .............................................................................................................................................. 37
CONCLUSION AND FUTURESCOPE OF WORK............................................................................. 37
5.1 Conclusion ..................................................................................................................................... 37
5.2 Limitation ...................................................................................................................................... 37
5.3 Future Scope of Work................................................................................................................... 37
REFERENCES .......................................................................................................................................... 38
APPENDIX ................................................................................................................................................ 39

9
CHAPTER 1

INTRODUCTION
1.1 Introduction
At this time, one of the major factors for loss of life, loss of infrastructures and materialsis a car
accident. Even though many quality roads are built, relatively latest car exists, different rules and
regulations are made statistically the car accidents are increasing year after year. The reasons for
these accidents are many failures to give way for pedestrians, over speed, influence of alcohol and
drug are the common and major ones. Starting from this point of view we designed a system which
can reduce the accidents caused by over speed and drunken driving.
1.2 Problem statement
In our world car accident increases from day to day because of many reasons. From those reasons
most car accidents occur due to drunken driving and over speed. Therefore this project will be a
solution to the problem by providing an embedded system, which installed in the vehicles.

1.3 Project objective


The main objective of this project is to design and implement over speed and alcohol detection
system for vehicles.

Specific objectives:-

 To protect the great human life from car accident


 To avoid loss of materials and
 To give a better car accident prevention system to the traffic station.

1.4 Scope of the project


The project includes design and implementation of both hardware and software.
 Microcontroller (PIC 16F877A) is used as central processor.
 Color sensor is used to detect the painted color on the road.
 MQ-3 Alcohol sensor is used to detect the alcohol concentration.
 RF Module is used to receive and transmit information
 The Serial communication precedes using RS232 cable.

10
 C– language for the Microcontroller and MySQL Server 2008 for the data base
 Micro C and Proteous is used for simulation purpose.

11
CHAPTER 2

LITERATURE REVIEW
To design a system that can achieve the objective of the project some studies have been carried
out, which involving three main subtopics such as previous case study on related projects, studies
of hardware and software.

2.1 Work review


There are some existing projects related to over speed and alcohol detection system. Some of them
are:-

In Ankita Mishra [1] “Design of RF based speed control system for vehicles”,

The system has Smart Display controller meant for vehicle’s speed control and monitors the zones,
which can run-on an embedded system. Smart Display &Control (SDC) can be custom designed
to fit into a vehicle’s dashboard, and displays information on the vehicle. The project is composed
of two separate units: zone status transmitter unit and receiver (speed display and control) unit.
Once the information is received from the zones, the vehicle’s embedded unit automatically alerts
the driver, to reduce the speed according to the zone, it waits for few seconds, and otherwise
vehicle’s SDC unit automatically reduces the speed. To know the zone status they used RF
transmitter and receiver, but this is a lit bit expensive. So, instead we used a color sensor which is
cheaper than RF Tx/Rx.

In JiangpengDai [2] they are proposed “Mobile Phone Based Drunk Driving Detection”,
Early detection and alert of dangerous vehicle maneuvers typically related to drunk driving. The
entire solution requires only a mobile phone placed in vehicle and with accelerometer and
orientation sensor. A program installed on the mobile phone computes accelerations based on
sensor readings, and compares them with typical drunk driving patterns extracted from real driving
tests. Once any evidence of drunk driving is present, the mobile phone will automatically alert the
driver or call the police for help well before accident actually happens. They implement the
detection system on Android G1 phone and have it tested with different kinds of driving behaviors.

12
But they are designed a system for drunk driving detection only, so there is no any mechanism to
stop the car in this system, our project worked on this issue.
In K.Govindaraju [3] proposed “An Embedded Based Vehicle Speed Control System Using
Wireless Technology”,

The main objective of this system is to operate the vehicle in safe speed at critical zones. The base
station having the transmitter which is designed for Frequency Modulation (FM), the receiver part
is implemented in Vehicle. The ARM processor is implemented at receiver side, which receives
the critical frequency, and then it is activated in critical mode. Speed Control Driver (SCD) can be
custom designed to fit into a vehicle’s dashboard, and displays information on the vehicle. Once
the information is received, it automatically alerts the driver, to reduce the speed according to the
time and zone. This system only used to inform the speed limit of the road to the driver but if the
driver ignores the warning there is no system to stop him, so we are designed a system by using
RF communication to inform for the nearest traffic station.

In Nimmy James [4] “Alcohol Detection System”,

The system has an alcohol sensor embedded on the steering of the car. Whenever the driver starts
ignition, the sensor measures the content of the alcohol in his breath and automatically switches
off the car if he is drunken. In this system the sensor delivers a current with a linear relationship
to the alcohol molecules from zero to very high concentration. The output of the sensor is fed to
the PIC microcontroller for comparison. If the measured value reaches the threshold, relay cut off
automatically and the buzzer produces sound. This alcohol detection system works only when the
driver starts ignition but the driver can start the car by other person (who is not drunken), our
project solves this problem whenever the driver is drinking alcohol, the alcohol sensor detects level
of alcohol concentration and if it is abnormal the system display and send the information to the
driver and traffic station respectively.

13
2.2 Component review
2.2.1 Alcohol sensor (MQ-3)
This alcohol gas sensor detects the concentration of alcohol gas in the air and outputs its reading
as an analog voltage. The concentration sensing range of 0.04 mg/L to 4 mg/L is suitable for
breathalyses.

Features:-
 High sensitivity to alcohol and small sensitivity to Benzene.
 Fast response and High sensitivity
 Stable and long life
 Operation Temperature: -10 to 70 degrees C
 Heater consumption: less than 750mW
 Simple drive circuit

Figure 1-MQ3 Alcohol sensor

Basically, MQ3 alcohol sensor has 6pins, the cover and the body. Even though it has 6 pins, you
can use only 4 of them. Two of them are for the heating system, which call H and the other 2 are
for connecting power and ground, which called A and B.
At the inside of the sensor, there is little tube. Basically, this tube is a heating system that is made
of aluminum oxide and tin dioxide and inside of it there are heater coils, which practically
produce the heat. 2 pins that called Pin H are connected to the heater coils and the other ones are
connected to the tube.

How does it work? The core system is the cube. As you can see in this cross-sectional view,
basically, it is an Alumina tube cover by SnO2, which is tin dioxide. And between them there is
an Aurum electrode, the black one. And also you can see how the wires are connected. So, why do

14
we need them? Basically, the alumina tube and the coils are the heating system, the yellow, brown
parts and the coils in the picture.

Figure 2-Working principle of MQ3 alcohol sensor


Working Process: If the coil is heated up, SnO2 ceramics will become the semi - conductor, so
there are more movable electrons, which means that it is ready to make more current flow.
Then, when the alcohol molecules in the air meet the electrode that is between alumina and tin
dioxide, ethanol burns into acetic acid then more current is produced. So the more alcohol
molecules there are, the more current we will get. Because of this current change, we get the
different values from the sensor

There is a straightforward formula used to calculate your blood alcohol content (BAC). Alcohol
content in a volume of breath or blood is expressed as mg/L (milligrams per liter). A 1% blood
alcohol content is 10g/L or 10,000mg/L. Since this level would almost certainly be fatal, let’s scale
this down from “dead” to “drunk”. A 0.1% BAC is 1000mg/L.

How does this relate to the breath? It turns out that there is a standard conversion from breath
alcohol content to BAC that is employed by commercial Breathalyzers. Breath and blood alcohol
content differ by a factor of 2100; that is, for every mg of alcohol in the breath, there are 2100mg
of alcohol in the blood. So, a person with BAC of 0.1% has 1000mg/L of alcohol in their blood
and 1000/2100 = 0.4762mg alcohol in their breath. So, our final formula for calculating BAC from
the alcohol measured in the breath is:

% BAC = breath mg/L * 0.21

15
2.2.2 Color sensor (TCS3103)
The TCS3103 RGB Light-to-Voltage Converters combine three photodiodes with optical filters,
amplifiers, and gain-switching circuitry on a single chip. The output of each channel is a voltage
that is linearly proportional to light intensity (irradiance) on the corresponding photodiode element.
Each channel on the device consists of a photodiode with a red, green, or blue optical filter, a
current-to-voltage converter, and gain control elements. The voltage from each of the red, green,
and blue channels is output on the VOR, VOG, and VOB pins, respectively [9].

Figure 3-TCS 3103 Color sensor

Features:-

 Three-Channel RGB Color Sensor


 Converts Light Intensity to Voltage
 Single-Voltage Supply Operation 4.5 V to 5.5 V
 Programmable gain settings:
 Low Supply Current 270 micro Ampere Typical
 Fast Response Time Rise Time = 12 micro second Typical
 Low Dark Offset

The TCS3103 is intended for use in a variety of applications including color-point feedback
control in solid-state illumination and backlight systems, color adjustment in printers, process
controls, diagnostic systems, paper and product handling, toys, and games.

16
2.2.3 DC Motor
A DC motor is any of a class of electrical machines that converts direct current electrical power
into mechanical power. The most common types rely on the forces produced by magnetic fields.
Nearly all types of DC motors have some internal mechanism, either electromechanical or
electronic, to periodically change the direction of current flow in part of the motor. Most types
produce rotary motion; a linear motor directly produces force and motion in a straight line. DC
motors were the first type widely used, since they could be powered from existing direct-current
lighting power distribution systems. A DC motor’s speed can be controlled over a wide range,
using either a variable supply voltage or by changing the strength of current in its field windings.
Small DC motors are used in tools, toys, and appliances.
The universal motor can operate on direct current but is a lightweight motor used for portable
power tools and appliances. Larger DC motors are used in propulsion of electric vehicles, elevator
and hoists, or in drives for steel rolling mills. The advent of power electronics has made
replacement of DC motors with AC motors possible in many applications.

Figure 4-Dc motor

2.2.4 Motor Driver


This is a motor driver IC that can drive two motor simultaneously. L293D IC is a dual H-bridge
motor driver IC. One H-bridge is capable to drive a dc motor in bidirectional. L293D IC is a current
enhancing IC as the output from the sensor is not able to drive motors itself so L293D is used for
this purpose. L293D is a 16 pin IC having two enables pins which should always be remain high
to enable both the H-bridges and can run a motor up to 600 mA. Logical Supply Voltage will
decide what value of input voltage should be considered as high or low. So if we set Logical Supply
Voltage equals to +5V, then -0.3V to1.5V will be considered as Input Low Voltage and 2.3 V to
5V will be considered as Input High Voltage.

17
Figure 5-L293D Motor driver

2.2.5 Microcontroller
Microcontroller is a computer-on-a-chip. It is an inexpensive single-chip computer and sometimes
referred to as one-chip microcomputers, used to control a wide range of electrical and mechanical
appliances. The microcontroller existing on the encapsulated silver of silicon has features and
similarities to our standard Personal computers. The microcontroller is capable of storing and
running a program,

This powerful (200 nanosecond instruction execution) yet easy-to-program (only 35 single word
instructions) CMOS FLASH-based 8-bit microcontroller packs Microchip's powerful PIC
architecture into an 40 pin package and is upwards compatible with the PIC16C5X, PIC12CXXX
and PIC16C7X devices. The PIC16F877A features 256 bytes of EEPROM data memory, self-
programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2
capture/compare/PWM functions, the synchronous serial port can be configured as either 3-wire
Serial Peripheral Interface (SPI) or the 2-wire Inter-Integrated Circuit (I²C) bus and a Universal
Asynchronous Receiver Transmitter (USART). All of these features make it ideal for more
advanced level A/D applications in automotive, industrial, appliances and consumer applications
[8].

Figure 6-PIC16F877A Microcontroller

18
Features:-

 Single-supply 5V In-Circuit Serial Programming


 Self-reprogrammable under software control
 Selectable oscillator options
 10-bit, up to 8-channel Analog-to-Digital Converter (A/D)
 Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)with 9-bit
address detection
 Two Capture, Compare, PWM modules
o Capture is 16-bit, max. Resolution is 12.5 ns
o Compare is 16-bit, max. Resolution is 200 ns
o PWM max. Resolution is 10-bit
 Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle

2.2.6 LCD display


LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16× 2 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 and even (unlike in seven segments), animations and so on. A16× 2 LCD means
it can display 16 characters per line and there are 2 such lines. In this LCD each character is
displayed in 5× 7 pixel matrix. This LCD has two registers, namely, command and data. The
command register stores the command instructions given to the LCD. A command is an instruction
given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor
position, controlling display etc. [6].

Figure 7-16× 2 LCD Display

19
CHAPTER 3

METHODOLOGY
3.1 Introduction
The over speed and alcohol detection system consists of several parts (components) which are actuators,
processor, driver and communication unit. In addition to this, alcohol and color sensor are there to provide
feedback signal to the MCU. The alcohol (MQ3) and color sensor (TCS3103) are used to detect the
alcoholic concentration of the driver and the RGB colors painted on the road respectively. Then, the data
from sensors will be transmitting as inputs to the microcontroller. The microcontroller acted as a brain and
decided a proper command based on the inputs from the sensors. Then the outputs from the microcontroller
will be sending to the motor drive, RF module (or X-bee) and LCD. The motor drive is used to control the
movement of the motor which is motor rotate forward or backward, X-bee is used to transmit the appropriate
information to the traffic police station and the LCD is used to show the current alcoholic concentration
and speed status of the driver and the vehicle respectively.

3.2 Communication unit


3.2.1 Wireless Sensor Network
A Wireless Sensor Network is a self-configuring network of small sensor nodes communicating
among themselves using radio signals, and deployed in quantity to sense, monitor and understand
the physical world. WSN provide a bridge between the real physical and virtual worlds. Allow the
ability to observe the previously unobservable at a fine resolution over large spatiotemporal scales.
Have a wide range of potential applications to industry, science, transportation, civil infrastructure,
and security. In our project we used this WSN to communicate sensors from one place to another
place.

RF module

An RF module (radio frequency module) is a (usually) small electronic device used to transmit
and/or receive radio signals between two devices. In an embedded system it is often desirable to
communicate with another device wirelessly. This wireless communication may be accomplished
through optical communication or through radio frequency (RF) communication. For many
applications the medium of choice is RF since it does not require line of sight. RF communications
incorporate a transmitter and/or receiver. RF modules may comply with a defined protocol for RF

20
communications such as ZigBee, Bluetooth low energy, or Wi-Fi, or they may implement a
proprietary protocol. For our project we used ZigBee sensor to transfer data and communicate.

Table 1-Zigbee and other wireless technologies

Market name Zigbee GSM/GPRS Wi-Fi Bluetooth


standard 802.15.4 CDMA/1xRTT 802.11b 802.15.1
Application Monitoring White area voice Web, Email, Cable
focus and control and data Video replacement
System 4kb-32kb 16Mb 1Mb 16kb
resource
Battery life 100-1000 1-7 0.5-5 1-7
Network size Unlimited 1 32 7
Bandwidth 20-250 124-68 11000 720
Transmission 1-100 1000 1-100 1-10
range
Success Reliability Reach, Speed Cost
Metrics Quality flexibility convenience

ZigBee and its underlying 802.15.4 standard provide networks with two kinds of devices – full
function devices (FFDs) and reduced function devices (RFDs). All must have 64-bit IEEE
addresses, although short 16-bit addresses can be allocated to reduce packet size. FFDs may be
network coordinators or routers, while the endpoint devices that interact with the physical world
are the RFDs. All ZigBee networks must have a coordinator. The coordinator sets up the network,
is aware of all its constituent nodes, handles and stores information, acts as a repository for security
keys, and manages the information transmitted and received within the network. Routers act as
intermediaries, channeling information between devices. The endpoint devices have limited
functionality in order to reduce system cost and complexity. They are also the cheapest devices to
manufacture. They require limited memory and usually only interact with the physical world. They
have just enough capability to talk to their parent nodes, be they the coordinator or routers.

21
Figure 8-Zigbee Module

3.2.2 RS 232 Connector


RS 232 is one of the most widely used standards for sending serial data that is in use even today.
The RS–232 standard is used for many applications where it is necessary to send over a relatively
straight forward set of cables.
The RS–232 system for serial data transmission has the advantage of simplicity while still offering
a high level of capability. As a result, it has remained in use for many years and there is still no
sign of its demise.
The RS 232 connector has 9 pin and 25 pin in case of IBM COM port and can be simpler. It used
up to 9600 baud per second asynchronous serial transmission rate with UART mode
communication. Generally, baud rate set at 300, 600, 1200, 4800 and 9600. But when transmitting
up to 0.25m or 1m on cable (untwisted) the maximum baud rate can be 115.2 k or 38.4 k baud per
second, respectively [5].
RS-232 standard define the voltage levels that corresponding to logical one and logical zero levels.
Valid signals are plus or minus 3 to 25 volts. The range nears zero volts is not a valid RS-232level;
logic one defines as a negative voltage, the signal condition is called Marking, and has the
functional significance of OFF. Logic zero is positive, the signal condition is spacing, and has the
function ON. So a logic zero represented as +3v to +25 and logic 0ne represented as-3v to -25.

22
Figure 9-RS232 connector

Usually all the digital IC’s works on TTL or CMOS voltage levels which cannot be used to
communicate over RS-232 protocol. So a voltage or level converter is needed which can convert
TTL to RS-232 and RS 232 to TTL voltage level.

3.3 Overall system design


The microcontroller will get an input from the alcohol, color and speed sensor. It will process those
input to provide an appropriate electrical output signal to the communication units (RF module)
and motor which in turn transmit the correct data and control the motor operation respectively.
Power
supply

Alcohol
sensor
PIC 16F877A PWM speed Motor
microcontroller control
Color sensor

Communication
Unit

Figure 10-Overall system design

23
3.4 Electronic hardware
3.4.1 Power supply
 Switching mode

A switched-mode power supply (SMPS) is an electronic power supply that incorporates a


switching regulator to convert electrical power efficiently. Like other power supplies, an SMPS
transfers power from a source, like mains power, to a load, such as a personal computer, while
converting voltage and current characteristics. Unlike a linear power supply, the pass transistor of
a switching-mode supply continually switches between low-dissipation, full-on and full-off states,
and spends very little time in the high dissipation transitions, which minimizes wasted energy.
Ideally, a switched-mode power supply dissipates no power. Voltage regulation is achieved by
varying the ratio of on-to-off time. In contrast, a linear power supply regulates the output voltage
by continually dissipating power in the pass transistor. This higher power conversion efficiency is
an important advantage of a switched-mode power supply. Switched-mode power supplies may
also be substantially smaller and lighter than a linear supply due to the smaller transformer size
and weight.

Switching regulators are used as replacements for linear regulators when higher efficiency, smaller
size or lighter weight are required. They are, however, more complicated; their switching currents
can cause electrical noise problems if not carefully suppressed, and simple designs may have a
poor power factor.

 A linear power supply (Power dissipation mode)


A linear power supply, on the other hand, regulates the output voltage by dissipating excess power
in Ohmic losses (by use of a resistor or a pass transistor in its active mode). Because a linear
regulator regulates either output voltage or current by dissipating the excess electric power in the
form of heat, its maximum power efficiency is voltage-out/voltage-in. To function properly, a
moderately complex regulator circuit is used to achieve low load and ensure line regulation.
Another benefit is linear regulated power supplies also have very little ripple and very little output
noise (also known as EMI and RFI).

24
3.4.2 Microcontroller unit

Here PIC16F877A microcontroller is used to all the operation regarding the embedded system.
PORT A is used to receive analogue signal from alcohol sensor (MQ3), color sensor and speed
sensor, Pin 0 to 5 of PORTB is used to provide signal (data) to the LCD display, pin 3 of PORTC
is used to send signal to the LED, pin2 of PORTC is used to provide enabling signal to the motor
driver and finally pin 1 to 2 of PORTD is used to drive the DC motor through the motor driver.

3.4.3 Motor drive circuit

It is on bread board circuit which is able to control two DC motors in both directions. The two
inputs are connected to PORTD.RD0 to PORTD.RD1 of the microcontroller and the two output
pins are connected to a DC motor to control the rotation of the motors. Enable pins is connected
directly to PORTC.RC2 in order to make it to operate in a PWM Mode. This will help to drive
motors with variable speed.

Figure 11-Motor driver circuit

3.4.4 Level convertor circuit

The most commonly used RS 232 level converter is MAX-232. This IC requires four external
capacitor (each 10uF) for its internal charge pumps which can generate RS232 voltage levels (-
10v and +10v) from 5v power supply. A MAX-232 is actually a dual driver /receiver and we are
just used one. The input pin is connected to PORTC.RC6 of the microcontroller and the output pin
is connected to the DB9 connector in order to transmit data and make it capable of half duplex
UART communication. On the Pc’s side, only three lines are connected (Tx, Rx and Ground) to
the COM port through a 9 pin connector [10].

25
Figure 12-Level convertor

3.5 Materials
The list of tools and components used during the project are stated below:-

 Voltage regulator (LM7805)


 Resistors (330Ω,10kΩ)
 Capacitors (10uF, 25uF or 5uF)
 Push buttons
 LED
 PIC16F877A microcontroller
 Dc motor (12v)
 Motor drive(L293D)
 LCD Display (16× 2)
 Alcohol sensor (MQ-3)
 IR sensor
 RS-232 connector
 MAX-232
 Bread board
 Pc(personal computer)

26
3.6 Software design
Interface:-

a) Alcohol sensor (MQ-3)

Since all analogue sensors need ADC to convert its analogue value to the digital value, which is
connected to the microcontroller unit. So we must determine the cofactor value of the sensor. First
we set the output value of the sensor to its corresponding voltage value (i.e. at 0.04mg/l and 4mg/l
it gives 0v and 5v respectively). Since the microcontroller (PIC16F877A) has 10 bit ADC, we
calculated the respective digital value (0-1023) of the reading alcohol concentration.

Mathematically:

For 0.047916mg/l = 10mv

X = Volt

𝑋×10𝑚𝑣
Then Volt=
0.047916𝑚𝑔/𝑙

10𝑋
Volt = ( ) v.
47.9

Then at 5v = 1023

Volt = Val

𝑉𝑜𝑙𝑡×1023 10𝑋
Val =
5𝑣
= (( ) v× 1023)÷ 5𝑣
47.9

Finally, X = ( 𝑉𝑎𝑙 × 0.02341) mg/l

Where: X is alcohol concentration in mg/l

Volt is voltage value in mv and

Val is digital value

b) Color sensor (TCS3103)

Although the output of the device can be connected to a comparator for simple threshold
measurements, or to another amplifier stage, most applications will require that the three channels
27
be connected to analog to digital converters (ADCs) so that the light and color information can be
processed by a microcontroller. In many cases, the outputs can be directly connected to the ADC
inputs. In some cases, for example if the light is modulated, it may be desirable to insert active or
passive low-pass filters on the channels prior to the ADC, to smooth out the modulation ripple that
would otherwise result in noisy measurements. The cutoff frequency of the filters would, of course,
depend upon the modulation frequency of the incoming light. With a pulse-width modulated
(PWM) input light signal, it may be possible to synchronize the ADC sampling on-time of the
PWM signal. In this case, a low-pass filter would not be required because the device output would
be sampled only during the on time of the input light source.

c) Communication protocol

There are two types of communication serial and parallel communication. But serial
communications are used in microcontroller based systems, mostly due to the scarcity of available
input/output pins. Besides for long distance communications, serial data transfer is more simple
and cost effective as the required hardware connections in the data link can be reduced to three
(i.e. Tx, Rx and Gnd).

There are two different types of serial communications: Synchronous and Asynchronous. The key
challenge in a serial data link is to maintain the synchronization between the transmitter and the
receiver. The asynchronous method uses a start and stop bit protocol to synchronize the two ends.
Each character byte is sent in a frame consisting of a start bit, followed by the character bits,
followed (optionally) by a parity bit, and finalized by one or more stop bits. The sender and
receiver have to be initialized to use the same data rate, number of data bits, and number of stop
bits.

In idle condition, the transmit output is at logic high. When the transmitter is ready to send a
character byte, it signals the receiver by pulling the transmitter line low for one clock period. This
is the start bit and it tells the receiver that a frame follows. The receiver reads the number of
character bits expected according to the adopted protocol until the line is pulled to logic high by
the transmitter (one more stop bits), and that is the end of the frame. The whole process is repeated
every time the transmitter has to send a character byte. The receiver is resynchronizes itself to the
transmitter every time the data is sent using the start bit.

28
The USART module inside the PIC16F877A microcontroller supports both types of serial
communications but it is the best suited for the asynchronous method. In asynchronous mode, RC6
acts as a data transmit (Tx) output and RC7 as data receive (Rx) input. A byte of serial data is sent
as a string of 10 bits; a start bit, eight data bits, and a stop bit [7].

Start Bit Bit0 Bit1 Bit 2 Bit 3 Bit4 Bit5 Bit6 Bit7 Stop Bit

Figure 13-A string of 10 bit data


UART support data transmission from 5 bits to 9 bits, with parity option for data integrity checking
and option for 1, 1.5 and 2 stop bits. UART can work on various speeds starting from 300bps up
to 4 Mbps. Most common used baud rates are 9600, 9800 and 115200. In simplify an 8-bit UART
protocol consists of a start bit, 8 data bits and one stop bits. For this project we used 9600 bit per
second.

The pc’s serial port (also known as COM port) uses the RS 232-C standard for serial
communication.

c) LCD Display (16*2)

The LCD display units data pins D4 to D7 are interface to the port are 33 to 36 of the
microcontroller for data receiving and controlling process. The interfacing ports are getting the
data and displaying to the LCD display. RS-Reset pin interface to the port of 37 and EN-Enable
pin interface to the port of 38. The read and write pin are connecting to the ground. The reset
enable pin is used to display the receiving data.

3.7 Computer software


Here the computer software receive the serial data from the RF (radio frequency) receiver through
serial communication by using RS232 cable, process the data so as to convert the data in to an
information to let the user know what exactly it mean and finally display the information to the
end user and at the same time store the information in to data base.

29
Figure 14-Software architecture

3.7.1 System overview

The graphical user interface (GUI) is developed by using C# and the data base is by using MySQL
server 2008. The developed GUI application is capable of showing the plate number, the fault type
and street number. The data base developed is again capable of storing the record which includes
the plate number, fault type and street number and street name matching table. The GUI will store
those records in to the data base and at the same time retrieve the information so as to display the
most recent information to the end user.

Figure 15-System over view


The following picture shows the appearance of the GUI.

30
Figure 16-GUI (Graphical user interface)
There is two part here in these GUI, one is to desplay the current fault information and another is
to desplay the most recent one. The could be three different states for each fault type normal,
warning and abnormal. But the information is not going to be desplayed unless at least there is one
fault. If there is one fault the remainig could be at normal or warning state. For instance the drive
plate number might be 34256, the alcohol fault might be abnormal and the care is at station which
means the speed fault is normal. Again there coul be speed fault leaving the alcohol fault normal.
But there is no probablity of having a speed fault after detecting an alcohol fault, since wenever
an alcohol fault is detected the system by it self will make the car to stop after a moment.

And the following is to show arcitechture of the data base.

Figure 17-Data base architecture


Here there is predefined street name and number association table. Whenever the GUI receive the
the street ID number from the microcontroller, it will directeley make a matching and desplay the

31
associated name of the street. And again the fault record table will record the plate number of the
car, fault type, fault condition and finally date and time.

3.8 Software Architecture

Figure 18-Flow chart

32
CHAPTER 4

RESULTS AND DISCUSSION


4.1 Result
Focus is directly shifted to the implementation after all software and hardware design takes place.
The software design algorithm is coded using micro C compiler in C-language and MYSQL in C#
language. The hardware is simulated using proteus professional 8 and finally implemented the
prototype on bread board for demonstration.

Figure 19-Overall simulation


The LCD display is used to demonstrate the current alcoholic concentration and speed status of
the driver and the vehicle respectively. The LED is used to indicate the transmission of fault to the
traffic police station.

33
 Simulated result of alcohol sensor

Figure 20-Simulated result of alcohol sensor

 Simulated result of color sensor

Figure 21-PWM for 120 Kph

34
Figure 22-PWM for 80 Kph

Figure 23-PWM for 60 Kph

Figure 24-PWM for over speed


35
 Hardware result

Figure 25-Hardware connection

4.2 Discussion
The MQ-3 Alcohol sensor is cheaper in cost and is as effective as other types of breath alcohol
detector. Furthermore, the system can be easily interfaced to a microcontroller as the output yield
is in voltages. When power dissipation comes in to concern, the sensor model has very low power
dissipation although it works with presence of heat because it only needs low voltage value in the
range of 3.3v to 5v as its input.

Sensitivity of the sensor is also relatively high compared to the other models. Although the sensor
is capable of detecting other substances and misinterprets it as alcohol, the sensitivity towards
alcohol is much higher and this makes it a very reliable alcohol detecting device.

36
CHAPTER 5

CONCLUSION AND FUTURESCOPE OF WORK


5.1 Conclusion

The project gives a system that can detect the amount of alcohol concentration of the driver in the
vehicle to certain range and activates the microcontroller to control the engine and other extra
information which acts as an indicator that enables other drivers to judge the driver has taken
alcohol and needs any assistant or help. In addition to this, the system can detect the over speeding
of the vehicle and took action by sending the appropriate information to the traffic police station
via RF module (Xbee) and those who have the authority takes necessary penalty to drunken and
over speed drivers to prevent from similar situation.

5.2 Limitation
Since the system needs a well-coordinated traffic police stations, therefore this might be hold back
the feasibility of the project in most Ethiopian road.

5.3 Future Scope of Work


The project can be further advanced by interfacing a GPS in the system that will inform about the
position of the vehicle; as a result provides easy location and since the blood pressure changes due
to the alcohol consumptions, instead of using alcohol sensor we can monitor the blood pressure or
heart beat by different sensors, which can lead to a better method. Finally, more advanced control
algorithm designed by Fuzzy logic or neural network can lead to a stable control of the vehicle.

37
REFERENCES
1. Ankita Mishra, Jyoti Solanki , Harshala Bakshi, Priyanka SaxenaPranav Paranjpe. "Design of RF
based speed control system for vehicles." International Journal of Advanced Research in
Computer and Communication Engineering, October 2012: Vol. 1, Issue 8.

2. Jiangpeng Dai, Jin Teng, Xiaole Bai, Zhaohui Shen and Dong Xuan. "Mobile Phone Based Drunk
Driving Detection." February,2010.

3. K.Govindaraju, S.Boopathi, F.Parvez Ahmed, S.Thulasi Ram , M.Jagadeeshraja. "Embedded Based


Vehicle Speed Control System." INTERNATIONAL JOURNAL OF INNOVATIVE RESEARCH IN
ELECTRICAL, ELECTRONICS, INSTRUMENTATION AND CONTROL ENGINEERING, August 2014: Vol.
2, Issue 8.

4. Nimmy James, Aparna C,Teena P John. "Alcohol Detection System." International journal of
reasrch in computer and communication technology, January- 2014: Vol 3, Issue 1.

5. PIC Microcontroller projects. 2011. Pic projects.net.

6. R.Deepa. International Jornal of Engineering Science and Innovation Technology Volume 4,


January 2015: 171-178.

7. R-B. Embedded Lab. October 23, 2011. http://www.embeddedlab.com.

8. Sons, Wilay and. PIC16F877A data sheet. Microchip., 2004.

9. TCS3103-TCS3104_B-Datasheet. Unterpremstaetten,Austria: TAOS inc., 2010.

10. Texas instruments incorporated[SLLS047, M. MAX232X DUAL EIA-232 Drivers/Receivers(Rem.M).


2005.

38
APPENDIX
C-code for the system

int count = 0;

int alco_level = 0;

char uart_rd;

unsigned short gear1 = 255;

unsigned short gear2 = 150;

unsigned short gear3 = 100;

#define colorsensor PORTA.RA2

#define speedsensor PORTA.RA5

#define motor PORTD

#define forward 0b00000010

#define stop 0x00

#define ID 0x00

#define alcohol 0x01

#define speed 0x02

#define fault PORTC.RC3

// LCD module connections

sbit LCD_RS at RB4_bit;

sbit LCD_EN at RB5_bit;

sbit LCD_D4 at RB0_bit;

sbit LCD_D5 at RB1_bit;

sbit LCD_D6 at RB2_bit;

sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;

39
sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D4_Direction at TRISB0_bit;

sbit LCD_D5_Direction at TRISB1_bit;

sbit LCD_D6_Direction at TRISB2_bit;

sbit LCD_D7_Direction at TRISB3_bit;

// End LCD module connections

char text1[] = "WELCOME";

char text2[] = "Alch:";

char text3[] = "Sped:";

char text4[] = "120Kph ";

char text5[] = "80Kph ";

char text6[] = "60Kph ";

char text7[] = "Good ";

char text8[] = "Warning ";

char text9[] = "AbNormal";

void main ( )

portb = 0x00;

portd = 0x00;

porta = 0x00;

portc = 0x00;

trisa = 0xff;

trisc = 0x00;

trisb = 0x00;

40
trisd = 0x00;

Delay_ms (100);

UART1_Init (9600);

Delay_ms (100);

adcon1 = 0x04;

Delay_ms (100);

pwm1_start ();

pwm1_init (1000);

/*delay_ms (100);

pwm2_start ( );

pwm2_init (1000);

delay_ms (100);*/

pwm1_start ( );

pwm1_init (1000);

delay_ms (100);

adc_init ();

delay_ms (100);

lcd_init ( );

delay_ms 100);

lcd_cmd (_lcd_cursor_off);

lcd_cmd (_lcd_clear);

lcd_out (1, 4, text1);

delay_ms (2000);

lcd_cmd (_lcd_cursor_off);

41
lcd_cmd (_lcd_clear);

lcd_out (1, 1, text2);

lcd_out (2, 1, text3);

while (1)

delay_ms (100);

alco_level = adc_read (0);

delay_ms (100);

if (alco_level >= 769)

UART1_Write (ID);

delay_ms (100);

UART1_Write (alcohol);

delay_ms (100);

motor = forward;

lcd_out (1,7,text 9);

fault = 1;

pwm1_set_duty (gear1);

delay_ms (1000);

pwm1_set_duty (gear2);

delay_ms (1000);

pwm1_set_duty (gear3);

delay_ms (1000);

pwm1_set_duty (0);

delay_ms (1000);

42
motor = stop;

delay_ms (300);

break;

If (speedsensor == 1)

UART1_Write (ID);

delay_ms (100);

UART1_Write (speed);

delay_ms (100);

while (speedsensor)

motor = forward;

lcd_out (2, 7, text8);

fault = 1;

if(speedsensor == 0)

fault = 0;

if (colorsensor == 1)

while (colorsensor == 1);

count++;

43
/*if (count >= 3)

count = 0;*/

if ((alco_level <= 512))

motor = forward;

pwm1_set_duty (gear1);

lcd_out (1,7, text 7);

// lcd_out (2, 7,"****");

if((alco_level >= 513)&& (alco_level <= 768))

motor = forward;

pwm1_set_duty(gear1);

lcd_out(1,7,text8);

// lcd_out(2,7,"****");

if ((alco_level <= 512) && (count == 1))

motor = forward;

pwm1_set_duty(gear1);

lcd_out(1,7,text7);

lcd_out(2,7,text4);

44
}

if((alco_level >= 513)&& (alco_level <= 768) && (count == 1))

motor = forward;

pwm1_set_duty(gear1);

lcd_out(1,7,text8);

lcd_out(2,7,text4);

if ((alco_level <= 512) && (count == 2))

motor = forward;

pwm1_set_duty (gear3);

lcd_out (1, 7, text7);

lcd_out (2, 7, text6);

If ((alco_level >= 513) && (alco_level <= 768) && (count == 2))

motor = forward;

pwm1_set_duty (gear3);

lcd_out (1,7, text 8);

lcd_out (2, 7, text6);

if ((alco_level <= 512) && (count == 3))

45
{

count = 0;

motor = forward;

pwm1_set_duty (gear2);

lcd_out (1, 7, text7);

lcd_out (2,7, text 5);

if ((alco_level >= 513) && (alco_level <= 768) && (count == 3))

count = 0;

motor = forward;

pwm1_set_duty (gear2);

lcd_out (1, 7, text 8);

lcd_out (2, 7, text 5);

46

You might also like