81
INTELLECTUAL ACCIDENT AVOIDANCE SYSTEM A PROJECT REPORT Submitted by A.DINESH (070107603010) S.GOBINATH (070107603012) R.KAVINKUMAR (070107603015) in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING IN ELECTRONICS AND COMMUNICATION ENGINEERING EXCEL ENGINEERING COLLEGE

Project Report Ackowledgement

Embed Size (px)

DESCRIPTION

for final year engineering students those who are doing under the anna university of coimbatore

Citation preview

Page 1: Project Report Ackowledgement

INTELLECTUAL ACCIDENT AVOIDANCE

SYSTEM

A PROJECT REPORT

Submitted by

A.DINESH (070107603010)

S.GOBINATH (070107603012)

R.KAVINKUMAR (070107603015)

in partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

EXCEL ENGINEERING COLLEGE

ANNA UNIVERSITY COIMBATORE 641047

APRIL 2011

Page 2: Project Report Ackowledgement

ANNA UNIVERSITY COIMBATORE 641047

BONAFIDE CERTIFICATE

Certified that this project report “INTELLECTUAL ACCIDENT AVOIDANCE SYSTEM” is the bonafide work of “A.DINESH, S.GOBINATH, R.KAVINKUMAR” who carried out the project work under my supervision.

SIGNATURE SIGNATURE

SUPERVISOR HEAD OF THE DEPARTMENT

Ms.S.MonicaaDevi Mr.K.M.PalaneswamyLecturer, ProfessorDepartment of ECE Department of ECEExcel Engineering College Excel Engineering CollegeNH-47 New, Pallakapalayam NH -47 New, PallakapalayamKomarapalayam KomarapalayamNamakkal – 637303 Namakkal– 637303

--------------------------------------------- ------------------------------------------

Internal Examiner External Examiner

Page 3: Project Report Ackowledgement

ACKNOWLEDGEMENT

I hereby record my gratitude to our respected Honorary Chairman

Dr.A.K.NATESAN and Vice Chairman Dr.N.MADHAN KARTHICK, Excel

Group of Institutions who had provided us the facilities for the successful

completion of our project.

With great pleasure and honor I express my sincere thanks to

Dr.R.MALATHY, Principal, Excel Engineering college for her valuable

suggestions to complete this report in a successful manner.

I owe my special thanks to Prof. K.M.PALANESWAMY, Head, Dept. of

Electronics and Communication Engineering, Excel Engineering College for his

Constructive ideas.

My special thanks are due to my Project Guide Ms. S.MonicaaDevi Lecturer,

Dept. of Electronics and Communication Engineering, Excel Engineering College

for her valuable suggestions, guidance and support throughout the project work.

I would like to convey my special thanks to Ms.R.SATHYA, Project

Coordinator, Dept Of Electronics and Communication Engineering, Excel

Engineering college for her encouragement and support.

Next, I wish to thank Ms.DHARANI, & Mr.RAJEIV Embedded System

Developer, SANDS INSTITUTE OF TECHNOLOGY, CHENNAI Who had given me

necessary permission and instructions to do this project work successfully.

Finally, I express my heartfelt thanks to my family members, friends and well

wishers for their support and help for the successful completion of this project work.

CHAPTER NO. TITLE PAGE NO

Page 4: Project Report Ackowledgement

List of Table

List of Figures

List of Abbreviations

i

ii

iii

1 Introduction

1.1 Company Profile

1.2 Objective

1

3

2 System Analysis

2.1 Existing System

2.1.1 Drawbacks

2.2 Proposed System

2.3 Feasibility Study

2.3.1 Economical Feasibility

2.3.2 Technical Feasibility

2.3.3 Social Feasibility

4

4

4

5

5

5

6

3 System Specifications

3.1 Hardware Requirements

3.2 Software Requirements

3.3 Requirement Specification

7

7

7

4 Software Description

4.1 Front End

4.2 Features

8

16

5 Project Description

5.1 Problem Definition

5.2 Overview of the Project

5.3 Module Description

5.3.1 Modules

5.4 Data Flow Diagram

5.5 E-R Diagram

5.6 Database Design

5.7 Input Design

5.8 Output Design

5.9 System Design

18

21

22

23

24

25

26

27

27

Page 5: Project Report Ackowledgement

6 System Testing

6.1 Unit Testing

6.2 Integration Testing

6.3 Validation Testing

6.4 Test Cases

29

30

31

31

7 System Implementation

7.1 User Training

7.2 module implementation

32

32

33

8 Conclusion & Future Enhancements

8.1 Conclusion

8.2 Future Enhancements

34

34

9 Appendix

9.1 Source Code

9.2 Screen Shots

35

47

10 References 66

CHAPTER 1

Page 6: Project Report Ackowledgement

1 INTRODUCTION

1.1.1 COMPANY PROFILE

Overview

SANDS Training Division bridges the gap between What is taught in the Universities

and What is required by the Industries in the areas of DSP, VLSI and Embedded Systems.

Sands Institute of Technology is a hardware company, with a focus on development of

hardware products, Young & bright Engineering graduates are given theoretical & on the job

training in DSP, VLSI and Embedded Systems to prepare them for the generic needs of the

Industry. Advanced courses in DSP, VLSI and Embedded Systems are imparted and hands-

on training is given to working technical professionals to enhance their skill sets & to enable

them move up the Technological Chain.

Vision

To maximize and expand our customer’s capabilities by building long-term customer

relationships, by providing high value hardware services using our Global delivery model and

a world–class employee base with a commitment to customer service, quality and

innovation.

Services

While the initial training is conducted either at the SANDS premises or at the

respective College/University, the advanced training is conducted either at SANDS premises

or the customers place. SANDS being a recognized member of Windows Embedded Partner

Program (WEPP), Certified Third party Developer for Analog Devices Inc. USA and Texas

Instruments, USA. is able to provide high technology projects to the students & professionals.

SANDS is able to groom about 2000 students and professionals every year by providing high

technology projects.

Technology

Page 7: Project Report Ackowledgement

DSP Process

VLSI technologies

Microprocessor Technologies

Microcontroller Technologies

Microsoft Technologies

Assemble languages Technologies

Address

Sands Institute of Technology,

96,4th Avenue,

Ashok Nagar First Floor,

Chennai,

Tamil Nadu 600083,

India.

Page 8: Project Report Ackowledgement

1.1.2 Objective

The objective of this project is to reduce the death rate due to the accident

happen in the road transporting due to the drunken drive and inefficiency of the

driving knowledge that particular vehicle. Also there are many accidents had done by

the thieves at the time of chasing by the cops, to give the more security to the user the

system also having the code locking security via giving the password by their own at

the time of starting.

Our system involves an alcohol detecting sensor and gives the condition of the

driver that he takes the alcohol or not, by checking it only it will give the permission

to switch on the vehicle to the driver, and the password authentication system which is

unique for every individual. The personal password for every individual are set by

them and maintained secretly in the embedded system that is fixed in their vehicle. So

that the details of a person can be verified by the system and takes that as key for the

particular vehicle.

This project is used to improve the security performance and provide the safety

for the driver as well as the passengers of that vehicle, the alcohol sensor and keypad

input is taken for this process to check for the driver’s consciousness and security.

Page 9: Project Report Ackowledgement

CHAPTER 2

2 SYSTEM ANALYSIS

2.1 EXISTING SYSTEM

The traffic analyzing and position of the vehicle is the existing system used for avoid

the accidents, but this system has several drawbacks.

1. At the old the system only checks for the position of the vehicle.

2. At the second the system takes the analysis to avoid accident for more traffic and

highways through the GPS.

3. The system is never checks the condition of the driver

4. At old system the concept is to give alert to the driver and not for controlling the

vehicle.

2.1.1 Drawbacks

The system takes time to response for analyzing the position of the vehicle by

GPS.

The system is not possible while there is no coverage of GPS system and

failure.

All the sensors are in not secured places on the vehicle.

2.2 PROPOSED SYSTEM

Here we are using the new approaches are the Embedded technology to connect with

the process called INTELLECTUAL ACCIDENT AVOIDANCE SYSTEM, by using these

efficiently follows the working process.

First process is used to reduce cost overhead, because we are using all the controlling

process for control the vehicle by the controller itself. The feature of the project will be using

the GSM technology for efficiency, fast and to give the immediate report to the particular

mobile station.

ADVANTAGE:

1. Low power consumption.

2. It improves security performance in the highly secured areas compare than others.

3. Easy working process.

Page 10: Project Report Ackowledgement

FEASIBILITY STUDY

The feasibility of the project is analyzed in this phase, security project and some cost

estimates. During system analysis the feasibility study of the proposed system is to be carried

out. This is to ensure that the proposed system is not a burden to the country. For feasibility

analysis, some understanding of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are:

1. Economical Feasibility

2. Technical Feasibility

3. Social Feasibility

2.3.1 Economical Feasibility

This study is carried out to check the economic impact that the system will have on

the organization. The amount of fund that the company can pour into the research and

development of the system is limited. The expenditures must be justified. Thus the developed

system as well within the budget and this was achieved because most of the technologies

used are freely available.

2.3.2 Technical Feasibility

This study is carried out to check the technical feasibility, that is, the technical

requirements of the new implementations. Any technology developed must not have a high

demand on the available technical resources. This will lead to high demands on the available

technical resources. This will lead to high demands being placed on the features. The

developed system must have a modest requirement, as only minimal or null changes are

required for implementing this system process.

2.3.3 Social Feasibility

The aspect of study is to check the security level of the society. This includes

the process of training and secures the country. The user to use the system efficiently. The

level of acceptance by the security depends on the methods that are employed to educate

the user about the system and to make him familiar with it. His level of confidence must

be raised also able to make some constructive process.

Page 11: Project Report Ackowledgement

CHAPTER 3

3. SYSTEM SPECIFICATIONS

Today the accident avoidance system is an important thing in order to avoid the accident

due to drunken driving. Our project is “Intellectual accident avoidance system” which

controls the prevention of accident and driver safety. It consists of two applications such as

security and safety. PIC16F877A microcontroller and sensor and keypad are used.

3.1 OVERVIEW OF PROJECT

Our project Intellectual Accident Avoidance System using alcohol sensor in

embedded system. In which the accident occur by drunken drive and inefficiency of

knowledge about that vehicle is prevent by this system.

The four wheelers are mostly used vehicles for long travelling by everyone in any

time. The driver may have drunken state at the time. Based on the condition of the driver only

most of the accidents are happen in nowadays,

The recent report from the highways department about 85 percentage of the road

accidents are happen due to the drunken driving and inefficient knowledge of the driver about

the road line instructions due to the lack of consciousness of the driver.

Alcohol sensor is a gas sensor and which is used to sense the gas i.e. if the driver is in

drunken state. It gives information to the microcontroller and it will not allow the driver to

start the vehicle or change it to minimum speed level i.e. 20km/hr.

The security system which is produced by a particular password is gives the security

of the vehicle from thief’s and make sure that the correct person is driving the car from the

keypad function we can get the password and secure the car from inefficiency driving.

Page 12: Project Report Ackowledgement

3.2 EMBEDDED SYSTEM

An embedded system is a special purpose computer controlled Electro-mechanical

system in which the computer is completely encapsulated by the device it controls. An

embedded system has specific requirements and pre-defined tasks, unlike a general purpose

personal computer. The core of any embedded system is a microprocessor, programmed to

perform a few tasks. This is to be compared to other computer systems with general purpose

hardware and externally loaded software. Embedded systems are often designed for mass

production.

The utility if the end product is the goal when designing an embedded system, not the

capability of the embedded computer itself. Embedded products are typically sold on the

basis of capabilities, features and system cost rather than which CPU is used in them or

cost/performance of the CPU.

3.2.1 FEATURES OF EMBEDDED SYSTEM

High performance

Low power consumption

More compact

Reduced design and development time

Reduced cost and memory

Page 13: Project Report Ackowledgement

3.3 SYSTEM WORKING FLOW GRAPH STAGE-I

FIGURE 3.3 SYSTEM WORKING FLOWGRAPH STAGE-1

Page 14: Project Report Ackowledgement

3.4 SYSTEM WORKING FLOW GRAPH STAGE-II

FIGURE 3.4 SYSTEM WORKING FLOW GRAPH STAGE-II

Page 15: Project Report Ackowledgement

CHAPTER 4

4. PROJECT DESCRIPTION

4.1 COMPONENTS

Our project is done under the domain of microcontroller which is having all the

controlling process with the inbuilt functions and the peripherals that which having the

internal memory and all timers and ect, to directly connected to the processor and can

controls the external peripherals directly with the microcontroller. For an embedded system

there are defined as that the combination of both hardware and software is work together to

getting an required output for that particular task according to that for our system we have

that both components as detailed below

The two main components in our project are:

4.1.1 HARDWARE COMPONENTS

In our project “Hardware components” are

Microcontroller unit

Power supply unit

Sensor and interfacing unit

Keypad

DC Motor

4.1.2 SOFTWARE COMPONENTS

The software components are,

PIC C Compiler

Embedded C

Page 16: Project Report Ackowledgement

4.2.3 BLOCK DAIGRAM

FIGURE 4.2.4 GENERAL BLOCK DIAGRAM

PIC16F877A

Microcontroller

Alcohol Sensor

Key pad

Relay

Relay

Motor

1

Motor

2

Vehicle Model

Page 17: Project Report Ackowledgement

4.3 MICROCONTROLLER

A microcontroller is a small computer on a single integrated circuit containing a

processor core, memory, and programmable input/output peripherals. Program memory in the

form of NOR flash or OTP ROM is also often included on chip, as well as a typically small

amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the

microprocessors used in personal computers or other general purpose applications.

Microcontrollers are used in automatically controlled products and devices, such as

automobile engine control systems, implantable medical devices, remote controls, office

machines, appliances, power tools, and toys. By reducing the size and cost compared to a

design that uses a separate microprocessor, memory, and input/output devices,

microcontrollers make it economical to digitally control even more devices and processes.

Mixed signal microcontrollers are common, integrating analog components needed to control

non-digital electronic systems. The basic internal designs of microcontrollers are pretty

similar. Figure shows the block diagram of a typical microcontroller. All components are

connected via an internal bus and are all integrated on one chip. The modules are connected

to the outside world via I/O pins.

A PIC microcontroller is a processor with built in memory and RAM and you can use it to control your projects. So it saves you building a circuit that has separate external RAM, ROM and peripheral chips.

4.3.1 Features

In fact a PIC microcontroller is an amazingly powerful fully featured processor with

Internal RAM

EEROM

FLASH memory and Peripherals

10 bit ADC

TIMERS

CCP Module

Watch dog timer

Page 18: Project Report Ackowledgement

4.3.2 INPUT / OUTPUT – I/O

A PIC Microcontroller can control outputs and react to inputs e.g. you could drive a

relay or read input buttons. With the larger devices it's possible to drive LCDs or seven

segment displays with very few control lines as all the work is done inside the PIC Micro.

Comparing a frequency counter to discrete web designs you'll find two or three chips for

the microcontroller design and ten or more for a discrete design. So using those saves

prototype design effort as you can use built in peripherals to take care of lots of the circuit

operation. Many now have a built in ADC so you can read analogue signal levels so you don't

need to add an external devices e.g. you can read an LM35 temperature sensor directly with

no interface logic.

4.3.3 TIMER / COUNTERS

Each PIC microcontroller has up to three timers that you can either use as a timer or a

counter (Timer 1 & 2) or a baud clock (Timer 2).  

4.3.4 TIMER 0

The original timer: Timer 0 was the first timer developed and you can find it in all the

earliest devices e.g. 16F84 up to the most current, 16F877A. It is an 8 bit timer with an 8 bit

prescaler that can be driven from an internal (Fosc/4) or external clock.  It generates an

interrupt on overflow when the count goes from 255 to zero.

Timer 0 always synchronizes the input clock. Read and write timer 0 but you cannot

read the prescaler. The prescaler changes its effect depending on whether it is a timer

prescaler or a watch dog prescaler - so the same prescaler setting may prescale by 2 or by 1

depending on its use.

4.3.5 TIMER 1

This is a 16 bit timer that generates an overflow interrupt when it goes from 65535 to

zero.   It has an 8 bit programmable prescaler and you can drive it from the internal clock

(Fosc/4) or an external pin. To eliminate false triggering it also has an optional input

synchronizer for external pin input. This timer can be used in sleep mode and will generate a

wakeup interrupt on overflow.

Page 19: Project Report Ackowledgement

Timer 1 is also read by the CCP module to capture an event time. Note: Using this

timer in sleep mode will use more current. In addition it can be used to drive a low power

watch crystal.  This is something that sounds good but I don't recommend you do it as watch

crystals are extremely difficult to drive correctly.  You should only use it if you are going to

make a PCB and follow all the guidelines in making it noise free. I used a DS1307 in the Real

Time clock project which drives the crystal directly but even this is difficult to get operating

accurately.

4.3.6 TIMER 2

This is an 8 bit timer with an 8 bit prescaler and an 8 bit postscaler.  It takes its input

only from the internal oscillator (Fosc/4). This timer is used for the time base of a PWM

when PWM is active and it can be software selected by the SSP module as a baud clock. It

also has a period register that allows easy control of the period. When timer 2 reaches the

PR2 register value then it resets.  This saves having to check the timer value in software and

then reset the timer and since it is done in hardware the operation is much faster - so you can

generate fast clocks with periods that are multiples of the mainclock.

4.3.6 BAUD RATES

There is a table of baud rates in microchip data sheet DS33023A which indicates the

expected percentage error for a specific clock rate and in general the higher the main clock

the lower the error. for an 8MHz clock - if you use BRGH=1 and an 8MHz clock we get

accurate baud rates up to 38.4kbaud.  You have to force this to work e.g. in mikroC the built

in USART routines use BRGH=0 so at 8MHz the baud rate is only accurate to 9.6kbaud. a

super-accurate baud rate the best way is to use a clock crystal that ends up giving you that

baud rate i.e. work back through the baud rate equations to find the crystal you need.

4.3.7 CCP 

The Capture/Compare/PWM module has three modes of operation:

Capture - Capture the time of an event.

Compare - Generate an output when Timer 1 reaches a value.

PWM - Pulse Width Modulation.

Page 20: Project Report Ackowledgement

CAPTURE 

Capture mode is used to capture the value of Timer 1 when a signal at the CCP pin

goes high (or low depending on how the CCP is set up).  The CCP can accurately capture the

arrival time of a signal at the CCP pin so it can be used for pulse time measurement.

COMPARE

Compare mode is used to generate an output when Timer 1 reaches a value you put

into CCPR1.  One special event trigger mode lets you start the ADC when the compare mode

triggers.

PWM

PWM gives you one Pulse Width Modulation output with 10 bit resolution and with

no software overhead - once started it operates all by itself unless you want to change the

duty cycle. It uses Timer 2 to define its operation using Timer 2 period register to define the

frequency of the PWM.

COMPARATOR and COMPARATOR VOLTAGE REFERENCE 

The comparator is module that has two analogue comparators which can be set up in

one of 8 different ways. Either digital or analogue inputs can be compared to reference

voltages. In one mode an internally generated voltage reference is used as an input to both

comparators and in the same mode multiplexing lets you monitor up to four different input

pins. We can even send the output of the comparator to a pin so that it is used  independently

from the microcontroller e.g. in a circuit where you need a comparator you don't need an

extra chip The analogue level must be between Vdd and Vss as protection diodes won't allow

anything else. The module will generate an interrupt if the comparator output changes.

You can use it in sleep mode and the interrupt will wake it up. The source impedance of the

analogue signal must be smaller than 10k.

Page 21: Project Report Ackowledgement

4.3.8 SSP 

The Synchronous Serial Port lets you communicate with devices that use either the

SPI (Serial Peripheral Interface) or I2C (Inter IC communication) protocols.  Note that for

full Master mode I2C operation you need to choose a PIC device that has the MSSP device

(Master Synchronous Serial Port). SPI and I2C are shared so you can only use one at a time

(or you could use the I2C bit banged routines in the Real Time Clock project to have both at

the same time).

4.3.9 PSP

The Parallel Slave Port lets you to connect the PIC microcontroller directly into a

microprocessor system. It provides an 8 bit read/write data bus and RD (read) WR (write) and

CS (chip select) inputs - all active low. This will let you add a PIC microcontroller to a

system so that the PIC microcontroller can be treated as a memory mapped peripheral.  It will

let the microcontroller behave just as though it was another microprocessor building block.

4.3.10 SPECIAL FEATURES

WDT

If your software goes haywire then this timer resets the processor.  To stop the reset

the well behaved software must periodically issue the CLRWDT instruction to stop a resert.

The WDT runs using its own oscillator.  It runs during sleep and shares Timer 0 prescaler.

POR

Power on Reset starts PIC microcontroller initialization when it detects a rising edge

on MCLR.

PWRT

If you enable this then 72ms after a POR the PIC microcontroller is started.

OST

Oscillator Start-up Timer delays for 1024 oscillator cycles after PWRT (if PWRT is

enabled) ensuring that the oscillator has started and is stable.  It is automatic and only used

for crystal oscillator modes and is active after POR or wake from sleep.

Page 22: Project Report Ackowledgement

SLEEP

Sleep mode (or low power consumption mode) is entered by executing the 'SLEEP'

command.  The device can wake from sleep caused by an external reset, Watch Dog Timer

timeout, INT pin RB port change or peripheral interrupt.

CURRENT

The PIC I/O ports are high current ports capable of directly driving LEDs (up to 25ma

output current) - the total current allowed usually ~200mA this is often for the whole chip (or

specified for several ports combined together). 

4.3.11 PIC MICROCONTROLLER FLASH MEMORY

The PIC 16F877a microcontroller have the flash memory about 8K which are used

here for the RISC programming instruction fetching and encoding this may also be the one of

the reason for the speed of calculation of the microcontroller to performing its particular

tasking.

This is the program storage area and gives you the most important benefit for using a

PIC microcontroller. You may think that 1k or even 8k is so tiny that it won't be useful but

each PIC microcontroller uses RISC (Reduced Instruction Set Computing) which simply

means that it has a cleverly arranged instruction set that only has a few instructions.  

The mid range parts have 35 instructions. If you use the high level language as

recommended in this site then you won't need to be too aware of the instruction set it just

means you can do a lot with a small amount of memory.  Most of the projects on this site

although they are fully working projects fit within 2k words.

4.3.12 PIC MICROCONTROLLER RAM

The PIC microcontroller RAM size is also important as it stores all your variables and

intermediate data. Note: You can usually alter the program to use less RAM by choosing the

right variable sizes or changing how your program works For example doesn’t use floating

point alter it to use a different variable type e.g. you can use long integers with fixed point

operation to avoid floating point.

Page 23: Project Report Ackowledgement

4.3.13 PIC MICROCONTROLLER EEROM

The PIC 16F877a microcontroller have the EEPROM value of 256k for programming

and fetching the opcodes that are give all the information’s to the microcontroller for its

operating tasks.

In our project there may have large usage about the rate of half of its wording space

for programming and passwords which are used for the security purpose through the keypad

interfacing and all the peripherals particulars.

Electrically Erasable ROM is used to store data that must be saved between power up

and power down. This area is readable and writable and has a much longer life than the main

program store i.e. it has been designed for more frequent use.

The EEPROM memory is basically used for the program that are written for

performing the particular tasks in the sequence that are instructed by the programmer for the

fast and reliable programming the Embedded C language is written by using the library

functions that are inbuilt in the compiler the EEPROM had the number of registers that are

called and stores the program data for any process of that particular microcontroller.

4.4 CODE LOCK WITH 4X3 KEYPAD

4.4.1 INTRODUCTION

Code locks make the task of access management more flexible and easy to configure.

Mechanical locks require new keys to be manufactured every time a user with access

privileges is added. The lock has to be reconfigured or replaced to change access privileges of

a single user, and it may also have to be replaced if any of the keys is lost. This module had

been used in this project to give the security to the owner of that particular vehicle to give

identification of their own password through this system. For the identification of the vehicle

also it need the well experienced and knowledge as well as consciousness of the driver. This

application note describes how to build a code lock with an PIC microcontroller and a

handful of components. The code lock uses a 4x3 keypad for user input, a piezoelectric

buzzer for audible feedback and an LCD for informational output. The design is based on

port output of the microcontroller, but can easily be migrated to other PIC microcontrollers.

Page 24: Project Report Ackowledgement

4.4.2 THEORY OF OPERATION

The code lock described in this application note consists of a PIC16F877a have the

inbuilt keypad, and an LCD, a piezoelectric buzzer and the actual (door) lock peripherals.

The PIC constantly scans the keypad for user input and will release the lock when the correct

number sequence has been entered. An LCD is used for feedback and status information. A

small piezoelectric buzzer is used for giving audible feedback on keystrokes and lock status.

4.4.3 KEYPAD

The input device is a standard 4x3 matrix keypad. The keypad contains 12 keys,

symmetrically arranged in four rows with four keys, each. Each column and row of the

keypad is connected to an I/O pin. The microcontroller continually scans the keypad by

setting all row pins except one to high and reading all column pins. All column inputs have

pull-up resistors enables so when a key is pressed the microcontroller will record a low level

on one of the column inputs.

1 2 3

4 5 6

7 8 9

C 0 S

FIGURE 4.2.4 3x4 KEYPAD LAYOUTS

Page 25: Project Report Ackowledgement

4.2.5 INTERFACING and LOCK CODE PROGRAMING

The lock code programming is easier in the pic c compiler in the base of

embedded c code, the two inbuilt functions are used for the code checking and interfacing

with the keypad two ports of the PIC microcontroller are used for the input and one port is

used for the output the flow chart shown below details the program flow of the code lock and

keypad interfacing of the PIC16f877a.

4.2.7 IMPLEMENTATION

The hardware implementation is rather straightforward. A prototype can be built

easily using PORTS A, B, &C, of 40pin PIC microcontroller, some jumper cables and the

essential keypad. The firmware is written entirely in C language. This is to make the design

easy to understand and to make further development of the design as straightforward as

possible. The software is fully documented in the doxygen documentation provided with the

source code. Compiler requirements and info are also listed in the file.

FIGURE 4.2.6 CODE LOCK FLOW CHART

Page 26: Project Report Ackowledgement

4.2.8 KEYPAD DRIVER

The keypad driver uses timer/counter 0 to time the scanning sequence. After a

timer/counter overflow the active keypad row is increased and wrapped around, when

necessary. A key push is registered and decoded via the Pin Change Interrupts.

Associated files:

• KPD.c

• KPD.h

Note: debug WIRE requires one of the pins used for the keypad interface. When the symbol

DEBUGWIRE in KPD.h is defined this pin will be freed for debugging, but the last row of

the keypad cannot be used.

4.2.9 EVENT TIMER

The design uses the watchdog timer as an event window handler. Each key press

refreshes the watchdog timer and if no key presses are detected within a predefined time the

watchdog interrupt will trigger. In PIC 28/40 it is possible to choose between a watchdog and

interrupt and a hardware reset. The watchdog interrupt service routine clears the keypad

buffer and erases the line of LCD where keystrokes have been recorded.

4.2.10 MULTIPLE ACCESS CODES

It is a simple task to add multiple access codes to the design. The only limit is the

amount of memory available. The default firmware fits into the memory of an ATtiny24

without code compression techniques. Applying code compression (by setting IAR compiler

to Release Mode) frees up some space for additional access codes. More space is naturally

available in pin and functionally compatible devices, such as PIC16F8xx.

4.2.11 FETURES

High sensitive

Accuracy

No need of external source

Inbuilt function

Page 27: Project Report Ackowledgement

Easy to interface

Low memory require

4.2.12 APPLICATION

Security

Identification

Safety measures

Home appliances

4.3 ALCOHOL SENSOR

At present drunken drivers have increased enormously and so is the deaths due to

drunken drivers. The main reason for driving drunk is that the police are not able to check

each and every car and even if they catch any one the police can be easily bribed. So there is

a need for a effective system to check drunken drivers. In our alcohol detection system the

ignition of the fuel is regulated by a sensor circuit. The sensor circuit is used to detect

whether alcohol was consumed by the driver recently. Our design also consists of a blood

pulse rate sensor which is used to check whether alcohol is consumed while driving.

4.3.1 INTRODUCTION

Drunken drivers have been let unchecked in the society. Though there are laws to

punish drunken drivers they cannot be fully utilized as police cannot stand on every road

corner to check each and every car driver whether he has drink or not. This leads to severe

accidents as such that happened in Delhi in which a car ran over four road dwellers killing

them on the spot. So there is a necessity to develop a efficient alcohol detection system.

4.3.2 WORKING PRINCIPLE OF ALCOHOL SENSOR

In our alcohol detection system the ignition circuit is controlled by interfacing a set of

sensors, logic circuit and a micro processor. We know that the ignition key of a vehicle has to

be turned in two steps, one for switching on the electrical circuit and second step for cranking

the engine. As per our design whenever the driver turns the first step a gas mask is dropped

down from the ceiling of the car. The driver has to exhale deeply through the mask. The

exhaled air reaches the sensor unit where it’s checked for co2 and alcohol. The alcohol and

Page 28: Project Report Ackowledgement

co2 sensor unit gives output as per the condition of the air through the logic circuit which is

sent to the micro processor. Depending upon the output the microprocessor controls the

ignition process.

4.3.3 DESIGN OF ALCOHOL SENSOR

The basic principle of alcohol sensor is that potassium dichromate salt changes its

colour when it reacts with alcohol. This is the principle of the alcohol detectors used by

police. Initially the potassium dichromate is in orange color which when reacts with alcohol it

turns green. This color change is detected by a photo sensor which generates signal as per the

change of color. The sensor equipment consists of potassium dichromate salt chamber in

which potassium dichromate salt pellets are loaded against the pressure of the spring loaded

piston. The chambers exit is closed by a solenoid port such that when the key is turned the

solenoid gets energized and the port is opened. When the port is opened due to piston

pressure a salt pellet is pushed into the testing chamber.

Initially the color of potassium di chromate is orange. When the driver is not drunken

there will be no reaction taking place so there will be no change is color, if the driver is

drunken there will be change in color. There is also one more instance in which the driver

does not breathe in at all so there will be no change in color. If such is a case then the design

is not fool proof. So in order to overcome this defect, CO2 sensors are installed in the system.

CO2 can be sensed by a ceramic sensor. The circuit consist of a testing chamber which

consists of a ceramic sensor which detects the presence of CO2. The sensor consist of a

ceramic material like zirconium which compares the carbon-di-oxide level in the test

chamber with that of pre programmed value and generates votage as per the co2 content

which is sent to the logic circuit.

4.3.4 C2H5OH (ALCOHOL) GAS SENSOR MODULE (MQ6)

These Gas Sensor Modules are designed to allow a microcontroller to determine when

a preset gas level has been reached or exceeded. The type of gas detected depends on which

module you are using. 27904 detect Alcohol (C2H5OH). Interfacing with these sensors is

done through a 4-pin SIP header and requires two I/O pins from the host microcontroller. The

sensor modules are intended to provide a means of comparing gas sources and being able to

set an alarm limit when the source becomes excessive. Parallax does not provide gas

Page 29: Project Report Ackowledgement

calibration data on these modules and such data as well as the alarm settings are the

responsibility of the user to define.

4.3.4.a CIRCUIT DIAGRAM FOR ALCOHOL SENSOR

4.3.5 FEATURES

Easy SIP header interface

Compatible with most microcontrollers

Low-power standby mode

4.3.6 KEY SPECIFICATIONS

Power requirements: 5 VDC @ ~165 mA (heater on) / ~60 mA (heater off)

Interface: 1 TTL compatible input (HSW), 1 TTL compatible output (ALR)

Operating temperature: 14 to 122 °F (-10 to 50°C)

Dimensions: 1.50 x 1.0 x 1.0 in (38.1 x 25.4 x 25.4 mm)

4.3.7 PACKING LIST

Gas Sensor

Gas Sensor PCB Assembly

Potentiometer adjustment tool

Page 30: Project Report Ackowledgement

4.3.8 PRECAUTIONS

Be aware that the gasses detected by these gas sensors can be deadly in high

Concentrations. Automotive exhaust and charcoal cooking grill exhausts emit carbon

monoxide (CO). Propane Gas (LPG) can leak from propane grills and furnaces and Methane

(CH4) can be found in animal farming areas.

Always be careful to perform gas tests in well ventilated areas. These gas sensor

modules are not designed for or approved for any Application involving health or human

safety. These gas sensor modules are For experimental purposes only.

Parallax, inc. Absolves itself of all liability And responsibility associated with the

customer's use of these gas sensor Modules and is not responsible for any bodily injury, death

or property Damage as a result of using these gas sensor modules.

4.3.9 CONNECTING AND TESTING

The gas sensor canister plugs into the socket on the front of the module. The gas

sensors are essentially resistive devices and are not polarized, so there is no need to be

concerned about plugging it in “backwards.” It will work in either orientation. The 4-pin SIP

header on the Gas Sensor Module makes it easy to connect to a breadboard or SIP socket.

The four connections are defined in the table below.

Connection to a 5V microcontroller, such as the BASIC Stamp® module, would be

pretty straight forward and require two I/O pins; one input for detecting the alarm signal and

the other an output for controlling the internal heater.

For a 3.3V microcontroller such as the Propeller TM chip, a 3.9 kΩ (10 kΩ could be used)

resistor would be required from the ALR output to the Propeller chip input pin. For the

Propeller to control the heater switch input (HSW) you would need an NPN switching

transistor, such as a 2N3904 and a 1 kΩ resistor. The schematic for this connection is shown

below.

Page 31: Project Report Ackowledgement

4.3.10 Switching circuit for the Propeller chip.

Note: HIGH signal is required to turn on heater due to inversion of signal by the transistor.

4.3.11 Pin Definitions and Ratings

4.3.12 THEORY OF OPERATION

These gas sensor modules use gas sensors from Hanwei Electronics. When their internal heating elements are activated, these gas sensors respond to their specific gas by reducing their resistance in proportion to the amount of that gas present in the air exposed to the internal element. On the gas sensor modules this is part of a voltage divider formed by the internal element of each gas sensor and potentiometer R3 (Set Point). The output of this voltage divider is fed into the non-inverting inputs of the two op-amps on the LT1013 dual op-amp IC. Op-amp A is configured as a buffer with unity gain and is used to provide a non-loaded test point for the signal voltage at TP1 (+) and TP2 (-). The signal voltage is also being fed into op-amp B which is configured as a comparator that gets its reference voltage at the inverting input from potentiometer R4 (Trip Level) and is also available at TP3 (+) and TP4 (-).

Page 32: Project Report Ackowledgement

The output of op-amp B goes out to the ALR pin through a 1 kΩ resistor providing a TTL-compatible signal to a microcontroller. This output also connects to a red LED on the gas sensor modules. The zero gas span adjustment is set via potentiometer R3. As mentioned above R3 allows you to change the span/range of the voltage divider formed by the gas sensor and R3 which is the bottom leg of the divider, electrically speaking. Adjusting R3 to lower values will make the gas sensor less sensitive but more stable. Avoid setting R3 below 200 ohms as at this point you will be close to shorting the output to ground. Setting R3 to higher values will make the gas sensor more responsive, but without a minimum load it will become unstable after a certain point. The trip level adjustment is set via potentiometer R4. This is just a simple voltage divider that lets you set the voltage from 0V to 5V. This voltage is compared to the voltage coming from the gas sensor/R3 divider. When the voltage from the gas sensor is higher than the voltage set by potentiometer R4 the red LED will light and the ALR output will be high (5 V). The section below describes how to configure these gas sensor modules to detect gas with minimal calibration.

4.3.12.1 Calibration

The procedure for setting these potentiometers is explained below. Please note that turning the potentiometer clockwise decreases voltage, while turning the potentiometer counter-clockwise increases it. This can be compared to a water valve.

For the CO sensor, please read the CO Sensor Specifics on page 5 before attempting calibration.

Place the Gas Sensor Module in a clean air environment and supply power to the module. The heater should be active during this time. Allow at least 10 minutes before making adjustments.

Adjust potentiometer R4 until the voltage across TP3 (+) and TP4 (-) reads approximately 0.80 V.

Adjust potentiometer R3 until the voltage across TP1 (+) and TP2 (-) reads approximately 0.80 V.

At this point adjusting R3 up/down should make the LED toggle on/off. Adjust R3 so the LED just goes off.

Apply your gas source to the gas sensor. The LED should light up.

Remove the gas source and allow the sensor to settle. The LED should go back out.

If the LED does not go out within 60 seconds, adjust R3 until the LED goes out and repeat the two previous steps.

The gas sensor module’s ALR pin should only be checked when the heater is on and the readings have stabilized.

Page 33: Project Report Ackowledgement

Note: Temperature and humidity are factors that could affect the sensor, making calibration difficult. If this should happen try adjusting the voltages used in the calibration up or down as necessary to find a more stable range.

4.3.13 SOURCES OF GAS FOR CALIBRATION / TESTING

The use of a standard butane hair curler is an easy, safe source to use for a very low

carbon monoxide (CO) gas concentration (less than 500 ppm) and can be used during

calibration and testing of the CO Gas Sensor Module. An unlit propane torch can be used as a

source for calibration and testing of the LPG Gas Sensor Module.

These are readily available from any hardware store and most department stores. Be

careful not to leave the valve open very long. Simply cracking the valve just a little can

trigger the gas sensor. We have not found an easy reliable source of methane for calibration

and testing of the CH4 Gas Sensor Module,

However the CH4 gas sensor is responsive to propane as well so that could be used

for testing. Breathing gently through a small plastic tube (a drinking straw will work) can be

used for calibrating the C2H5OH Gas Sensor Module. The tube will help get the gas to the

sensor and should condense most of the water vapour in your breath that may interfere with

the sensor.

4.3.14 TECHNICAL DATA MQ-6 GAS SENSOR

4.3.14.A. Standard work condition

Symbol Parameter name Technical condition Remarks

Vc Circuit voltage 5V±0.1 AC OR DC

VH Heating voltage 5V±0.1 ACOR DC

PL Load resistance 20KΩ

RH Heater resistance 33Ω±5% Room Tem

PH Heating consumption less than 750mw

Page 34: Project Report Ackowledgement

4.3.14.B. Environment condition

Symbol Parameter name Technical condition RemarksTao Using Tem -10 -50℃ ℃

Tas Storage Tem -20 -70℃ ℃RH Related humidity less than 95%Rh

O2 Oxygen concentration 21% (standard condition) Oxygen concentration can affect sensitivity is

over.

minimum value 2%

4.3.14.C. Sensitivity characteristic

Symbol Parameter name Technical condition Remarks

Rs Sensing Resistance 10KΩ- 60KΩ

(1000ppm LPG ) Detecting concentration scope:

200-10000ppm LPG, iso-butane, propane, LNG.

α(1000ppm/4000ppm LPG)

Concentration slope rate

≤0.6

Standard

detecting

condition

Temp: 20 }2 Vc:5V±0.1℃ ℃�

Humidity: 65%±5% Vh: 5V±0.1

Preheat time

Over 24 hour

4.3.14. D. Structure and configuration

Parts Materials1 Gas sensing layer SnO22 Electrode Au3. Electrode line Pt4. Heater coil Ni-Cr alloy5. Tubular ceramic Al2O36. Anti-explosion

NetworkStainless steel gauze(SUS316 100-mesh)

7. Clamp ring Copper plating Ni8. Resin base Bakelite9. Tube Pin Copper plating Ni

Page 35: Project Report Ackowledgement

4.3.15 BASIC MEASURING CIRCUIT

4.3.16 INTERNAL CIRCUIT OF ALCOHOL SENSOR

Page 36: Project Report Ackowledgement

4.3.17 CONFIGURATION DIAGRAM OF MQ-6

Structure and configuration of MQ-6 gas sensor is shown as Fig. 1 (Configuration A or B), sensor composed by micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitive layer, measuring electrode and heater are fixed into a crust made by plastic and stainless steel net. The heater provides necessary work conditions for work of sensitive components. The enveloped MQ-6 have 6 pin ,4 of them are used to fetch signals, and other 2 are used for providing heating current

4.3.18 SENSITIVITY CHARACTERISTICS OF THE MQ-6

Page 37: Project Report Ackowledgement

4.3.19. SENSITIVITY CHARACTERISTIC CURVE

Fig.4.3.19 is shows the typical dependence of the MQ-6 on temperature and humidity.

Ro: sensor resistance at 1000ppm of LPGin air at 33%RH and 20 degree.

Rs: sensor resistance at 1000ppm of LPG in air at different temperatures and humidity’s.

4.3.20 SENSITVITY ADJUSTMENT

Resistance value of MQ-6 is difference to various kinds and various concentration

gases. So, when using this component, sensitivity adjustment is very necessary. we

recommend that you calibrate the detector for 1000ppm of LPG concentration in air and use

value of Load resistance ( RL) about 20KΩ(10KΩ to 47KΩ). When accurately measuring,

the proper alarm point for the gas detector should be determined after considering the

temperature and humidity influence.

4.4 RELAY UNIT

A relay is an electrically operated switch. Many relays use an electromagnet to

operate a switching mechanism mechanically, but other operating principles are also used.

Relays are used here for controlling the output dc motor while it get signals from the PIC

microcontroller these are driven the motor circuits while at using the starting and also for the

motor that is for using the door opening of that particular vehicle after giving the correct

password, The first relays were used in door opening DC motor circuits, repeating the signal

coming in from one circuit and re-transmitting it to another. Relays were used extensively in

switching board of the project and used to give the output to the two motors externally that

are connected with the relay circuit directly.

Page 38: Project Report Ackowledgement

A type of relay that can handle the high power required to directly drive an electric

motor is called a contactor. Relays control power circuits with no moving parts, instead using

a semiconductor device to perform switching. Relays with calibrated operating characteristics

and sometimes multiple operating coils are used to protect electrical circuits from overload or

faults; in modern electric power systems these functions are performed by digital instruments

still called "protective relays".

A contactor is a very heavy-duty relay used for switching electric motors and lighting

loads, although contactors are not generally called relays. Continuous current ratings for

common contactors range from 10 amps to several hundred amps. High-current contacts are

made with alloys containing silver. The unavoidable arcing causes the contacts to oxidize;

however, silver oxide is still a good conductor. Such devices are often used for motor starters.

A motor starter is a contactor with overload protection devices attached. The overload

sensing devices are a form of heat operated relay where a coil heats a bi-metal strip, or where

a solder pot melts, releasing a spring to operate auxiliary contacts. These auxiliary contacts

are in series with the coil. If the overload senses excess current in the load, the coil is de-

energized. Contactor relays can be extremely loud to operate, making them unfit for use

where noise is a chief concern.

Since relays are switches, the terminology applied to switches is also applied to

relays. A relay will switch one or more poles, each of whose contacts can be thrown by

energizing the coil in one of three ways:

o COM = Common, always connect to this; it is the moving part of the switch

o NC = Normal Closed, COM is connected to this when the relay coil is OFF.

o NO = Normal Open, COM is connected to this when the relay coil is ON.

The relay switches are used here for the normal open Com that why they use to give

the turn ON of the motor used to open the door after that the NO COM relay circuit is used

for the starting of the vehicle engine to get starting after the negative output is taken from the

alcohol sensor that may decided by the microcontroller based upon the program.

Page 39: Project Report Ackowledgement

4.4.2 RELAY CIRCUIT DISCRIPTION

4.4.2 RELAY CIRCUIT-SPST

Parts:

R1 5K 1/4W Resistor

R2, R3, R4 5K Pot

Q1 NPN Phototransistor

Q2 2N3906 PNP Transistor

K1 Low Current 12V SPST Relay

K2 High Current 12V SPDT Relay

S1 SPST Switch

B1 Car Battery

MISC Case, wire, board, knobs for pots

Normally-open (NO) contacts connect the circuit when the relay is activated; the circuit is

disconnected when the relay is inactive. It is also called a Form A contact or "make" contact.

NO contacts can also be distinguished as "early-make" or NOEM, which means that the

contacts will close before the button or switch is fully engaged. Normally-closed (NC)

contacts disconnect the circuit when the relay is activated; the circuit is connected when the

relay is inactive. It is also called a Form B contact or "break" contact.NC contacts can also be

distinguished as "late-break" or NCLB, which means that the contacts will stay, closed until

Page 40: Project Report Ackowledgement

the button or switch is fully disengaged. Change-over (CO), or double-throw (DT), contacts

control two circuits: one normally-open contact and one normally-closed contact with a

common terminal. It is also called a Form C contact or "transfer" contact ("break before

make"). If this type of contact utilizes “make before break" functionality, then it is called

a Form D contact.

4.4.3 WORKING CONDITION

Voltage signal

from

Microcontroller

Transistor Q1 Transistor Q2 Relay

1 On Off Off

0 Off On On

4.4.3 RELAY SWITICHING CONDITION

4.4 DC MOTOR

The DC motor used here for the demonstration of the vehicle for the door opening

after the correct password given through the keypad input from the ports and also there were

using another motor for the vehicle running and starting of the produced output from the port

signalling of the microcontroller.

When a current passes through the coil wound around a soft iron core, the side of the

positive pole is acted upon by an upwards force, while the other side is acted upon by a

downward force. According to Fleming's left hand rule, the forces cause a turning effect on

the coil, making it rotate. To make the motor rotate in a constant direction, "direct current"

commutators make the current reverse in direction every half a cycle (in a two-pole motor)

thus causing the motor to continue to rotate in the same direction. A problem with the motor

shown above is that when the plane of the coil is parallel to the magnetic field—i.e. when the

rotor poles are 90 degrees from the stator poles—the torque is zero. In the pictures above, this

occurs when the core of the coil is horizontal—the position it is just about to reach in the last

picture on the right. The motor would not be able to start in this position. However, once it

Page 41: Project Report Ackowledgement

was started, it would continue to rotate through this position by inertia. There is a second

problem with this simple pole design. At the zero-torque position, both commutator brushes

are touching (bridging) both commutator plates, resulting in a short-circuit. The power leads

are shorted together through the commutator plates, and the coil is also short-circuited

through both brushes (the coil is shorted twice, once through each brush independently).

Note that this problem is independent of the non-starting problem above; even if there were a

high current in the coil at this position, there would still be zero torque. The problem here is

that this short uselessly consumes power without producing any motion (nor even any coil

current.) In a low-current battery-powered demonstration this short-circuiting is generally not

considered harmful. However, if a two-pole motor were designed to do actual work with

several hundred watts of power output, this shorting could result in severe commutator

overheating, brush damage, and potential welding of the brushes—if they were metallic—to

the commutator. Carbon brushes, which are often used, would not weld. In any case, a short

like this is very wasteful, drains batteries rapidly and, at a minimum, requires power supply

components to be designed to much higher standards than would be needed just to run the

motor without the shorting.

4.4.1 WORKING OF DC MOTOR

A simple DC electric motor. When the coil is powered, a magnetic field is generated

around the armature. The left side of the armature is pushed away from the left magnet and

drawn toward the right, causing rotation. Even for fans and flywheels, the clear weaknesses

remaining in this design—especially that it is not self-starting from all positions—make it

impractical for working use, especially considering the better alternatives that exist. Unlike

the demonstration motor above, DC motors are commonly designed with more than two

poles, are able to start from any position, and do not have any position where current can

flow without producing electromotive power by passing through some coil. Many common

Page 42: Project Report Ackowledgement

small brushed DC motors used in toys and small consumer appliances, the simplest mass-

produced DC motors to be found, have three-pole armatures. The brushes can now bridge two

adjacent commutator segments without causing a short circuit. These three-pole armatures

also have the advantage that current from the brushes either flows through two coils in series

or through just one coil. Starting with the current in an individual coil at half its nominal

value (as a result of flowing through two coils in series), it rises to its nominal value and then

falls to half this value. The sequence then continues with current in the reverse direction. This

results in a closer step-wise approximation to the ideal sinusoidal coil current, producing a

more even torque than the two-pole motor where the current in each coil is closer to a square

wave. Since current changes are half those of a comparable two-pole motor, arcing at the

brushes is consequently less.

If the shaft of a DC motor is turned by an external force, the motor will act like a

generator and produce an Electromotive (EMF). During normal operation, the spinning of the

motor produces a voltage, known as the counter-EMF (CEMF) or back EMF, because it

opposes the applied voltage on the motor. The back EMF is the reason that the motor when

free-running does not appear to have the same low electrical resistance as the wire contained

in its winding. This is the same EMF that is produced when the motor is used as a generator

(for example when an electrical load, such as a light bulb, is placed across the terminals of

the motor and the motor shaft is driven with an external torque). Therefore, the total voltage

drop across a motor consists of the CEMF voltage drop, and the parasitic voltage drop

resulting from the internal resistance of the armature's windings. The current through a motor

is given by the following equation:

The mechanical power produced by the motor is given by:

As an unloaded DC motor spins, it generates a backwards-flowing electromotive force

that resists the current being applied to the motor. The current through the motor drops as the

rotational speed increases, and a free-spinning motor has very little current. It is only when a

load is applied to the motor that slows the rotor that the current draw through the motor

increases.

Page 43: Project Report Ackowledgement

4.4.2 THE COMMUTATING PLANE

In a dynamo, a plane through the centers of the contact areas where a pair of brushes

touches the commutator and parallel to the axis of rotation of the armature is referred to as

the commutating plane. In this diagram the commutating plane is shown for just one of the

brushes, assuming the other brush made contact on the other side of the commutator with

radial symmetry, 180 degrees from the brush shown.

4.4.2. ARMATURE CONSTRUCTION OF DC MOTOR

4.4.3 COMPENSATION FOR STATOR FIELD DISTORTION

In a real dynamo, the field is never perfectly uniform. Instead, as the rotor spins it induces

field effects which drag and distort the magnetic lines of the outer non-rotating stator.

Exaggerated example of how the field is

distorted by the rotor.

Iron filings show the distorted field across

the rotor.

The faster the rotor spins, the further the degree of field distortion. Because the

dynamo operates most efficiently with the rotor field at right angles the stator field, it is

Page 44: Project Report Ackowledgement

necessary to either retard or advance the brush position to put the rotor's field into the correct

position to be at a right angle to the distorted field.

4.4.4 SPEED CONTROL

Here the speed control of the DC motor is needed at the stage of the second working

stage to reduce the speed control while the sensor is detecting the alcohol content present in

the driver breath at the time of the running condition. Then the microcontroller will switch to

the pwm module for reducing the speed of that particular vehicle for the demonstration

purpose here we are controlling the speed of the DC motor by controlling the voltage applied

to it that is it will switch it into low voltage output to the motor circuit.

Generally, the rotational speed of a DC motor is proportional to the voltage applied to

it, and the torque is proportional to the current. Speed control can be achieved by variable

battery tapings, variable supply voltage, resistors or electronic controls. The direction of a

wound field DC motor can be changed by reversing either the field or armature connections

but not both. This is commonly done with a special set of contactors (direction contactors).

The effective voltage can be varied by inserting a series resistor or by an

electronically controlled switching device made of thyristors, transistors, or,

formerly, mercury arc rectifiers. In a circuit known as a chopper, the average voltage applied

to the motor is varied by switching the supply voltage very rapidly. As the "on" to "off" ratio

is varied to alter the average applied voltage, the speed of the motor varies.

The percentage "on" time multiplied by the supply voltage gives the average voltage

applied to the motor. Therefore, with a 100 V supply and a 25% "on" time, the average

voltage at the motor will be 25 V. During the "off" time, the armature's inductance causes the

current to continue through a diode called a "fly back diode", in parallel with the motor.

At this point in the cycle, the supply current will be zero, and therefore the average

motor current will always be higher than the supply current unless the percentage "on" time is

100%. At 100% "on" time, the supply and motor current are equal. The rapid switching

wastes less energy than series resistors. This method is also called pulse-width

modulation (PWM) and is often controlled by a microprocessor. An output filter is sometimes

installed to smooth the average voltage applied to the motor and reduce motor noise.

Since the series-wound DC motor develops its highest torque at low speed, it is often

used in traction applications such as electric locomotives, and trams. Another application is

starter motors for petrol and small diesel engines. Series motors must never be used in

applications where the drive can fail. As the motor accelerates, the armature current reduces.

Page 45: Project Report Ackowledgement

The reduction in field causes the motor to speed up until it destroys itself. This can also be a

problem with railway motors in the event of a loss of adhesion since, unless quickly brought

under control, the motors can reach speeds far higher than they would do under normal

circumstances. This can not only cause problems for the motors themselves and the gears, but

due to the differential speed between the rails and the wheels it can also cause serious damage

to the rails and wheel treads as they heat and cool rapidly. Field weakening is used in some

electronic controls to increase the top speed of an electric vehicle.

Page 46: Project Report Ackowledgement

CHAPTER 5

5 SOFTWARE DISCRIPTION

5.1 CCS C Compiler

Intelligent and highly optimized CCS C compilers contain Standard C operators and

Built-in Function libraries that are specific to PIC registers, providing developers with a

powerful tool for accessing device hardware features from the C language level. Standard C

pre processors, operators and statements can be combined with hardware specific directives

and CCS provided built-in functions and example libraries to quickly develop applications

incorporating leading edge technologies such as capacitive touch, wireless and wired

communication, motion and motor control and energy management.

5.2 BENEFITS OF C COMPILER

CCS provides a complete integrated tool suite for developing and debugging embedded

applications running on Microchip PIC®MCUs and dsPIC® DSCs. The heart of this

development tools suite is the CCS intelligent code optimizing C compiler which frees

developers to concentrate on design functionality instead of having to become an MCU

architecture expert.

Maximize code reuse by easily porting from one MCU to another. Device Support

Minimize lines of new code with CCS provided peripheral drivers, built-in

functions and standard C operators

Built-in functions  are specific to PIC® MCU registers, allowing access to hardware

features directly from C

5.3 DEVICE SPECIFIC OPTIMIZATION AND INITIALIZATION

Device specific include files contain all the information the compiler needs to optimize

code generation for the specific PIC® MCU.

Op-code length

Memory size

Pin functionality

Page 47: Project Report Ackowledgement

Memory banking

Peripheral resources

Hardware stack size

This detailed information enables the compiler to make intelligent decisions regarding

code optimization at the sub family and device level, generating denser code than would be

possible if the compiler treated all devices within a Microchip PIC® family the same. Learn

how an optimizing C compiler.

The device specific include files also initialize device registers and peripherals,

relieving developers from the tedium of studying data sheets to learn register map details,

flag settings, etc.

The compiler can handle in-line or separate functions, as well as parameter passing in

re-usable registers. Transparent to the user, the compiler handles calls across pages

automatically and analyzes program structure and call tree processes to optimize RAM and

ROM Usage.

5.4 COMPILER DEVICE SUPPORT for PIC16F877A

OPCODE RANGE

Midrange; 14-bit opcodes; CCS PCM Compiler

H/W FEATURES

UART(9)

ADC(8)

EEPROM(256)

SPI I2C-M

COMP

VREF

PSP

TIMERS(3)

CCP(2 )

Page 48: Project Report Ackowledgement

PRGMEM

I/O Pins -33

Ready to run examples and tested peripheral drivers allow developers to quickly start

their project. To learn more about our C compiler, check out the compiler details and view

the CCS Compiler Quick Start Webinar.

The C Aware IDE is an ideal environment to create C source code with integrated

built-in functions, analyze it's performance, and debug the compiled code in real-time while

running on Microchip devices.

Key C Aware IDE Components:

Project manager

C-Aware text editor

Compilation control to completely or partially build projects

Utilities for file comparison, numeric conversion, disassembly, parametric device

selection and more

C-Source code level in-circuit debugger

Output file viewers for list files, symbol maps, call trees, etc.

Documentation creation tools

5.4 EMBEDDED C PROGRAMMING

5.4.1 Syntax and Functions

Items marked with * are for PIC10 – PIC18 compilers only.

Items marked with + are for PIC24 and dsPIC® compilers only.

Page 49: Project Report Ackowledgement

5.4.2 STANDARD C SYNTAX:

· if, else, while, do, switch, case, for, return,

goto, break, continue

· Structures and Unions may be nested.

· ! ~ ++ -- * = = , & | · Custom bit fields (1-8 bits) within

structures.

· * / % << >> ^ && || ?: · ENUMurated types

· <= < > >= == != · Constant variables, arrays, structures and

strings.

· = += -= *= /= %= >>= <<= &= ^=m |= · Full function parameter support (any

number and kind).

· typedef, static, auto, const, enum,

struct, union

· C++ reference parameters and comments

allowed

· Arrays up to 5 subscripts

5.5 BUILT-IN FUNCTIONS: 

There are many built-in functions are available in the pic c compiler, that are use at the

time of programming to give an easier and efficient programming for the user here shown

below all the built-in functions of the compiler is listed below.

Page 50: Project Report Ackowledgement

_mul( )

abs( )

acos( )

adc_done( )

adc_done( )

adc_done2( )+

adc_done2( )+

asin( )

assert( )

atan( )

atan2( )

atoe( )

atof( )

atof48( )+

atof64( )+

atoi( )

atoi32( )+

atoi48( )+

atol( )

atol32( )*

bit_clear( )

bit_first( )+

bit_last( )+

bit_set( )

bit_test( )

brownout_enable( )*

bsearch( )

calloc( )

ceil( )

clear_interrupt( )

cos( )

cosh( )

crc_calc(mode)+

crc_calc8( )+

crc_init(mode)+

dac_write( )

dci_data_received( )+

dci_read( )+

dci_start( )+

dci_transmit_ready( )

+

dci_write( )+

delay_cycles( )

delay_ms( )

delay_us( )

disable_interrupts( )

div( )

dma_start( )+

dma_status( )+

enable_interrupts( )

erase_eeprom( )*

erase_program_eepro

m( )*

erase_program_memo

ry( )+

exp( )

ext_int_edge( )

fabs( )

fgetc( )

fgets( )

floor( )

fmod( )

fprintf( )

fputc( )

fputs( )

free( )

frexp( )

get_capture( )+

get_motor_pwm_coun

t( )+

Page 51: Project Report Ackowledgement

get_timer_x( )*

get_timerx( )+

get_timerxy( )+

get_tris_x( )

getc( )

getch( )

getchar( )

getenv( )

gets( )

goto_address( )

i2c_isr_state( )

i2c_poll( )

i2c_read( )

i2c_slaveaddr( )

i2c_speed( )

i2c_start( )

i2c_stop( )

i2c_write( )

input( )

input_change_x( )

input_state( )

input_x( )

interrupt_active( )

isalnum( )

isalpha(char)

isamong( )

iscntrl(x)

isdigit(char)

isgraph(x)

islower(char)

isprint(x)

ispunct(x)

isspace(char)

isupper(char)

isxdigit(char)

itoa( )

jump_to_isr( )*

kbhit( )

label_address( )

labs( )

lcd_contrast( )*

lcd_load( )*

lcd_symbol( )*

ldexp( )

ldiv( )

log( )

log10( )

longjmp( )

make16( )

make32( )

make8( )

malloc( )

memchr( )

memcmp( )

memcpy( )

memmove( )

memset( )

modf( )

nargs( )

offsetof( )

offsetofbit( )

output_X( )*

output_bit( )

output_drive( )

output_float( )

output_high( )

output_low( )

output_toggle( )

output_x( )+

Page 52: Project Report Ackowledgement

perror( )

pmp_address(address)

+

pmp_input_full( )+

pmp_output_full( )+

pmp_overflow( )+

pmp_read( )+

pmp_write( )+

port_x_pullups( )*

pow( )

printf( )

psp_input_full( )

psp_output_full( )

psp_overflow( )

psp_read( )+

psp_write( )+

putc( )

putchar( )

puts( )

pwr( )+

qei_get_count( )+

qei_set_count( )+

qei_status( )+

qsort( )

rand( )

read_adc( )

read_adc( )

read_adc2( )+

read_adc2( )+

read_bank( )*

read_calibration( )*

read_configuration_m

emory( )

read_eeprom( )

read_external_memor

y( )*

read_program_eepro

m( )*

read_program_memor

y( )

read_rom_memory( )

+

realloc( )

reset_cpu( )

restart_cause( )

restart_wdt( )

rotate_left( )

rotate_right( )

rtc_alarm_read( )*

rtc_alarm_read( )+

rtc_alarm_write( )*

rtc_alarm_write( )+

rtc_read( )*

rtc_read( )+

rtc_write( )+

rtos_await( )

rtos_disable( )

rtos_enable( )

rtos_msg_poll( )

rtos_msg_read( )

rtos_msg_send( )

rtos_overrun( )

rtos_run( )

rtos_signal( )

rtos_stats( )

rtos_terminate( )

rtos_wait( )

rtos_yield( )

set_adc_channel( )

set_adc_channel( )

Page 53: Project Report Ackowledgement

set_adc_channel2( )+

set_adc_channel2( )+

set_compare_time( )+

set_motor_pwm_duty

( )+

set_motor_pwm_even

t( )+

set_motor_unit( )+

set_power_pwm_over

ride( )*

set_power_pwmx_dut

y( )*

set_pullup( )+

set_pwm1_duty( )*

set_pwm2_duty( )*

set_pwm3_duty( )*

set_pwm4_duty( )*

set_pwm5_duty( )*

set_pwm_duty( )+

set_rtcc( )*

set_timerx( )

set_timerxy( )+

set_tris_x( )

set_uart_speed( )

setjmp( )

setup_adc( )

setup_adc( )

setup_adc2( )+

setup_adc2( )+

setup_adc_ports( )

setup_adc_ports( )

setup_adc_ports2( )+

setup_adc_ports2( )+

setup_capture( )+

setup_ccp1( )*

setup_ccp2( )*

setup_ccp3( )*

setup_ccp4( )*

setup_ccp5( )*

setup_ccp6( )*

setup_comparator( )*

setup_comparator( )+

setup_compare( )+

setup_counters( )*

setup_crc(mode)+

setup_dac( )

setup_dac( )*

setup_dci( )+

setup_dma( )+

setup_external_memo

ry( )*

setup_lcd( )*

setup_low_volt_detect

( )+

setup_motor_pwm( )+

setup_opamp1( )*

setup_opamp2( )*

setup_oscillator( )

setup_pmp( )*

setup_pmp(option,

address_mask)+

setup_power_pwm( )

setup_power_pwm_pi

ns( )

setup_psp(option,

address_mask)

setup_qei( )+

setup_rtc( )*

setup_rtc( )+

setup_rtc_alarm( )*

setup_rtc_alarm( )+

Page 54: Project Report Ackowledgement

setup_spi( )

setup_spi2( )

setup_timer_0( )*

setup_timer_1( )*

setup_timer_2( )*

setup_timer_3( )*

setup_timer_4( )*

setup_timer_5( )*

setup_timerx ( )+

setup_uart( )

setup_vref( )+

setup_wdt ( )+

setup_wdt( )*

shift_left( )

shift_right( )

sin( )

sinh( )

sleep( )

sleep_ulpwu( )*

spi_data_is_in( )

spi_data_is_in2( )

spi_read( )

spi_read2( )

spi_write( )

spi_write2( )

spi_xfer( )

sprintf( )

sqrt( )

srand( )

strcat( )

strchr( )

strcmp( )

strcoll( )

strcopy( )

strcpy( )

strcspn( )

strerror( )

stricmp( )

strlen( )

strlwr( )

strncat( )

strncmp( )

strncpy( )

strpbrk( )

strrchr( )

strspn( )

strstr( )

strtod( )

strtof( )+

strtof48( )+

strtok( )

strtol( )

strtoul( )

strxfrm( )

swap( )

tan( )

tanh( )

tolower( )

touchpad_getc( )

touchpad_hit( )

touchpad_state( )

toupper( )

va_arg( )

va_end( )

va_start( )

write_bank( )*

write_configuration_

memory( )

write_eeprom( )

Page 55: Project Report Ackowledgement

write_external_memo

ry( )*

write_program_eepro

m( )*

write_program_memo

ry( )

Page 56: Project Report Ackowledgement

5.6 PRE-PROCESSORS: 

Page 57: Project Report Ackowledgement

#ASM #BANKX+

#BANKY+

#BANK_DMA+

#BIT =const.const*

#BIT id=id.const*

#BIT+

#BUILD

#BYTE id=const*

#BYTE id=id*

#BYTE+

#CASE

#DEFINE id string*

#DEFINE+

#DEFINEDINC

#DEVICE chip

#ELIF

#ELSE

#ENDASM

#ENDIF

#ERROR

#EXPORT

#EXPORT*

#FILL_ROM

#FUSES options

#HEXCOMMENT

#ID "filename"*

#ID CHECKSUM*

#ID number*

#ID+

#IF expr*

#IF+

#IFDEF id*

#IFDEF+

#IFNDEF

#IGNORE_WARNINGS

#IMPORT

#IMPORT*

#INCLUDE FILENAME"*

#INCLUDE+

#INLINE

#INT_DEFAULT

#INT_GLOBAL*

#INT_xxx

#LINE*

#LIST

#LOCATE id=const*

#LOCATE+

#MODULE

#NOLIST

#OCS

#OPT

#ORG

#PIN_SELECT

#PRAGMA cmd*

#PRAGMA+

#PRIORITY*

#RECURSIVE+

#RESERVE

#ROM

#SEPARATE

#SERIALIZE

#TASK

#TYPE

#UNDEF id*

#UNDEF+

#USE DELAY

#USE DYNAMIC_MEMORY

#USE FAST_IO

#USE FIXED_IO

#USE I2C

#USE RS232

#USE RTOS

#USE SPI

#USE STANDARD_IO

#USE TOUCHPAD

#WARNING

#WORD

#ZERO_RAM

_ _DATE_ _

_ _DEVICE_ _

_ _FILENAME_ _

_ _FILE_ _

Page 58: Project Report Ackowledgement

_ _LINE_ _

_ _PCB_ _*

_ _PCD_ _+

_ _PCH_ _*

_ _PCM_ _*

_ _TIME_ _

Page 59: Project Report Ackowledgement

5.7 Optimized String Handling

String compression for 7-bit ASCII strings has been implemented for Microchip's 14-

bit opcodes PIC12 and PIC16 families. Studies conducted by CCS show that string functions

that used to take 2,300 bytes of ROM to implement now consume as little as 1,884, a savings

of 18%.

Strings can be used in switch statements, making it much easier developers to perform

string comparisons. Comparisons that can take many individual string handling function calls

to implement with other compilers can be handled directly in the switch statement, resulting

in tighter and more maintainable source code and a smaller ROM footprint.

Variable Length Constant Strings

Formatted printf allows easy formatting and display in HEX or decimal.

Efficient Bit Oriented Code

Standard one bit type (Short Int) permits the compiler to generate very efficient bit

oriented code.

Bit Arrays

Efficient Data Structures Mapped into Program Memory

Flexible constant data structure handling  allows the compiler to handle lookup tables

that are virtually unlimited in size. This is of particular interest to developers using

large lookup tables for trigonometric functions or storing FPGA configuration

memory images in on-chip MCU memory.

Constants (including strings and arrays) are saved in program memory

DSP performance can be enhanced by manually assigning variables to data spaces for

faster access with pre-processor directives

Page 60: Project Report Ackowledgement

5.8 ARITHMETIC LIBRARIES

 Standard C math libraries are supplied with the CCS compiler.

1, 8, 16 and 32-bit integer types and 32-bit floating point are supported for all devices

48 and 64-bit integer types and 64-bit floating point for PIC24 and dsPIC DSC devices

The compiler also has the ability to represent decimal numbers using a new data type, the fixed point decimal.

Fixed point decimal  gives you decimal representation, but at integer speed. This gives you a phenomenal speed boost over using float.

DSP in-line assembly is supported for your most performance critical code.