Mini Project Documentation

60
1.OVERVIEW 1.1 INTRODUCTION Nowadays with the advancement of technology particularly in the field of micro-controllers,all the activities in our day-to-day living have become part of information technology and we find controllers in each and every application. In this project work ATMEL 89S52 micro-controller is used, this is 8-bit micro-controller. This circuit is designed with ultrasonic sensors. When the signal is interrupted due to the obstacle, the circuit generates high signal and it is fed to microcontroller. In this way accidents can be avoided to certain extent. 1.2 AIM OF THE SYSTEM The main objective of the system is designing a system that can detect any obstacle in the path of a vehicle. This is achieved by sending and receiving signals using embedded based micro-controller concept. 1.3 METHODOLOGY The problems that surfaced during the project were selecting the right kind of device and interfacing these devices appropriately. The approach used was to minimize costs and complexity and at the same time not sacrifice the objectives of the project. 1

Transcript of Mini Project Documentation

Page 1: Mini Project Documentation

1.OVERVIEW

1.1 INTRODUCTION

Nowadays with the advancement of technology particularly in the field of micro-

controllers,all the activities in our day-to-day living have become part of information

technology and we find controllers in each and every application. In this project work

ATMEL 89S52 micro-controller is used, this is 8-bit micro-controller. This circuit is

designed with ultrasonic sensors. When the signal is interrupted due to the obstacle, the

circuit generates high signal and it is fed to microcontroller. In this way accidents can be

avoided to certain extent.

1.2 AIM OF THE SYSTEM

The main objective of the system is designing a system that can detect any obstacle in

the path of a vehicle. This is achieved by sending and receiving signals using embedded

based micro-controller concept.

1.3 METHODOLOGY

The problems that surfaced during the project were selecting the right kind of device

and interfacing these devices appropriately. The approach used was to minimize costs

and complexity and at the same time not sacrifice the objectives of the project.

Hardware Specifications:

AT89S52 Micro-controller

Ultrasonic Sensors

LCD Display

Buzzer

Resistors, Capacitors, Transformer, Regulator

Software Specifications:

Keil Compiler

Language: Embedded C or Assembly Language

1

Page 2: Mini Project Documentation

1.4 SIGNIFICANCE OF THE WORK

The keep distance warning system using embedded based micro-controller concept is

a basic program for avoiding accidents due to any obstacle. This principle can be further

utilized to develop superior programs. Thus, it can be used in various applications like

home appliances, economic security, automobiles etc…

1.5 ORGANIZATION OF WORK

In this report, Chapter 1 deals with a brief introduction and aim of the project.

Chapter 2 covers the information about embedded systems and the block diagram of the

project. Micro-controller concept is discussed in Chapter 3 which is followed by Chapter

4 which covers Regulated power supply. Chapter 5 deals with ultrasonic sensors. Chapter

6 deals with LCD display and Chapter 7 covers about buzzers. The report also has the

software used and coding of the project in Chapter 8 and finally followed by results and

conclusion.

2

Page 3: Mini Project Documentation

2. INTRODUCTION TO EMBEDDED SYSTEMS

2.1 EMBEDDED SYSTEMS

An embedded system is a special purpose computing system designed to perform

one or a few dedicated functions, often with real time computing constraints. It is usually

embedded as a part of a complete device including hardware and software. In contrast, a

general purpose computer, such as a personal computer can do many different tasks

depending on programming. Embedded systems have become very important today as

they control many of the common devices we use.

Many embedded systems have substantially different design constraints than

desktop computing applications. No single characterization applies to the diverse

spectrum of embedded systems. However, some combination of cost pressure, long life-

cycle, real time requirements, reliability requirements and design function dis-culture can

make it difficult to be successful applying traditional computer systems methodologies

and tools to embedded applications. Embedded systems in many cases must be optimized

for life-cycle and business driven factors rather than for maximum computing

throughput. There is currently little tool support for expanding embedded computer

design to the scope of holistic embedded system design. However, knowing the strengths

and weaknesses of current approaches can set expectations appropriately, identify risk

areas to tool adopters and suggest ways in which tool builders can meet industrial needs.

Since the embedded system is dedicated to specific tasks, design engineers can

optimize it, reducing the cost of the product or increasing the reliability and performance.

Some embedded systems are mass produced and thus benefit from economies of scale.

2.2 EXAMPLES OF EMBEDDED SYSTEMS

An embedded system encompasses the CPU as well as many other resources. In

addition to the CPU and memory hierarchy, there are a variety of interfaces that enable

the system to measure, manipulate and otherwise interact with the external environment.

Some differences with desktop computing may be:

3

Page 4: Mini Project Documentation

The human interface may be as simple as a flashing light or as complicated as real time

robotic vision.

The diagnostic part may be used for diagnosing the system that is being controlled and

not just for diagnosing the computer.

Special purpose field programmable (FPGA), application specific (ASIC) or evev non-

digital hardware may be used to increase the performance or safety.

Software often has a fixed function and is specific to the application.

Instead of executing spreadsheets, word processing and engineering analysis. Embedded

systems typically execute control laws, finite state machines and signal processing

algorithms. They must often detect and react to faults in both, the computing and

surrounding electromechnical systems and must manipulate application specific use.

2.3 BLOCK DIAGRAM

Using the embedded systems concept, the keep distance warning system can be

used to detect the obstacle and avoid accidents to some extent. The block diagram for it is

as given below:

Fig 2.3: Block Diagram of the System

4

AT 89S52

MICRO -

CONTROLLER

LCD DISPLAYPOWER

SUPPLY

ULTRASONIC SENSOR

BUZZER

Page 5: Mini Project Documentation

3. MICROCONTROLLER

3.1 INTRODUCTION

A micro-controller consists of a powerful CPU tightly coupled with memory,

various I/O interfaces such as serial port, parallel port, timer or counter, interrupt

controller, data acquisition interfaces like A/D converter, D/A converter integrated on a

single silicon chip.

If a system is developed with a microprocessor, the designer has to go for external

memory such as RAM, ROM, EPROM and peripherals. But controller is provided with

all these facilities on a single chip. Development of a micro-controller reduces PCB size

and cost of the design.

One of the major differences between a micro-processor and a micro-controller is

that a controller often deals with bits not bytes as in the real world application. Intel has

introduced a family of micro-controllers called the MCS-51.

3.2 FEATURES

Compatible with MCS-51 Products

8 Kbytes 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

256 x 8-Bit Internal RAM

32 Programmable I/O Lines

Three 16-Bit Timer/Counters

Six Interrupt Sources

Programmable Serial Channel

Low Power Idle and Power Down Modes

5

Page 6: Mini Project Documentation

3.3 DESCRIPTION OF AT89S52

The AT89S52 provides the following standard features: 8Kbytes of Flash, 256 bytes

of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level interrupt

architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition,

the AT89S52 is designed with static logic for operation down to zero frequency and

supports two software selectable power saving modes. The Idle Mode stops the CPU

while allowing the RAM, timer/counters, serial port, and interrupt system to continue

functioning. The Power down Mode saves the RAM contents but freezes the oscillator,

disabling all other chip functions until the next hardware reset.

By combining a versatile 8-bit CPU with Flash on a monolithic chip, the AT89S52 is

a powerful microcomputer which provides a highly flexible and cost effective solution to

many embedded control applications.

6

Page 7: Mini Project Documentation

3.4 ARCHITECTURE OF AT89S52

Fig 3.4 Architecture Of AT89S52

7

Page 8: Mini Project Documentation

3.5 PIN DIAGRAM

Fig 3.5: Pin Diagram Of AT89S52

3.6 PIN DESCRIPTION

8

Page 9: Mini Project Documentation

VCC

Pin 40 provides Supply voltage to the chip. The voltage source is +5v.

GND

Pin 20 is the grounded.

Port 0

Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. When 1s are

written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 may also be

configured to be the multiplexed low-order address/data bus during accesses to external

program and data memory. In this mode P0 has internal pull-ups. Port 0 also receives the

code bytes during Flash programming, and outputs the code bytes during program

verification. External pull-ups are required during program verification.

Port 1

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups from pin 1 to 8.

When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be

used as inputs. As inputs, Port 1 pins that are externally being pulled low will source

current because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to

be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input

(P1.1/T2EX), respectively, as shown in following table. Port 1 also receives the low-

order address bytes during Flash programming and program verification.

Table 1: Port1 Functions

Port 2

9

Page 10: Mini Project Documentation

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28.

When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be

used as inputs. As inputs, Port 2 pins that are externally being pulled low will source

current because of the internal pull-ups. Port 2 also receives the high-order address bits

and some control signals during Flash programming and verification.

Port 3

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups from pin 10 to 17.

When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and

can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will

source current because of the pull-ups. Port 3 also serves the functions of various

special features of the AT89C52 as listed below:

Table 2: Port3 Functions

RST

Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin,

the microcontroller will reset and terminate all activities. A high on this pin for two

machine cycles while the oscillator is running resets the device.

ALE

Address Latch Enable is an output pin and is active high. Address Latch Enable

output pulse for latching the low byte of the address during accesses to external memory.

10

Page 11: Mini Project Documentation

This pin is also the program pulse input (PROG) during Flash programming. However

one ALE pulse is skipped during each access to external Data Memory.

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.

EA

External Access Enable EA 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. EA should be strapped to VCC for internal program executions.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

XTAL1 and XTAL2 are the input and output, respectively, of an inverting

amplifier which can be configured for use as an on chip oscillator, as shown in Figure

5.3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an

external clock source, XTAL2 should be left unconnected while XTAL1 is driven as

shown in Figure 5.4.

11

Page 12: Mini Project Documentation

Fig 3.6: Crystal Connections

3.7 MEMORY DESCRIPTION

The total memory of 89S52 system is logically divided in Program memory and

Data memory. Program memory stores the programs to be executed, while data memory

stores the data like intermediate results, variables and constants required for the execution

of the program. Program memory is invariably implemented using EPROM, because it

stores only program code which is to be executed and thus it need not be written into.

However, the data memory may be read from or written to and thus it is implemented

using RAM.

Further, the program memory and data memory both may be categorized as on-

chip (internal) and external memory, depending upon whether the memory physically

exists on the chip or it is externally interfaced. The 89S52 can address 8Kbytes on-chip

memory whose map starts from 0000H and ends at 1FFFH. It can address 64Kbytes of

external program memory under the control of PSEN (low) signal.

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes

occupy a parallel address space to the Special Function Registers. That means the upper

128bytes have the same addresses as the SFR space but are physically separate from SFR

space.

When an instruction accesses an internal location above address 7FH, the address

mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of

RAM or the SFR space.

12

Page 13: Mini Project Documentation

Instructions that use direct addressing access SFR space. Instructions that use indirect

addressing access the upper 128 bytes of RAM.

The lowest 32 bytes of the on-chip RAM form 4 banks of 8 registers each. Only

one of these banks can be active at any time. Bank is chosen by setting 2 bits in PSW.

Default bank ( at power up) is bank 0 (locations 00-07). The 8 registers in any active

bank are referred to as R0 to R7. Locations 30H to 7FH are for general purpose RAM.

3.8 SPECIAL FUNCTION REGISTERS

Special function registers are the areas of memory that control specific functionality

of the AT89S52 micro-controller.

Accumulator (0E0h)

As its name suggests, it is used to accumulate the results of large no. of

instructions. It can hold 8 bit values.

B register (0F0h)

The B register is very similar to accumulator. It may hold 8-bit value. The B

register is only used by MUL AB and DIV AB instructions. In MUL AB the higher byte

of the products gets stored in B register. In DIV AB the quotient gets stored in B with the

remainder in A.

Stack pointer (081h)

The stack pointer holds 8-bit value. This is used to indicate where the next value

to be removed from the stack should be taken from. When a value is to be pushed on to

the stack, the 8052 first store the value of SP and then store the value at the resulting

memory location. When a value is to be popped from the stack, the 8052 returns the value

from the memory location indicated by SP and then decrements the value of SP.

Data pointer (Data pointer low/high, address 82/83h)

13

Page 14: Mini Project Documentation

The SFRs DPL and DPH work together to represent a 16-bit value called the data

pointer. The data pointer is used in operations regarding external RAM and some

instructions code memory. It is a 16-bit SFR and also an addressable SFR.

Program counter

The program counter is a 16 bit register, which contains the 2 byte address, which

tells the next instruction to execute to be found in memory. When the 8052 is initialized

PC starts at 0000h and is incremented each time an instruction is executes. It is not

addressable SFR.

PCON (power control, 87h)

The power control SFR is used to control the 8052’s power control modes.

Certain operation modes of the 8052 allow the 8052 to go into a type of “sleep mode”

which consumes low power.

TCON (Timer control, 88h)

The timer mode control SFR is used to configure and modify the way in which

the 8052’s two timers operate. This SFR controls whether each of the two timers is

running or stopped and contains a flag to indicate that each timer has overflowed.

Additionally, some non-timer related bits are located in TCON SFR. These bits are used

to configure the way in which the external interrupt flags are activated, which are set

when an external interrupt occur.

TMOD (Timer Mode, 89h)

14

SMOD ---- --- ---- GF1 GF0 PD IDL

TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

Page 15: Mini Project Documentation

The timer mode SFR is used to configure the mode of operation of each of the

two timers. Using this SFR your program may configure each timer to be a 16-bit timer,

or 13 bit timer, 8-bit auto reload timer, or two separate timers. Additionally you may

configure the timers to only count when an external pin is activated or to count “events”

that are indicated on an external pin.

TIMER 1 TIMER 0

If Gate = 0, software instruction is used to start and stop the timer.

If Gate = 1, hardware instruction is used to start and stop the timer.

__

If C/ T = 1, then 8052 is used as a counter.

__

If C/ T = 0, then 8052 is used as a timer.

M1, M0 are mode selection bits.

M1 M0 Mode

0 0 0(13 bit count mode)

0 1 1(16 bit count mode)

1 0 2(Auto reload mode)

1 1 3(Multiple mode)

T0 (Timer 0 low/ high, address 8A/ 8C h)

These two SFRs together represent timer 0. Their exact behavior depends on how

the timer is configured in the TMOD SFR.

T1 (Timer 1 low/ high, address 8B/ 8D h)

15

Gate

C/ T M1 M0 Gate

C/ T M1 M0

Page 16: Mini Project Documentation

These two SFRs together represent timer 1. Their exact behavior depends on how

the timer is configured in the TMOD SFR.

P0 (Port 0, address 80h, bit addressable)

This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0

of port 0 is pin P0.0, bit 7 is pin P0.7. Writing a value of 1 to a bit of this SFR will send a

high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.

P1 (Port 1, address 90h, bit addressable)

This is port 1 latch. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 1 is first written on P1 register. For e.g., bit 0

of port 1 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a

high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.

P2 (Port 2, address 0A0h, bit addressable)

This is port 2 latch. Each bit of this SFR corresponds to one of the pins on a

micro controller. Any data to be outputted to port 2 is first written on P2 register. For e.g.,

bit 0 of port 2 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will

send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low

level.

P3 (Port 3, address 0B0h, bit addressable)

This is port 3 latch. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 3 is first written on P3 register. For e.g., bit 0

of port 3 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a

high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.

IE (Interrupt Enable, 0A8h)

16

Page 17: Mini Project Documentation

The interrupt enable SFR is used to enable and disable specific interrupts. The

low 7 bits of the SFR are used to enable/disable the specific interrupts, where the MSB

bit is used to enable or disable all the interrupts. Thus, if the high bit of IE 0 all interrupts

are disabled regardless of whether an individual interrupt is enabled by setting a lower

bit.

EA _ _ _

ET2 ES ET1 EX1 ET0 EX0

IP (Interrupt Priority, 0B8h)

The interrupt priority SFR is used to specify the relative priority of each interrupt.

On 8052, an interrupt may be either low or high priority.

_ _ _ _ _ _ PT2 PS PT1 PX1 PT0 PX0

PSW (Program Status Word, 0D0h)

The Program Status Word is used to store a number of important bits that are set

and cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary

carry flag, the parity flag and the overflow flag. Additionally, it also contains the register

bank select flags, which are used to select, which of the “R” register banks currently in

use.

SBUF (Serial Buffer, 99h)

SBUF is used to hold data in serial communication. It is physically two registers.

One is writing only and is used to hold data to be transmitted out of 8052 via TXD. The

17

CY AC F0 RS1 RS0 OV - - - - P

Page 18: Mini Project Documentation

other is read only and holds received data from external sources via RXD. Both mutually

exclusive registers use address 99h.

SCON

SM0, SM1 are serial mode control bits.

SM0 SM1 Mode

0 0 0

0 1 1

1 0 2

SM2 is multiprocessor mode control bit.

1= Multiprocessor mode

0= Normal mode

REN is receiver enable bit.

1= Receive enabled

0= Receive disabled

TB8 is 9th transmit bit which is enabled only in mode 2 and mode 3.

RB8 is 9th bit received which is used in mode 2 and mode 3.

RI is set to indicate receipt of a serial word.

TI is set to indicate completion of a serial transmission.

4. REGULATED POWER SUPPLY

4.1 INTRODUCTION

18

SM2 SM1 SM0 REN TB8 RB8 TI RI

Page 19: Mini Project Documentation

Most digital logic circuits and processors need a 5V power supply. To use these

parts, we need to build a regulated 5V source. Usually you start with an unregulated

power supply ranging from 9V to 24V DC. To make a 5V power supply, we use a

LM7805 voltage regulator IC (Integrated circuit). The IC is as shown below:

Fig 4.1: Voltage Regulator

The LM7805 is simple to use. You simply connect the positive lead of your

unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect

the negative lead to the Common pin and then when you turn on the power, you get a 5

volt supply from the Output pin. Sometimes the input supply line may be noisy. To help

smooth out this noise and get a better 5V output, a capacitor is usually added to the

circuit, going between the 5V output and ground (GND). We use a F capacitor.

4.2 BLOCK DIAGRAM

19

Page 20: Mini Project Documentation

Fig 4.2: Block Diagram of Power Supply

4.3 CIRCUIT DIAGRAM

Fig 4.3: Circuit Diagram of Power Supply

20

Page 21: Mini Project Documentation

Above is the circuit of a basic unregulated dc power supply. A bridge rectifier D1

to D4 rectifies the ac from the transformer secondary, which may also be a block rectifier

such as WO4 or even four individual diodes such as 1N4004 types.The principal

advantage of a bridge rectifier is you do not need a centre tap on the secondary of the

transformer. A further but significant advantage is that the ripple frequency at the output

is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes filtering somewhat easier.

As a design example consider we wanted a small unregulated bench supply for

our projects. Here we will go for a voltage of about 12 - 13V at a maximum output

current (IL) of 500ma (0.5A). Maximum ripple will be 2.5% and load regulation is 5%.

Now the RMS secondary voltage (primary is whatever is consistent with your

area) for our power transformer T1 must be our desired output Vo PLUS the voltage

drops across D2 and D4 (2 * 0.7V) divided by 1.414.This means that Vsec = [13V +

1.4V] / 1.414 which equals about 10.2V. Depending on the VA rating of your

transformer, the secondary voltage will vary considerably in accordance with the applied

load. The secondary voltage on a transformer advertised as say 20VA will be much

greater if the secondary is only lightly loaded.

If we accept the 2.5% ripple as adequate for our purposes then at 13V this

becomes 13 * 0.025 = 0.325 Vrms. The peak to peak value is 2.828 times this value. Vrip

= 0.325V X 2.828 = 0.92 V and this value is required to calculate the value of C1. Also

required for this calculation is the time interval for charging pulses. If you are on a 60Hz

system it it 1/ (2 * 60) = 0.008333 which is 8.33 milliseconds. For a 50Hz system it is

0.01 sec or 10 milliseconds.

Remember the tolerance of the type of capacitor used here is very loose. The

important thing to be aware of is the voltage rating should be at least 13V X 1.414 or

18.33. Here you would use at least the standard 25V or higher (absolutely not 16V).With

our rectifier diodes or bridge they should have a PIV rating of 2.828 times the Vsec or at

least 29V. Don't search for this rating because it doesn't exist. Use the next highest

standard or even higher. The current rating should be at least twice the load current

maximum i.e. 2 X 0.5A or 1A. A good type to use would be 1N4004, 1N4006 or 1N4008

types.

21

Page 22: Mini Project Documentation

These are rated 1A at 400PIV, 600PIV and 1000PIV respectively. Always be on

the lookout for the higher voltage ones when they are on special.

4.4 IC VOLTAGE REGULATORS

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

contain the circuitry for reference source, comparator amplifier, control device, and

overload protection all in a single IC. Although the internal construction of the IC is

somewhat different from that described for discrete voltage regulator circuits, the external

operation is much the same. IC units provide regulation of either a fixed positive voltage,

a fixed negative voltage, or an adjustably set voltage.

A power supply can be built using a transformer connected to the ac supply line to

step the ac voltage to desired amplitude, then rectifying that ac voltage, filtering with a

capacitor and RC filter, if desired, and finally regulating the dc voltage using an IC

regulator. The regulators can be selected for operation with load currents from hundreds

of mill amperes to tens of amperes, corresponding to power ratings from mill watts to

tens of watts.

Three-Terminal Voltage Regulators:

Fixed Positive Voltage Regulators:

Vin Vout

C2

C1

Fig 4.4: Three Terminal Voltage Regulator

Fig shows the basic connection of a three-terminal voltage regulator IC to a load.

The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input

terminal, a regulated output dc voltage, Vo, from a second terminal, with the third

terminal connected to ground. While the input voltage may vary over some permissible

voltage range, and the output load may vary over some acceptable range, the output

22

IN OUT78XX

GND

Page 23: Mini Project Documentation

voltage remains constant within specified voltage variation limits. A table of positive

voltage regulated ICs is provided in table. For a selected regulator, IC device

specifications list a voltage range over which the input voltage can vary to maintain a

regulated output voltage over a range of load current. The specifications also list the

amount of output voltage change resulting from a change in load current (load regulation)

or in input voltage (line regulation).

IC No. Output voltage(v) Maximum input voltage(v)

7805

7806

7808

7810

7812

7815

7818

7824

+5

+6

+8

+10

+12

+15

+18

+24

35V

40V

Table 3: Positive Voltage Regulators in 7800 series

23

Page 24: Mini Project Documentation

5. ULTRASONIC SENSORS

5.1 INTRODUCTION

Ultrasonic sensors (also known as transceivers when they both send and receive)

work on a principle similar to radar or sonar. According to this principle the attributes of

a target are calculated by interpreting the echoes from radio or sound waves for radar or

sonar respectively. Ultrasonic sensors generate high frequency sound waves and evaluate

the echo which is received back by the sensor. Sensors calculate the time interval

between sending the signal and receiving the echo to determine the distance to an object.

These systems typically use a transducer which generates sound waves in the

ultrasonic range, above 20,000Hz, by turning electrical energy into sound and then upon

receiving the echo, they turn the sound waves into electrical energy which can be

measured and displayed.

The microphones and loudspeakers used to receive and transmit the ultrasonic

sound are called transducers. An ultrasonic transducer is a device that converts energy

into ultrasound or sound waves above the normal range of human hearing. The location at

which a transducer focuses the sound can be determined by the active transducer area and

shape, the ultrasound frequency and the sound velocity of the propagation medium. To

detect the ultrasonic signals,detectors are used. Since piezoelectric crystal generate a

voltage when force is applied to them, the same crystal can be used as an ultrasonic

detector.

5.2 PING SENSOR

Fig 5.2: Ping Sensor

24

Page 25: Mini Project Documentation

The Ping sensor measures distance using sonar. These devices typically transmit a

short burst of ultrasonic sound toward a target which reflects the sound back to the sensor

i.e., an ultrasonic pulse is transmitted from the unit and distance to target is determined

by measuring the time required for the echo return. Output is a variable-width pulse that

corresponds to the distance to the target.

Features:

The PING))) has only has 3 connections, which include Vdd, Vss, and 1 I/O pin.

The 3-pin header makes it easy to connect using a servo extension cable, no

soldering required.

Several sample codes are available using the Ping))) sensor.

5.3 USES IN INDUSTRY

Ultrasonic sensors are used to detect the presence of targets and to measure the

distance to targets in many automated factories and process plants. Sensors with an on or

off digital output are available for detecting the presence of objects.

5.4 ROLE IN THIS SYSTEM

For sensing the obstacle, two ultrasonic sensors are used. These sensors are

arranged side by side. From one sensor ultrasonic pulse is delivered & this is transmitted

in one line. Whenever there is any obstacle, the pulse gets reflected. The reflected energy

is detected by another sensor. In this way, whenever reflected energy is being detected, a

buzzer and a display board are also energized. Thus, the driver can be made aware of the

situation.

25

Page 26: Mini Project Documentation

6. LCD DISPLAY

6.1 INTRODUCTION

A liquid crystal display (LCD) is a thin, flat panel used for electronically

displaying information such as text, images, and moving pictures. Its uses include

monitors for computers, televisions, instrument panels, and other devices ranging from

aircraft cockpit displays, to every-day consumer devices such as video players, gaming

devices, clocks, watches, calculators, and telephones. Among its major features are its

lightweight construction, its portability, and its ability to be produced in much larger

screen sizes. Its low electrical power consumption enables it to be used in battery-

powered electronic equipment.

It is an electronically-modulated optical device made up of any number of pixels

filled with liquid crystals and arrayed in front of a light source (backlight) or reflector to

produce images in color or monochrome. Each pixel of an LCD typically consists of a

layer of molecules aligned between two transparent electrodes and two polarizing filters.

With no actual liquid crystal between the polarizing filters, light passing through the first

filter would be blocked by the second polarizer.The surface of the electrodes that are in

contact with the liquid crystal material are treated so as to align the liquid crystal

molecules in a particular direction. The direction of the liquid crystal alignment is then

defined by the direction of rubbing.

Electrodes are made of a transparent conductor called Indium Tin Oxide

(ITO).Before applying an electric field, the orientation of the liquid crystal molecules is

determined by the alignment at the surfaces of electrodes. In a twisted nematic device

(still the most common liquid crystal device), the surface alignment directions at the two

electrodes are perpendicular to each other, and so the molecules arrange themselves in a

helical structure, or twist. This reduces the rotation of the polarization of the incident

light, and the device appears grey. This light will then be mainly polarized perpendicular

to the second filter, and thus be blocked and the pixel will appear black. By controlling

the voltage applied across the liquid crystal layer in each pixel, light can be allowed to

pass through in varying amounts thus constituting different levels of gray.

26

Page 27: Mini Project Documentation

6.2 PIN DIAGRAM OF LCD

GND GND for backlight

VCC VCC for backlight

CONTRAST D7

RS D6

R/W D5

ENABLE D4

D0 D3

D2

D1

Fig 6.2: Pin Diagram Of LCD

6.3 PIN DESCRIPTION

VCC

Pin 2 provides Supply voltage to the chip. The voltage source is +5v.

GND

Pin 1 is the grounded.

CONTRAST

Pin 3 provides contrast function. By enabling this pin, we can adjust the

brightness or dullness of the LCD display.

RS

Pin 4 is RS i.e., Register Selection.

27

1 16

2 15

3 14

4 13

5 12

6 11

7 10

8 9

Page 28: Mini Project Documentation

R/W

Pin 5 is Read/Write pin.

ENABLE

Pin 6 is enable pin which tells whether the LCD is connected to micro-controller

or not.

D0--D7

Pins 7-14 are called data pins designated as D0 – D7.

Pins 15, 16 are used for supply and ground for back-up-light respectively.

6.4 FACTORS FOR DESIGNING LCDs

Resolution: The horizontal and vertical screen size expressed in pixels (e.g., 1024x768).

Unlike CRT monitors, LCD monitors have a native supported resolution for best display

effect.

Viewable size: The size of an LCD panel measured on the diagonal (more specifically

known as active display area).

Response time: The minimum time necessary to change a pixel's color or brightness.

Response time is also divided into rise and fall time. For LCD monitors, this is measured

in btb (black to black) or gtg (gray to gray).

Brightness: The amount of light emitted from the display ( more specifically known as

luminance ).

Contrast ratio: The ratio of the intensity of the brightest bright to the darkest dark.

Aspect ratio: The ratio of the width to the height (for example, 4:3, 5:4, 16:9 or 16:10).

6.5 DRAWBACKS OF LCDs

Many LCDs are incapable of displaying very low resolution screen modes (such

as 320x200) due to scaling limitations.

Some types of LCDs have a more limited color resolution.

LCDs typically have longer response times than their plasma and CRT

counterparts.

6.6 ROLE IN THIS SYSTEM

28

Page 29: Mini Project Documentation

Whenever the signal about the obstacle is being detected by the sensors, the

micro-controller activates the display board. The micro-controller is programmed in such

a way that when there is any obstacle, the LCD displays “ KEEP DISTANCE VEHICLE

AHEAD” and when there is no obstacle, the LCD displays “KEEP DISTANCE NO

VEHICLE AHEAD”. Here “KEEP DISTANCE” is just title which is displayed in the 1 st

row of the 2x16 LCD and “VEHICLE AHEAD” & ”NO VEHICLE AHEAD” is the

information which is being displayed in the 2nd row of the 2x16 LCD ( 2x16 denotes that

LCD display has 2 rows and each can hold 16 bits/characters).

7. BUZZER

29

Page 30: Mini Project Documentation

7.1 INTRODUCTION

Fig 7.1: Traditional buzzer

The above figure shows a traditional buzzer.This buzzer (buzz, bullroarer, button-

on-a-string), is an ancient mechanical device used for ceremonial purposes and as a toy. It

is constructed by centering an object at the midpoint of a cord or thong and winding the

cord while holding the ends stationary. The object is whirled by alternately pulling and

releasing the tension on the cord. The whirling object makes a buzzing or humming

sound, giving the device its common name.

A buzzer is often constructed by running string through two of the holes on a

large button and is a common and easily made toy.American Indians used the buzzer as a

toy and also to call up the wind. It was also used ceremonially.

Thus, a buzzer is an electric signaling device, such as a doorbell, that makes a

buzzing sound. It can also be considered as a push button at an outer door that gives a

ringing or buzzing signal when pushed.

An electric buzzer is as shown below:

Fig 7.2: Electric Buzzer

30

Page 31: Mini Project Documentation

7.2 ROLE IN THIS SYSTEM

Many accidents at High-ways are taking place due to the close running of

vehicles, all of sudden, if the in front vehicle driver reduces the speed or applies breaks,

then it is quite difficult to the following vehicle driver to control his vehicle, resulting in

an accident. To avoid this, the warning system, which contains buzzer and display system

can be arranged at rear side of a vehicle. While display system displays the message, the

buzzer also produces a buzzing sound simultaneously.

8. CIRCUIT DESCRIPTION

31

Page 32: Mini Project Documentation

8.1 CIRCUIT`

Fig 8.1: Circuit Diagram Of System

8.2 WORKING

32

Page 33: Mini Project Documentation

This system consists of a buzzer and display system arranged at rear side of a

vehicle.

Whenever there is any obstacle, immediately the display board will be energized

and it shows “KEEP DISTANCE VEHICLE AHEAD”.

At the same time buzzer also will be energized, the buzzer and display board both

remains in energized condition up to some time .

For sensing the obstacle, two ultrasonic sensors are used which are arranged side

by side.

From one sensor, signal is delivered and is transmitted in one line. Whenever

there is any obstacle, the signal gets reflected. The reflected energy is detected by

another ultrasonic sensor.

In this way accidents can be avoided to some extent.

9. CODING

33

Page 34: Mini Project Documentation

9.1 CODE

#include<reg51.h>

sfr ldata=0x90;//port 1

sbit rs=P2^5;

sbit rw=P2^6;

sbit en=P2^7;

sbit usonic=P0^1;

sbit buzzer=P0^7;

lcddata(char temp[ ],int);

lcdcmd(unsigned char);

lcddelay(unsigned int);

main( )

{

buzzer=1;

lcdcmd(0x38);

lcdcmd(0x0E);

lcdcmd(0x01);

lcdcmd(0x81);

lcddata("KEEP DISTANCE",14)

while(1)

{

if(usonic==0)

{

lcdcmd(0xC0);

buzzer=0;

lcddata("VEHICLE AHEAD",13);

lcdcmd(0x0C);

34

Page 35: Mini Project Documentation

}

else

{

buzzer=1;

lcdcmd(0xC0);

lcddata("NO VEHICLE AHEAD",16);

lcdcmd(0x0C);

}

}

}

lcddelay(unsigned int k)

{

int i,j;

for (i=0;i<=k;i++)

for (j=0;j<=1275;j++);

}

lcdcmd(unsigned char value)

{

ldata=value;

rs=0;

rw=0;

en=1;

lcddelay(1);

en=0;

return;

}

lcddata(char temp[16],int s)

{

35

Page 36: Mini Project Documentation

for(s=0;s<16;s++)

{

ldata=temp[s];

rs=1;

rw=0;

en=1;

lcddelay(1);

en=0;

}

}

10. RESULTS AND CONCLUSIONS

36

Page 37: Mini Project Documentation

10.1 RESULT

We have thus seen how obstacles can be detected in the path of any vehicle using

embedded based micro-controller and thus can avoid accidents to some extent.

10.2 CONCLUSIONS

Thus, we conclude that by employing this system on a vehicle, we can prevent

accidents.

10.3 FUTURE SCOPE

This system is a rapidly growing field and there are new and improved strategies

popping up all the time. For the most part these systems are all built around the same

basic structure, a central box that monitors several detectors and perimeter guards and

sounds an alarm when any of them are triggered.

This system is best for guiding the perimeter of a house or a business center the

points where an intruder would enter the building. In this system IR sensor is used to

detect the intrusion. Similarly the vibration and temperature sensors recognize vibration

disturbances and accidental fires respectively. This project provides an efficient and

economical security system. This system finds applications in industries, banks and

homes.

Incorporating the features discussed below can further enhance the system.

This system can detect intrusion only at discrete points. This system detection

feature can be extended to scanning a complete area. Thus the intrusion into the

building can be detected with much more efficiency.

The redialing feature can also be incorporated such that if the call is not put

forward the first time, the auto dialer will dial the same number until the call is

successfully completed.

A pre-recorded voice message can be delivered to the owner notifying him about

the intrusion into the premises.

37

Page 38: Mini Project Documentation

The addition of the above discussed advancements certainly builds this project into a

much flexible and reliable security system.

APPENDIX A

A.1 KEIL SOFTWARE

38

Page 39: Mini Project Documentation

An assembler is a software tool designed to simplify the task of writing computer

programs. It translates symbolic code into executable object code. This object code may

then be programmed into a microcontroller and executed. Assembly language programs

translate directly into CPU instructions that instruct the processor what operations to

perform. Therefore, to effectively write assembly language programs, you should be

familiar with both, the microprocessor architecture and the assembly language.

Assembly language operation codes (mnemonics) are easily remembered. You

can also symbolically express addresses and values referenced in the operand field of

instructions. Since you assign these names, you can make them as meaningful as the

mnemonics for the instructions. For example, if your program must manipulate a date as

data, you can assign it to the symbolic name DATE. If your program contains a set of

instructions used as a timing loop (a set of instructions executed repeatedly until a

specific amount of time has passed), you can name the instruction group TIMER_LOOP.

An assembly language program has three constituent parts:

1. Machine instructions

2. Assembler directives

3. Assembler controls

A Machine instruction is a machine code that can be executed by the machine.

Detailed discussion of the machine instructions can be found in the hardware manuals of

the 8052.

An Assembler directive is used to define the program structure and symbols and

generate non-executable code (data, messages etc…). Assembler directives instruct the

assembler how to process subsequent assembly language instructions. Directives also

provide a way for you to define program constants and reserve space for variables.

An Assembler control sets the assembly mode and directs the assembly flow.

Assembler controls direct the operation of the assembler when generating a listing file or

object file. Typically, controls do not impact the code that is generated by the assembler.

Controls can be specified on the command line or within an assembler source file.

A.2 DIRECTIVE CATEGORIES

39

Page 40: Mini Project Documentation

The AX51 assembler has several directives that permit you to define symbol

values, reserve and initialize storage, and control the placement of your code. The

directives should not be confused with instructions. They do not produce executable

code, and with the exception of the DB, DW and DD directives, they have no direct

effect on the contents of the code memory. These directives change the state of the

assembler, define user symbols, and add information to the object file. Some of the

assembler directives are listed below:

BIT – It defines a bit address in bit data space.

BSEG – It defines an absolute segment within the bit address space.

CODE -- It assigns a symbol name to a specific address in the code space.

CSEG – It defines an absolute segment within the code address space.

DATA – It assigns a symbol name to a specific on-chip data address.

DB – It generates a list of byte values.

DBIT – It reserves a space in bit units.

DD – It generates a list of double word values.

DS – It reserves a space in byte units.

DSB – It also reserves a space in byte units.

DSD – It reserves a space in double word units.

DSEG – It defines an absolute segment within the indirect internal data space.

DSW – It reserves space in word units; Advances the location counter of the current

segment.

DW – It generates a list of word values.

END – It indicates the end of the program.

EQU – It sets symbol value permanently.

EVEN – It ensures word alignment for variables.

EXTERN – It defines symbols referenced in the current module that are defined in other

modules.

IDATA – It assigns a symbol name to a specific indirect internal address.

ISEG – It defines an absolute segment within the indirect internal address.

LABEL – It assigns a symbol name to an address location within a segment.

LIT – It assigns a symbol name to a string.

40

Page 41: Mini Project Documentation

NAME – It specifies the name of the current module.

ORG – It sets the location counter of the current segment.

PROC – It defines the start of the function.

ENDP – It defines the end of the function.

PUBLIC – It identifies symbols which can be used outside the current module.

RSEG – It selects a relocatable segment.

SEGMENT – It defines a relocatable segment.

SET – It sets symbol value temporarily.

USING – It sets the predefined symbolic register address and reserve space for the

specified register bank.

XDATA – It assigns a symbol name to a specific off-chip data address.

XSEG – It defines an absolute segment within the external data address space.

The directives are divided into the following categories:

Segment Control

Generic Segments: SEGMENT, RSEG

Absolute Segments: CSEG, DSEG, BSEG, ISEG, XSEG

Symbol Definition

Generic Symbols: EQU, SET

Address Symbols: BIT, CODE, DATA, IDATA, XDATA

SFR Symbols: sfr, sfr16, sbit

Text Replacement: LIT

Memory Initialization

DB, DW, DD

Memory Reservation

DBIT, DS, DSB, DSW, DSD

Procedure Declaration

PROC, ENDP, LABEL

Program Linkage

41

Page 42: Mini Project Documentation

PUBLIC, EXTRN, EXTERN, NAME

Address Control

ORG, EVEN, USING

Others

END, _ _ERROR_

REFERENCES

42

Page 43: Mini Project Documentation

1. Muhammad Ali Mazidi and Janice Gillispi Mazidi, “The 8051 Microcontroller and

Embedded Systems”.

2. A.K.Ray, “The 8051 Microprocessor and Microcontroller”.

3.Kenneth.J.Ayala, “The 8051 Microcontroller Architecture, Programming &

Applications”.

4. B.Ram, “Fundamentals of Microprocessors and Microcomputers”.

5. D.V.Prasad, "Electronic Components”.

6. Ramesh.S.Gaonkar, “Microprocessor Architecture, Programming & Applications”.

7. Datasheets of Microcontroller AT89S52

8. www.electronicsforu.com

9. www.alldatasheets.com

10. www.atmel.databook.com

11. www.keil.com

43