Vous êtes sur la page 1sur 39

ACCIDENT PREVENTION USING EYE BLINK SENSOR

Abstract:

Automobile has great importance in our daily life. We utilize it to go to our workplace,
travel all over the place, deliver goods. Speed is one of the important to consider while driving
and the driver stress of the over-shift it also leads to the sudden accident. The Speed of the
vehicle can be measured with help of speed limiter so the speed is controlled and also if the
driver is tired or not can be checked. The IR Sensor is used to detect the eye blinking. The eye
blink is a sensor which is placed in front of the driver on the top. While in driving time the eye
blink in normal means it checks when the eye close to particular second’s buzzer will be
indicated to alert him to wake up.
Now a day’s accidents are increasing at a large pace, and various technologies are
beingintroduced to reduce the accidents. In this project we provide means of accident
prevention usingeye blink wherein the vehicle is stopped immediately and intimated wherever
needed.In this project we have two sections. One is transmitter section which is located in
thevehicle and another one is Receiver section located in remote place (Police station, near
ones,etc). In the transmitter section the eye blink sensor is placed near the eye to sense the
blink countand this information is transmitted in the form of pulses and is given to the
Microcontroller.

TheMicrocontroller uses this information to compare with the normal eye blink
programmed in thechip and if any abnormal situation arises the vehicle is stopped with an
alarm indication, thisoperation is enabled by means of the driver circuit connected to the
vehicle motor and the signalis transmitted via RF-transmitter at the frequency of 433.92 MHz.In
the Receiver side the transmitted signal is received and the signal is decoded andgiven to the
Microcontroller, which uses this information for displaying the alert message in theLCD as
programmed, simultaneously a buzzer alert is given.Accidents due to driver drowsiness can be
prevented using eye blink sensors. The driver is supposed to wear the eye blink sensor frame
throughout the course of driving and blink has to be for a couple of seconds to detect
drowsiness. Any random changes in steering movement leads to reduction in wheel speed.
The threshold of the vibration sensor can be varied and accordingly action can be taken. The
outcome is that the vibrator attached to eye blink sensor’s frame vibrates if the driver falls
asleep and also the LCD displays the warning messages. The wheel is slowed or stopped
depending on the condition. This is accompanied by the owner being notified through the
GSM module, so the owner can retrieve the driver’s location, photograph and police station
list near to driver’s location. This is how the driver can be alerted during drowsiness and the
owner can be notified simultaneously
2. Literature Survey

1. Introduction

For any vehicle accidents driver’s faults are the most accountable aspect to cause dangerous
problem to the society. Many drivers cannot control the vehicles due to different reasons it
may cause severe accidents and sometime death. For vehicle accidents various factors involved
such as drunk driving, over speeding, many distractions like texting while driving, talking with
others, playing with children etc. one of the important factor is sleeping on the wheel. People
know the dangerous of alcohol consumption and run the vehicles but they not understand the
seriousness of fatigue driving. In India, Ministry of Road Transport and Highway released a
report in 2015, every day around 1,374 accidents may happen and almost 400 people deaths
occur. Every hour because of vehicle accidents approximately 57 road accidents and 17 people
dies. In that 54.1 percent of people are in the age group of 15 to 34 years are killed in vehicle
accident. The Government of India, Ministry of Road Transport and Highway Government of
India prepare a strategy to diminish the amount of motorway accidents and losses by 50 % by
2020.

Globally vehicle accidents have seemed one of the major community health problems. In India
almost 5 lakh road accidents happened in the year 2015. A fatigue Driver those who falls asleep
at the move fails to control the vehicle, not possible to take immediate action and results in a
crash so it is necessary to monitor the drowsiness of the driver to prevent accidents.

Automatic driver drowsiness can be detected using artificial intelligence and visual
information.

System is to detect, track and examine face and eyes of drivers for this different real vehicle
image of drivers are taken to validate the algorithms.

It is a real time system work in different light conditions [1]. The numbers of accidents are
increased due to several factor, one of the main factor is that driver fatigue. Driver’s sleepiness
is also implemented using video based approach. This system is noninvasive and human
related elements are used. Band power and Empirical Mode Decomposition methods are used
to investigate and extract the signal, SVM (Support Vector Machine) used to confirm the
analysis and to categorize the state of vigilance of the driver [2].

The system designs to find the drivers drowsiness using the hypothesis of Bayesian networks.
The interaction between driver and vehicle features are extracted to get reliable symptoms of
driver drowsiness. It presents more suitable and accurate strategies to design drowsy driver
detection system [3].

Brain and visual activity is used in drowsiness detection system. Electroencephalographic (EEG)
channel used to monitor the brain activity. Diagnostic techniques and fuzzy logic are used in
EEG- based drowsiness detector. Using blinking detection and characterization for visual
activity monitored. Electrooculographic (EOG) channel are used to extract the Blinking features
[4].

Image processing and pattern classification used to take the driver facial pictures, tracking the
features of driver face and categorizing the driver’s sleepiness level. 17 different features

points are determined after examining the facial muscle activities using Active Appearance
Model (AAM). K-Nearest-Neighbor method applied to categorize sleepiness into 6 levels,
driver’s smile also detected with this method [5].

Head posture estimation method is used for detection of drowsy driver. In this method Viola
and Jones algorithm for driver face detection [6].

This method is nonintrusive and sturdy for finding the driver drowsiness in real time. Support
Vector Machine (SVM) is using for extracting the face from video frames and Circular Hough
Transform (CHT) is useful for mouth and eye state analysis [7].

In this approach machine learning used to determine the human behavior during driver
drowsiness, for this 30 different facial actions including eye blink, yawning and head
movements are collected to detect the driver drowsiness [8].

3. Methodology

The concept of drowsy driver detection system focuses on the functioning of all sensor
modules used in the project. This helps explain the inputs received by modules and the outputs
they produce.

3.1 Eye Blink Sensor

This sensor module consists of the eye blink sensor frame, the IR sensor and a relay. The
vibrator device is connected to the eye blink sensor frame which is to be worn by the driver.
This vibrator vibrates whenever an accident occurs or the driver falls asleep. The frame consists
of the IR transmitter which transmits the IR rays towards the driver’s eyes and an IR receiver
which receives the reflected rays when the eyes are closed. The relay provides the extra current
required by this module and hence is also connected to the SST microcontroller board [9].

3.2 LCD

LCD is a device which displays the messages in case the driver falls asleep or accident occurs.
The messages displayed are

―SLEEPING‖ and ―ACCIDENT OCCURRED‖ as per the situation. All the modules are
connected to it so that the particular signals can be received and hence message could be
displayed. It uses the power supply from the SST microcontroller board displays a
―WELCOME‖ message. It also provides 5V power to other modules [10].

3.3 LM317PSU Board

This board is connected to the relay chip which in further connected to the eye blink sensor
system module. This board’s main purpose is to fulfill the power requirements of the eye blink
sensor module.

3.4 DC Motor

The motor acts as the wheel of the vehicle and it rotates when the power is supplied to it
through L298 chip. The speed of rotation is slowed down when the driver falls asleep as
detected by the eye blink sensor, in the other case the wheel is stopped when the accident
occurs.

3.5 Vibration Sensor

The purpose of this sensor is to sense any jerk given to the vehicle which is the emulation of
the accident occurrence in real time. This receives power from the 5V port of the LCD.

The output produces and sends signals to dc motor driver and stops the rotation of the wheel,
that is, the motor.

3.6 L298 Motor Driver


The DC motor receives power from this motor driver, which in turn is powered from the SST
microcontroller board. The enable pins of this driver should be high to send the power to the
motor.

3.7 GSM Module

The GSM module used is GSM-SIM300. This module’s primary function is to send an audio
warning message to the owner’s registered number that is, in case of any accident the owner
is notified by it android application which plays an audio saying

―accident occurred, kindly check your phone‖. A sim card is to be fixed in this module to
simultaneously send a text message on the owner’s phone.

3.8 Accelerometer 3-Axis and ADC0809

The accelerometer used is ADXL335 3-axis which acts as steering and measures any increase
in the speed. The reference speed taken in this project is 150kmph. As the vehicle turns
randomly, the accelerometer generates analog values which are further given to the ADC0809,
the converter used in this project. These digital values in turn act as inputs to the dc motor,
the LCD and the vibrator.

3.9 SST Microcontroller

This is the main working unit which connects all the inputs and outputs to its 4 ports namely,
P0 P1 P2 P3 and each of them have 8-pins which act as pins for input and output. The main ac
dc power supply f 12V is given to this board. It has a huge RAM and ROM which helps the
program run faster as compared to other microcontrollers and also provides extra memory
storage capacity [11].

4. Implementation

4.1 Hardware Requirements

The various sensors form the hardware part of the project and power supply is AC DC 12V
adapter. Other hardware modules are specified as follows:

1) PIC16F877A.
2) CAN Transceivers

3) Alarm circuit.

4) SST Micro Controller

5) Power Supply

6) IR eye blink sensor

7) LM 358 comparator

8) Accelerometer

9) LCD

10) Vibrator Output devices

4.2 Software Requirements

For the implementation of the modules, the coding language is specified in this part and also
the platforms used for coding and the android application development:

1) Keil C compiler

2) Embedded C

3) Android studio

4.3 General Constraints

To developing the system the subsequent constraints were kept in mind:

• The IR eye blink sensor’s transmitter and receiver should be in a straight line.

• There shall be no element of doubt regarding the correctness of the distance


measured.

• The system must have the android app for location detection since phone’s processor
is faster than that used by GSM module.

• The system should be robust.


4.4 Development Methods

The development methods decide a large section of how the final system functions, and thus
care is taken to ensure that the best practices, tools and equipments are used. The system will
be developed using Keil IDE. The programming language embedded C will also be used.
Certain sections of the system will be ported android application development for
performance enhancement. The main modules would be microcontroller, IR sensor, LM358
comparator, accelerometer, LCD and android phone [12].

4.5 System Architecture

Drowsy driver detection system is divided into subsystems and these sub systems gives some
interconnected services. Architecture design can be defined as proving a framework for sub-
system control, in the first stage of the design process all subsystems of the drowsy driver
detection system are identified and hence, the design process output is a output of this a
explanation of the software architecture. A basic structural framework for a system can be
established through architectural design process. The identification of the major components
of the system and communications between these components is considered under this.

The system architecture below portrays the blocks required for the implemented system.
Figure 1 outlines the system architecture. The sensors need to detect respective parameters
and pass the signals to microcontroller. The outputs from SST are used as inputs by various
output devices to control the speed and display the message [13].
Fig. 1: System Architecture

Figure 2., depicts the structure chart of the complete system. The structure chart contains all
the components of the system.

4.6 Input Module

Fig. 2: Structure Chart

• Input

The inputs to this module are signals from ports of microcontroller.This section is responsible
for taking in crisp values of the vehicle, eye blink movements any vibration caused to vehicle
due to accident.

• Purpose

The purpose of this module is obtaining values from each sensor and comparing them with
reference values.

• Functionality

The functionality of this module is to obtain the raw values and pass signals to SST.
• Input

The input to this module are the crisp values of vehicle speed, IR from eye blink sensor and
values from shock due to accident.

• Output

The output of this module is fed into SST80C51 microcontroller.

4.7 SST Microcontroller

This section contains three inputs and outputs to various output devices. It receives the signals
from the previous modules

• Purpose

The purpose of this module is to pass the received values as input to output devices.

• Functionality

This module provides inputs to the output devices.

• Input

The inputs would be outputs received by input devices.

• Output

The output of SST would be passed to other output devices so various functionalities could be
carried out as demanded by project.

4.8 Output Devices

This section contains DC motor, LCD, vibrator, GSM module which perform their respective
functionalities.

• Purpose

The purpose of this module is to carry out respective functionalities such as slowing down the
vehicle speed, alerting the driver, notifying the owner and displaying message on the LCD.

• Functionality

This module takes the input from the SST microcontroller through ports and carries out
intended goals.
Output

The output of SST would be passed to other output devices so various functionalities could be
carried out as demanded by project.

4.9 Aid for All 8051 Alternatives

One of the most fastest growing Microcontroller Architecture are 8051 alternatives, today
nearly more than 400 device alternatives available with various silicon vendors. For large
applications Philips 80C51MX architecture the New extended 8051 devices are used because
of the large storage capacity with several Mbytes. Keil also provides different Development
tools for best support for these different variants are recorded below [14].

4.10 Bit 80C51 5 V Low Power 64 Kb Flash Microcontroller

The P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1kB of data RAM. These
devices are designed to be drop-in and software-compatible replacements for the popular
P89C51RB2/RC2/RD2 devices. It supports both the In-System Programming (ISP) and In-
Application Programming (IAP) boot codes with 12-clock (default) or 6-clock mode selection.it
contains three 16 bit times/counters. In-System programming and In- Application
Programming on chip flash user code memory is 64 kb. Operating frequency in 12x mode is 0
MHz to 40 M Hz. Non- volatile data storage is the 128-B page erase for efficient use of code
memory [16].

4.11 PCA

The Programmable Counter Array (PCA0) gives enhanced timer functionality and requiring less
CPU involvement compare to the standard 8051 counter/timers. Dedicated 16-bit
counter/timer and five 16-bit capture/compare modules are there in PCA. Each
capture/compare module has its own associated I/O line (CEXn) which is routed through the
Crossbar to Port I/O when enabled [17]. They can be programmed in any of the following
modes: Rising or falling edge timer, Software timer, High speed output and PWM

4.12 Accelerometer

An accelerometer is an electromechanical device. Acceleration force will measure using this


device, due to cause of gravity i.e. g force it shows acceleration and it measures in g units. It is
used in tilt-sensing applications as well as dynamic acceleration resulting from motion, shock,
or vibration.

The ADXL335 is a popular three-axis analog accelerometer IC, which reads off the X, Y and Z
acceleration as analog voltages. Complete 3-axis acceleration measurement gives the
ADXL335, within range ±3 g in the x, y and z axis. Analog voltages are proportional to the
acceleration are the output signals of this module. Poly silicon surface-micro machined sensor
and signal conditioning circuitry contains in ADXL335 [18].

4.13 Eye Blink Sensor

To observe the solidness of the traffic, we will be placing a few sets of IR transmitter & receiver
sensors on the side of the roads. On side IR transmitter device will be installed & right opposite
to the IR transmitter, an IR receiver will be positioned. This set of IR transmitter & receiver will
be placed at interim distance on the road [19].

The IR transmitters are attached to supply, so that they will transmit high signal all the time.
The IR receivers are attached to the comparator circuit, to get digital signals. A low power
operational amplifier LM324 IC has been used to build a comparator circuit. Two set of LM324
IC has been used in this project [20].

4.14 Vibration Sensor

The vibration sensor buffers a piezoelectric transducer. The transducer generates the voltages,
when the transducer moved from neutral axis, distortion makes strain within the piezoelectric
element. Security purpose only this vibration sensor decorator is designed and it produced
alarm through movement or vibration, and it sends a signal to control panel, a new type of
multi directional security vibration detector with multi directional detection also developed
[21].

5. Testing

For unit testing the following contents are suggestive testing strategy in the system [22]:

• The design description characteristics and source code for each module to be trialed
are first reviewed.

• An evaluation committee is responsible for validation of the Unit Test Plan.


• A trial "stub" is created to allocate input to or fetch output from the trial module.

• The code is then compiled in the trial environment to check for any anomalies.

• The trials are executed and data received out of the verified software are compared
with the expected, as recorded in the Unit Test Plan.

• The code is retested and results are recorded, when an updated version is available

• Final report form archived from that unit is said to have cleared all trials.

• Every possible tweaks/ related to software requirements and draft documents are
provided.

6. Results

6.1 The Drowsy Driver Detection System

The results obtained by running the module are as follows:

• The owner’s phone receives an audio warning message.

• The owner can retrieve the location of the driver by choosing the ―location‖ option.

• The owner can also get a list of driver’s nearby police stations. With this, the
photograph of the driver can be sent to owner’s email address as specified in the clamped
phone.

• The wheel/motor is stopped as soon as an accident occurs, the vibrator in the eye blink
sensor frame vibrates and displays a message on the LCD.

• When the driver falls asleep, the vibrator vibrates and the LCD displays the message.
Along with this, the vehicle speed is automatically reduced.

• When the accelerometer is tilted randomly, that acts as the steering, a message is
displayed on the LCD the speed of the vehicle is reduced.

• With all of the above mentioned, the android applications send and receives details
simultaneously.

6.2 Vibration Sensor Senses Vibration


Fig. 3: Vibration Sensor senses vibration

Figure 3 shows that when a jerk or vibration is given to the sensor, the vibration sensor is
activated and the wheel is stopped. The LCD displays a warning message as ―ACCIDENT
OCCURRED‖ and the vibrator on the eye blink sensor frame vibrates continuously.

6.3 Eye is shut

Fig. 4: Eye is shut

Figure 4 shows that when the eyes are closed then the vibrator vibrates and the speed of the
wheel is decreased. The LCD displays a ―SLEEPING‖ message.
5,12 V PS

1 Power supply

1.1 Block diagram

Block diagram (Power supply)

The ac voltage, typically 220V rms, is connected to a transformer, which


steps that ac voltage down to the level of the desired dc output. A diode rectifier
then provides a full-wave rectified voltage that is initially filtered by a simple
capacitor filter to produce a dc voltage. This resulting dc voltage usually has
some ripple or ac voltage variation. A regulator circuit removes the ripples and
also remains the same dc value even if the input dc voltage varies. This voltage
regulation is usually obtained using one of the popular voltage regulator IC units.
2 Schematic diagram

2.2 Working principle

2.2.1 Transformer

The potential transformer will step down the power supply voltage (0-
230V) to (0-15V and 0-9V) a level. If the secondary has less turns in the coil then
the primary, the secondary coil's voltage will decrease and the current or AMPS
will increase or decreased depend upon the wire gauge. This is called a STEP-
DOWN transformer. Then the secondary of the potential transformer will be
connected to the rectifier.

2.2.2 Bridge rectifier

When four diodes are connected as shown in figure, the circuit is called
as bridge rectifier. The input to the circuit is applied to the diagonally opposite
corners of the network, and the output is taken from the remaining two corners.
Let us assume that the transformer is working properly and there is a
positive potential, at point A and a negative potential at point B. the positive
potential at point A will forward bias D3 and reverse bias D4.

The negative potential at point B will


forward bias D1 and reverse D2. At this time D3
and D1 are forward biased and will allow current
flow to pass through them; D4 and D2 are reverse
biased and will block current flow. The path for
current flow is from point B through D1, up through Load, through D3, through
the secondary of the transformer back to point B.

One-half cycle later the polarity across the secondary of the transformer
reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow
will now be from point A through D4, up through Load, through D2, through the
secondary of transformer, and back to point A. Across D2 and D4. The current
flow through Load is always in the same direction. In flowing through Load this
current develops a voltage corresponding to that. Since current flows through
the load during both half cycles of the applied voltage, this bridge rectifier is a
full-wave rectifier.

One advantage of a bridge rectifier over a conventional full-wave rectifier


is that with a given transformer the bridge rectifier produces a voltage output that
is nearly twice that of the conventional half-wave circuit.
This bridge rectifier always drops 1.4Volt of the input voltage because of the
diode. We are using 1N4007 PN junction diode, its cut off region is 0.7Volt.
So any two diodes are always conducting, total drop voltage is 1.4 volt.

1.2.3 Filter
If a Capacitor is added in parallel with the load resistor of a Rectifier to
form a simple Filter Circuit, the output of the Rectifier will be transformed into a
more stable DC Voltage. At first, the capacitor is charged to the peak value of the
rectified Waveform. Beyond the peak, the capacitor is discharged through the
load until the time at which the rectified voltage exceeds the
capacitor voltage. Then the capacitor is charged again and the process repeats
itself.

1.2.3 IC voltage regulators

Voltage regulators comprise a class of widely used ICs. Regulator IC


units contain the circuitry for reference source, comparator amplifier, control
device, and overload protection all in a single IC. IC units provide regulation of
either a fixed positive voltage, a fixed negative voltage, or an adjustably set
voltage.

A fixed three-terminal voltage regulator has an unregulated dc input


voltage, it is applied to one input terminal, a regulated dc output voltage from a
third terminal, with the second terminal connected to ground.

The series 78 regulators provide fixed positive regulated voltages from 5


to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated
voltages from 5 to 24 volts.

This is a regulated power supply circuit using the 78xx IC series. These
regulators can deliver current around 1A to 1.5A at a fix voltage levels. The
common regulated voltages are 5V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, and 24V. It
is important to add capacitors across the input and output of the regulator IC to
improve the regulation.
In this circuit we are using 7805 and 7812 regulator so it converts variable
dc into constant positive 5V and 12V power supply respectively.

Component description:

1) Input
2) Ground
3) Output

Types of Positive voltage regulator:


IR DETECTION Circuit

N Schematic Diagram:

Schematic Explanation:

Infrared transmitter is one type of LED which emits infrared rays generally called as IR
Transmitter. Similarly IR Receiver is used to receive the IR rays transmitted by the IR transmitter. One
important point is both IR transmitter and receiver should be placed straight line to each other.

The transmitted signal is given to IR transmitter whenever the signal is high, the IR transmitter
LED is conducting it passes the IR rays to the receiver. The IR receiver is connected with comparator.
The comparator is constructed with LM 358 operational amplifier. In the comparator circuit the
reference voltage is given to Non inverting input terminal. The inverting input terminal is connected
IR receiver. When interrupt the IR rays between the IR transmitter and receiver, the IR receiver is not
conducting. So the comparator Non inverting input terminal voltage is higher then inverting input.
Now the comparator output is in the range of 0V. This voltage is given to microcontroller and LED will
OFF.

When IR transmitter passes the rays to receiver, the IR receiver is conducting due to that non
inverting input voltage is Higher than inverting input. Now the comparator output is +5Volt so the
output is given to microcontroller so LED will glow. This circuit is mainly used to for Line tracking and
length calculators etc.

2. MICRO CONTROLLER

2.1 CONCEPTS OF MICROCONTROLLER :

Microcontroller is a general purpose device, which integrates a number of the components of


a microprocessor system on to single chip. It has inbuilt CPU, memory and peripherals to make it as a
mini computer. A microcontroller combines on to the same microchip:

 The CPU core


 Memory(both ROM and RAM)
 Some parallel digital i/o

Microcontrollers will combine other devices such as:

 A timer module to allow the microcontroller to perform tasks for certain time periods.
 A serial i/o port to allow data to flow between the controller and other devices such as a
PIC or another microcontroller.
 An ADC to allow the microcontroller to accept analogue input data for processing.

Microcontrollers are :

 Smaller in size
 Consumes less power
 Inexpensive
Micro controller is a stand alone unit ,which can perform functions on its own
without any requirement for additional hardware like i/o ports and external memory.

The heart of the microcontroller is the CPU core. In the past, this has traditionally been based on a 8-
bit microprocessor unit. For example Motorola uses a basic 6800 microprocessor core in their
6805/6808 microcontroller devices.

In the recent years, microcontrollers have been developed around specifically


designed CPU cores, for example the microchip PIC range of microcontrollers.

2.2 INTRODUCTION TO PIC :

The microcontroller that has been used for this project is from PIC series. PIC
microcontroller is the first RISC based microcontroller fabricated in CMOS (complimentary metal
oxide semiconductor) that uses separate bus for instruction and data allowing simultaneous access of
program and data memory.

The main advantage of CMOS and RISC combination is low power consumption
resulting in a very small chip size with a small pin count. The main advantage of CMOS is that it has
immunity to noise than other fabrication techniques.

PIC (16F877) :

Various microcontrollers offer different kinds of memories. EEPROM, EPROM, FLASH


etc. are some of the memories of which FLASH is the most recently developed. Technology that is used
in pic16F877 is flash technology, so that data is retained even when the power is switched off. Easy
Programming and Erasing are other features of PIC 16F877.

PIC START PLUS PROGRAMMER :

The PIC start plus development system from microchip technology provides the product
development engineer with a highly flexible low cost microcontroller design tool set for all microchip
PIC micro devices. The picstart plus development system includes PIC start plus development
programmer and mplab ide.
The PIC start plus programmer gives the product developer ability to program user
software in to any of the supported microcontrollers. The PIC start plus software running under mplab
provides for full interactive control over the programmer.

2.3 SPECIAL FEATURES OF PIC MICROCONTROLLER :

CORE FEATURES :

• High-performance RISC CPU


• Only 35 single word instructions to learn
• All single cycle instructions except for program branches which are two cycle
• Operating speed: DC - 20 MHz clock input
 DC - 200 ns instruction cycle
• Up to 8K x 14 words of Flash Program Memory,
 Up to 368 x 8 bytes of Data Memory (RAM)
 Up to 256 x 8 bytes of EEPROM data memory
• Pin out compatible to the PIC16C73/74/76/77
• Interrupt capability (up to 14 internal/external
• Eight level deep hardware stack
• Direct, indirect, and relative addressing modes
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
• Watchdog Timer (WDT) with its own on-chip RC Oscillator for reliable operation
• Programmable code-protection
• Power saving SLEEP mode
• Selectable oscillator options
• Low-power, high-speed CMOS EPROM/EEPROM technology
• Fully static design
• In-Circuit Serial Programming (ICSP) via two pins
• Only single 5V source needed for programming capability
• In-Circuit Debugging via two pins
• Processor read/write access to program memory
• Wide operating voltage range: 2.5V to 5.5V
• High Sink/Source Current: 25 mA
• Commercial and Industrial temperature ranges
• Low-power consumption:
2mA typical @ 5V, 4 MHz

20mA typical @ 3V, 32 kHz

1mA typical standby current

PERIPHERAL FEATURES :

• Timer0: 8-bit timer/counter with 8-bit prescaler

• Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep

via external crystal/clock

• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

• Two Capture, Compare, PWM modules

Capture is 16-bit, max resolution is 12.5 ns,

Compare is 16-bit, max resolution is 200 ns,

PWM max. resolution is 10-bit

• 10-bit multi-channel Analog-to-Digital converter

• Synchronous Serial Port (SSP) with SPI. (Master Mode) and I2C. (Master/Slave)

• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with

9- bit address detection.

• Brown-out detection circuitry for Brown-out Reset (BOR)

2.4 ARCHITECTURE OF PIC 16F877 :

The complete architecture of PIC 16F877 is shown in the fig 2.1. Table 2.1 gives details
about the specifications of PIC 16F877. Fig 2.2 shows the complete pin diagram of the IC PIC 16F877.
FIG 2.1 ARCHITECTURE OF PIC 16F877

TABLE 2.1 SPECIFICATIONS

DEVICE PROGRAM FLASH DATA MEMORY DATA EEPROM

PIC 16F877 8K 368 Bytes 256 Bytes

FIG 2.2 PIN DIAGRAM OF PIC 16F877


TABLE 2.2 PIN OUT DESCRIPTION

Legend: I = input O = output I/O = input/output P = power

— = Not used TTL = TTL input ST = Schmitt Trigger input

Note

1. This buffer is a Schmitt Trigger input when configured as an external interrupt 2. This
buffer is a Schmitt Trigger input when used in serial programming mode.

3. This buffer is a Schmitt Trigger input when configured as general purpose I/O and a TTL

input when used in the Parallel Slave Port mode (for interfacing to a microprocessor bus).

4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a

CMOS input otherwise.


Legend: I = input O = output I/O = input/output P = power

— = Not used TTL = TTL input ST = Schmitt Trigger input

Note :

1. This buffer is a Schmitt Trigger input when configured as an external interrupt.

2. This buffer is a Schmitt Trigger input when used in serial programming mode.

3. This buffer is a Schmitt Trigger input when configured as general purpose I/O and a TTL

input when used in the Parallel Slave Port mode (for interfacing to a microprocessor bus).

4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a

CMOS input otherwise.

2.5 I/O PORTS :

Some pins for these I/O ports are multiplexed with an alternate function for
the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be
used as a general purpose I/O pin.

Additional Information on I/O ports may be found in the IC micro™ Mid-Range


Reference Manual,

PORTA AND THE TRISA REGISTER :

PORTA is a 6-bit wide bi-directional port. The corresponding data direction


register is TRISA. Setting a TRISA bit (=1) will make the corresponding PORTA pin an input, i.e., put the
corresponding output driver in a Hi-impedance mode. Clearing a TRISA bit (=0) will make the
corresponding PORTA pin an output, i.e., put the contents of the output latch on the selected pin.
Reading the PORTA register reads the status of the

pins whereas writing to it will write to the port latch. All write operations are read-modify-write
operations. Therefore a write to a port implies that the port pins are read; this value is modified, and
then written to the port data latch. Pin RA4 is multiplexed with the Timer0 module clock input to
become the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open drain output. All
other RA port pins have TTL input levels and full CMOS output drivers. Other PORTA pins are
multiplexed with analog inputs and analog VREF input. The operation of each pin is selected by
clearing/setting the control bits in the ADCON1 register (A/D Control Register1).

The TRISA register controls the direction of the RA pins, even when they are being used as
analog inputs. The user must ensure the bits in the TRISA register are maintained set when using them
as analog inputs.

TABLE 2.3 PORT A FUNCTION

Legend: TTL = TTL input, ST = Schmitt Trigger input

TABLE 2.4 SUMMARY OF REGISTERS ASSOCIATED WITH PORTA

Legend: x = unknown, u = unchanged, - = unimplemented locations read as '0'. Shaded


cells are not used by PORTA.
PORTB AND TRISB REGISTER :

PORTB is an 8-bit wide bi-directional port. The corresponding data direction register
is TRISB. Setting a TRISB bit (=1) will make the corresponding PORTB pin an input, i.e., put the
corresponding output driver in a hi-impedance mode. Clearing a TRISB bit (=0) will make the
corresponding PORTB pin an output, i.e., put the contents of the output latch on the selected pin.
Three pins of PORTB are multiplexed with the Low Voltage Programming function; RB3/PGM, RB6/PGC
and RB7/PGD. The alternate functions of these pins are described in the Special Features Section. Each
of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups.

This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically
turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on
Reset.

Four of PORT B’s pins, RB7:RB4, have an interrupt on change feature. Only pins configured as
inputs can cause this interrupt to occur (i.e. any RB7:RB4 pin configured as an output is excluded from
the interrupt on change comparison). The input pins (of RB7:RB4) are compared with the old value
latched on the last read of PORTB. The “mismatch” outputs of RB7:RB4 are OR’ed together to generate
the RB Port Change Interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the device from
SLEEP. The user, in the interrupt service routine, can clear the interrupt in the following manner:

a) Any read or write of PORTB. This will end the mismatch condition.

b) Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF. Reading PORTB
will end the mismatch condition, and allow flag bit RBIF to be cleared. The interrupt on change feature
is recommended for wake-up on key depression operation and operations where PORTB is only used
for the interrupt on change feature. Polling of PORTB is not recommended while using the interrupt
on change feature. This interrupt on mismatch feature, together with software configurable pull-ups
on these four pins, allow easy interface to a keypad and make it possible for wake-up on key
depression

PORTC AND THE TRISC REGISTER :


PORTC is an 8-bit wide bi-directional port. The corresponding data direction register
is TRISC. Setting a TRISC bit (=1) will make the corresponding PORTC pin an input, i.e., put the
corresponding output driver in a hi-impedance mode. Clearing a TRISC bit (=0) will make the
corresponding PORTC pin an output, i.e., put the contents of the output latch on the selected pin.
PORTC is multiplexed with several peripheral functions. PORTC pins have Schmitt Trigger input buffers.

When the I2C module is enabled, the PORTC (3:4) pins can be configured with normal
I2C levels or with SMBUS levels by using the CKE bit (SSPSTAT <6>). When enabling peripheral
functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override
the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an
input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify write
instructions (BSF, BCF, XORWF) with TRISC as destination should be avoided. The user should refer to
the corresponding peripheral section for the correct TRIS bit settings.

TABLE 2.7 PORTC FUNCTIONS

TABLE 2.8 SUMMARY OF REGISTERS ASSOCIATED WITH PORTC

2.6 MEMORY ORGANISATION :

There are three memory blocks in each of the PIC16F877 MUC’s. The program
memory and Data Memory have separate buses so that concurrent access can occur.
PROGRAM MEMORY ORGANISATION :

The PIC16f877 devices have a 13-bit program counter capable of addressing 8K *14
words of FLASH program memory. Accessing a location above the physically implemented address will
cause a wraparound. The RESET vector is at 0000h and the interrupt vector is at 0004h.

DATA MEMORY ORGANISTION :

The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the special functions Registers. Bits RP1 (STATUS<6) and RP0 (STATUS<5>) are
the bank selected bits.

RP1:RP0 Banks

00 0

01 1

10 2

11 3

Each bank extends up to 7Fh (1238 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function Registers are General Purpose
Registers, implemented as static RAM. All implemented banks contain special function registers.
Some frequently used special function registers from one bank may be mirrored in another bank for
code reduction and quicker access.

PIC16F877 REGISTER FILE MAP


GENERAL PURPOSE REGISTER FILE :

The register file can be accessed either directly or indirectly through the File Selected
Register (FSR). There are some Special Function Registers used by the CPU and peripheral modules for
controlling the desired operation of the device. These registers are implemented as static RAM. The
Special Function Registers can be classified into two sets; core (CPU) and peripheral. Those registers
associated with the core functions.

2.7 INSTRUCTION SET SUMMARY :

Each PIC 16f877 instruction is a 14-bit word, divided into an OPCODE which specifies
the instruction type and one or more operand which further specify the operation of the instruction.
The PIC16F877 instruction set summary in Table 2.13 lists byte-oriented, bit-oriented, and literal and
control operations. It shows the opcode Field descriptions.

TABLE 2.13 OPCODE FIELD DESCRIPTIONS


For byte-oriented instructions, ‘f’ represents a file register designator and ’d’
represents a destination designator. The file register designator specifies which file register is to be
used by the instruction. The destination designator specified where the result of the operation is to
be placed. If ‘d’ is zero, the result is placed in the w register. If ‘d’ is one, the result is placed in the file
register specified in the instruction.

For bit-oriented instructions, ‘b’ represents a bit field designator which selects the
number of the bit affected by the operation, which ‘f’ represents the address of the file in which the
bits is located. For literal and control operations, ‘k’ represents an eight or eleven bit constant or literal
value.

The instruction set is highly orthogonal and is grouped into three basic categories:

• Byte-oriented operations

• Bit-oriented operations

• Literal and control operations


All instructions are executed within one single instruction cycle, unless a conditional
test is true or the program counter is changed as a result of an instruction. In this case, the execution
takes two instruction cycles with the second cycle executed as a NOP. One instruction cycle consists
of four oscillator periods. Thus, for an oscillator frequency of 4 MHz, the normal instruction execution
time is 1 ms. If a conditional test is true or the program counter is changed as a result of an instruction,
then the instruction execution time is 2 ms.

TABLE 2.14 16F877 INSTRUCTION SET


ALARM

Schematic diagram:
Buzzer:

A buzzer or beeper is a signalling device, usually electronic, typically used in automobiles,


household appliances such as a microwave oven, or game shows. It most commonly consists of a
number of switches or sensors connected to a control unit that determines if and which button was
pushed or a preset time has lapsed, and usually illuminates a light on the appropriate button or control
panel, and sounds a warning in the form of a continuous or intermittent buzzing or beeping sound.
Initially this device was based on an electromechanical system which was identical to an electric bell
without the metal gong (which makes the ringing noise).

Circuit description:

The circuit is designed to control the buzzer. The buzzer ON and OFF is controlled by switching
transistor (BC 547). The buzzer is connected in the transistor collector terminal.

When high pulse (5 Volt) signal is given to base of the transistor, the transistor is conducting
and closes the collector and emitter terminal. Hence the buzzer was already getting a volt power

Schematic diagram:
Schematic explanation:

This circuit is designed to control the load. The load may be motor or
any other load. The load is turned ON and OFF through relay. The relay ON and
OFF is controlled by the pair of switching transistors (BC 547). The relay is
connected in the Q2 transistor collector terminal. A Relay is nothing but
electromagnetic switching device which consists of three pins. They are
Common(3rd pin), Normally close (5th pin) and Normally open (4th pin).

The relay common pin is connected to supply voltage. The normally open
(NO) pin connected to load. When high(5 volt) pulse signal is given to base of

Relay:
relay is an electrically operated switch. Current flowing through the coil
of the relay creates a magnetic field which attracts a lever and changes the switch
contacts. The coil current can be on or off so relays have two switch positions and
they are double throw (changeover) switches. Relays allow one circuit to switch
a second circuit which can be completely separate from the first. For example a
low voltage battery circuit can use a relay to switch a 230V AC mains circuit.
There is no electrical connection inside the relay between the two circuits; the
link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is
usually used to amplify the small IC current to the larger value required for the
relay coil.

Relays are usually SPDT or DPDT but they can have many more sets of
switch contacts, for example relays with 4 sets of changeover contacts are
readily available. Most relays are designed for PCB mounting but you can solder
wires directly to the pins providing you take care to avoid melting the plastic
case of the relay. The animated picture shows a working relay with its coil.

7. Conclusion
The proposed system helpful to avoid vehicle accidents because of
driver’s sleepiness using eye blink sensor, in this paper we study

and design the system for driver fatigue detection. If the driver becomes
drowsy the eye blink sensor’s frame vibrates attached to the vehicle and also
the LCD displays the warning messages and it alerts the driver’s through alarm
sound to avoid the road accidents. The wheel is slowed or stopped depending
on the condition. This is accompanied by the owner being notified through the
GSM module, so the owner can retrieve the driver’s location, photograph and a
list of nearby police stations.

References

[1] MarcoJavier Flores, JoséMaría Armingol and Arturo de la Escalera,

―Driver Drowsiness Warning System Using Visual Information for Both


Diurnal and Nocturnal Illumination Conditions‖, Springer, EURASIP Journal on
Advances in Signal Processing, 2010.

[2] Belhassen AkroutWalid Mahdi, ―A Blinking Measurement Method


for Driver Drowsiness Detection‖, Springer, Proceedings of the 8th International
Conference on Computer Recognition Systems CORES, pp 651-660, 2013.
[3] Ji Hyun Yang, Zhi-Hong Mao, Member, IEEE, Louis Tijerina, Tom
Pilutti, Joseph F. Coughlin, and Eric Feron, ―Detection of Driver Fatigue
Caused by Sleep Deprivation‖, IEEE TRANSACTIONS ON SYSTEMS, MAN, AND
CYBERNETICS—PART A: SYSTEMS AND HUMANS, VOL. 39, NO. 4, JULY 2009.

[4] Antoine Picot, Sylvie Charbonnier, Alice Caplier, ―On-Line


Detection of Drowsiness Using Brain and Visual Information‖, Published in: IEEE
Transactions on Systems, Man, and Cybernetics

- Part A: Systems and Humans ( Volume: 42, Issue: 3) Page(s): 764 –


775, May 2012.

[5] Satori Hachisuka, Kenji Ishida, Takeshi Enya, Masayoshi Kamijo,

―Facial Expression Measurement for Detecting Driver


Drowsiness‖, springer, International Conference on Engineering Psychology and
Cognitive Ergonomics. EPCE 2011: Engineering Psychology and Cognitive
Ergonomics pp 135-144, 2011.

Vous aimerez peut-être aussi