Você está na página 1de 118

Eye Tracking based Driver Fatigue Monitoring

and Warning System


A DISSERTATION

SUBMITTED TO PUNJAB ENGINNERING COLLEGE UNIVERSITY OF


TECHNOLOGY CHANDIGARH & CDAC MOHALI

IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE


AWARD OF THE MASTER DEGREE

MASTER OF ENGINEERING
(Electronic Product Design &Technology)

SUBMITTED BY
HARDEEP SINGH
(Roll No. 0820808)

hardeepsingh.ec08@pec.edu.in
DEPARTMENT OF ELECTRONICS & ELECTRICAL COMMUNICATION

PUNJAB ENGINNERING COLLEGE UNIVERSITY OF


TECHNOLOGY
CHANDIGARH-160012
INDIA
2010

[1]
CERTIFICATE

This is to certify that the dissertation entitled EYE TRACKING BASED DRIVER
FATIGUE MONITORING AND WARNING SYSTEM submitted by Hardeep Singh
(Student ID-0820808) in partial fulfilment of the requirement for the award of the Degree of
Masters of Engineering in Electronics Product Design & Technology, P.E.C University of
Technology, Chandigarh is a record of Students own work carried out by him under my
supervision and guidance.

Co-guide Guide

(Mrs. Jasbir Kaur) (Mr. J.S Bhatia)

Assistant Professor Director


Dept. of E&EC C-DAC, Mohali
P.E.C University of Tech, Chd Punjab

DECLARATION
I hereby declare that the work carried out in this dissertation is my original work and has not
been submitted for the award of any other degree course.

Date: (Hardeep Singh)


Place: Student ID-0820808
Department of E&EC
P.E.C University of Tech
Chandigarh-160012

Mobile : 9878832094

[2]
ACKNOWLEDGEMENT

The creation of this Thesis requires the combined sincere efforts, hard work talent and
blessings of many near and dear, who directly or indirectly helped me in completing my
research work.

I sincerely express my deep gratitude to Mr. J.S Bhatia (Director, CDAC Mohali) and Mrs
Jasbir Kaur (Asst. Professor, P.E.C University of Tech Chandigarh) for their value able
guidance, constructive suggestions, constant encouragement, motivation and supervision
throughout my thesis work. Their endless support helped me in channelling my efforts and
ideas in proper direction.

I wish to express my special thanks to Er. Dilip Kumar (Sr. Design Engineer, CDAC
Mohali) for his constructive criticism and constant encouragement and allowing me to use the
lab facilities for carrying out thesis work. I wish to express my sincere thanks to the whole
teaching and non teaching faculty of CDAC Mohali and P.E.C University of Technology,
Chandigarh for their constant encouragement and sincere suggestions.

In last but not least I offer heartiest appreciation to all my friends for ever willing cooperation,
moral support and best wishes for successfully taking this study.

(HARDEEP SINGH)

ID- 0820808

M.E (E.P.D.T)

[3]
ABSTRACT

The Project entitled Eye Tracking based Driver Fatigue Monitoring and Warning System
consists of the hardware and the software modules. The main idea behind this project is to
develope a non-intrusive system which can detect fatigue of driver and issue a timely warning.
Since large number of road accidents are caused by driver drowsiness. Hence this system will
be helpful in preventing many accidents, and consequently save money and reduce personal
suffering.

This system will detect eye movement to detect the fatigue state of driver. By monitoring the
eyes using camera and developing an algorithm we can detect symptoms of driver fatigue early
enough to avoid an accident. So this project will be helpful in detecting driver fatigue in
advance and will gave a warning output in form of sound and vibration. For indication of
warning we will use two approaches i.e one by blowing alarm and second by seat belt vibration
whose frequency will vary between 100 to 300 Hzs. Moreover the warning will be deactivated
manually rather than automatically. So for this purpose a deactivation switch will be used to
deactivate warning.

Moreover if driver felt drowsy there is possibility of sudden acceleration or de-acceleration


hence we can judge this by plotting a graph in time domain and when all three input variables
shows a possibility of fatigue at one moment then a warning signal is shown in form of text or
red colour circle. This will directly give an indication of drowsiness/fatigue which can be
further used as record of driver performance or can be used by traffic police which can take
further action accordingly.

[4]
LIST OF FIGURES

Figure Description Page No.

Fig-1.1 Progression of drowsiness and concordance of predicted - 6


and observed PERCLOS Values.

Fig-1.2 Drowsiness judgment example - 8

Fig-1.3 Block Diagram of Eye tracking based Driver Fatigue - 9


Monitoring and Warning system.

Fig-1.4 Flow chart of Eye Tracking System - 10

Fig-1.5 Steering wheel gripping pressure Variability Detection - 11

Fig-1.6 Relay Circuit Diagram - 13

Fig-2.1 Pin Diagram of 89C52 - 15

Fig-2.2 Diagram for oscillator connections - 18

Fig-2.3 Oscillator connections - 19

Fig-2.4 USB Camera - 21

Fig-2.5 Pin diagram of ADC 0808 - 23

Fig-2.6 Resistor Ladder and switch tree - 25

Fig-2.7 3 Bit A/D Transfer Curve - 26

Fig-2.8 Opto coupler - 27

Fig-2.9 Relay Contact Sets - 29

Fig-2.10 Electromagnetic relay - 29

Fig-2.11 Opto coupler relay connections - 30

Fig-2.12 Asynchronous data format - 32

Fig-2.13 25 pin connector on a DTE device - 34

Fig-2.14 9 pin connector on a DTE device, RS 232 DB9 - 35


[5]
Fig-2.15 Pin Detail of D25 Pin Connector - 38

Fig-2.16 D25 Pin Connection with Microcontroller - 39

Fig-3.1 Block Diagram of Power Supply - 40

Fig-3.2 Power Supply Circuit - 42

Fig-3.3 Steering wheel gripping pressure Variability Detection - 42

Fig-3.4 ADC Interfacing with Microcontroller - 43

Fig-4.1 A simple blank GUI - 46

Fig-4.2 GUI developed for the project - 47

Fig. 5.1 Data Acquisition System - 50

Fig-5.2 1 Hz sine wave quantized by a 3 bit A/D converter - 55

Fig-5.3 Quantization Error - 55

Fig-5.4 Signal Polarity - 56

Fig-6.1 Design Space of Product - 59

Fig-6.2 Levels of creativity - 64

Fig-6.3 Complete Circuit Diagram - 69

Fig-6.4 PCB Layout - 70

Fig-6.5 Complete Hardware of System - 71

Fig-7.1 Driver Original Image - 72

Fig-7.2 Driver Eyes open - 73

Fig-7.3 Driver Eyes closed - 73

Fig-7.4 Steering Wheel Gripping pressure - 73

Fig-7.5 Vehicle Speed variation - 74

Fig-7.6 Sample Result of working system - 74

[6]
LIST OF TABLES

Figure Description Page No.

Table 2.1 Pin description of RS232 DB9 - 36

Table 2.2 Port Addresses and IRQs in the PC - 38

Table 5.1 Components of Data Acquisition System - 49

Table 5.2 Types of Sensors - 52

[7]
LIST OF ABBREVIATIONS

1) AC Alternating Circuit

2) ASIC Application Specific Integrated Circuits

3) BER Bit-Error Rate

4) BPS Bits per second

5) CCD Charge coupled device

6) CIL Common Intermediate Language

7) CPU Central processing unit

8) CLI Common Language Infrastructure

9) CLR Common Language Runtime

10) CLS Common Language Specification

11) CS Chip Select

12) C# C Sharp

13) DC Direct Circuit

14) DCE Data Communications Equipment

15) DIN Data In

16) DIP Dual inline package

17) DRC Design Rule Check

18) DTE Data Terminal Equipment

19) EA Enable

20) EMI Electromagnetic Interference

21) EPC Electronic Product Code

22) Ft Feet

23) FM Frequency Modulation


[8]
24) FLIR Face lift Image replacement

25) Fps Frames per second

26) GND Ground

27) GHz Giga hertz

28) GUI Graphical User Interface

29) ID Identification

30) IDE Integrated Development Environment

31) INTR Interrupt

32) IC Integrated Circuit

33) I/O Input/Output

34) Kb Kilo Byte

35) K Kilo ohm

36) KN Kilo Newton

37) LCD Liquid Crystal Display

38) LED Light Emitting Diode

39) MCU Micro control Unit

40) MHz Mega hertz

41) MOS Metal Oxide Semi Conductor

42) MM Mili Meters

43) OS Operating System

44) OSC Oscillator

45) PC Personal Computer

46) PCB Printed Circuit Board

47) PERCLOS Percent Eye Closure

48) PTH Plated Through Hole

49) PROM Programmable Read Only Memory

[9]
50) RAM Random Access Memory

51) RAD Rapid Application Development

52) RD Read

53) ROM Read Only Memory

54) RST Reset

55) SQL Structured Query Language

56) SFR Special Function Register

57) TE Transmit Enable

58) TTL Transistor-Transistor Logic

59) TV Television

60) USB Universal serial bus

61) VLSI Very Large Scale Integration

62) W Watt

63) WR Write

64) XTAL Crystal

65) 3D Three Dimensional

66) F Micro farad

67) pF Pico farad

[10]
CONTENTS

Certificate i
Acknowledgement ii
Abstract iii
List of Figures iv
List of Tables vi
List of Abbreviations vii

CHAPTER 1: INTRODUCTION 1-13

1.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2.1 Sleepiness and Drowsiness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2.2 Distraction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.3 Inattention. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Inattentive Driving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


1.3.1 Drowsy Driving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Distracted Driving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Literature Survey. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


1.4.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 PERCLOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.3 Steering Wheel Variability Detection. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.5 Objective of the work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.6 System Theory and Detail. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


1.6.1 Input Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
(i) Eye Tracking Unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
(ii) Steering Wheel gripping pressure Variability Detection Unit . . . . . . . . . . . 11
(iii)Speed Variation Detection Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.6.2 Image Processing Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.6.3 Output and Warning Unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

CHAPTER 2: HARDWARE DESCRIPTION 14-39

2.1. Microcontroller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
[11]
2.1.1 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.2 Pin Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.3 I/O Port pins and their functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
(i) Port 0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
(ii) Port 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
(iii) Port 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
(iv) Port 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
(v) RST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
(vi) ALE/PROG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
(vii) PSEN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
(viii) EA/VPP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1.4 Oscillators and clock circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.2 Programming the microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19


2.2.1 Steps involved in writing a program. . . . . . . . . . . . . . . . . . . . . . . . . . 20
(i) UNIPROG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
(ii) ASEM 51. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.3 USB Camera. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


2.3.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.2 How it works. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.3 Outside Factors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.4 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.4 ADC(Analog to Digital Convertor-ADC0808). . . . . . . . . . . . . . . . . . . . . . . . 23


2.4.1 General Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4.2 Pin Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.4 Key Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.5 Functional Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
(i) Multiplexer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
(ii) The Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.5 Opto coupler 4N35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27


2.5.1 General Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.6 Relay. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.1 Opto coupler Relay Connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.7 Serial Port Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29


2.7.1 Serial Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
[12]
(i) Interfacing Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
(ii) Transmission Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
a) Synchronous. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
b) Asynchronous. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
(iii)Error Check in Data Communication . . . . . . . . . . . . . . . . . . . . . . 33
(iv) Standard in Serial I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.7.2 Communicating by bits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33


2.7.3 The Parity bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.8 DCE DTE Devices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34


2.8.1 Baud vs Bit per Second. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.8.2 Null Modem Cables and Null Modem Adapters. . . . . . . . . . . . . . . . . 37
2.8.3 D pin Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.8.4 Interfacing of Microcontroller parallel port. . . . . . . . . . . . . . . . . . . . 39

CHAPTER 3: CIRCUIT DESCRIPTION 40-43

3.1 Power Supply.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40


3.1.1 Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
(i) Transformer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
(ii) Bridge Rectifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
(iii)Filter Capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
(iv) Voltage Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.1.2 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

3.2 Interfacing of Microcontroller with ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42


3.2.1 Circuit Diagram.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

CHAPTER 4: MATLAB SOFTWARE BASICS 44-48

4.1 Software Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44


4.2 Introduction to MATLAB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.3 Keil Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.3.1 Linker control file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.3.2 Map file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.3.3 Project Target. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.3.4 Source file group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.3.5 Toolset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

CHAPTER 5: DATA ACQUISITION 49-59


[13]
5.1. Data Acquisition System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.2 Data Acquisition Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
(i) Analog input subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
(ii) Analog output subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
(iii) Digital input output subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
(iv) Counter timer subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.3 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.4 Signal Conditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
(i) Amplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
(ii) Filtering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
(iii)Electric Isolation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
(iv) Multiplexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
(v) Excitation Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.2 Analog Input Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53


5.2.1 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.2.2 Quantization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
(i) Quantisation error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.2.3 Input Range and Polarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.2.4 How Are Acquired Samples Clocked?. . . . . . . . . . . . . . . . . . . . . . . . . 57
(i) Onboard Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
(ii) Computer Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
(iii)External Clock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.2.5 Channel Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.2.6 Transferring Data from Hardware to System Memory. . . . . . . . . . . . . . 58
(i) FIFO Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
(ii) Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
(iii)DMA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

CHAPTER 6: DESIGN PHASES OF ELECTRONIC PRODUCT 60-70

6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.1.1 Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.1.2 Product Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.1.3 Design Space of Product. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
(i) Product Physiognomy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
(ii) Product Physiography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
(iii) Product Anatomy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

6.2 Design phase of Electronic Product. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62


6.2.1 Aesthetic Design Phase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
[14]
6.2.2 Engineering Design Phase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.2.3 Ergonomic Design Phase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

6.3 Creativity in Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64


6.3.1 Creativity in Product Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
(i) Conceptual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
(ii) Physical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.3.2 Creativity Techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
(i) Analytic . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
(ii) Non Analytic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

6.4 General Rules for PCB Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65


6.4.1 Conductor Routing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.4.2 Hole Diameter Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.4.3 Solder Pad Diameter Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66

6.5 Design Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66


6.5.1 Electrical Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.5.2 Mechanical Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

6.6 EMI consideration for Designing a Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67


6.6.1 Factors in Material Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.6.2 Maintaining continuity: Gaskets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.6.3 Other considerations for chassis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.6.4 Capabilities of PCB Manufacturer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

6.7 Complete Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

6.8 PCB Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

6.9 Complete Hardware of the System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

CHAPTER 7: RESULTS AND DISCUSSION 72-74

7.1 Hardware Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72


7.2 Software Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.2.1 The first window shows Original Image of Driver. . . . . . . . . . . . . . . . . 72
7.2.2 The Second window shows Driver iris and eye brows when Eyes open. 73
7.2.3 The Third window shows image of eye brows when Eyes closed. . . . . 73
7.2.4 The Fourth window shows Steering wheel gripping pressure variation. 73
7.2.5 The Fifth window shows Vehicle speed variation. . . . . . . . . . . . . . . . . . 74
7.2.6 The Sixth window shows complete algorithm results. . . . . . . . . . . . . . . 74
[15]
CHAPTER 8: CONCLUSION AND FUTURE SCOPE 75

8.1 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2 Futute Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

REFERENCES 76-78

APPENDIX A: COMPONENTS USED 79

APEENDIX B: MATLAB PROGRAM 80-85

APPENDIX C: DATA SHEETS 86-102

[16]
CHAPTER 1
INTRODUCTION
1.1 Overview
Driver fatigue is one of the three commonest causes of motor vehicle accidents and the effect of
driver fatigue has been underestimated in the past due to difficulties in identifying fatigue as
the cause of a crash. The problem of driver fatigue of course moves far beyond just road
vehicles to all modes of transportation, being an important factor in rail, sea and air accidents as
well.
Driver fatigue commonly causes fall asleep motor vehicle accidents. These tend to be more
severe or fatal compared with other road accidents. This is because they often involve a single
vehicle running off the road at high speed, they tend to occur on higher speed roadways, and
braking or other preventative measures may be absent. If truck drivers are involved, the
potential to cause death or serious injury to other road users is greatly increased.

It is commonly known that drowsiness and driving is not a good combination. To be a good
driver it is necessary to be perceptive, alert and focused on the task and it is difficult to
combine these qualities with drowsiness. Another characteristic that is a bad combination with
driving is distraction. Both these disturbances have the same effect on the driver in the sense
that they have a negative effect on the perception, reaction time and focus, to name a few
things.
Drowsiness and distraction are parts of the human behaviour, which makes the problem with
drowsiness and inattentive driving difficult to completely eliminate. A similar case is alcohol
which also has a negative effect on the driving abilities, but can (theoretically) be removed
from the roads.

1.2 Definitions:

To be able to examine the effects of drowsiness, distraction and inattention it is necessary to


start with the definitions of these words.

1.2.1 Sleepiness and Drowsiness


Sleepiness, also referred to as drowsiness, is a basic physiological state that affects humans
among others and it originates from changes of the alertness during each 24-hour sleep-wake
cycle. This is caused by the internal body clocks, which programs us to be asleep twice a day:
[17]
in the middle of the night and between 14:00-16:00 in the afternoon [1]. Sleepiness is a stage
when the body needs to sleep and is defined as the inclination to sleep [1]. Sleepiness should
not be confused with fatigue, which is the consequence of physical labour or a long experience,
and is defined as disinclination to continue the task at hand [2].

1.2.2 Distraction
Distraction is a shift in attention from the primary task to another task (secondary task). In
behavioural models, human is modelled as information processing resource who has a maximal
limit of information that can be processed [4]. In these models distraction is modelled as
surrounding disturbances taking processing resources from the main task. Distraction can result
in reduced performance of the primary task. There are several degrees of distraction, but no
fixed scale. This is a problem when detecting a degree of distraction, because it is difficult to
say that one thing steals more attention than another. Usually distraction is measured as the
reduction of performance of the primary task.

Another important part in the distraction is the drivers willingness to engage in the secondary
task. How much the person engages in the task affects how distracted the person is. Distraction
happens all the time in the daily life but the usual effect of the everyday distraction is very
harmless. It results in a shift in attention from one thing to another for a brief or longer
moment. This usually has little effect on the primary task other than a delay. An example of
this is a person reading the newspaper when he hears a car alarm go off. The result of this is
that he stops reading for a while, but soon he continues reading with only a slight delay.

Sometimes this delay in the primary task may have a serious impact on a person, when he is
driving for example. Distraction in a car is different from the everyday drowsiness because
during the time you are not paying attention to the road, something may happen, which may
cause the vehicle to crash in the worst case.

1.2.3 Inattention
Inattention is when a person is not paying attention to, or focusing on a task. It could be caused
by drowsiness, distraction, fatigue, boredom or other things. If the drowsiness and distraction is
compared with inattention, it is like cause and effect.

[18]
Drowsiness and distraction can be the cause of inattention. In the word inattention it is not so
important what caused it, just that the result is inattention. With drowsiness and distraction the
effect is usually inattention, but here it is also important what caused it.

1.3 Inattentive Driving


Inattention has a negative effect on a number of characteristics that are important while driving.
It has a decreasing effect in vigilance, reaction time, memory, coordination, memory processing
and decision making, to name a few [1].

Recent research has shown that sleep deprivation and late stages of inattention has the same
effect as alcohol intoxication. In a research study, people were deprived of sleep and asked to
do different tests. The results were that persons who were awake for 17 hours had the same
results as a rested person with blood alcohol concentration (BAC) of 0.05% (0.5). A group of
people that had been kept awake for 24 hours performed the same as people who had a BAC of
0.1% (1%) [1].

1.3.1 Drowsy Driving


Drowsy driving causes a lot of accidents on the roads all over the world. Cars are involved in
96% of the drowsy driving accidents and trucks are involved in 3%. However for trucks the
expected number of involvement per lifecycle in drowsy driving accidents is about four times
greater than for a car, because of the long vehicle lives and high usage [10].

Trucks are especially affected by the problem with drowsy driving because of the long
transport distances and the workload management with tight deliverance schedules. In 1998
there were approximately 1.6 million truck tractors and 3.6 million trailers used in the
transportation industry in the world. Drowsiness of truck drivers causes 1 200 deaths and 76
000 injuries annually, world-wide [9].
In the truck industry 57% of all crashes are caused by drowsiness1, which makes it the number
one cause for heavy vehicle crashes [26]. With the constantly growing traffic conditions, this
problem will further grow. The physical and psychological effects that drowsiness has on
humans are impossible to combine with the qualities that are expected from a good driver.
Drowsiness changes the abilities of the driver in the following areas:

[19]
1) Slow reaction time
2) Reduced vigilance
3) Slow information processing
4) Reduced memory capacity
5) Worse coordination
6) Slow decision making

1.3.2 Distracted Driving


During the last few years the number of distracting equipment in the vehicle has increased
dramatically. Nowadays there are mobile phones, car audio equipment, navigation systems,
TV-screens, DVD-players and cruise controls only to name a few. All these things steal
attention from the primary task (driving) which can expose the driver to a dangerous situation.
The trend is that the amount of distracting equipment in the vehicles is increasing as they get
more available and easier to use at the same time as the complexity of these equipment
increases. The result of this is that the drivers are more and more exposed to inattentive driving.

In research of distraction it is usually helpful to examine distraction in terms of four different


categories:
Visual distraction looking away from the roadway
Auditory distraction music or mobile phone
Biomechanical distraction adjusting the radio volume or changing channel
Cognitive distraction using navigation system

These are the main kinds of distraction that the driver can be exposed to while driving. How
much distraction a certain device causes is determined by the workload combined with the
willingness of the driver to engage in that task. This means that the worst kinds of equipment
are interesting and demanding, which could be a description of a mobile phone, a radio or a
navigation system, for example. Distraction causes many accidents annually and in some
countries it is actually illegal to drive a car while speaking in a mobile phone without a hands-
free system. Approximately 0.1% of all the car drivers have been involved in an accident
caused by someone using a mobile phone. This may not seem much, but it is estimated (based
on these numbers) that 292 000 people have experienced a vehicle crash caused by a person
using a mobile phone [14].
[20]
1.4 Literature Survey
1.4.1 Overview
One system that today is considered the most effective in the detection of inattentive driving is
the system based on eye detection. An enhanced percentage of eyelid closure is one of the most
reliable predictors of drowsiness or inattention [23].

The best detection of primarily drowsiness, but also of inattention is the measurement of brain-
waves, heart rate and pulse [26]. To measure this while driving causes annoyance to the driver,
because multiple sensors have to be attached to the driver. This can affect the driver so much
that it changes the driving behaviour, which is not good at all in traffic safety research. Eye
detection on the other hand gives an accurate detection with minimal impact on the driver.

Eye closures occur with a high frequency just before the off-road accidents caused by
drowsiness that has been recorded. In the minute preceding the accident an increase of the
eyelid closure can be detected and 20-30 seconds before the accident a dramatic increase can be
seen [10].

The eye detection system consists of a camera and demanding eye-tracking software. The
camera, usually mounted on the dashboard in front of the driver, records the eyes of the driver.
This signal is then processed in an advanced system to detect how many percents the eyes are
open, the frequency of eye blinking and in which direction the driver is looking. With this
signal it is then possible to detect the status of the driver with the accuracy of about 1 mm in the
recorded images [27].

The eye detection systems are good but not perfect, when the driver is wearing glasses there
might be errors in the detection, which in some systems leads to false warnings. Sunglasses
cause problems that almost none of the systems can deal with, which makes the inattention
detection almost impossible when the driver is wearing sunglasses. Different ethnical people
are another problem, the eyes of Asian people differ from European people, but most
manufacturers claim that it shouldnt be a problem.

[21]
1.4.2 PERCLOS

PERCLOS (PERcent eyelid CLOSure) is a measure of driver alertness, which was identified
as the most reliable and valid in a study by the US Federal Highway Administration; various
authors refer PERCLOS as a standard for drowsiness detection. The measure is the percentage
of eyelid closure over the pupil over time and reflects slow eyelid closures rather than blinks.
The PERCLOS drowsiness metric was established in a 1994 driving simulator study as the
proportion of time (%) in a minute when the eyelids are at least 80 percent closed.

PERCLOS system is defined as proportion of time that the eyes of the driver are closed (more
that 80%) over a specified period that can be changed to suite the driver or the situation. This
system is created to measure slow eyelid closures rather than blinks. PERCLOS originates from
a drowsiness detection system that was created in a driving simulator in 1994, and has been
developed ever since [25].

Based on research by Wierwille[11], the US Federal Highway Administration (FHWA) and the US
National Highway Traffic Safety Administration (NHTSA) considers PERCLOS to be among the
most promising known real-time measures of alertness for in-vehicle drowsiness-detection
systems[10].

Figure 1.1 Progression of drowsiness and concordance of predicted and observed


PERCLOS value.

[22]
P70: the proportion of time when the eyes were closed at least 70 percent.
P80: the proportion of time when the eyes were closed at least 80 percent (the P80 metrics is
usually referred as PERCLOS)
EYEMEAS (EM): the mean square percentage of the eyelid closure rating.

PERCLOS has been validated in two separate laboratories as an accurate predictor of


performance degradation caused by drowsiness [24]. It is now used as a standard for
drowsiness detection in many research projects [11] and some in-vehicle detection systems try
to estimate the PERCLOS value from in-vehicle signals, this is called estimated PERCLOS
(ePERCLOS).

The eye detection system provides information of how much the eyes are closed at every
moment and with this information the PERCLOS value can be computed. This is done by
simply calculating the percent of the time that the eyes are closed more then 80% for every
three minutes. This value is then compared to a limit value to see if the driver is considered
drowsy or not.

PERCLOS is the result of a simple mathematical algorithm which is included in the majority of
the commercial eye detection systems. The problem is to detect the eyelid opening in the
camera systems, which is done with image processing. The ordinary PERCLOS system is a
measurement of the time when the eyes of the driver are between 80% and 100% closed. If the
time exceeds a boundary value a warning is given. Usually this detection is calculated over 3-
minute periods. The warning limit can be changed to suit the situation but a limit value that is
commonly used is 0.12%, so when PERCLOS is above 0.12% the driver is considered drowsy.

1.4.3 Steering Wheel Variability Detection


As reported by Wylie et al [11], steering wheel variability is related to the amount of
drowsiness in drivers (variability greater as driver become more drowsy) after being adjusted
for road dependent effects.

Steering wheel variability is related to the amount of drowsiness in drivers (variability greater
as drivers become more drowsy) after being adjusted for road dependent effects. Steering wheel
variability is also strongly and reliably affected by location on the route. Therefore this measure
[23]
must be corrected for route dependent effects if it is to achieve its full potential as an indicator
of driver fatigue. The adjustment for route dependent effects can be performed for example by
subtracting the all-driver average steering wheel variability associated with each mile of road,
thus reducing the variation associated with road curvature. The authors of the article also
suggest considering the power spectral density of the steering wheel angle in relation to fatigue.
Clearly this approach is arduous for real-time measurements.

Figure 1.2 Drowsiness judgment example General judgment (actua-tion) is the system
output (detection of drowsiness), self declaration is the drivers subjective drowsiness
experience, the fluctuation (pulse of the driver) and the steering adjustments intervalare
the recorded input variables for the drowsiness detection.

1.5 Objective of Work

The main idea behind the Project entitled Eye Tracking based Driver Fatigue Monitoring
and Warning System is to develope a non-intrusive system [12] which can detect fatigue of
driver and issue a timely warning. It will have both hardware and the software modules.

This project will have three input units, one Image processing unit and two Output units/
Warning units.

[24]
1.6 System Theory and Detail
The system consists of three input variables and one Image processing unit i.e computer and
two output units i.e warning components and a microcontroller.

Input Variables Warning/Output Variables

1. Eye tracking unit 1. Sound alarm

2. Speed variation detection unit 2. Seat belt vibration

3. Steering wheel gripping pressure detection unit

Driver
Sensors on Car Speedometer
steering

ADC Circuit ADC Circuit

Camera for
tracking eye
movement so
Seat belt Microcontroller
that driver
vibration
cannot go for
sleep.

Buffer IC Buffer IC
Image processing of eye
movement i.e if driver try
to go for a sleep by closing
his eyes for half second
Microcontroller will turn on
buzzer and Seat belt
PC vibration and data get
recorded as track record of
(computer) driver for future reference.

Fig.1.3 Block Diagram of Eye tracking based Driver Fatigue Monitoring


and Warning system

[25]
1.6.1 Input Units

This system will consists three input units to study the drowsy behaviour of driver namely Eye
Tracking unit, Steering wheel gripping pressure variability detection unit and Speed variation
detection unit.

(i) Eye Tracking Unit

This is the most crucial unit as the accuracy of warning issued will largely depends on this unit.
Hence it can also be called the heart of this system.

Driver face monitoring system [6] is a real-time system that can detect driver fatigue and driver
distraction using machine vision approaches. An algorithm is used for driver hypo-vigilance
detection based on eye-region processing and without explicit eye detection stage. In this
method, horizontal projection of top half-segment of facial image is used to extract symptoms
of fatigue and distraction.

Drivers Image

Face detection

Eye detection

Recognition of eyes
whether open or closed

Calculation of criteria for judging


drowsiness/ fatigue

Is driver
drowsy

WARNING

Fig. 1.4 Flow chart of Eye Tracking based System

[26]
The Algorithm used here is very much fast as compared to PERCLOS [5] earlier used by other
hence the Processing time of this system is less than half second hence it is quite fast and issues
timely warning to the driver.

This system will detect a driver fatigue by processing of eye-region. As shown in flow chart in
Figure 1.4. After image acquisition, face detection is the first stage of processing. Then
symptoms of hypo-vigilance are extracted from the eyes. If eyes are blinking normally no
warning is issued but when the eyes are closed for more than half second this system issues
warning to the driver in form of alarm and vibration.

(ii) Steering wheel gripping pressure variability detection unit

The technique used here is that human body conducts current. Hence by using a conducting
wire on non conducting steering wheel of Vehicle and an Analog to Digital Convertor (ADC)
connected through a Transistor which acts as a switch. Whenever driver hold the steering
tightly more current flows through base of Transistor as parallel resistances made by our
fingers add up in parallel and as a result net resistance decreases and base current increases.

Fig. 1.5 Steering wheel gripping pressure Variability Detection

[27]
Hence this variation is converted by ADC into some threshold and whenever output is less than
threshold it indicates Driver Drowsiness or Fatigue state.

(iii) Speed Variation Detection Unit

Speed variation detection unit consists of a speedometer and whenever driver felt drowsy there
is possibility of sudden acceleration or de-acceleration hence we can judge this by plotting a
graph in time domain and when all three input variables shows a possibility of fatigue at one
moment then a warning signal is shown in form of text or red colour circle. This will directly
give an indication of drowsiness/fatigue which can be further used as record of driver
performance or can be used by traffic police which can take further action accordingly.

1.6.2 Image Processing Unit

This approach analyzes the images captured by cameras to detect physical changes of drivers,
such as eyelid movement, eye gaze, yawn, and head nodding. For example, the PERCLOS
system developed by W. W. Wierwile[12] used camera and imaging processing techniques to
measure the percentage of eyelid closure over the pupil over time. The three-in-one vehicle
operator sensor developed by Northrop Grumman Co. also used the similar techniques[30].
Although this vision based method is not intrusive and will not cause annoyance to drivers. In
addition, this approach requires the camera to focus on a relative small area (around the drivers
eyes). It thus requires relative precise camera focus adjustment for every driver.

1.6.3 Output Units/Warning Units

For indication of warning this system will use two approaches i.e one by blowing alarm and
second by seat belt vibration whose frequency will vary between 100 to 300 Hzs. Moreover the
warning will be deactivated manually rather than automatically. So for this purpose a
deactivation switch will be used to deactivate warning. Microcontroller will switch on the
vibration sensor using the relay circuit shown in Figure 1.6.

[28]
Fig.1.6 Relay Circuit Diagram

[29]
CHAPTER 2
HARDWARE DESCRIPTION

2.1 Microcontroller
The main difference between a Microprocessor and a Microcontroller is that a Microcontroller
has inbuilt peripherals like timers, USART, Interrupt Controller etc. whereas in a
Microprocessor these have to be interfaced as separate ICs. In this project the Microcontroller
AT89C51 from the ATMEL Corp is used. The AT89C51 is a low- power, high-performance
CMOS 8-bit microcomputer with 4Kbytes of Flash programmable and erasable read only
memory (PEROM). The device is manufactured using Atmels high-density non volatile
memory technology and is compatible with the industry-standard MCS-51 instruction set and
pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional non volatile memory programmer. By combining a versatile 8-bit CPU with Flash
on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a
highly-flexible and cost-effective solution to many embedded control applications. Some of the
features of the AT89C51 Microcontroller are listed below.

2.1.1 Features
Compatible with MCS-51 Products
4K Bytes of In-System Reprogrammable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
128 x 8-bit Internal RAM
32 Programmable I/O Lines
Two 16-bit Timer/Counters
Six Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes

[30]
2.1.2 Pin Configuration The 89C52 have a total of 40 pins that are dedicated for various
functions such as I/O, RD, WR, address and interrupts. Out of 40 pins, a total of 32 pins are set
aside for the four ports P0, P1, P2, and P3, where each port takes 8 pins. The rest of the pins are
designated as Vcc, GND, XTAL1, XTAL, RST, EA, and PSEN.

Fig 2.1 Pin diagram of 89C52

All these pins except PSEN and ALE are used by all members of the 8051 and 8031 families.
In other words, they must be connected in order for the system to work, regardless of whether
the microcontroller is of the 8051 or the 8031 family. The other two pins, PSEN and ALE are
used mainly in 8031 based systems. The diagram of the 8052 packaged in a 40-pin DIP is
shown in figure 2.7 with the full-abbreviated names for the signals of each pin. Many of the
pins are used for more than one function.

2.1.3 I/O port pins and their functions

The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bits ports. All the ports upon
RESET are configured as output, ready to be used as output ports. To use any of these as input
port, it must be programmed.

[31]
(i) Port 0

Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for input or output. To use the
pins of port 0 as both input and output ports, each pin must be connected extremely to a 10K
ohm pull-up resistor. This is due to fact that port 0 is an open drain, unlike P1, P2, and P3. With
external pull-up resistors connected upon rest, port 0 is configured as output port. In order to
make port 0 an input, the poet must be programmed by writing 1 to all the bits of it. Port is also
designated as AD0-AD7, allowing it to be used for both data and address. When connecting a
microcontroller to an external memory, port 0 provides both address and data. The
microcontroller multiplexes address and data through port 0 to save pins. ALE indicates if P 0
has address or data. When ALE=0, it provides data D0-D7, but when ALE=1 it has address A0-
A7. Therefore, ALE is used for de-multiplexing address and data with the help of latch
74LS373.

(ii) Port 1

Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used as input or output. In contrast to
port 0, this port does not require pull-up resistor since it has already pull-up resistor internally.
Upon reset, port 1 is configures as an output port. Similar to port 0, port 1 can be used as an input
port by writing 1 to all its bits.

(iii)Port 2

Port 2 occupies a total of 8 pins (pin 21 to 28). It can be used as input or output. Just like P1,
port 2 does not need any pull-up resistors since it has pull-up resistors internally. Upon reset
port 2 is configured as output port. To make port 2 input, it must be programmed as such by
writing 1s to it.

(iv) Port 3

Port 3 occupies a total of 8 pins (pins10 to 17). It can be used as input or output, P3 does not
need any pull-up resistors, the same as P1 and P2 did not. Although port 3 is configured as
output port upon reset, this is not the way it is most commonly used. Port 3 has an additional
function of providing some extremely important signals such as interrupts.

Some of the alternate functions of P3 are listed below:

P3.0 RXD (Serial Input)


[32]
P3.1 TXD (Serial Output)

P3.2 INT0 (External interrupt 0)

P3.3 INT1 (External Interrupt 1)

P3.4 T0 (Timer 0 External Input)

P3.5 T1 (Timer 1 External Input)

P3.6 WR (External Memory Write Strobe)

P3.7 RD (External Memory Read Strobe)

(v) RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device.

(vi) ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during accesses to
external memory. This pin is also the program pulse input (PROG) during Flash programming.
In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may
be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped
during each access to external Data Memory. If desired, ALE operation can be disabled by
setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or
MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has
no effect if the microcontroller is in external execution mode.

(vii) PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C52 is
executing code from external program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access to external data memory.

(viii) EA/VPP
EA (External Access Enable) must be strapped to GND in order to enable the device to fetch
code from external program memory locations starting at 0000H up to FFFFH. Note, however,

[33]
that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to
VCC for internal program executions. This pin also receives the 12-volt programming enable
voltage (VPP) during Flash programming, for parts that require 12-volt VPP.

2.1.4 Oscillators and clock circuit

It is the heart of the microcontroller that generates the clock pulses by which all the internal
operations are synchronized. Pins XTAL1 and XTAL2 are provided for the connection of a
resonant network to form an oscillator. Typically, a quartz crystal and capacitor are employed
and thus crystal frequency will become the clock frequency of microcontroller. The figure 2.2
below shows oscillator connections with the microcontroller.

Fig: 2.2 Diagram for oscillator connections

The 8052 maximum and minimum frequency range between 1 MHz to 16 MHz and 20 MHz in
case of AT89C52. Thus, the 8052 operates on an external crystal. This is an electrical device
which, when energy is applied, emits pulses at a fixed frequency.

One can find crystals of virtually any frequency depending on the application requirements.
When using on 8051, the most common crystal frequencies are 12 MHz and 11.0592 MHz with
11.0592 being much more common.

Why would anyone pick such an oddball frequency? Theres a real reason for it has to do with
generating baud rates in the Serial communication. A cycle is, in reality, 12 pulses of the
crystal. That is to say, if an instruction takes on machine cycle to execute, it will take 12 pulses
of the crystal to execute. Since the crystal is pulsing 11,059,000 times per second and that one

[34]
machine cycle is 12 pulses, we can calculate how many instruction cycles the 8051 can execute
per second:

11,059,000/12 = 921,583

This means that the 8052 can execute 921,583 single-cycle instructions per second. Since a
large number of 8052 instructions are single cycle instructions it is often considered that the
8052 can execute roughly 1 million instructions per second, although in reality it is less and
depending on the instructions being used, an estimate of about 600,000 instructions per second
is more realistic.

The 8052 equipped with two timers, both of which may be controlled, set, read, and configured
individually. Keeping time and/or calculating the amount of time between events. Counting the
events themselves and generating baud rates for the serial port

If in some cases, it is essential to use frequency source other than a crystal oscillator, such as a
TTL oscillator, it will be connected to XTAL1; XTAL2 is left unconnected as shown in figure
2.3 below for oscillator connections

Fig: 2.3 Oscillator connections

2.2 Programming the Microcontroller


To program a microcontroller one must have two basic tools. One is the hardware-programmer
board and the second is the software-for downloading the program. The hardware programmer
board is used to hold the chip and enable the computer to download the program into the
microcontroller. The programmer board is serially connected to the computer.

[35]
The software you needed to program the microcontroller will be two fold. One is the compiler
and the other to download the program written. The compiler program automatically checks for
errors in the program and then compiles it into a hex file. This hex file is stored in the same
directory in which original program file is earlier stored. The compiler software used be us is
ASEM software. The downloading software used here is the UNIPROG. The uniprog can be
run in only the DOS mode. This is very user friendly software and can be operated easily. This
helps in erasing previous files and downloading new programs into the Microcontroller. It helps
out how to program the micro with step by step descriptions as follows.

2.2.1 Steps involved in writing a program to the Microcontroller:


1. Write the required program in the Notepad of windows with the syntaxes being followed as
per the rules of programming.
2. Save the written file in .asm extension. Now the assembly file has been created.
3. Next run this file in ASEM software by specifying the path of the file.
4. After this the ASEM software will check for errors and then convert this into .hex file.
5. Now run the system in the Dos Mode.
6. Next run the UNIPROG software
7. It automatically checks the IC placed in the board.
8. Then specify the hex file to be downloaded.
9. If any program is in the IC, you can erase it.
10. Now download the program and hence you are ready to work with the IC.

(i) UNIPROG is an open engine for support any hardware chip programmer. Its implement
an open architecture based in hardware-abstract algorithms and chip definitions, that can work
in any hardware. With UNIPROG the development of new and powerful programmers is not
limited by lack of software or the need of test chips.

(ii) ASEM-51 is a two-pass macro assembler for the Intel MCS-51 family of microcontrollers.
It is running on the PC under MS-DOS, Windows and Linux. The DOS real-mode assembler
ASEM.EXE requires only 256 kB of free DOS memory and MS- DOS 3.0 (or higher). The new
protected-mode assembler ASEMX.EXE requires a 286 CPU (or better), and at least 512 kB of
free XMS memory. The new Win32 console-mode assembler ASEMW.EXE requires a 386
CPU (or better) and Windows 9x, NT, 2000 or XP. The new Linux assembler ASEM requires a
[36]
386-based Linux system. The new HTML documentation set requires a 90 MHz Pentium (or
better) and a web browser. The ASEM-51 assembly language is a rich subset of the Intel
standard that guarantees maximum compatibility with existing 8051 assembler sources.
ASEM-51 can generate two sorts of object files: Intel-HEX format, which is directly accepted
by most EPROM programmers, and absolute OMF-51 format, which is required for many
simulators, emulators and target debuggers. Thus ASEM-51 is suitable for small and medium
MCS-51-based microcontroller projects in hobby, education and business. However, ASEM-
51has been designed to process also very large programs!

2.2.2 Features:

Fast, compact, reliable, easy to use, and well-documented


Easy installation, almost no configuration required
Command line operation, batch and networking capability
DOS (RM and PM), Win32 and Linux binaries available
Intel-compatible syntax
Five location counters, one for each of the MCS-51 address spaces
Assembly-time evaluation of arithmetic and logical expressions

2.3 Camera

Fig: 2.4 USB Camera

[37]
2.3.1 Introduction

Simply, the frame rate is the number of pictures a webcam can take and how quickly it can then
transfer them to the computer's screen. Frames are measured in "frames per second" (or fps). So
if the webcam says it has a 30 fps, that means it can take 30 pictures every second and then
transfer them to the computer screen.

2.3.2 How It Works

Once a picture (or frame) is captured by the webcam, it creates a JPEG file of the still image.
When the webcam has a low frame rate (15 fps or below), the webcam can only transmit a
series of these JPEG still images. When the frame rate is higher than 15 fps, the webcam can
actually stream video using the computer's Internet connection.

Frame rates generally range from 10 fps to 60 fps. For avoiding the chopping of video, stay
closer to 30 and higher want very

2.3.3 Outside Factors

Although the number on the box may say one thing, what your webcam actually captures may
be different. Certain things can affect a webcam's frame rate, such as the capabilities of
webcam's software program, exactly what you are trying to record, the resolution of the
webcam, and even the amount of light in the room. Likewise, running multiple devices via your
computer's USB ports can also slow down the frame rate.

2.3.4 Specifications:

USB 2.0 Compatible


LED brightness controller
CMOS chip type: Color CMOS image sensor
Built-in Microphone
High Definition: 480k pixels (640x480)
Sensor size: 4.86 x 3.64mm
Frame Rate: 320x240 up to 30 frame/sec(CIF), 24-bit True Color
Video Format: 24-bit RGB
Focus range: 5cm-Infinity
Manual Focus, automatic color compensated
Support OS: Win 98/98SE/ME/2000/XP
Works perfectly with ICQ, MSN, Yahoo, AOL messenger
Easily mounts to a PC monitor or a notebook
PC Camera software comes with this camera for viewing images
[38]
Weight: 99g
Cable length: 150cm

2.4 ADC 0808 (Analog to Digital Convertor)

2.4.1 General Description


The ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-
bit analog-to-digital converter, 8-channel multiplexer and microprocessor compatible control
logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The
converter features a high impedance chopper stabilized comparator, a 256R voltage divider
with analog switch tree and a successive approximation register. The 8 channel multiplexer can
directly access any of 8-single-ended analog signals.
The device eliminates the need for external zero and full scale adjustments. Easy interfacing to
microprocessors is provided by the latched and decoded multiplexer address inputs and latched
TTL TRI-STATE outputs. The design of the ADC0808, ADC0809 has been optimized by
incorporating the most desirable aspects of several A/D conversion techniques. The ADC0808,
ADC0809 offers high speed, high accuracy, minimal temperature dependence, excellent long-
term accuracy and repeatability, and consumes minimal power. These features make this device
ideally suited to applications from process and machine control to consumer and automotive
applications.

2.4.2 Pin Diagram

Fig 2.5 Pin diagram of ADC 0808

[39]
2.4.3 Features

Easy interface to all microprocessors


Y Operates ratio metrically or with 5 VDC or analog span
adjusted voltage reference
No zero or full-scale adjust required
8-channel multiplexer with address logic
0V to 5V input range with single 5V power supply
Outputs meet TTL voltage level specifications
Standard hermetic or molded 28-pin DIP package
28-pin molded chip carrier package
ADC0808 equivalent to MM74C949
ADC0809 equivalent to MM74C949-1

2.4.4 Key Specifications

Resolution 8 Bits
Total Unadjusted Error g(/2 LSB and g1 LSB
Single Supply 5 VDC
Low Power 15 mW
Conversion Time 100 ms

2.4.5 Functional Description

(i) Multiplexer
The device contains 8-channel single-ended analog signals inputs. A particular input channel is
selected by using the address decoder. The input states for the address lines to select any
channel. The address is latched into the decoder on the low-to-high transition of the address
latch enable signal.

(ii) The Converter


The 8 bit converter is designed to give fast, accurate, and repeatable conversions over a wide
range of temperatures. The converter is partitioned into 3 major sections: the 256R ladder
network, the successive approximation register, and the comparator. The converter's digital
outputs are positive true. The 256R ladder network approach (Figure 2.6) was chosen over the

[40]
conventional R/2R ladder because of its inherent monotonicity, which guarantees no missing
digital codes. Monotonicity is particularly important in closed loop feedback control systems. A
non-monotonic relationship can cause oscillations that will be catastrophic for the system.
Additionally, the 256R network does not cause load variations on the reference voltage. The
bottom resistor and the top resistor of the ladder network in Figure 2.6 are not the same value
as the remainder of the network. The difference in these resistors causes the output
characteristic to be symmetrical with the zero and full-scale points of the transfer curve. The
first output transition occurs when the analog signal has reached a(/2 LSB and succeeding
output transitions occur every 1 LSB later up to full-scale.

The successive approximation register (SAR) performs 8 iterations to approximate the input
voltage. For any SAR type converter, n-iterations are required for an n-bit converter. Figure 2.7
shows a typical example of a 3-bit converter. In the ADC0808, ADC0809, the approximation
technique is extended to 8 bits using the 256R network.

Fig.2.6 Resistor Ladder and switch tree.


[41]
The A/D converter's successive approximation register (SAR) is reset on the positive edge of
the start conversion (SC) pulse. The conversion is begun on the falling edge of the start
conversion pulse. A conversion in process will be interrupted by receipt of a new start
conversion pulse. Continuous conversion may be accomplished by tying the end of- conversion
(EOC) output to the SC input. If used in this mode, an external start conversion pulse should be
applied after power up. End-of-conversion will go low between 0 and 8 clock pulses after the
rising edge of start conversion. The most important section of the A/D converter is the
comparator. It is this section which is responsible for the ultimate accuracy of the entire
converter. It is also the comparator drift which has the greatest influence on the repeatability of
the device. A chopper-stabilized comparator provides the most effective method of satisfying
all the converter requirements.

The chopper-stabilized comparator converts the DC input signal into an AC signal. This signal
is then fed through a high gain AC amplifier and has the DC level restored. This technique
limits the drift component of the amplifier since the drift is a DC component which is not
passed by the AC amplifier. This makes the entire A/D converter extremely insensitive to
temperature, long term drift and input offset errors.

Fig.2.7 3 Bit A/D Transfer Curve

[42]
2.5 Opto coupler 4N35

2.5.1 General Description


In electronics, an opto-isolator (or optical isolator, opto coupler, photocoupler, or photo MOS)
is a device that uses a short optical transmission path to transfer a signal between elements of a
circuit, typically a transmitter and a receiver, while keeping them electrically isolated since the
signal goes from an electrical signal to an optical signal back to an electrical signal, electrical
contact along the path is broken. Different sections of a circuit of a circuit operate at their own
voltage levels. Opto couplers are used to isolate these lines. If there is any transient voltage or
noise in one of the lines, the opto coupler stops it from with the other lines. It is mainly used for
signal and electrical isolation.

Relays can of course provide this kind of isolation, but even small relays tend to be fairly bulky
compared with ICs and many of todays other miniature circuit components. Because they are
electro-mechanical, relays are also not as reliable and only capable of relatively low speed
operation. Where small size, higher speed and greater reliability are important, a much better
alternative is to use an opto coupler. The figure 2.8 below shows the 6 pin opto coupler IC and
internal structure of an opto coupler.

Fig: 2.8 Opto coupler

The input part has an infrared LED chip and the output has a silicon diode chip. A thin,
transparent, Mylar plate embedded in clear silicone separates these. Resistors are also placed in
the circuit. The assembly is sealed in plastic. From this diagram the anode of the LED is pin 1
and the cathode is pin 2. The emitter of the phototransistor is pin 4, the collector is pin 5, and
the base is pin 6. When a forward bias voltage is applied to the input terminals of the LED an
input current flows in the LED circuit. When an electrical signal is applied to the input of the
opto-isolator, its LED lights, its light sensor then activates, and a corresponding electrical
signal is generated at the output. With a photodiode as the detector, the output current is
[43]
proportional to the amount of incident light supplied by the emitter. This current produces an
infrared light that hits the silicon chip. The input signal is connected to the LED and the output
signal is connected to the transistor. The infrared light varies with the input voltage. There are
many situations where signals and data need to be transferred from one subsystem to another
within a piece of electronics equipment, or from one piece of equipment to another, without
making a direct-ohmic electrical. Often this is because the source and destination are (or may
be at times) at very different voltage levels, like a microcontroller which is operating from 5V
DC but being used to control a triac which is switching 240V AC. In such situations the link
between the two must be an isolated one, to protect the microcontroller from over voltage
damage. These use a beam of light to transmit the signals or data across an electrical barrier,
and achieve excellent isolation.

Opto couplers typically come in a small 6 pin or 8-pin IC package, but are essentially a
combination of two distinct devices, an optical transmitter, typically a gallium arsenide LED
(light emitting diode) and an optical receiver such as a phototransistor or light triggered diac.
The two are separated by a transparent barrier which blocks any electrical current flow between
the two, but does allow the passage of light.

2.5.2 Features

o Also available in white package by specifying -M suffix, eg. 4N25-M


o UL recognized (File # E90700)
o VDE recognized (File # 94766)
o Add option V for white package (e.g., 4N25V-M)
o Add option 300 for black package (e.g., 4N25.300)

2.6 Relay

The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an
electromagnet as shown in figure 2.9. When the coil is energized, by passing current through it,
the core becomes temporarily magnetized. The magnetized core attacks the iron armature. The
armature is pivoted which causes it to operate one or more sets of contacts. When the coil is de-
energized the armature and contacts are released. The coil can be energized from a low power
source such as a transistor while the contacts can switch high powers such as the mains supply.
The relay can also be situated remotely from the control source. Relays can generate a very
[44]
high voltage across the coil when switched of. This can damage other components in the
circuit. To prevent this, a diode is connected across the coil.

Fig: 2.9 Relay contact sets

The cathode of the diode is connected to the most positive end of the coil. The spring sets
(contacts) can be a mixture of n.o (normally open), n.c (normally closed) and c.o (common) as
shown in figure 2.10.

Fig: 2.10 Electromagnetic relay

2.6.1 Opto coupler Relay Connection:

The figure 2.11 shows the connection of opto coupler with relay. The Normally open pin is
connected to AC mains; the pin normally closed is connected to ground. The common pin is
connected to the robo car. One end of the coil is connected to the emitter of the transistor and
the other end is connected to 5V supply.

[45]
Fig:2.11 Opto coupler relay connections

2.7 Serial Port Communication

All IBM PC and compatible computers are typically equipped with two serial ports and one
parallel port. Although these two types of ports are used for communicating with external
devices, they work in different way. A parallel port sends and receives data eight bits at a time
over 8 separate wires. This allows data to be transferred very quickly; however, the cable
required is more bulky because of the number of individual wires it must contain. Parallel ports
are typically used to connect a PC to a printer and are rarely used for much else. A serial port
sends and receives data one bit at a time over one wire. While it takes eight times as long to
transfer each byte of data this way, only a few wires are required. In fact, two way (full
duplex) communications is possible with only three separate wires one to send, one to
receive, and a common signal ground wire.

Serial data communication uses two methods, asynchronous and synchronous. The
synchronous transfers a single byte at a time. The data coming in at the receiving end of the
data line in a serial data transfer is all 0s and 1s: it is difficult to make sense of the data unless
the sender and receiver agree on as set of rules, a protocol, on how the data is packed, how
many bits constitute a character, and when the data begins and ends.

Serial communication requires that you specify the following four parameters:
[46]
The baud rate of the transmission
The number of data bits encoding a character
The sense of the optional parity bit
The number of stop bits
Each transmitted character is packaged in a character frame that consists of a single start
bit followed by the data bits, the optional parity bit, and the stop bit or bits.

2.7.1 Serial Interface

Basic concepts concerning the serial communication can be classified into categories below:

Interfacing requirements
Transmission format
Error check in data communication
Standards in serial I/O

(i) Interfacing Requirements

The serial interface requirement is very much similar to parallel interface requirement.
Computer identifies the peripheral through port address and enable if using the read and write
signals. The primary difference between the parallel I/O and serial I/O is the number of lines
used for data transfer. Parallel I/O requires the entire bus while the serial I/O requires only one
or pair of data lines for communication

(ii) Transmission Format

Transmission format for communication is concerned with the issues such as synchronization,
direction of data flow, speed, errors and medium of transmission. Serial data can be sent
synchronously or asynchronously.

a) Synchronous Data Transmission For synchronous data transmission data is sent in blocks

at a constant rate. The start and end of the block are identified with specific bytes or bits
patterns.

b) Asynchronous Data Transmission For asynchronous transmission each data character has

[47]
a bit which identifies its start and 1or 2 bits, which identifies its end. Since each character is
individually identified, characters can be sent at any time (asynchronously), in the same way
that a person types on a keyboard.

The asynchronous format is character oriented. Each character carries the information of the
start and stop bits. When no data is being transferred, a receiver stage high at the logic 1 called
mark; logic 0 is called space. The transmission of data begins with one start bit (low)
followed by a character and one or two stop bits (high). This is known as framing. The
asynchronous format is generally used in low speed transmission (less than 20k bits/sec) in
serial I/O one bit is sent out at a time. Therefore how long the bit stays on or off is determined
by the speed at which bits are transmitted. The receiver should be set up to receive the bits at
the same rate of transmission; otherwise the receiver may not be able to differentiate between
the two consecutive 0s and 1s.

The rate at which the bits are transmitted (bits/sec) is called baud. Each equipment has its own
baud rate requirements. Baud rate is a measure of how fast data are moving between
instruments that use serial communication. If the instrument is transmitting at 9,600 baud, the
duration of the start bit and each subsequent bit is about 0.104ms. The entire character frame of
eleven bits would be transmitted in about 1.146 ms.

Knowing the structure of a character frame and the meaning of baud rate as it apply to serial
communication, maximum transmission rate in characters per second can be calculated for a
given communication setting. This rate is just the baud rate divided by the bits per frame. If the
transmission rate is set at 9,600 baud, you get 9,600/11=872 characters per second. The figure
2.12 below shows the format of the frame transmitted using asynchronous transmission.

Fig: 2.12 Asynchronous data format

[48]
(iii) Error check in data communication

During transmission, various types of errors can occur. These errors need to be checked,
therefore, additional information for error checking is sent during transmission the receiver can
check the received data against the error check information, and if the error is detected, the
receiver can request there retransmission of that data segment. Three methods generally used
for this purpose are parity check, checksum and redundancy check.

(iv) Standard in Serial I/O

The serial I/O technique is commonly used to interface terminals, printers etc. a standard is
normally defined by a professional organization (such as IEEE). A standard may include such
items as assignment of pin positions for signals, voltage levels, speed of data transfer, length of
cable and mechanical specifications. When data are transmitted as voltage, the commonly used
standard is known as RS232C. It is defined as reference to data terminal equipment (DTE) and
data communication equipment (DCE). The rate of transmission is RS232 is restricted to a
maximum of 20k baud and a distance of 50 feet.

2.7.2 Communicating by bits

In data framing for asynchronous communication, the data, such as ASCII characters, are
packed in between start bit and stop bit. The start bit is always one bit but the stop bit can be
one or two bits. The start bit is always a 0 (low) and the stop bit is 1 (high). Once the start bit
has been sent, the transmitter sends the actual data bits. There may either be 5, 6, 7 or 8 data
bits, depending on the number you have selected. Both receiver and the transmitter must agree
on the number of data bits, as well as the baud rate. Almost all devices transmit data using
either 7 or 8 data bits. Notice that when only 7 data bits are employed, you cannot send ASCII
values greater than 127. Likewise, using 5 bits limits the highest possible value to 31. After the
data has been transmitted, a stop bit is sent. A stop bit has a value of 1- or a mark state- and it
can be detected correctly even if the previous data bit also had a value of 1. This is
accomplished by the stop bits duration.

2.7.3 The Parity Bit

Besides the synchronization provided by the use of start and stop bits, an additional bit called a
parity bit may optionally is transmitted along with the data. A parity bit affords a small amount
of error checking, to help detect data corruption that might occur during transmission. When
[49]
even or odd parity is being used, the number of marks (logical 1 bit) in each byte is counted,
and a single bit is transmitted following the data bits to indicate whether the number of 1 bit
just sent is even or odd. For example, when even parity is chosen, the parity bit is transmitted
with a value of 0 if the number of preceding marks is an even number. For the binary value of
01100011 the parity bit would be 0. If even parity was in effect and the binary number
11010110 was sent, then the parity bit would be 1. Odd parity is just the opposite, and the
parity bit is 0 when the number of mark bits in the preceding word is an odd number. Parity
error checking is very rudimentary. While it will tell you if there is a single bit error then the
parity bit was received in errors. Also, if an even number of bits is in error then the parity bit
would not reflect any error at all. Mark parity means that the parity bit is always set to the mark
signal condition and likewise space parity always sends the parity bit in the space signal
condition. Since these two parity options serve no useful purpose whatsoever, they are almost
never used.

2.8 DCE and DTE devices

DTE stands for Date Terminal Equipment, and DCE stands for Data communications
Equipment. These terms are used to indicate the pin-out for the connectors on a device and the
direction of the signals on the pins. Computer is a DTE device, while most other devices are
usually DCE devices.

The RS-232 standard states the DTE devices use a 25 pin male connector, and DCE devices use
a 25-pin female connector. You can therefore connect a DTE device to a DCE using a straight
pin-for-pin connection. However, to connect two like devices, you must instead use a null
modem cable. Null modem cables cross the transmit and receive lines in the cable, and are
discussed later in this chapter. The figure 2.13 and 2.14 shows the connections and signal
directions for both 25 and 9 pin connectors.

Fig 2.13: 25 pin connector on a DTE device

[50]
Fig: 2.14: 9 pin connector on a DTE device, RS 232 DB9

The TD (transmit data) wire is the one through which data from a DTE device is transmitted to
a DCE device. This wire is used by a DCE device to receive its data. The DTE device puts this
line in a mark condition to tell the remote device that it is ready and able to receive data. If the
DTE device is not able to receive data (typically because it receive buffer is almost full), it will
put this line in the space condition as a signal to the DCE to stop is almost full), it will put this
line in the space condition as a signal to the DCE to stop sending data. When the DTE device is
ready to receive more data (i.e after data has been removed from its receive buffer), it will
place this line back in the mark condition. The complement of the RTS wire is CTS, which
stands for clear to send. The DCE device puts this line in a mark condition to tell the DTE
device that it is ready to receive the data.

Likewise, if the DCE device is unable to receive data, it will place this line in the space
condition. Together, these two lines make up what is called RTS/CTS or hardware flow
control. The software Wedge supports this type of flow control, as well as Xon/Xoff or
software flow control. Software flow control uses special control characters transmitted from
one device to another to tell the other device to stop or start sending data. With software flow
control the RTS and CTS lines are not used.

DTR stands for Data Terminal Ready. Its intended function is very similar to the RTS line.
DSR (Data Set Ready) is the companion to DTR in the same way that CTS is to RTS. Some
serial devices use DTR and DSR as signals to simply confirm that a device is connected and is
turned on. The software Wedge sets DTR to the mark state when the serial port is opened and
leaves it in that state until the port is closed. The DTR and DSR lines were originally designed
to provide an alternate method of hardware handshaking. It would be pointless to use both
RTS/CTS and DTR/DSR for flow control signals at the same time. Because of this, DTR and
DSR are rarely used for flow control.

[51]
Pin Number Direction of Signal

1 Carrier Detect (CD) (from DCE) incoming signal from a modem

2 Received Data (RD) Incoming Data from a DCE

3 Transmitted data (TD) outgoing data to a DCE

4 Data Terminal Ready (DTR) Outgoing handshaking signal

5 Signal ground common reference voltage

6 Data set ready (DSR) incoming handshaking signals

7 Request to sent (RTS) outgoing flow control signal

8 Clear to send (CTS) incoming flow control signal

9 Ring Indicator (RI) (from DCE) incoming signal from a modem

Table 2.1 Pin description of RS232 DB9

CD stands for Carrier Detect. Carrier Detect is used by modem to signal that it has a made a
connection with another modem, or has detected a carrier tone. The last remaining line is RI or
Ring Indicator. A modem toggles the state of this line when an incoming call rings your phone.
The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a
modem. Because most modems transmit status information to a PC when either a carrier signal
is detected (i.e. when a connection is made to another modem) or when the line is ringing, these
two lines are rarely used.

2.8.1 Baud vs. Bits per Second

The baud unit is named after Jean Maurice Emile Baudot, who was an officer in the French
Telegraph Service. He is credited with devising the first uniform-length 5-bit code for character
of the alphabet in the late 19th century. What baud really refers to is modulation rate or the
number of times per second that a line changes state? This is not always the same as bits per
second (BPS). If you connect two serial devices together using direct cables then baud and BPS
are in fact the same.
[52]
If you connect two serial devices together using direct cables then baud and BPS are in fact the
same. Thus, if you are running at 19200 BPS, then the line is also changing states 19200 times
per second. But when considering modems, this isnt the case. Because modems transfer
signals over a telephone line, the baud rate is actually limited to a maximum of 2400 baud. This
is a physical restriction of the lines provided by the phone company. The increased data
throughput achieved with 9600 or higher baud modems is accomplished by using sophisticated
phase modulation and data compression technique.

2.8.2 Null Modem Cables and Null Modem Adapters

If you connect two DTE devices (or two DCE devices) using a straight RS232 cable, then the
transmit line on each device will be connected to the transmit line on the other device and the
receive lines will likewise be connected to each other. A null modem cable or null modem
adapter simply cross the receiver and transmit lines so that transmit on one end is connected to
receive on the other end and vice versa. In addition to transmit and receive, DTRs and
asynchronous communication, the two devices initially synchronize themselves to each other,
and then continually send characters to stay in sync. Even when data is not really being sent, a
constant flow of bits allows faster data transfer rates than asynchronous methods, because
additional bits to mark the beginning and end of each data byte are not required. The serial
ports on IBM style PCs are asynchronous devices and therefore only support asynchronous
serial communications. Asynchronous means no synchronization, and thus does not require
sending and receiving idle characters. However, the beginning and end of each byte of data
must be identified by start and stop bits. The start bit indicates when the data byte is about to
being and the stop bit signals when it ends. The requirement to send these additional to bits
causes asynchronous communication to be slightly slower than synchronous however it has the
advantage that the processor does not have to deal with the additional idle characters. An
asynchronous line that is idle is identified with a value of 1 (also called a mark state). By using
this value to indicate that no data is currently being sent, the devices are able to distinguish
between an idle state and a disconnected line. When a character is about to be transmitted, a
start bit is sent. A start bit has a value of 0 (also called a space state). Thus, when the line
switches from a value of 1 to a value of 0, the receiver is alerted that a data character is about to
be sent RS232 communication is asynchronous. That is a clock signal is not sent with the data.
Each word is synchronized using its start bit, and an internal clock on each side, keeps tabs on
the timing.
[53]
Port addresses and IRQs in the PC are as given below:

Name Addresses IRQ

COM1 3F8 4

COM2 2F8 3

COM3 3E8 4

COM4 2E8 3

Table 2.2 Port Addresses and IRQs in the PC

2.8.3 D 25 Pin Connector

Fig: 2.15 Pin Detail of D25 Pin Connector

Because the parallel port on a computer was mainly designed to connect printers with one-way
communication, a trick is used to achieve full two way data transfer between both sides. Five
error and status message inputs are redefined as data inputs. Instead of reading full bytes, the
communication software reads these five bits and combines multiple groups of data back to
bytes. The sender and receiver have to use the same protocol to convert bytes to groups of 5
bits and vice versa.

[54]
2.8.4 Interfacing of Microcontroller parallel port

Fig: 2.16 Circuit of D25 Pin Connection with Microcontroller

[55]
CHAPTER 3
CIRCUIT DESCRIPTION
3.1 Power Supply

BRIDGE SHUNT VOLTAGE


TRANSFORMER RECTIFIER CAPACITOR REGULATOR

Fig.3.1 Block Diagram of Power Supply

3.1.1 Description

The power supply circuit comprises of four basic parts:

(i) Transformer steps down the 220 V a/c. into 12 V a/c. The transformer work on the
principle of magnetic induction, where two coils: primary and secondary are wound around
an iron core. The two coils are physically insulated from each other in such a way that
passing an a/c. current through the primary coil creates a changing voltage in the primary
coil and a changing magnetic field in the core. This in turn induces a varying a/c. voltage in
the secondary coil.

(ii) Bridge Rectifier is used in most electronic power supplies is the single-phase bridge
rectifier with capacitor filtering, usually followed by a linear voltage regulator. A rectifier
circuit is necessary to convert a signal having zero average value into a non-zero average
value. A rectifier transforms alternating current into direct current by limiting or regulating
the direction of flow of current. The output resulting from a rectifier is a pulsating D.C.
voltage. This voltage is not appropriate for the components that are going to work through
it.

(iii) Filter Capacitor is used to smooth the ripple of the D.C. voltage. The filter capacitor of
1000 F 25V is used to stores electrical charge. If it is large enough the capacitor will store
charge as the voltage rises and give up the charge as the voltage falls. This has the effect of
smoothing out the waveform and provides steadier voltage output. A filter capacitor is
connected at the rectifier output and the d.c voltage is obtained across the capacitor.

When this capacitor is used in this project, it should be twice the supply voltage. When the
filter is used, the RC charge time of the filter capacitor must be short and the RC discharge
time must be long to eliminate ripple action. In other words the capacitor must charge up

[56]
fast, preferably with no discharge. When the rectifier output voltage is increasing, the
capacitor charges to the peak voltage Vm. Just past the positive peak, the rectifier output
voltage starts to fall but at this point the capacitor has +Vm voltage across it. Since the
source voltage becomes slightly less than Vm, the capacitor will try to send current back
through the diode of rectifier. This reverse biases the diode. The diode disconnects or
separates the source the source form load. The capacitor starts to discharge through load.
This prevents the load voltage from falling to zero. The capacitor continues to discharge
until source voltage becomes more than capacitor voltage. The diode again starts
conducting and the capacitor is again charged to peak value Vm.

When capacitor is charging the rectifier supplies the charging through capacitor branch as
well as load current, the capacitor sends currents through the load. The rate at which
capacitor discharge depends upon time constant RC. The longer the time constant, the
steadier is the output voltage. An increase in load current i.e. decrease in resistance makes
time constant of discharge path smaller. The ripple increase and d.c output voltage V dc
decreases. Maximum capacity cannot exceed a certain limit because the larger the
capacitance the greater is the current required to charge the capacitor.

(iv) Voltage Regulator regulates the supply if the supply if the line voltage increases or
decreases. The series 78xx regulators provide fixed regulated voltages from 5 to 24 volts.
An unregulated input voltage is applied at the IC Input pin i.e. pin 1 which is filtered by
capacitor. The out terminal of the IC i.e. pin 3 provides a regular output. The third terminal
is connected to ground. While the input voltage may vary over some permissible voltage
range, and the output voltage remains constant within specified voltage variation limit. The
78xx ICs are positive voltage regulators whereas 79xx ICs are negative voltage regulators.

These voltage regulators are integrated circuits designed as fixed voltage regulators for a
wide variety of applications.

These regulators employ current limiting, thermal shutdown and safe area compensation.
With adequate heat sinking they can deliver output currents in excess of 1 A. These
regulators have internal thermal overload protection. It uses output transistor safe area
compensation and the output voltage offered is in 2% and 4% tolerance.

[57]
3.1.2 Circuit Diagram

Fig.3.2 Power Supply Circuit

3.2 Interfacing of Microcontroller with ADC 0808

Fig.3.3 Steering Wheel Gripping Pressure Variability Detection

[58]
This system works on the technique that human body conducts current. Hence by using a
conducting wire on non conducting steering wheel of vehicle and by using an Analog to Digital
Convertor (ADC) and connected through a transistor which act as a switch and when the driver
hold the steering tightly more current flows through base of Transistor as parallel resistances
made by our fingers add up in parallel and as a result net resistance decreases and base current
increases. Hence this pressure variation is converted by ADC into some threshold and
whenever output is less than threshold it indicates Driver Drowsiness or Fatigue state.

3.2.1 Circuit Diagram

Fig.3.4 ADC Interfacing with Microcontroller

[59]
CHAPTER 4
MATLAB SOFTWARE BASICS
4.1 Software Description

For the Urban search and rescue robot different types of sensors can be used and accordingly
their interfacing has to be done using some software. One of sensor used is a Webcam.
Interfacing of which with the system requires coding either in MATLAB or C#. MATLAB is a
numerical computing environment and programming language. Also a reprogrammable
microcontroller is necessary. The criterion for choosing microcontroller was its easy
availability, cost and its memory type.

The microcontroller comes with different memory types, the first being UV erasable memory
type that has a quartz window and is exposed to UV to erase the memory. Microchip provides
this option for the PIC16 series and the UV erasable devices are identified by the model
number extension JW. These devices are produced in a ceramic dual in line package and are
identical to the OTP (one time programmable) version except for the packaging and cost. The
other option considered was the FLASH based memory type AT89C51 family, which is a new
series of devices that employ electronically erasable memory. These devices are available in
DIP or surface mount packages.

The FLASH devices are more convenient to reprogram than the windowed version as they
dont require exposure to UV light and hence the reprogramming time is much shorter. The
microcontroller AT89C52 chosen for the development of the system is much cheaper than the
windowed PIC16C73A-JW. It has 8K of program memory and has the capability to write to its
own memory.

As a webcam is used therefore it is interfaced using MATLAB. The videos and images
captured by the Webcam are stored and processed with the help of programming in MATLAB.

4.2 Introduction to MATLAB

MATLAB is a numerical computing environment and programming language maintained by


The Math Works. MATLAB allows easy matrix manipulation, plotting of functions and data,

[60]
implementation of algorithms, creation of user interfaces, and interfacing with programs in
other languages.

MATLAB stores images using Image Processing Toolbox. The Image Processing Toolbox
extends the basic capabilities of MATLAB by providing a number of specialized I/O, display,
and processing functions for images and image processing. It stores most images as two-
dimensional arrays (i.e., matrices), in which each element of the matrix corresponds to a single
pixel in the displayed image (Pixel is derived from picture element and usually denotes a single
dot on a computer display.) Some images, such as true color images, require a three-
dimensional array, where the first plane in the third dimension represents the red pixel
intensities, the second plane represents the green pixel intensities, and the third plane represents
the blue pixel intensities. This convention makes working with images in MATLAB similar to
working with any other type of matrix data, and makes the full power of MATLAB available
for image processing applications. An image is stored as a matrix using standard MATLAB
matrix conventions. There are five basic types of images supported by MATLAB:

1. Indexed images
2. Intensity images
3. Binary images
4. RGB images
5. 8-bit images
The Image Processing Toolbox provides functions imread and imwrite that will read and write
several standard image types. A Graphical User Interface GUI uses a combination of
technologies and devices to provide a platform the user can interact with, for the tasks of
gathering and producing information.

The GUI contains

An axes
A pop-up menu listing three data sets that correspond to MATLAB functions: peaks,
membrane, and sinc.
A static text component to label the pop-up menu
Push buttons, each of which provides a different kind of plot: surface, mesh, and
contour.

[61]
Fig: 4.1 A simple blank GUI

The figure 4.1 above shows how a blank GUI is formed. It can have push buttons, radio
buttons, scroll buttons, axis, toggle button, static text, list box, check box etc.

When you save a GUI, GUIDE creates two files, a FIG-file and an M-file. The FIG-file, with
extension .fig, is a binary file that contains a description of the layout. The M-file, with
extension .m, contains the code that controls the GUI.

The figure 4.2 shows the GUI developed for the project.

[62]
Fig 4.2: GUI developed for the project

4.3 Keil Software


Keil software is used for the software implementation of the developed system. vision 2
integrated development environments is and IDE that encapsulates a project manager, make
facility, tool configuration, editor and a powerful debugger. vision2 is used to write and
compile the programs using the tools. It can transfer the assembly language as well as C code
into the hex file. Keil software consists of a linker control file, Map file, Project Target, Source
file group, Toolset, Linker Control File.

4.3.1 Linker control File It is a text file vision passes to the linker when linking. The
control file includes all directives and names of object files and library files to include in the
output file.

4.3.2 Map File the map file is a listing file generated by the linker.

[63]
4.3.3 Project Target In a project, a target is an executable program that is generated. A
project may generate that runs on an 8051. Targets may be created for builds with no
optimization and for builds with full optimization.

4.3.4 Source file Group In a project, a group is a number of source files that compose the
project target. Although you may individually specify the toolset options for file, a group lets
you apply the same options to a group of source files. The options for a group may be different
from the options for the target.

4.3.5 Toolset A toolset include an assembler, compiler, linker, HEX converter, debugger, and
the other associated tools for a particular device family like the 8051. All of the tools or
programs in a toolset are dedicated to generating target code for a specific family of chips.

To evaluate the software for correct operation the file was programmed into the microcontroller
on the relevant development board.

[64]
CHAPTER 5
DATA ACQUISITION
5.1 Data Acquisition System
5.1.1 Overview
The Data Acquisition Toolbox software, in conjunction with the MATLAB technical
computing environment, gives you the ability to measure and analyze physical phenomena. The
purpose of any data acquisition system is to provide you with the tools and resources necessary
to do so. Data acquisition system is a collection of software and hardware that connects it to the
physical world. A typical data acquisition system consists of these components.

COMPONENTS DESCRIPTION
Data acquisition At the heart of any data acquisition system lies the data acquisition
hardware hardware. The main function of this hardware is to convert analog
signals to digital signals, and to convert digital signals to analog signals.

Sensors and actuators Sensors and actuators can both be transducers. A transducer is a device
(transducers) that converts input energy of one form into output energy of another
form. For example, a microphone is a sensor that converts sound energy
(in the form of pressure) into electrical energy, while a loudspeaker is
an actuator that converts electrical energy into sound energy.

Signal Sensor signals are often incompatible with data acquisition hardware.
conditioning To overcome this in compatibility, the signal must be conditioned. For
hardware example, you might need to condition an input signal by amplifying it
or by removing unwanted frequency components. Output signals might
need conditioning as well.

Computer The computer provides a processor, a system clock, a bus to transfer


data, and memory and disk space to store data.

Software Data acquisition software allows you to exchange information between


the computer and the hardware. For example, typical software allows
you to configure the sampling rate of your board, and acquire a
predefined amount of data.

Table 5.1 Components of Data Acquisition System

[65]
Physical phenomenon Data Acquisition
System

SENSOR SIGNAL
CONDITIONING

ACQUISITION COMPUTER SOFTWARE


ACTUATOR HARDWARE

Data Analysis
Physical phenomenon
Fig. 5.1 Data Acquisition System

The figure depicts the two important features of a data acquisition system:
Signals are input to a sensor, conditioned, converted into bits that a computer can read, and
analyzed to extract meaningful information. For example, sound level data is acquired from a
microphone, amplified, digitized by a sound card, and stored in MATLAB workspace for
subsequent analysis of frequency content.
Data from a computer is converted into an analog signal and output to an actuator. For
example, a vector of data in MATLAB workspace is converted to an analog signal by a sound
card and output to a loudspeaker.

5.1.2 Data Acquisition Hardware


Data acquisition hardware is either internal and installed directly into an expansion slot inside
the computer, or external and connected to your computer through an external cable, which is
typically a USB cable. At the simplest level, data acquisition hardware is characterized by the
subsystems it possesses. A subsystem is a component of your data acquisition hardware that
performs a specialized task. Common subsystems include following:

(i) Analog input subsystems convert real-world analog input signals from a sensor into bits
that can be read by your computer. Perhaps the most important of all the subsystems commonly
available, they are typically multichannel devices offering 12 or 16 bits of resolution. Analog
input subsystems are also referred to as AI subsystems, A/D converters, or ADCs.
[66]
(ii) Analog output subsystems convert digital data stored on your computer to a real-world
analog signal. These subsystems perform the inverse conversion of analog input subsystems.
Typical acquisition boards offer two output channels with 12 bits of resolution, with special
hardware available to support multiple channel analog output operations. Analog output
subsystems are also referred to as AO subsystems, D/A converters, or DACs.

(iii) Digital input/output subsystem (DIO) subsystems are designed to input and output digital
values (logic levels) to and from hardware. These values are typically handled either as single
bits or lines, or as a port, which typically consists of eight lines. While most popular data
acquisition cards include some digital I/O capability, it is usually limited to simple operations,
and special dedicated hardware is often necessary for performing advanced digital I/O
operations.

(iv) Counter/timer (C/T) subsystems are used for event counting, frequency and period
measurement, and pulse train generation.

5.1.3 Sensors
A sensor converts the physical phenomena of interest into a signal that is input into your data
acquisition hardware. There are two main types of sensors based on the output they produce:
digital sensors and analog sensors. Digital sensors produce an output signal that is a digital
representation of the input signal, and has discrete values of magnitude measured at discrete
times. A digital sensor must output logic levels that are compatible with the digital receiver.
Some standard logic levels include transistor-transistor logic (TTL) and emitter-coupled logic
(ECL). Examples of digital sensors include switches and position encoders.

Analog sensors produce an output signal that is directly proportional to the input signal, and is
continuous in both magnitude and in time. Most physical variables such as temperature,
pressure, and acceleration are continuous in nature and are readily measured with an analog
sensor. For example, the temperature of an automobile cooling system and the acceleration
produced by a child on a swing all vary continuously. Some common analog sensors and the
physical variables they measure are listed below.

[67]
SENSOR PHYSICAL VARIABLE
Accelerometer Acceleration
Microphone Pressure
Pressure Gauge Pressure
Resistive Temperature device (RTD) Temperature
Strain Gauge Force
Thermocouple Temperature
Table 5.2 Types of Sensors

5.1.4 Signal Conditioning


Sensor signals are often incompatible with data acquisition hardware. To overcome this
incompatibility, the sensor signal must be conditioned. The type of signal conditioning required
depends on the sensor used. For example, a signal might have a small amplitude and require
amplification, or it might contain unwanted frequency components and require filtering.
Common ways to condition signals are as follows:

(i) Amplification
Low-level less than around 100 milli volts usually need to be amplified. High-level signals
might also require amplification depending on the input range of the analog input subsystem.
For example, the output signal from a thermocouple is small and must be amplified before it is
digitized. Signal amplification allows to reduce noise and to make use of the full range of the
hardware thereby increasing the resolution of the measurement.

(ii) Filtering
Filtering removes unwanted noise from the signal of interest. A noise filter is used on slowly
varying signals such as temperature to attenuate higher frequency signals that can reduce the
accuracy of the measurement. Rapidly varying signals such as vibration often require a
different type of filter known as an Antialiasing filter. An Antialiasing filter removes
undesirable higher frequencies that might lead to erroneous measurements.

(iii) Electrical Isolation The sensor signals should be electrically isolated from the computer
for safety purposes because high-voltage transients could damage the computer. We can also
use electrical isolation to make sure that the readings from the data acquisition hardware are not

[68]
affected by differences in ground potentials. For example, when the hardware device and the
sensor signal are each referenced to ground, problems occur if there is a potential difference
between the two grounds. Using electrically isolated signal conditioning modules eliminates the
ground loop and ensures that the signals are accurately represented.

(iv) Multiplexing
A common technique for measuring several signals with a single measuring device is
multiplexing. Signal conditioning devices for analog signals often provide multiplexing for use
with slowly changing signals such as temperature. The A/D converter samples one channel,
switches to the next channel and samples it, switches to the next channel, and so on. Because
the same A/D converter is sampling many channels, the effective sampling rate of each
individual channel is inversely proportional to the number of channels sampled. We must take
care while using multiplexers so that the switched signal has sufficient time to settle.

(v) Excitation Source


Some sensors require an excitation source to operate. For example, strain gauges, and resistive
temperature devices (RTDs) require external voltage or current excitation. Signal conditioning
modules for these sensors usually provide the necessary excitation. RTD measurements are
usually made with a current source that converts the variation in resistance to a measurable
voltage.
5.2 Analog Input Subsystem
Many data acquisition hardware devices contain one or more subsystems that convert (digitize)
real-world sensor signals into numbers that computer can read. Such devices are called Analog
input subsystems (AI subsystems, A/D converters, or ADCs). After the real-world signal is
digitized, you can analyze it, store it in system memory, or store it to a disk file. The function
of the analog input subsystem is to sample and quantize the analog signal using one or more
channels. We can think of a channel as a path through which the sensor signal travels. Typical
analog input subsystems have eight or 16 input channels available to us after data is sampled
and quantized, it must be transferred to system memory. Analog signals are continuous in time
and in amplitude (within predefined limits). Sampling takes a snapshot of the signal at
discrete times, while quantization divides the voltage (or current) value into discrete
amplitudes. Sampling, quantization, channel configuration, and transferring data from hardware
to system memory.
[69]
5.2.1 Sampling
Sampling takes a snapshot of the sensor signal at discrete times. For most applications, the time
interval between samples is kept constant (for example, sample every millisecond) unless
externally clocked. For most digital converters, sampling is performed by a sample and hold
(S/H) circuit. An S/H circuit usually consists of a signal buffer followed by an electronic switch
connected to a capacitor. The operation of an S/H circuit follows these steps:
1) At a given sampling instant, the switch connects the buffer and capacitor to an input.
2) The capacitor is charged to the input voltage.
3) The charge is held until the A/D converter digitizes the signal.
4) For multiple channels connected (multiplexed) to one A/D converter, the previous steps
are repeated for each input channel.

The entire process is repeated for the next sampling instant. A multiplexer, S/H circuit, and
A/D converter are illustrated in the next section. Hardware can be divided into two main
categories based on how signals are sampled: scanning hardware, which samples input signals
sequentially, and simultaneous sample and hold (SS/H) hardware, which samples all signals at
the same time.

5.2.2 Quantization
Sampling takes a snapshot of the input signal at an instant of time. When the snapshot is taken,
the sampled analog signal must be converted from a voltage value to a binary number that the
computer can read. The conversion from an infinitely precise amplitude to a binary number is
called quantization.
During quantization, the A/D converter uses a finite number of evenly spaced values to
represent the analog signal. The number of different values is determined by the number of bits
used for the conversion. Most modern converters use 12 or 16 bits. Typically, the converter
selects the digital value that is closest to the actual sampled value.

[70]
Fig. 5.2 1 Hz sine wave quantized by a 3 bit A/D converter.

The number of quantized values is given by 23 = 8, the largest representable value is given by
111 = 22 + 21+ 20 = 7.0, and the smallest represent able value is given by 000 = 0.0.

(i) Quantization Error


There is always some error associated with the quantization of a continuous signal. Ideally, the
maximum quantization error is 0.5 least significant bits (LSBs), and over the full input range,
the average quantization error is zero. The quantization error for the above sine wave is
calculated by subtracting the actual signal from the quantized signal.

Fig 5.3 The quantization error

[71]
5.2.3 Input Range and Polarity
The input range of the analog input subsystem is the span of input values for which a
conversion is valid. You can change the input range by selecting a different gain value. For
example, National Instruments AT-MIO-16E-1 board has eight gain values ranging from 0.5
to 100. Many boards include a programmable gain amplifier that allows you to change the
device gain through software.

When an input signal exceeds the valid input range of the converter, an over range condition
occurs. In this case, most devices saturate to the largest represent able value, and the converted
data is almost definitely incorrect. The gain setting affects the precision of your measurement
the higher (lower) the gain value, the lower (higher) the precision.

An analog input subsystem can typically convert both unipolar signals and bipolar signals. A
unipolar signal contains only positive values and zero, while a bipolar signal contains positive
values, negative values, and zero. Unipolar and bipolar signals are depicted below
In many cases, the signal polarity is a fixed characteristic of the sensor and we must configure
the input range to match this polarity.

Fig 5.4 Signal Polarity

The range of signals expected from our sensor so that you can configure the input range of the
analog input subsystem to maximize resolution and minimize the chance of an over range

[72]
5.2.4 How Are Acquired Samples Clocked?
Samples are acquired from an analog input subsystem at a specific rate by a clock. Like any
timing system, data acquisition clocks are characterized their resolution and accuracy. Timing
resolution is defined as the smallest time interval that you can accurately measure. The timing
accuracy is affected by clock jitter. Jitter arises when a clock produces slightly different values
for a given time interval. For any data acquisition system, there are typically three clock
sources that you can use: the onboard data acquisition clock, the computer clock, or an external
clock. Data Acquisition Toolbox software supports all of these clock sources, depending on the
requirements of our hardware.

(i) Onboard Clock. The onboard clock is typically a timer chip on the hardware board that is
programmed to generate a pulse stream at the desired rate. The onboard clock generally has
high accuracy and low jitter compared to the computer clock. You should always use the
onboard clock when the sampling rate is high, and when you require a fixed time interval
between samples.
(ii) Computer Clock. The computer clock is used for boards that do not possess an onboard
clock. The computer clock is less accurate and has more jitter than the onboard clock, and is
generally limited to sampling rates below 500 Hz. The computer clock is referred to as the
software clock in this guide.
(iii) External Clock. An external clock is often used when the sampling rate is low and not
constant. For example, an external clock source is often used in automotive applications where
samples are acquired as a function of crank angle.

5.2.5 Channel Configuration


The input channels can be configured in one of these two ways:
Differential
Single-ended
The choice of input channel configuration might depend on whether the input signal is floating
or grounded. A floating signal uses an isolated ground reference and is not connected to the
building ground. As a result, the input signal and hardware device are not connected to a
common reference, which can cause the input signal to exceed the valid range of the hardware
device. To circumvent this problem, we must connect the signal to the onboard ground of the
device. Examples of floating signal sources include ungrounded thermocouples and battery
[73]
devices. A grounded signal is connected to the building ground. As a result, the input signal
and hardware device are connected to a common reference.

5.2.6 Transferring Data from Hardware to System Memory


The transfer of acquired data from the hardware to system memory follows
these steps:
1. Acquired data is stored in the hardwares first-in first-out (FIFO) buffer.
2. Data is transferred from the FIFO buffer to system memory using interrupts or DMA.

These steps happen automatically. Typically, all thats required from us is some initial
configuration of the hardware device when it is installed.

(i) FIFO Buffer


The FIFO buffer is used to temporarily store acquired data. The data is temporarily stored until
it can be transferred to system memory. The process of transferring data into and out of an
analog input FIFO buffer is given below:
1. The FIFO buffer stores newly acquired samples at a constant sampling rate.
2. Before the FIFO buffer is filled, the software starts removing the samples. For example, an
interrupt is generated when the FIFO is half full, and signals the software to extract the
samples as quickly as possible.
3. Because servicing interrupts or programming the DMA controller can take up to a few
milliseconds, additional data is stored in the FIFO for future retrieval. For a larger FIFO
buffer, longer latencies can be tolerated.
4. The samples are transferred to system memory via the system bus (for example, PCI bus or
AT bus).
After the samples are transferred, the software is free to perform other tasks until the next
interrupt occurs. For example, the data can be processed or saved to a disk file. As long as the
Average rates of storing and extracting data are equal, acquired data will not be missed and
your application should run smoothly.

(ii) Interrupts
The slowest but most common method to move acquired data to system memory is for the
board to generate an interrupt request (IRQ) signal. This signal can be generated when one
[74]
sample is acquired or when multiple samples are acquired. The process of transferring data to
system memory via interrupts is given below:
1) When data is ready for transfer, the CPU stops whatever it is doing and runs a special
interrupt handler routine that saves the current machine registers, and then sets them to
access the board.
2) The data is extracted from the board and placed into system memory.
3) The saved machine registers are restored, and the CPU returns to the original interrupted
process.
4) The actual data move is fairly quick, but there is a lot of overhead time spent saving,
setting up, and restoring the register information.

(iii) DMA
Direct memory access (DMA) is a system whereby samples are automatically stored in system
memory while the processor does something else. The process of transferring data via DMA is
given below:
1) When data is ready for transfer, the board directs the system DMA controller to put it into
in system memory as soon as possible.
2) As soon as the CPU is able (which is usually very quickly), it stops interacting with the
data acquisition hardware and the DMA controller moves the data directly into memory.
3) The DMA controller gets ready for the next sample by pointing to the next open memory
location.
4) The previous steps are repeated indefinitely, with data going to each open memory
location in a continuously circulating buffer. No interaction between the CPU and the
board is needed.

The computer supports several different DMA channels. Depending on the application, we can
use one or more of these channels, For example, simultaneous input and output with a sound
card requires one DMA channel or the input and another DMA channel for the output.

[75]
CHAPTER 6
ELECTRONIC PRODUCT DESIGN

6.1 Introduction
Industrial Design being a new discipline, there is a lack of reference texts and instruction
material dealing with fundamental issues. It is therefore to begin with this phase we must
understand some basic terms related to electronics product design.

6.1.1 Product

A product is a physical entity created by man for beneficial purpose using materials and
processes. In Industrial design a product is representative of a system made up of various sub
parts which in turn are made of components.

Only when there is direct physical or perceptual interaction with the human being, a thing
produced is classified as a PRODUCT in Industrial design. Even if only one component is
involved which satisfies the requirement of direct interaction with the user, in term of fulfilling
the need, is classified as complete product in Industrial design, and is considered as system. A
system in Industrial design always includes the user and environment. A person interacting
with a system does not come directly in contact with the internal components that make up
system.

From the above definition it is observed that a thing produced can perform many functions. In
Industrial design it is classified either as a product or a component depending on its hierarchy
and role in system. For example a large nut is a component that is to be always used along with
a bolt to perform a well defined primary task of resisting force. If same nut is used creatively as
a paper weight it get classified in Industrial Design from a mere component to a total product.

In the same way, a printed circuit board (PCB) is not a product in Industrial design, though for
an electro chemist or an electronic engineer it is final product.

6.1.2 Product Design

A product is made up of parts put together so as to form a coherent connected whole. It is


therefore a SYSTEM. Designing a product essentially means the creation of a system.

[76]
Therefore in order to understand Design with respect to product, a product has to be studied as
a system and not as a study of various individual ingredients that go into making a product.

Product Design is a multi-disciplinary process which usually involves market, testing as


well as post production refinement.

Product design does not usually imply the utilization of new technologies to create novel
products. Typically it entails the refinement or upgrading of existing designs, to improve
functionality or appeal.

Another goal is to lower the cost of manufacture for competitive advantage.

6.1.3 Design Space of Product

There are some variables which are useful in understanding the product as a system. These
variables can be grouped into three specific areas from the products point of view. These are
as follows: Anatomy

Physigonomy

Physiography

PRODUCT SPACE

Fig: 6.1 Design Space of Product

(i) Product Physiognomy represents all factors that determine the appearance of the product.
It is representative of visual meaning, a products appearance conveys, to user.

(ii) Product Physiography represents all factors that determine the physical characteristics
and surface features of product.
[77]
(iii) Product Anatomy represents all factors that go into its physical structure and its
construction.

6.2 Design Phases of Electronic Product

6.2.1 Aesthetic Design Phase

Aesthetics is the outlook of the equipment i.e first impression of quality. The following factors
affect the aesthetic look of the electronic product.

Size of equipment

Form of enclosure

Surface finish

Graphics

Arrangement of components on control panel

6.2.2 Engineering Design Phase

The translation of the plan prepared during the designing process into a production prototype
and evaluating it as per the target specifications is the engineering design. The electronic
module, mechanical parts and sub assemblies are fabricated as per drawing and prototype is
assembled from the modules. The following tasks performed during this phase:

1. Circuit Design, bread-boarding and testing of electronic functional modules, which


eventually were converted into individuals PCBs.

2. Design of PCB layouts and preparation of fabrication drawings.

3. Fabrication process used in PCB fabrication.

4. Design of power supply for the equipment and for different modules using the terminals.

5. Design of software (algorithm, flowcharts, simulation and coding).

6. Functional and result testing of modules.

[78]
6.2.3 Ergonomic Design Phase

It is the functional design of the equipment e.g interface design, display and control, safety,
maintainability, handling etc that helps in making the system user friendly. It is the study of
interaction of a man with machines and man made environment.

Basic Ergonomic Requirements are:

1. Product must be safe to handle.

2. Product must be reliable.

3. All operations must be within users limits.

4. Operation must follow the natural phenomenon of user.

5. All operations must involve low physiological cost for operations.

6.3 Creativity in Design

Creativity is a highly complex cognitive ability present in all human beings in varying degree
of proportion. The act of producing new is central to the concept of creativity. In creative
thinking the end product is a new idea or a new solution, or new path to a solution. Creative
thinking works on an open mind principle.

6.3.1 Creativity in Product Design

Uniqueness in products is incorporated by design INNOVATION. The act of innovation starts


from an IDEA. New product ideas are generated by being creative.

Creativity is used for not only producing non existing futuristic products but also to improve
the existing ones, in all aspects ranging from Ergonomics, Materials, Manufacturing processes
to produce Aesthetics and Anatomy.

The main applications of creativity in Product Design are at two levels namely Conceptual and
Physical level.

[79]
CREATIVITY

CONCEPTUAL LEVEL PHYSICAL LEVEL

Fig: 6.2 Levels of Creativity

(i) Conceptual level creativity results in a hitherto non existing product. Creativity is used to
identify an emerging new need. An entire product is then conceptualised to fulfil this need.
The emphasis is on thinking about the problem in different ways and seeking path breaking
solutions through Insight. Besides conceptualisation from scratch, creativity is also used to
build into the product, that elusive feature that makes it stand out in function as well as
visual statement from its competitors.

(ii) Physical Level creativity results in a continuous cycle of improvements in the existing
products principle and parts, (for example electronic circuits, fasteners etc. The systematic
application of creativity at the physical level is seen in Value Engineering. The Japanese
call this continuous creative input as Kaizen and have made it the very base of their highly
successful TQM programmes.

Problems at the physical level could be as simple as eliminating unwanted fasteners or


reducing the number of moving parts or refining the fundamental operating principle of the
product.

6.3.2 Creativity Techniques

Techniques for creative problems solving can be broadly classified into two categories:

(i) Analytical: These apply logical thought processes like systematic analysis, derivation
and logical deduction. These techniques are exercised with in formal structuring of
information. Engineers are quite familiar with these techniques. However these
techniques are more useful in stimulating the brain.

(ii) Non Analytical: These are right brain stimulating techniques. They do require the left
brains co-operation in implementing them.

[80]
6.4 General rules for PCB designing

General rule is to place those components, whose position is fixed for final fitting and
interconnections. Then place the components, which are connected to these fixed
components.
Components should be placed on the grid of 2.5 mm.
Larger components are placed first and the space in between is filled with smaller ones.
All components should be placed in such a manner that dismounting of the other
components is not necessary if they have to be replaced.
Components should be placed in a row or a column so that it gives good overview.

6.4.1 Conductor routing rules

The simple rule is that the conductor length should be as short as possible. In simple
circuits where lot of space is available, conductors can be run in any direction so as to
give the shortest interconnection length.
Conductor forming sharp angles should be avoided otherwise these give problem in
etching.
Where one or several conductors have to pass between pads or other conducting areas,
the spacing has to be equally distributed.
Minimum spacing is applied only where it cannot be avoided otherwise higher spacing
should be given.
In double-sided PCBs, it is normal practice to draw the tracks on components side in the
direction of y-axis and tracks on solder side in the direction of x-axis.
Distribute maximum number tracks on the solder side and the rest on the component
side.

6.4.2 Hole- Diameter Rules

The number of holes diameter on a PCB has to be kept minimum.


Satisfactory soldering results are usually obtained if the diameter of the finalized and
plated holes gives about 0.2-0.5 mm clearance as compared with the nominal diameter
of the component lead.
Hole diameter = effective lead diameter + hole location tolerance ( PTH) + 0.2mm
[81]
6.4.3 Solder Pad Diameter Rules

In PCBs with PTH (plated through hole), the widths of the annular ring should be at
least 0.5mm, but without PTH the annular rings must be more because there is no
through-hole plating to give mechanical strength to the solder pads.
As a rule solder pad diameter is approximately 3 times the component lead diameter.
The pads are placed always exactly and properly centered on grid intersections
The conductor width should always be less than the solder pad diameter.
The pattern around the hole should be maintained as uniformly as possible to, enable
symmetrical solder joints.

6.5 Design Elements

Design inputs, which are provided by the equipment designer to the PCB designer, are known
as design Elements. The various design elements to be considered are:

Board Size (minimum and maximum)


Number of layers
Hole sizes
Board-thickness
Conductor widths
External connection
Mounting holes
Type of circuit (Analog, Digital)
Component details with specifications

(i) Electrical Design

There are some important electrical factors that must be accounted for a proper printed circuit
board design. Resistance and capacitance are the most important design factors. Copper
conductor tracks on a PCB have a finite resistively, which introduces a voltage drop
proportional to the current flowing in the particular conductor.

(ii) Mechanical Design The various mechanical factors that have to be taken into consideration
for designing of a PCB are:
[82]
The board size should be optimum and compatible with PCB manufacturing process.
Horizontal or vertical board mounting, as a consequence of other factors such as heat
and dust.
Proper hole diameter should be provided for component mounting.
Board mounting holes should be provided.
Heavy components should be adequately fixed.

6.6 EMI consideration for designing a Product

As electronic systems become more complex, the need to protect against unwanted
electromagnetic interference (EMI) becomes more urgent. Components generating high
amounts of electromagnetic radiation can interrupt the overall operation of a system or cause a
potential security issue by revealing sensitive data. Proper system enclosure design can prevent
this problem. Unfortunately, such designs are not simple and require consideration of many
variables to ensure proper shielding performance. Many times, engineers try to improve the
shielding effectiveness of the enclosures by adding and expensive gasket or some other minor
design change to solve an issue that appears long after the design process is under way.

Such last minute steps can be avoided by careful analysis and calculations during the initial
design process. A robust process consists of following EMI standards, defining chassis goals
and EMI parameters, choosing the proper materials and the judicial use of gaskets.

6.6.1 Factors in Material Selection


Parameters should be identified that needs limits and value to be assigned. Parameters might
include design for emission suppression, design for limiting susceptibility, the shielding
standard to be met, and the frequency range of the equipment inside the enclosure, the
attenuation levels are to be met, the type of environment where the enclosure will be used, or
others. Following are some factors that need to be considered in selecting material for the
enclosures

One of the first consideration factors is cost, as most designs must carefully balance system
requirements, EMI protection and overall cost. Manufacturability and cost considerations are
not the same for all the companies, but sometimes they are the driving factors in designing a
shielded enclosure. If the goal is emission suppression, the enclosure material should have a
maximum absorption loss of the emitted field. If the components in the enclosures are to be
[83]
protected from outside fields, the enclosure material should have maximum combination of
absorption and reflection losses.

Another important factor in selecting material for a shielded enclosure is the conductivity and
continuity of the enclosure. A perfectly welded closed box would be ideal. However, the user
needs to have easy access inside the enclosure to mount equipment. So it is common to have
doors, side panels and I/O panel openings. Most of the time shielding effectiveness depends on
how the electromagnetic waves are transmitted across the boundaries of these openings.

These openings cause a major problem in the design of shielded enclosures because a
commercial enclosure cannot be completely sealed. The most common openings in an
enclosure are doors, side panels, I/O panels, ventilation ports and cable that ingress/egress. All
openings in an enclosure will act as slot radiators of electromagnetic waves unless continuity is
restored.

6.6.2 Maintaining continuity: Gaskets


Gasketing is used to help maintain electrical continuity across enclosures openings. The gasket
material should be galvanically compatible with the material of the enclosures. The purpose of
the gasket is to improve conductivity in order to reduce emissions. But all gaskets are porous to
some extent, and the porous spots in the gasket can act as slot radiators at high frequencies. It is
important to calculate the shielding effectiveness of the gasket given its porosity. In addition,
most gaskets have a limited lifetime, normally defined in cycles for a particular compression
limit.

6.6.3 Other considerations for chassis


Some enclosures have natural or forced convection cooling which require an inlet and an
exhaust for air. In this kind of situation an arrangement needs to be made allowing air to come
in and go out, but not the electromagnet waves. The answer is a wave guide. A wave guide is
nothing more than a tube made long enough such that it cuts off electromagnetic waves and
acts likes a brick wall. The rule of thumb regarding length of the wave guide is that it should be
at least five times its diameter.

Cables and connectors are considered part of the enclosure and must also be shielded. The
cables carrying power in and out of the enclosure radiate some electromagnetic waves. Proper
insulating covers for the cables and their associated connectors should be used to eliminate any
chance of cable-based EMI radiation..
[84]
6.6.4 Capabilities of the PCB manufacturer

Maximum number of layers


Minimum track width possible
Maximum size of board possible
Tolerances
Other capabilities

6.7 Complete Circuit

Fig.6.3 Eye Tracking based Driver Fatigue Monitoring and Warning System

6.8 PCB Layout

[85]
The Figure 6.4 shows the layout that has been developed in ORCAD 9.1 for the developed
schematic shown in Figure 6.3. Footprints of all the components can be observed in rectangular
boxes. Red lines shows the tracks, Blue lines shows the jumpers which has to be done manually
with jumper wires on component side, Yellow line shows the boundary of the PCB. The final
designed PCB was then manufactured.

Fig.6.4 PCB Layout

6.9 Complete Hardware of the System

[86]
The figure 6.5 below shows the complete hardware developed for the Eye Tracking based
Driver Fatigue detection and Warning System.

Fig: 6.5 Complete hardware for the system

CHAPTER 7
[87]
RESULTS AND DISCUSSION

7.1 Hardware Results

The hardware developed Eye Tracking based driver fatigue Monitoring and Warning
System is very advanced product related to driver safety in the roads as this product detects
driver drowsiness and gives Warning in form of alarm and vibration in less than one second
time which is the major achievement of this product.

7.2 Software Results

7.2.1 The first window shows Original Image of Driver

Fig 7.1 Driver Original Image

This window is used for driver eye detection so that driver iris may be detected when eyes are
kept inside region between two imaginary lines drawn horizontally.

7.2.2 The Second window shows Driver iris and eye brows when Eyes open

[88]
Fig 7.2: Driver eyes open

7.2.3 The Third window shows image of eye brows when Eyes closed

Fig 7.3: Driver eyes closed

7.2.4 The Fourth window shows Steering Wheel Pressure

Fig 7.4: Steering Wheel Gripping Pressure

7.2.5 The Fifth window shows Vehicle Speed Variation

[89]
Fig 7.5 Vehicle Speed Variation

7.2.6 The Sixth window shows complete algorithm results

Fig 7.6 Sample results of working system

CHAPTER 8
[90]
CONCLUSION AND FUTURE SCOPE

8.1 Conclusion

This study achieves a design and development of a system for the advanced driver security
system which detects driver fatigue in less than one second and also develope the performance
record of driver in form of graph i.e Speed versus Time and Steering gripping pressure
variation which can be saved on hard disk for future reference.

8.2 Future Scope

To provide better evidence of the usefulness of this system future research should address the
following issues. Research should be done to make system work more accurately when driver
is in motion with respect to camera as here camera used is highly directional.

Thus would help in more security and privacy of systems. It should be noted and understood
that with respect to the embodiments of the present invention, the ideas suggested may be
modified or substituted to achieve the general overall resultant high efficiency

REFERENCES
[91]
[1] S. Jane, W. Jean, V. Bradley, Why Do People Have Drowsy Driving Crashes, Input
From People Who Just Did, AAA Foundation for Traffic Safety, 1999.

[2] Mc. Afferty, Kevin, The Safety Network, Rseau-Scurit, Canadian Association of
Road Safety Professionals (CARSP), 2000.

[3] M.H Sigari, Driver Hypo-Vigilance Detection based on Eyelid Behavior, in


Proceedings of the Seventh International Conference on Advances in Pattern Recognition,
IEEE Computer Society, 2009. pp. 426-429.

[4] H. Jonathan, D. Thomas, Hanowski, Richard, W. Walter, A. Christina, In-Vehicle


Information Systems Behavioural Model and Design Support: Final Report, U.S
Department of Transportation, Federal Highway Administration, 2000.

[5] W. W. Wierwille, S. S. Wreggit, C. L. Kirn, L. A. Ellsworth, R. J. Fairbanks III, Research


on vehicle-based driver status/performance monitoring: development, validation, and
refinement of algorithms for detection of driver drowsiness, National Highway Traffic
Safety Administration, U.S. DOT Tech Report No. DOT HS 808 247, 1994.

[6] Dr. P.R Bajaj, M.S Devi, Driver Fatigue Detection Based on Eye Tracking, in
Proceedings of the First International Conference on Emerging Trends in Engineering and
Technology, IEEE Computer Society, 2008, pp. 649-652.

[7] R. Grace, V.E Byrne, D.M Bierman, J.M Legrand, D Gricourt, R.K Davis, J.J Staszewski, B
Carnahan, A Drowsy Driver Detection System for Heavy Vehicles, in Proceedings of the
IEEE, 1998, pp. I36-1-8.

[8] K. Ambak, R Atiq, R Ismail, Intelligent Transport System for Motorcycle Safety and
Issues, in Proceedings of the European Journal of Scientific Research, Vol. 28, No. 4, 2009,
pp. 600-611.

[9] G. Richard, B. Vicky, B. Damian, L.J.Michel, G. David; Davis, R.S. James; C. Brian, A
Drowsy Driver Detection System For Heavy Vehicles, IEEE 0-7803-5086-3, 1998.

[10] A. Kircher, M. Uddman, J. Sandin, Vehicle control and drowsiness, Project Report in
Proceedings of the Swedish National Road Transport, Linkping Sweden, 2002.

[11] C.D Wylie, T. Shultz, J.C Miller et al: Commercial Motor Vehicle Driver Fatigue and
[92]
Alertness Study, TP Report No. 12876E, July 2001.

[12] E. Bekiaris, S. Nikolaou, A. Mousadakou, System for effective Assessment of driver


vigilance and Warning According to traffic Risk Estimation, Project Report in
Proceedings of the Design Guidelines for Driver drowsiness detection & avoidance,
AWAKE Consortium, 2004.

[13] T. DOrazio, M. Leo, G.Cicirelli, A. Distante, An Algorithm for real time eye detection
in face images, in Proceedings of the 17th International Conference on Pattern Recognition,
IEEE Computer Society, Vol. 4, 2004, pp. 1051-4651.

[14] R. Dawn, National Survey of Distracted and Drowsy Driving, The Gallup
Organisation and NHTSA, 2003.

[15] K. Lin, J. Huang, J. Chen, C. Zhou, Real-time Eye Detection in Video Streams, in
Proceedings of the Fourth International Conference on Natural Computation, IEEE Computer
Society, Vol. 9, No. 8, 2008, pp. 193-196.

[16] M. Pereira, H. Hamama, N. Dapzol, M.P. Bruyas, A. Simoes, Simultaneous interaction


with in-vehicle systems while turning left: comparison among three groups of drivers, in
Proceedings of the IET Intelligent Transport Systems, Vol. 3, No. 4, 2009, pp. 369378.

[17] E. Rogado, J.L. Garca, R. Barea, L.M. Bergasa, E. Lpez, Driver Fatigue Detection
System, in the Proceedings of the IEEE International Conference on Robotics and
Biomimetics Bangkok, Thailand, 2009, pp. 1105-1110.

[18] J. F. May, C.L. Baldwin, Driver fatigue: The importance of identifying causal factors
of fatigue when considering detection and countermeasure technologies, in the
Proceedings of the Transportation Research Elsevier, Part F 12, 2009, pp. 218224.

[19] I. Park, J.H. Ahn, H. Byun, Efficient Measurement of Eye Blinking under Various
Illumination Conditions for Drowsiness Detection Systems, in Proceedings of the18th
International Conference on Pattern Recognition, IEEE Computer Society, Vol. 6, 2006, pp.
111-120.

[20] L. Yunqi, Y. Meiling, S. Xiaobing, L. Xiuxia, O. Jiangfan, Recognition of Eye States in


Real Time Video, in Proceedings of the International Conference on Computer Engineering
and Technology, IEEE Computer Society, Vol. 10, No.105, 2009, pp. 554-559.

[21] F. D. Torre, C. J.G. Rubio, E. Martinez, Subspace Eye Tracking for Driver Warning,
in Proceedings of the IEEE, Vol. 8, No. 3, 2003, pp 329-332.

[93]
[22] Y. Jie, Y. DaQuan, W. WeiNa, X. XiaoXia, W. Hui, Real-Time Detecting System of
the Drivers Fatigue, in Proceedings of the IEEE, Vol. 6, 2006, PP. 233-234.

[23] B. Roman, H. Karel, P. Lubomr, S. Pavel, S. Petr; V, Petr, Detection of Fatigue States
of a Car Driver, Czech Technical University in Prague, Faculty of Electrical Engineering.

[24] G. Richard, S. Sonya, Drowsy Driver Monitor and Warning System, Robotic
Institute, Carnegie Mellon University, Pittsburgh Pennsylvania, 2001

[25] K. Ron, R, Paul, PERCLOS: A Valid Psychophysiological Measure of Alertness by


Psychomotor Vigilance, Federal Highway Administration, Office of Motor Carriers, 1998

[26] Ji. Qiang, Y. Xiaojie, Real-Time Eye, Gaze, and Face Pose Tracking for Monitoring
Driving Vigilance, Elsevier Science Ltd, 2002.

[27] S. Ebenhard, Presentation and demonstration at Scania, Senso Motoric Instruments


(SMI), 2003

[28] W. Jian, L. Bing, Design and Simulated Implementation of MATLAB-based Warning


System for Fatigue Driving Driver, in Proceedings of the Ninth International Conference on
Intelligent Hybrid Systems, IEEE Computer Society, Vol. 9, 2009, pp 467-470.

[29] K. Matti, Methods for Machine Vision Based Driver Monitoring Applications,
Espoo 2006. VTT Publications 621.82 p. + app. 79 p

[30] R. P. Hamlin, Three-in-one vehicle operator sensor, Transportation Research Board,


National Research Council, IDEA program project final report ITS-18, 1995.

APPENDIX A
[94]
COMPONENT USED

S.NO COMPONENTS
1 Microcontroller 89C52

2 ADC 0808

3 10K Variable Resistor

4 USB Digital camera

5 Vibrator

6 Push Button Tag Switches

7 Alarm

8 BC 547 Transistor

9 0-12V Transformer

10 IN4007 Diode

11 7805 Voltage Regulators

12 11.0592 MHZ Crystal

13 4.7K, 1k , 100 Resistance

14 10F/25v Electrolytic Capacitor

15 0.1F,33pF Ceramic Capacitor

16 D25 Connector

17 Connecting Wire

18 2pin, 3 pin Connector

APPENDIX B
MATLAB PROGRAM
[95]
-------------------------------------------------------------------
hwInfo = imaqhwinfo('winvideo')

device1 = hwInfo.DeviceInfo(1)

device1.SupportedFormats

vid=videoinput('winvideo',1,'YUY2_320x240')

set(vid,'ReturnedColorSpace','rgb');

triggerconfig(vid,'manual');

set(vid,'FramesPerTrigger',1);

set(vid,'TriggerRepeat', 100000);

stop(vid);

start(vid);

dio1=digitalio('parallel','lpt1');

dio2=digitalio('parallel','lpt1');

outreg=addline(dio1,0:7,0,'out');

inreg=addline(dio2,0:4,1,'in');

putvalue(dio1.line(1),0);

%****************************************************************
*****

tic;

toc;

[96]
t=2;

for i=1:200

trigger(vid);

image1=getdata(vid,1);

for i=1:320

image1(35,i,1)=0;image1(35,i,2)=255;image1(35,i,3)=0;

image1(100,i,1)=0;image1(100,i,2)=255;image1(100,i,3)=0;

end

r=1;c=1;

Ir=image1(35:100,1:320,:);

figure(1),imshow(image1)

title('oringal image')

%-------------------------------------------------

imr=Ir(:,:,1);

imR1=im2bw(imr,100/255);

im1=~(imR1);

ir1=bwareaopen(im1,4);

ir1=imfill(ir1,'holes');

ir1=imopen(ir1,strel('disk',4));

[lw,numr]=bwlabel(ir1);
[97]
for i=1:numr;

y=strcat('y',num2str(i));

x=strcat('x',num2str(i));

[y,x]=find(lw==i);

[xs,ys]=size(x);

if (xs <10 || xs>350)

for j=1:xs

ir1(y(j,1),x(j,1),:)=0;

end

end

end

[lw,numr]=bwlabel(ir1);

if (numr<4)

t1=toc;

if(t1>.1)

if(t1>.5)

display('warning')

putvalue(dio1.line(1),1);

pause(2);

end

else
[98]
tic;

end

else

tic;

display('open')

putvalue(dio1.line(1),0);

end

figure(2),imshow(ir1)

title('iris detected image')

%---------------------------------------------------------------------

pressurematrix(1,500)=0;

speedmatrix(1,500)=0;

timematrix(1,500)=0;

pressurematrix(1,1)=10;

speedmatrix(1,1)=120;

timematrix(1,1)=0;

pressure1=getvalue(dio2.line(3));

speed0=getvalue(dio2.line(2));

speed1=getvalue(dio2.line(4));

[99]
if (pressure1==0)

pressurematrix(1,t)=2;

else

pressurematrix(1,t)=8;

end

if (speed0==1 && speed1==1)

speedmatrix(1,t)=100;

else if (speed0==1 && speed1==0)

speedmatrix(1,t)=60;

else if (speed0==0 && speed1==1)

speedmatrix(1,t)=40;

else

speedmatrix(1,t)=20;

end

end

end

timematrix(1,t)=t;

pause(.1)

figure(3),plot(timematrix,pressurematrix);

title('time Vs Pressure');

figure(4),plot(timematrix,speedmatrix);
[100]
title('time Vs speed');

t=t+1;

%---------------------------------------------------------------------

end

%****************************************************************
*****

APPENDIX C
DATASHEET OF AT89C52
[101]
[102]
[103]
[104]
[105]
[106]
[107]
[108]
[109]
[110]
[111]
DATASHEET OF 7805 VOLTAGE REGULATOR

[112]
DATASHEET OF ADC 0808
[113]
[114]
[115]
[116]
[117]
[118]

Você também pode gostar