Anda di halaman 1dari 78

ACKNOWLEDGEMENT

The successful completion of any task would be incomplete without expression of simple
magnitude to the people who encouraged our work. Though words are not enough to express
the sense of gratitude towards everyone who directly or indirectly helped in our endurances
Lastly we thank our family and all those who helped us directly or indirectly for the
completion of the project.

PROJECT ASSOCIATES
G.Dileepkumar
V.Anukaran
V.Venkatesh

ABSTRACT

In present day to day life man has been changing and with him there has been also
tremendous change in technology. The introduction of high end technologies, digital signal
processing and VLSI has changed the face of the world. The man has tend to become safer,
secure and at same time reducing the overhead of labour using these technologies.
This project mainly uses embedded systems technology. To define embedded systems in
simple words, it is a combination of computer hardware and software, designed to perform
one task.
The robot is a small application of such vast embedded technology.
The robot is a mechanical device which performs human related tasks with its own artificial
intelligences.
OBJECTIVE: The main objective of this Fire fighting mobile robot is to avoid the
obstacles in traveling path. Initially the robot moves on its path. On robot, IR transmitter of
38 KHz is present which continuously sends IR signals modulated at 38 KHz in direction of

ECE 1
robot, and also 38 KHz IR receiver which receives IR signals is placed behind the
transmitter. When ever a obstacle occurs the IR signals are reflected back from the obstacle
and these signals are sensed by the IR receiver and it generates hardware interrupt to
microcontroller (AT89c51).
The microcontroller which is interfaced to dc geared motors changes the moving direction of
the robot in such a way to avoid the clash with obstacle and there by avoids the obstacle.

SYSTEM REQUIREMENTS
Hardware Description: Atmel 89c52, Quartz crystal(11.0592MHz), L293D driver ic, dc
geared motor, 555 timer , tsop 1738(IR sensor), infrared led,7805,7812 voltage regulators, ,
leds, resistors, capacitors, dc power supply, hook up wires.

Software Description: Keil, 8051 assembly, micro-flash programmer.


Platform: windows xp (or) windows 98

CONTENTS
CHAPTERS Page no’s
CERTIFICATE
ACKNOWLEDGEMENT
ABSTRACT
BLOCK DIAGRAM

 CHAPTER 1 :- INTRODUCTION 10
1.1 EMBEDDED SYSTEMS 10
1.1.1 EMBEDDED PRODUCT DEVELOPMENT LIFE CYCLE 12
1.1.2 DESIGN CONSIDERATIONS FOR AN EMBEDDED CYCLE 13
1.1.3 EMBEDDED SYSTEM CLASSIFICATION 15
1.2 MICROCONTROLLER UNIT 16
 CHAPTER 2:- OPERATING PRINCIPLE 18
 CHAPTER 3:- BLOCK DIAGRAM AND DESCRIPTION 19
BLOCK DIAGRAM 19
3.1 PROCESSOR 20

ECE 2
3.2 POWER SUP[PLY 20
3.2.1 RECTIFIER 21
3.2.2 MONOLYTHIC IC VOLTAGE REGULATOR 22
3.3 MOTOR DRIVER 23
3.4 MOTORS 25
 CHAPTER 4:- DEVICE DESCRIPTION 27
4.1 L293D MOTOR DRIVER
4.2.1 DESCRIPTION
4.2.2 OPERATION
4.4 LM7805,7812 VOLTAGE REGULATORS 46
4.4.1 FEATURES 46
4.4.2 DESCRIPTION 47
4.4.3 INTERNAL BLOCK DIAGRAM 47
4.7 IN4001 DIODES 55
4.7.1 FEATURES 55
4.7.2 TYPICAL APPLICATIONS 55
4.8 LIGHT EMITTING DIODES 56
4.8.1 SYMBOL OF LED 56
4.8.12 CROSS SECTIONAL VIEW OF LED 56
4.8.3 WORKING 58
4.8.4 COLOUR OF LED 59

4.9 IR LEDS 60
4.9.1 FEATURES 60
4.9.2 DESCRIPTION 60
 CHAPTER 5:- AT89C51 MICROCONTROLLER 61
5.1 INTRODUCTION 61
5.2 DESCRIPTION 62
5.3 FEATURES OF AT89C51 62
5.4 INTERNAL BLOCK DIAGRAM 63
5.5 PIN CONFIGURATION 64

ECE 3
5.6 OSCILLATOR CHARACTERSTICS 67
5.7 TYPES OF MEMORY 69
5.8 BASIC REGISTERS 73
 CHAPTER 6:- SOFTWARE USED 75
6.1 INTRODUCTION TO KEIL 75
6.2 C51 COMPILOR 75
 CHAPTER 7:- APPLICATIONS 77
7.1 APPLICATIONS 77

CONCLUSION 79

SCOPE OF THE PROJECT 79

SOURCE CODE 81

BIBLIOGRAPHY 84

BLOCK DIAGRAM

A
T
8
9
C
ECE 4 5
2
M
1 M M1
2
L
2
9
3
DTMF D M2
Decoder

LEDS
LEDS
Rel
ay Fan

Fire
Sensor

Buzzer

pi

CHAPTER 1

INTRODUCTION

In present day to day life man has been changing and with him there
has been also tremendous change in technology. The introduction of high end technologies,
digital signal processing and VLSI has changed the face of the world. The man has tend to
become safer, secure and at same time reducing the overhead of labour using these
technologies.
This project mainly uses embedded systems technology. To define
embedded systems in simple words, it is a combination of computer hardware and software,
designed to perform one task.
The robot is a small application of such vast embedded technology.
The robot is a mechanical device which performs human related tasks with its own artificial
intelligences.

ECE 5
1.1 EMBEDDED SYSTEMS
In this world of knowledge every thing around us is run by Computing
Systems. The technical Brilliance and Developments in different fields has led to a drastic
change in our lives especially in the communications field. Due to various changes in
technologies many systems have come up with breathtaking developments. One amongst
them is the EMBEDDED SYSTEMS. It is the evolution or further development of
computing system. Its applications provide tremendous opportunities for creative use of
computer technology. Almost every new system introduced in the market is an example of
Embedded System.

An embedded system is basically a close interaction of hardware and


software. The design part involves different instruction sets in terms of functionality,
compactness of code, power consumption, performance, and reliability so on. The
Embedded software interacts with the hardware circuitry to generate the desired
functionality. An embedded systems typically comprises the hardware, embedded RTOS,
device drivers, communication stacks and embedded application software.

Apart from the common computer applications there are many applications, which do
not need high performances.

ECE 6
For Eg. High Performance is not crucial in the case of a ‘microprocessor control’ used in
digital cameras, cell phones etc. So in these, small size and low power consumptions are of
key importance.
All these can be achieved by by placing a chip not only on the processor but also some input
– output interfaces, timer circuits and other design features to make it easy to implement a
complete control system using very few chips. So a physical system that employs computer
control for a specific purpose rather than for a general purpose computation is referred to as
an Embedded System. contrast to the desktops and PC’s, which can perform variety of tasks,
an Embedded system performs a single well-defined
Understand usertask, which is much simple gives good
requirements
performance.

Choose optimum
1.1.1 Embedded Product
electronic chip development Life Cycle
S/W Side H/W Side

HLL/ALL

PCB Layout design


Algorithm

Coding/Editing Assembling
Compiling/Assembling components

Debugging

Testing Testing

Simulator

S/W H/W

Download

ICE (In Circuit


Emulator)
ECE 7

Embedded Product
1.1.2 Design Considerations for an Embedded System

Unlike software designed for general-purpose computers, embedded software cannot


usually be run on other embedded system without significant modification. This is mainly
because of the incredible variety in the underlying hardware. The hardware in each
embedded system is tailored specifically to the application, in order to keep system costs low.
As a result, unnecessary circuitry is eliminated and hardware resources are shared whenever
possible.
In order to have software, there must be a place to store the executable code and
temporary storage for runtime data manipulation. These take the form of ROM and RAM,
respectively. All embedded systems also contain some type of inputs and outputs. It is almost
always the case that the outputs of the embedded system are a function of its inputs and
several other factors. The inputs to the system usually take the form of sensors and probes,
communication signals, or control knobs and buttons. The outputs are typically displays,
communication signals, or changes to the physical world.

Memory

Inputs Processor Outputs

Other common design requirement includes:


Processing power
Memory
Development cost

ECE 8
Number of Units
Expected Lifetime
Reliability

Processing power

This is the amount of processing power necessary to get the hob done. A
common way to compare processing power is the MIPS (millions of instructions per second)
rating. Other important features of the processor need to be consider is register width,
typically ranges from 8 to 64 bits.

Memory
The amount of memory (ROM and RAM) required holding the executable
software and data it manipulates. The amount of memory required can also affect the
processor selection. In general, the register width off a processor establishes the upper limit
of the amount of memory it can access.

Development cost
The development cost of the hardware and software design processes is a
fixed, one-time cost, so it might be that money is no object or that this is the only accurate
measure of system cost.
Number of units
The tradeoff between production cost and development cost is affected most
by the number of units expected to be produced and sold.
Expected lifetime
This indicates how long must the system continue to function? This affects all
sorts of design decisions from the selection of hardware components to how much the system
may cost to develop and produce.
Reliability

ECE 9
How reliable must the final product be? If it is a children’s toy, it doesn’t
always have to work right, but if it is part of a space shuttle or a car, it had sure better do
what it is supposed to each and every time.

Examples

Most of the things which we use in our day-to-day life is an example of embedded
systems.
Micro Oven - Automobile brakes
Washing Machines - Digital Camera
Toys - Home telemetry
Air Conditioners - Fax Machines
Automobiles - MPEG Decodes
Pagers - Modems
MP3 Players - Mobile Phones

Some common characteristics of embedded systems are:

• Single-functioned
• Executes a single program, repeatedly
• Tightly-constrained
• Low cost, low power, small, fast, etc.
• Reactive and real-time
• Continually reacts to changes in the system’s environment

1.2 EMBEDDED SYSTEM CLASSIFICATION

Autonomous Embedded Systems: These systems function in standalone mode Where the
response times are not critical. The input signals originating from transducers Convert a
physical quantity like temperature into electric signals. Also, the system output controls the
devices.

ECE 10
Eg. : Air Conditioners, CD Players.

Real time Embedded Systems: These are used to carry out time critical task process
control.
Eg. : Boiler Plant must open the valves in a stipulated time; else the pressure
Exceeding its threshold results in a catastrophe.

Networked Embedded Systems: They monitor plant parameters such as


temperature,Pressure, humidity and send the data over the network to a centralized system
for online monitoring.
Eg. : A network enabled web cam monitoring the plant floor transmits its video
output to a remote controlling organization.

Mobile Embedded Systems: Mobile gadgets need to store databases locally in


their memory. These gadgets imbibe powerful, computing and communication
capabilities to perform real time as well as non-real time tasks and handle
multimedia applications. The gadgets embed powerful processor and OS and a
lot of memory with minimal power consumption.
Advantages:
Customization yields lower area, power, cost.
Disadvantages:
Higher HW/software development overhead.
Design, compilers, debuggers may result in delayed time to market.

1.2 Microcontroller

Mirocontrollers are "embedded" inside some other device (often a consumer


product) so that they can control the features or actions of the product. Another name for a
microcontroller, therefore, is "embedded controller".
Microcontrollers are dedicated to one task and run one specific program. The program is
stored in ROM (read-only memory) and generally does not change.

ECE 11
Microcontrollers are often low-power devices and has a dedicated input device and often (but
not always) has a small LED or LCD display for output. A microcontroller also takes input
from the device it is controlling and controls the device by sending signals to different
components in the device.
For example, the microcontroller inside a TV takes input from the remote control and
displays output on the TV screen. The controller controls the channel selector, the speaker
system and certain adjustments on the picture tube electronics such as tint and brightness.
The engine controller in a car takes input from sensors such as the oxygen and knock sensors
and controls things like fuel mix and spark plug timing. A microwave oven controller takes
input from a keypad, displays output on an LCD display and controls a relay that turns the
microwave generator on and off. A microcontroller is often small and low cost. The
components are chosen to minimize size and to be as inexpensive as possible.
A microcontroller is often, but not always, ruggedized in some way.
The microcontroller controlling a car's engine, for example, has to work in temperature
extremes that a normal computer generally cannot handle. A car's microcontroller in Alaska
has to work fine in -30 degree F (-34 C) weather, while the same microcontroller in Nevada
might be operating at 120 degrees F (49 C). When you add the heat naturally generated by
the engine, the temperature can go as high as 150 or 180 degrees F (65-80 C) in the engine
compartment. On the other hand, a microcontroller embedded inside a VCR hasn't been
ruggedized at all. The actual processor used to implement a microcontroller can vary widely.

CHAPTER-2

ECE 12
OPERATING PRINCIPLE OF FIRE FIGHTING ROBOT

In this system microcontroller is interfaced with two dc motors with


driver circuit and seven segment display and Ir receiver and a transmitter is put on the robot
behind the receiver. On robot, IR transmitter which continuously emits IR signals of 38 KHz.
Those IR signals whenever they fall on objects are reflected back. The IR receiver which is
placed on the robot which receives signals of 38 KHz.
Initially on power on reset of the circuit robot moves in its path. On robot,
IR transmitter of 38 KHz is present which continuously sends IR signals modulated at 38
KHz in the direction of robot, and also 38 KHz IR receiver which receives IR signals is
placed behind the transmitter. When ever a obstacle occurs the IR signals are reflected back
from the obstacle and these signals are sensed by the IR receiver and it generates an hardware
interrupt to the microcontroller (89c52). The microcontroller which is interface to dc
geared motors changes the moving direction of the robot in such a way to avoid the clash
with obstacle and there by avoids the obstacle.

CHAPTER - 3

Block diagram and circuit description

The block diagram and its brief description of the project work are
explained in block wise and this block diagram consists the following blocks.

1. At89c52 micro controller


2. L293D
3. DC motors
4. LM324 comparator
5. power supplay
6. Relay
7. DTMF decoder
8. Fire Sensor
9. LEDs

ECE 13
A
T
8
C
5
2

10. Fan
11. Buzzer
BLOCK DIAGRAM

M
1 Mot
M
2
L or1
2
9
3
DTMF D Mot
Decoder or2

LEDS
LEDS
Rel
ay Fan

Fire
Sensor

Buzzer

3.1AT89C52(micro controller)

Microcontrollers are "embedded" inside some other device (often a consumer product) so that they can control
the features or actions of the product. Another name for a microcontroller, therefore, is "embedded
controller."

• Microcontrollers are dedicated to one task and run one specific program. The
program is stored in ROM (read-only memory) and generally does not change.
• Microcontrollers are often low-power devices.
• A microcontroller has a dedicated input device and often (but not always) has a small
LED or LCD display for output. A microcontroller also takes input from the device it
is controlling and controls the device by sending signals to different components in
the device.For example, the microcontroller inside a TV takes input from the remote

ECE 14
control and displays output on the TV screen. The controller controls the channel
selector, the speaker system and certain adjustments on the picture tube electronics
such as tint and brightness. The engine controller in a car takes input from sensors
such as the oxygen and knock sensors and controls things like fuel mix and spark
plug timing.

3.2Description
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8k bytes of Flash
programmable and erasable read only memory (PEROM)
The device is manufactured using Atmel’s high-density nonvolatile 11
Memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and
pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory programmer.
By combining a versatile 8-bit CPU with Flash on a monolithic chip.
The Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective
solution to many embedded control applications

3.3 Features
• The AT89C52 provides the following standard features:
• Compatible with MCS-51 Products
Endurance: 1,000 Write/Erase Cycles
• 8K Bytes of In-System Reprogrammable Flash Memory
• 128 bytes of Internal RAM (128 x 8-bit)
• 32 Programmable I/O Lines
• Two 16-bit Timer/Counters
• Five vector two-level interrupt architecture
• A full duplex serial port
• Three-level Program Memory Lock
• Six Interrupt Sources
• On-chip oscillator and clock circuitry

ECE 15
3.4 PIN DIAGRAM

3.5BLOCK DIGRAM

ECE 16
3.6Pin Description

VCC
Supply voltage.
GND
Ground.

ECE 17
Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can
sink eight TTL inputs. 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 bi-directional I/O port with internal pull-ups.


The Port 1 output buffers can sink/source four TTL inputs. 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 (IIL) because of the internal pull-ups.
Port 1 also receives the low-order address bytes during Flash programming and verification.
Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups.
The Port 2 output buffers can sink/source four TTL inputs. 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
(IIL) because of the internal pull-ups. Port 2 emits the high-order address byte
during fetches from external program memory and during accesses to externaldata
16-bitaddresses(MOVX@DPTR).Inthisapplication,itusesstrong memory that uses
internalpullupswhenemitting1s.Duringaccessestoexternaldatamemorythatuses
8-bit addresses (MOVX @ RI); Port 2 emits the contents of the P2 Special Function
Register. Port2also receives the high-order address bits and some control signals
during Flash programming and verification
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups.The Port 3 output buffers
can sink/source four TTL inputs. 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 (IIL) because of the pull-ups.Port 3 also serves the
functions of various special features of the AT89C51 as listed below:

ECE 18
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
WR (external data memory Write
P3.6
strobe)
RD (external data memory read
P3.7
strobe)

Port 3 also receives some control signals for Flash programming and verification.

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

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

Program Store Enable is the read strobe to external program memory. When the AT89C51 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.

ECE 19
EA /VPP
External Access Enable must be strapped to GND in order to enable the device to fetch code
from external program memory locations starting at 0000H up to FFFFH. Note, however,
that if lock bit 1 is programmed, EA will be internally latched on reset. 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

5.6 Oscillator Characteristics

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 1.
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 2. There are no requirements on the duty cycle of the
external clock signal, since the input to the internal clocking circuitry is through a divide-by-
two flip-flop, but minimum and maximum voltage high and low time specifications must be
observed.

ECE 20
OSCILLATOR CONNECTIONS

ECE 21
5.7 At89c51: Types of Memory

The 89c51 has three very general types of memory The memory types are On-Chip Memory,
External Code Memory, and External RAM

.. .

On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on
the microcontroller itself. On-chip memory can be of several types, but we'll get into that
shortly.

External Code Memory is code (or program) memory that resides off-chip. This is often in
the form of an external EPROM.

External RAM is RAM memory that resides off-chip. This is often in the form of
standard static RAM or flash RAM.

ECE 22
Code Memory: Code memory is the memory that holds the actual 89c51 program that is to
be run. This memory is limited to 64K and comes in many shapes and sizes: Code

memory may be found on-chip, either burned into the microcontroller as ROM or EPROM.
Code may also be stored completely off-chip in an external ROM or, more commonly, an
external EPROM. Flash RAM is also another popular method of storing a program. Various
combinations of these memory types may also be used--that is to say, it is possible to have
4K of code memory on-chip and 64k of code memory off-chip in an EPROM.

When the program is stored on-chip the 64K maximum is often reduced to 4k, 8k, or 16k.
This varies depending on the version of the chip that is being used. Each version offers
specific capabilities and one of the distinguishing factors from chip to chip is how much
ROM/EPROM space the chip has.

External RAM:

As an obvious opposite of Internal RAM, the 89c51 also supports what is called External
RAM.As the name suggests, External RAM is any random access memory which is found
off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also
slower. For example, to increment an Internal RAM location by 1 requires only 1 instruction
and 1 instruction cycle. To increment a 1-byte value stored in External RAM requires 4
instructions and 7 instruction cycles. In this case, external memory is 7 times slower!What
External RAM loses in speed and flexibility it gains in quantity. While Internal RAM is
limited to 128 bytes (256 bytes with an 8052), the 89c51 supports External RAM up to 64K.

On-Chip Memory As mentioned, the 89c51 includes a certain amount of on-chip


memory. On-chip memory is really one of two types: Internal RAM and Special Function
Register (SFR) memory. The layout of the 89c51's internal

memory is presented in the following memory map..

ECE 23
As is illustrated in above map, the 89c51 has a bank of 128 bytes of Internal RAM. This
Internal RAM is found on-chip on the 89c51 so it is the fastest RAM available, and it is also
the most flexible in terms of reading, writing, and modifying it’s contents. Internal RAM is
volatile, so when the 89c51 is reset this memory is cleared.

Register Banks:

The 89c51 uses 8 "R" registers which are used in many of its instructions. These
"R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7). These
registers are generally used to assist in manipulating values and moving data from one
memory location to another the Accumulator. Thus if the Accumulator (A) contained the
value 6 and R4 contained the value 3, the Accumulator would contain the value 9 after this

ECE 24
instruction was executed.However, as the memory map shows, the "R" Register R4 is really
part of Internal RAM. Specifically, R4 is address 04h. This can be see in the bright green
section of the memory map.But, the 89c51 has four distinct register banks. When the 89c51
is first booted up, register bank 0 (addresses 00h through 07h) is used by default. However,
your program may instruct the 89c51 to use one of the alternate register banks; i.e., register
banks 1, 2, or 3. In this case, R4 will no longer be the same as Internal RAM address 04h.
For example, if your program instructs the 89c51 to use register bank 3, "R" register R4 will
now be synonomous with Internal RAM address 1Ch.

The concept of register banks adds a great level of flexibility to the 89c51, especially when
dealing with interrupts (we'll talk about interrupts later). However, always remember that the
register banks really reside in the first 32 bytes of Internal RAM.

Bit Memory:

The 89c51, being a communications-oriented microcontroller, gives the user


the ability to access a number of bit variables. These variables may be either 1 or 0. There
are 128 bit variables available to the user, numberd 00h through 7Fh. The user may make use
of these variables with commands such as SETB and CLR. For example, to set bit number 24
(hex) to 1 you would execute the instruction:

SETB 24h

It is important to note that Bit Memory is really a part of Internal RAM. In fact, the 128 bit
variables occupy the 16 bytes of Internal RAM from 20h through 2Fh. Thus, if you write the
value FFh to Internal RAM address 20h you’ve effectively set bits 00h through 07h. Bit
variables 00h through 7Fh are for user-defined functions in their programs. However, bit
variables 80h and above are actually used to access certain SFRs on a bit-by-bit basis.

5.8 89c51: Basic Registers

The Accumulator:

ECE 25
The Accumulator, as it’s name suggests, is used as a general register to
accumulate the results of a large number of instructions. It can hold an 8-bit (1-byte) value
and is the most versatile register the 89c51 has due to the shear number of instructions that
make use of the accumulator. More than half of the 89c51’s 255 instructions manipulate or
use the accumulator in some way.

The "R" registers:

The "R" registers are a set of eight registers that are named R0, R1, etc.
up to and including R7.These registers are used as auxillary registers in many
operations. To continue with the above example, perhaps you are adding 10 and 20.
The original number 10 may be stored in the Accumulator whereas the value 20 may
be stored in, say, register R4. To process the addition you would execute the
command

The "B" Register:

The "B" register is very similar to the Accumulator in the sense that it may hold
an 8-bit (1-byte) value.The "B" register is only used by two 89c51 instructions: MUL AB and
DIV AB. Thus, if you want to quickly and easily multiply or divide A by another number,
you may store the other number in "B" and make use of these two instructions.Aside from
the MUL and DIV instructions, the "B" register is often used as yet another temporary
storage register much like a ninth "R" register.

The Data Pointer (DPTR):

ECE 26
The Data Pointer (DPTR) is the 89c51’s only user-accessable 16-bit (2-byte)
register. The Accumulator, "R" registers, and "B" register are all 1-byte values.DPTR, as the
name suggests, is used to point to data. It is used by a number of commands which allow the
89c51 to access external memory. When the 89c51 accesses external memory it will access
external memory at the address indicated by DPTR.While DPTR is most often used to point
to data in external memory, many programmers often take advantge of the fact that it’s the
only true 16-register available. It is often used to store 2-byte values which have nothing to
do with memory locations.

The Program Counter (PC):

The Program Counter (PC) is a 2-byte address which tells the 89c51 where the next
instruction to execute is found in memory. When the 89c51 is initialized PC always starts at 0000h
and is incremented each time an instruction is executed. It is important to note that PC isn’t always
incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by 2 or 3
in these cases

The Stack Pointer (SP):

The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit
(1-byte) value. The Stack Pointer is used to indicate where the next value to be removed from
the stack should be taken from.When you push a value onto the stack, the 89c51 first
increments the value of SP and then stores the value at the resulting memory location.When
you pop a value off the stack, the 89c51 returns the value from the memory location
indicated by SP, and then decrements the value of SP.

ECE 27
L293D MOTOR DRIVER

An Object that controls a DC motor using a L293D H-Bridge.

4.2.1 Description: An oDCMotor2 Object is a Hardware Object that uses three digital I/O
lines to control the direction, speed, and braking of a DC Motor by communicating with an
H-Bridge circuit which handles the voltage and current requirements of the DC Motor it is
connected to. The H-Bridge that the DC Motor Object is designed to work with has 2 drive
inputs and a PWM input. The L293 and L298 H-Bridges are configured in this way.

The oDCMotor2 Object is capable of driving a DC Motor at 255 different speeds, in forward
or reverse plus free spinning, active braking, and friction braking modes. The speed at which
the motor spins is specified by a single value which can be configured to have a range of 0 to
255 or -128 to +127.

When the speed value is configured with a range of -128 to +127, the speed value is then also
used to specify the direction that the motor turns. When this value is 0, the motor is at free-
spinning rest. When the value is a positive number from 1 to 127, the motor turns forward at
the speed indicated by the value. The higher the value, the faster the motor turns. When the
value is a negative number from -1 to -128, the motor turns backwards at the speed indicated
by the value. The lower the number, the faster the motor turns in reverse.

When the speed value is configured with a range of 0 to 255, the motor turn in a direction
specified by a direction value at the rate specified by the speed value. When this value is 0,
the motor is at free-spinning rest. When the value is 1 to 255, the motor turns forward at the
speed indicated by the value. The higher the value, the faster the motor turns.

The physical direction that the motor will turn can be set to: forward turns clockwise and
reverse turns counter-clockwise or forward turns counter-clockwise and reverse turns
clockwise.

ECE 28
A brake value is used to apply brakes and when this value is set to 1, the speed value is
ignored and the motor will quickly stop. The method used to stop the motor is active braking.

The maximum number of DC Motor Objects that can be dimensioned in a single application
program is 2, limited only be the number of PWM channels available in

4.2.2 Operation: The oDCMotor2 Object monitors the Value and the Brake
properties, and based on their numeric values controls the direction, speed, and braking of a
DC Motor by outputting control signals to a H-Bridge motor driver circuit such as the
L293D. To control the speed of the motor, a Pulse-Width-Modulated (PWM) clock cycle is
outputted on the I/O line specified by the IOLineP property. The direction that the motor
spins is controlled by setting one of the control lines specified by IOLine1 and IOLine2
properties to 1 while setting the other to 0. Whether or not the brakes are applied is controlled
by outputting the same value to both of the control lines specified by IOLine1 and IOLine2
properties. The L293D H-Bridge monitors the state of all three of these control lines and
controls the DC motor accordingly.

In normal operation, a 0 in the Value property will cause the PWM line to output 0 Volts,
causing the motor to be at a full stop. If the Value property is greater than 0, then the Pulse-
Width of the PWM output is set to correspond to the Value property, the Direction property
is set to 0, the I/O line specified by the IOLine1 property is set to 5 Volts and the I/O line
specified by the IOLine2 property is set to 0 Volts. This will cause the DC Motor to go
forward at a speed specified by the Value property. The higher the number (up to 127), the
faster the motor will turn. If the Value property is less than 0, then the Pulse-Width of the
PWM output is set to correspond to the absolute value of the Value property, the Direction
property is set to 1, the I/O line specified by the IOLine1 property is set to 0 Volts and the
I/O line specified by the IOLine2 property is set to 5. This will cause the DC Motor to go
backwards at a speed specified by the Value property. The lower the number (down to
negative 128), the faster the motor will turn in reverse.

ECE 29
If the Unsigned property is set to 1, then the operation is modified so that the Value property
is always expected to be a positive value. In this case, the application program is expected to
set the value of the Direction property, and the control lines specified by the IOLine1 and
IOLine2 properties are set according to the value that the Direction property was set to.

The actual direction that the DC Motor spins when going in the "forward" direction can be
reversed by setting the InvertOutD property to 1.

When the Brake property is set to 1, both of the control lines specified by the IOLine1 and
IOLine2 properties are set to the value specified by the InvertOutB property, and the PWM
output is set to the value specified by the Mode property. The required state of the PWM
while braking is on depends on the control circuit that is used. If the motor is being driven by
an L293D H-Bridge, then setting both the control lines to the same value will cause the
Motor to generate power back into itself, effectively driving the motor back the other way
which causes the motor to come to an abrupt stop. In this case, the Mode property need to be
1 which will set the PWM line to 5 Volts so that the motor will remain on to allow the
braking power to be applied. However, if the Brake line is connected to a mechanical
braking system, then the Mode property needs to be 0 which will set the PWM line to 0
Volts so that the Motor will shut off when the mechanical brake is applied.

The combination of the period and the prescale properties specify the PWM clock cycle's
frequency. The prescale property specifies how many times a 5-Mhz clock is divided. This
scaled down 5-Mhz clock is used to increment a Period-Duration Counter. A full PWM clock
cycle has been reached when the Period-Duration Counter reaches the value specified by the
period property. The prescale property can be set to divide the 5-Mhz clock by 1, 4, or 16,
giving frequencies of 5-Mhz, 1.25-Mhz, and 312.5-Khz. The period property can be set to
any value from 1 to 255. This results in 765 possible frequencies.

The Speed of the DC Motor is controlled by the Pulse-Width of the logic-high portion of the
cycle determined by the value property. At the beginning of each PWM clock cycle, the I/O
Line specified by the IOLineP property is set to 5 Volts. Each time the Period-Duration
Counter is incremented it is compared to the value specified by the value property. When the

ECE 30
Period-Duration Counter reaches the value specified by the value property the I/O Line is set
to 0-Volts.

The period property also dictates the resolution of the PWM pulse. If the period property is
set to 255 then the value property's range is 0 - 255. Likewise, if the period property is set to
10, then the value property's effective range is 0 - 10, because any value above 10 will never
be reached by the Period-Duration Counter.

The operate property specifies if the High going PWM pulse is generated. When the operate
property is set to 1 the PWM Object starts generating PWM pulses. When the operate
property is set to 0 the PWM pulses are discontinued and the I/O Line specified by the
IOLineP is set to 0-Volts. If a current PWM pulse was in progress it is cut short and the I/O
line is immediately set to 0-Volts. The control lines specified by the IOLine1 and IOLine2
properties are not changed when Operate is set to 0.
Properties:

The following table lists the Properties of the oDCMotor2 Object:

Property Description
Address Returns a pointer to the address of the oDCMotor2 Object instance.

Data-Type: Address, Read-Only

Data-Range: 0 - 127
Brake A value that specifies if the brake output is on.

When the Brake property is set to 1 the brake output goes active and the
PWM output is set to the value specified by Mode. The active output level
of the Brake output depends on the value of the InvertOutB property.

Data-Type: Bit, Flag

Data-Range: 0 - 1

ECE 31
Brake InvertOutB Brake Output
0 0 0 Volts
0 1 5 Volts
1 0 5 Volts
1 1 0 Volts

Direction Specifies the direction that the motor will turn or indicates the direction
that the motor is turning.

If the Unsigned property is 0 the Direction property is set to 0 if the Value


property is a positive number and set to 1 if the Value property is a
positive number.
If the Unsigned property is 1 the Direction property controls the output
values of the control lines specified by the IOLine1 and IOLine2
properties.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Direction Direction Output


0 0 Volts
1 5 Volts

InvertOutB A value that specifies if the brake output is inverted.

The InvertOutB property specifies what logic level the brake output gets
set to when the brake output goes active.

Data-Type: Bit

Data-Range: 0 - 1

InvertOutB Brake IOLine1 Output IOLine2 Output

ECE 32
0 0 Controlled by Direction Controlled by Direction
0 1 5 Volts 5 Volts
1 0 Controlled by Direction Controlled by Direction
1 1 0 Volts 0 Volts

InvertOutD A value that specifies if the direction output is inverted.

Data-Type: Bit, Flag

Data-Range: 0 - 1

InvertOutD Direction IOLine1 Output IOLine1 Output


0 0 5 Volts 0 Volts
0 1 0 Volts 5 Volts
1 0 0 Volts 5 Volts
1 1 5 Volts 0 Volts

IOLine1 A value that specifies the physical I/O Line to use for the first control
output line.

Data-Type: Byte

Data-Range: 0 - 31
IOLine2 A value that specifies the physical I/O Line to use for the second control
output line.

Data-Type: Byte

Data-Range: 0 - 31
IOLineP A value that specifies the physical I/O Line to use for the PWM output.

Data-Type: Bit

Data-Range: 0 - 1

ECE 33
The following table list the values of the IOLineP Property.

IOLineP Constant Description


0 The PWM signal is outputted on I/O Line 18.
18 can be assigned to IOLineP in place of 0 but it
will read back as 0.
1 The PWM signal is outputted on I/O Line 17.
17 can be assigned to IOLineP in place of 1 but it
will read back as 1.
Mode A value that specifies the level that the PWM line will be set to when the
brake is on.

Data-Type: Bit

Data-Range: 0 - 1

Mode Constant Description


When the brake line is set to 1, the PWM output will
0 cvOff
be set to 0 Volts.
When the brake line is set to 1, the PWM output will
1 cvOn
be set to 5 Volts.

Operate A value that specifies if the motor operates.

Data-Type: Bit, Flag

Data-Range: 0 - 1
Period A value that specifies the frequency of the PWM cycle.

Data-Type: Byte

Data-Range: 0 - 255

ECE 34
PreScale A value that specifies the base frequency of the period property.

Data-Type: Nibble

Data-Range: 0 - 3

The following table list the values of the PreScale Property.

PreScale Description
0 The base frequency is 5-Mhz
1 The base frequency of 5-Mhz is divided by 4 to get 1.25Mhz
2 The base frequency of 5-Mhz is divided by 16 to get 312 500hz
3 The base frequency of 5-Mhz is divided by 16 to get 312 500hz
(same as 2)
Unsigned A value that specifies if the Value property is signed or unsigned.

Data-Type: Bit

Data-Range: 0 - 1

Unsigned Value Range


0 -127 to +127
1 0 to 255
Value A value that specifies how fast and optionally in what direction the motor
turns.

Data-Type: Byte, Default

Data-Range: 0 to 255 or -128 to +127

Value Unsigned PWM Output Direction


127 0 Set to 1 (full-speed) Set to 0
1 to 126 0 Set to Value * 2 Set to 0

ECE 35
0 0 Set to 0 (off) Set to 0
-1 to -127 0 Set to abs(Value) * 2 Set to 1
-128 0 Set to 1 (full-speed) Set to 1
0 1 Set to 0 (full-stop) unchanged
1 to 254 1 Set to Value unchanged
255 1 Set to 1 (full-speed) unchanged

Connections:
The L293D H-Bridge is a dual H-Bridge and each one of its H-Bridges is a set of 2 push-
pull drivers that use a total of 3 I/O lines. IOLine1 and IOLine2 can be any 2 I/O lines of
the OOPic's 31 I/O lines. IOLineP can be I/O line 17 or 18. The L293D H-Bridge
requires a power supply that is capable of handling enough current to dive the attached
DC motor.

L293D H-Bridge Driver and DC Motor.

L293D First set Second set OOPic


Pin Name Description I/O Name I/O Name I/O Line
Output Enable for Outputs 1 and
1 Enable 1 IOLineP 17 or 18
2
2 Input 1 Control Line for Output 1 IOLine1 Any*
3 Output 1 Output 1
4 Gnd Gnd Gnd Gnd
5 Gnd Gnd Gnd Gnd
6 Output 2 Output 2
7 Input 2 Control Line for Output 2 IOLine2 Any*

ECE 36
8 Vs Supply Voltage of up to 36
Output Enable for Outputs 3 and
9 Enable 2 IOLineP 17 or 18
4
10 Input 3 Control Line for Output 3 IOLine1 Any*
11 Output 3 Output 3
12 Gnd Gnd Gnd Gnd
13 Gnd Gnd Gnd Gnd
14 Output 4 Output 4
15 Input 4 Control Line for Output 4 IOLine2 Any*
16 Vss Logic Supply Voltage volts

Caution:
Do not connect outputs of OOpic directly to dc motor. The TTL circuitry of the OOPic is
not designed to drive the power requirements of a DC Motor. Doing so can potentially
damage the OOPic's TTL outputs.

*Caution: I/O lines 16 through 23 are used for special purposes. Be sure not to specify
any of these I/o lines if these special functions are in use.

I realize that Seattle has developed it’s own mutant breed of controller circuits, I think it’s
based on the 68HC12, but I have successfully resisted all attempts to be lured to the dark side
of the force and will continue to use the BS-2 (Basic Stamp II). Here is a real quick
description of the L293D inputs:

1, 9 Enable pins. Hook them together and you can either keep them high and run the motor
all the time, or you can control them with your own controller.

2,7,10, 15 Control the two coils. Here is how you pulse them for a single cycle:

STEPPER COIL A1 COIL B1 COIL A2 COIL B2

ECE 37
TABLE

STEP 1 ON ON OFF OFF

STEP2 OFF ON ON OFF

STEP3 OFF OFF ON ON

STEP4 ON OFF OFF ON

3,6,11,14 Here is where you plug in the two coils. You want to ohm them out and make sure
you get one coil hooked up to 3,6 and another one hooked up to 11,14.4,5,12,13 Gets hooked
to ground.8 Motor voltage, usually about 6 volts.16 +5 volts. It’s a good idea to keep this
power supply separate from your motor power.

ECE 38
INTERNAL BLOCKDIAGRAM

ECE 39
DTMF DECODER

General Description
TheHT9170seriesareDualToneMultiFrequency(DTMF)rec
eiver
integratedwithdigitaldecoderandbandsplitfilterfunctions.TheHT
9170B andHT9170Dtypessupplypowerdown mode
andinhibitmodeoperations.All types of
theHT9170seriesusdigitalcountingtechniques to detect and decode
allthe16DTMF tone pairs into a 4-bitcodeoutput.Highlyaccurateswitched
capacitor filters areemployedtdivide tone (DTMF) signals intolowand high
group signals. A built-in dial tonerejection circuit is provided to eliminate the
need for prefiltering

Features
_ Operating voltage: 2.5V~5.5V
_ Minimal external components
_ No external filter is required
_ Low standby current (on power down mode)
_ Excellent performance
_ Tristate data output for _C interface
_ 3.58MHz crystal or ceramic resonator
_ 1633Hz can be inhibited by the INH pin
_ HT9170B: 18-pin DIP package
HT9170D: 18-pin SOP package

40
BLOCK DIGRAM

PinAssignment:

41
Pin description

42
Approximate internal connection circuit

DC Characteristics:

43
AC Characteristics

Functional Description:

Overview

44
The HT9170 series tone decoders consist ofthree band pass filters and two digital
decodecircuits to convert a tone (DTMF) signal intodigital code output.An
operational amplifier is built-in to adjust the input signal.The pre-filter is a
banrejection filter which reducesthe dialing tone from 350Hz to
400Hz.The low group filter filters low group frequencysignal
output whereas the high group filter filtershigh group frequency
signal output.Each filter output isfollowed by a zero-
crossingdetector with hysteresis. When each signal amplitudeat
the output exceeds the specifiedlevel, it is transferred to full
swing logic signal.When input signals are recognized to be
effective,DV becomes high, and the correct tonecode (DTMF)
digit is transferred

Steering control circuit


The steering control circuit is used for measuring the effective signal duration and
for protecting against drop out of valid signals. It employs the analog delay by
external RC time-constant controlled by EST. The timing is shown in Figure 3.
The EST pin is normally low and draws the RT/GT pin to keep low through
discharge of external RC. When a valid tone input is detected, EST goes high to
charge RT/GT through RC .When the voltage of RT/GT changes from 0 to VTRT
(2.35V for 5V supply), the input signal is effective, and the correct code will be
created by the code detector. After D0~D3 are completely attached, DV output
becomes high. When the voltage of RT/GT falls down from VDD to VTRT (i.e..,
when there is no input tone), DV output becomes low, and D0~D3 keeps data
until an ext valid tone input is produced. By selecting adequate external RC value,
the minimum acceptable input tone duration (tACC) and the minimum
acceptable inter-tone rejection (tIR)can be set. External components (R, C) are
chosen by the formula
tacc=tDP+tGTP;
tIR=tDA+tGTA;
where tACC: Tone duration acceptable time
tDP: EST output delay time (_L__H_)
tGTP: Tone present time
tIR: Inter-digit pause rejection time
tDA: EST output delay time (_H__L_)

tGTA: Tone absent time

45
DTMF data out put table

Data Output

46
The Data out put(D0~D3)are tristate outputs.When OE input becomes low,data
output(D0~D3)are high impedence.

Application Circuit:

LM324

47
Description
The LM324/LM324A,LM2902,LM224/LM224A consist of
four independent, high gain, internally frequency
compensated operational amplifiers which were designed
specifically to operate from a single power supply over a
wide voltage range. Operation from split power supplies is
also possible so long as the difference between the two
supplies is 3 volts to 32 volts. Application areas include
transducer amplifier, DC gain blocks and all the
conventional OP amp circuits which now can be easily
implemented in single power supply systems.

Internal Block

Features
• Internally frequency compensated for unity gain
• Large DC voltage gain: 100dB
• Wide power supply range:
LM224/LM224A, LM324/LM324A : 3V~32V (or ア1.5 ~
15V)
LM2902: 3V~26V (or ア1.5V ~ 13V)

48
• Input common mode voltage range includes ground
• Large output voltage swing: 0V to VCC -1.5V

• Power drain suitable for battery operation

Absolute Maximum rating

49
50
51
52
53
54
RELAY CIRCUITS

6.1 INTRODUCTION
All relays contain a sensing unit, the electric coil, which is powered by AC
or DC current. When the applied current or voltage exceeds a threshold
value, the coil activates the armature, which operates either to close the
open contacts or to open the closed contacts. When a power is supplied to
the coil, it generates a magnetic force that actuates the switch
mechanism. The magnetic force is, in effect, relaying the action from one
circuit to another. The first circuit is called the control circuit; the second is
called the load circuit.

55
There are three basic functions of a relay: On/Off Control, Limit
Control and Logic Operation.
On/Off Control: Example: Air conditioning control, used to limit and
control a “high power” load, such as a compressor
Limit Control: Example: Motor Speed Control, used to disconnect a
motor if it runs slower or faster than the desired speed
Logic Operation:
Example: Test Equipment, used to connect the instrument to a number
of testing points on the device under test.

6.2 TYPES OF RELAYS


There are two basic classifications of relays: Electromechanical and Solid
State. Electromechanical relays have moving parts, whereas solid state
relays have no moving parts. Advantages of Electromechanical relays
include lower cost, no heat sink is required, multiple poles are available,
and they can switch AC or DC with equal ease.

56
A.) Electromechanical Relays
General Purpose Relay: The general-purpose relay is rated by the amount
of current its switch contacts can handle. Most versions of the general-
purpose relay have one to eight poles and can be single or double throw.
These are found in computers, copy machines, and other consumer
electronic equipment and appliances.

Power Relay: The power relay is capable of handling larger power


loads – 10-50 amperes or more.
They are usually single-pole or double-pole units.

Contactor: A special type of high power relay, it’s used mainly to


control high voltages and currents in industrial electrical applications.
Because of these high power requirements, contactors always have
double-make contacts.

57
Time-Delay Relay: the contacts might not open or close until some
time interval after the coil has been energized. This is called delay-on-
operate. Delay-on-release means that the contacts will remain in their
actuated position until some interval after the power has been removed
from the coil. A third delay is called interval timing. Contacts revert to their
alternate position at a specific interval of time after the coil has been
energized. The timing of these actions be a fixed parameter of the relay,
or adjusted by a knob on the relay itself, or remotely adjusted through an
external circuit.

B.) Solid State Relays


These active semiconductor devices use light instead of magnetism to
actuate a switch. The light comes from an LED, or light emitting diode.
When control power is applied to the device’s output, the light Solid State
Relays is turned on and shines across an open space. On the load side of
this space, a part of the device senses the presence of the light, and
triggers a solid state switch that either opens or closes the circuit under
control. Often, solid state relays are used where the circuit under control
must be protected from the introduction of electrical noises. Advantages of
Solid State Relays include low EMI/RFI, long life, no moving parts, no
contact bounce, and fast response. The drawback to using a solid state
relay is that it can only accomplish single pole switching.

58
INTERFACING OF RELAY CIRCUIT TO 89C52

59
CONCLUSIONS
Relays are like remote control switches and are used in many
applications because of their relative simplicity, long life, and proven
high reliability. Relays are used in a wide variety of applications
throughout industry, such as in telephone exchanges, digital
computers and automation systems. Highly sophisticated relays are
utilized to protect electric power systems against trouble and power
blackouts as well as to regulate and control the generation and
distribution of power. In the home, relays are used in refrigerators,
washing machines and dishwashers, and heating and air-conditioning
controls. Although elays are generally associated with electrical
circuitry, there are many other types, such as pneumatic and
hydraulic. Input may be electrical and output directly mechanical, or
vice versa.

Source code

#include<at89x51.h>

#define DTMF_CTRL P0 //Data Valid(DV) of DTMF Connected to Port-0.0

#define DTMF_Data P1 //Output from DTMF to MICROCONTROLLER Input Data

#define DC_MOTORS P2 //Output from MICROCONTROLLER to


L293D Input Data for Driving Motors

#define FIRE_BUZZER_FAN P3 //Acting like Input and Output as FIRE,


BUZZER, FAN

60
#define Buzzer P3_0

#define Fire P3_1

#define Fan P3_2

sbit DV = P0^0; // data valide pin control manual, and all the other three pins control
pins

//sbit OE = P3^5; // out put enable;

//sbit INH = P3^6; // when it high detect the char;

//sbit PWDN = P3^7; // when it enable D0 to D3 goes into powerdown


mode;*/

sbit D0 = P1^0;

sbit D1 = P1^1;

sbit D2 = P1^2; //port P1.0 to P1.3 inputs from dtmf

sbit D3 = P1^3;

void delay(int sec,int ticks)

unsigned int i,j;

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

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

61
void Machine_Function (void)

unsigned int i;

if(Fire == 0)

Buzzer = 0;

Fan = 1;

else

Buzzer = 1;

Fan = 0;

i = DTMF_Data;

i = i & 0x0F;

switch (i)

case 0x02:

DC_MOTORS = 0x0A;

62
break;

case 0x04:

DC_MOTORS = 0x66;

delay(0,15000);

DC_MOTORS = 0x00;

break;

case 0x06:

DC_MOTORS = 0x99;

delay(0,15000);

DC_MOTORS = 0x00;

break;

case 0x08:

DC_MOTORS = 0x55;

break;

case 0x05:

DC_MOTORS = 0x00;

break;

63
}

void main()

DTMF_Data = 0x0FF;

FIRE_BUZZER_FAN = 0x0FF;

DV = 1; /* Make DV pin as Input pin */

//OE = 1; /* Make OE as Output pin */

//INH = 1; /* Make INH as Output pin */

//PWDN = 1; /* Make PWDN as Output pin */

delay(2,1275);

//INH = 0;

//PWDN = 0;

DC_MOTORS = 0x00; /* Make PORT2 as output port */

FIRE_BUZZER_FAN = 0x00;

while(1)

if((DV == 1)||(Fire == 0)) //condition for DV enabled or Fire


enabled

64
{

Machine_Function();

else

Buzzer = 1; // indicates Buzzer Disabled

Fan = 0; // indicates Fan Disabled

} // while terminated

} // main function terminated

65
66
DC MOTORS

Two geared head dc motors of rating 100 rpm are used. By changing polarities of
these dc motors they can move in forward and backward directions. The geared
head dc motors are used because these motors provide high initial torque. As
speed of dc motor increases torque decreases. The speed control of dc motors is
controlled by using pulse width modulation technique. In pulse width
modulation technique on time ,off time periods can be varies so that average
voltage can be varied. BY increasing on time period of pulse width average
voltage can be increase so that speed of dc motor is increase and by decreasing
on time period speed decrea

4.8 LIGHT EMITTING DIODE (LED)

LED's are special diodes that emit light when connected in a


circuit. They are frequently used as "pilot" lights in electronic appliances to
indicate whether the circuit is closed or not. As a clear (or often colored) epoxy
case enclosed the heart of an LED, the semi-conductor chip.
4.8.1 SYMBOL OF LED

67
4.8.2 CROSS SECTIONAL VIEW OF LED

The two wires extending below the LED epoxy enclosure, or the
"bulb" indicate how the LED should be connected into a circuit. The negative side
of an LED lead is indicated in two ways: 1) by the flat side of the bulb, and 2) by
the shorter of the two wires extending from the LED. The negative lead should be
connected to the negative terminal of a battery. LED's operate at relative low
voltages between about 1 and 4 volts, and draw currents between about 10 and 40
milliamperes. Voltages and currents substantially above these values can melt a
LED chip. The most important part of a light emitting diode (LED) is the semi-
conductor chip located in the center of the bulb as shown at the right. The chip

68
has two regions separated by a junction. The p region is dominated by positive
electric charges, and the n region is dominated by negative electric charges. The
junction acts as a barrier to the flow of electrons between the p and the n regions.
Only when sufficient voltage is applied to the semi-conductor chip, can the
current flow, and the electrons cross the junction into the p region. In the absence
of a large enough electric potential difference (voltage) across the LED leads, the
junction presents an electric potential barrier to the flow of electrons. When
sufficient voltage is applied to the chip across the leads of the LED, electrons can
move easily in only one direction across the junction between the p and n regions.
In the p region there are many more positive than negative charges. In the n
region the electrons are more numerous than the positive electric charges.When a
voltage is applied and the current starts to flow, electrons in the n region have
sufficient energy to move across the junction into the p region. Once in the p
region the electrons are immediately attracted to the positive charges due to the
mutual Coulomb forces of attraction between opposite electric charges. When an
electron moves sufficiently close to a positive charge in the p region, the two
charges "recombine". Each time an electron recombines with a positive charge,
electric potential energy is converted into electromagnetic energy. For each
recombination of a negative and a positive charge, a quantum of electromagnetic
energy is emitted in the form of a photon of light with a frequency characteristic
of the semi-conductor material (usually a combination of the chemical elements
gallium, arsenic and phosphorus). Only photons in a very narrow frequency range
can be emitted by any material. LED's that emit different colors are made of
different semi-conductor materials, and require different energies to light them.

4.8.3 Working:

The most important part of a light emitting diode (LED) is the semi-
conductor chip located in the center of the bulb as shown. The chip has two
regions separated by a junction. The p region is dominated by positive electric
charges, and the n region is dominated by negative electric charges. The junction

69
acts as a barrier to the flow of electrons between the p and the n regions. Only
when sufficient voltage is applied to the semi-conductor chip, can the current flow
and the electrons cross the junction into the p region.

In the absence of a large enough electric potential difference (voltage) across the
LEDleads, the junction presents an electric potential barrier to the flow of
electrons. When sufficient voltage is applied to the chip across the leads of the
LED, electrons can moveeasily in only one direction across the junction between
the p and n regions. In the p region there are many more positive than negative
charges. In the n region the electrons are more numerous than the positive electric
charges. When a voltage is applied and the current starts to flow, electrons in the
n region have sufficient energy to move across the junction into the p region.
Once in the p region the electrons are immediately attracted to the positive
charges due to the mutual Coulomb forces of attraction between opposite electric
charges. When an electron moves sufficiently close to a positive charge in the P
region, the two charges "re-combine".Each time an electron recombines with a
positive charge; electric potential energy is converted into electromagnetic
energy. For each recombination of a negative and a positive charge, a quantum of
electromagnetic energy is emitted in the form of a photon of light with a
frequency characteristic of the semi-conductor material (usually a combination of
the chemical elements gallium, arsenic and phosphorus). Only photons in a very
narrow frequency range can be emitted by any material.

4.8.4 Color of L.E.D

70
LED's that emit different colors are made of different semi-conductor
materials, and require different energies to light them.

The color of an LED is determined by the semiconductor material, not


by the coloring of the 'package' (the plastic body). LEDs of all colors are available
in uncolored packages which may be diffused (milky) or clear (often described as
'water clear'). The colored packages are also available as diffused (the standard
type) or transparent.

4.9 IR LEDS

4.9.1 Features

• Good optical to mechanical alignment


• Mechanically and wavelength matched to the
TO-18 series phototransistor

71
• Hermetically sealed package
• High irradiance level
• (*) Indicates JEDEC registered values
1. Dimensions for all drawings are in inches (mm).
2. Tolerance of ± .010 (.25) on all non-nominal dimensions
unless otherwise specified.

4.9.2 Description

• The 1N6264 is a 940 nm LED in a narrow angle, TO-46 package.

BUZZER

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


automobiles, household appliances such as a microwave oven, or game shows.

It most commonly consists of a number of switches or sensors connected to a


control unit that determines if and which button was pushed or a preset time has
lapsed, and usually illuminates a light on the appropriate button or control panel,
and sounds a warning in the form of a continuous or intermittent buzzing or
beeping sound. Initially this device was based on an electromechanical system
which was identical to an electric bell without the metal gong (which makes the
ringing noise). Often these units were anchored to a wall or ceiling and used the
ceiling or wall as a sounding board. Another implementation with some AC-

72
connected devices was to implement a circuit to make the AC current into a noise
loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm
speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric
sounder like a Sonalert which makes a high-pitched tone. Usually these were
hooked up to "driver" circuits which varied the pitch of the sound or pulsed the
sound on and off.

In game shows it is also known as a "lockout system," because when one person
signals ("buzzes in"), all others are locked out from signalling. Several game
shows have large buzzer buttons which are identified as "plungers".

The word "buzzer" comes from the rasping noise that buzzers made when they
were electromechanical devices, operated from stepped-down AC line voltage at
50 or 60 cycles. Other sounds commonly used to indicate that a button has been
pressed are a ring or a beep.

Some systems, such as the one used on Jeopardy!, make no noise at all, instead
using light. Another example is the buzzer at the end of each stage in Sasuke,
Kunoichi, and Viking. These buzzers do not make a sound or turn on a light;
instead, they stop a nearby digital clock, briefly fire two smoke cannons on each
side of the stage exit, and open the exit. However, at the end of the Heartbreaker
in Viking, the buzzer is replaced with a sword that, when removed, causes two
contacts to touch, closing the circuit and causing the latter two actions above to
occur.

ses vicevers

73
CHAPTER 6

SOFTWARE USED

6.1 Introduction to keil

We developed this application using keil software which is cross compiler


which converts c language code to assembly language code and generates hex

74
code which is dumped into the 8051 microcontroller using uc flash
programmer .we used c51 cross compiler. we developed code in assembly
language and it is compiled and converted into hex code by using C51 compiler.
Keil development tools for the 8051 Microcontroller Architecture support every
level of software developer from the professional applications engineer to the
student just learning about embedded software development.
The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-
time Kernels, Single-board Computers, and Emulators support all 8051
derivatives and help you get your projects completed on schedule.The Keil 8051
Development Tools are designed to solve the complex problems facing embedded
software developers.

6.2 C51 Compiler

The Cx51 Compiler creates object modules from the C files you write and
compile. Object modules created may be added into a library (using theLIB51
library manager) or may be linked with other object modules and libraries to form
a program (using the BL51 blinker or the LX51 linker The C programming
language is a general-purpose programming language that provides code
efficiency, elements of structured programming, and a rich set of operators. C is
not a big language and is not designed for any one particular area of application.
Its generality combined with its absence of restrictions, makes C a convenient and
effective programming solution for a wide variety of software tasks. Many
applications can be solved more easily and efficiently with C than with other
more specialized languages.The Cx51 Optimizing C Compiler is a complete
implementation of the American National Standards Institute (ANSI) standard for
the C language. The Cx51 Compiler is not a universal C compiler adapted for the
8051 target. It is a ground-up implementation, dedicated to generating extremely
fast and compact code for the 8051 microprocessor. The Cx51 Compiler provides
you with the flexibility of programming in C and the code efficiency and speed of
assembly language.The C language on its own is not capable of performing
operations (such as input and output) that would normally require intervention

75
from the operating system. Instead, these capabilities are provided as part of the
standard library. Because these functions are separate from the language itself, C
is especially suited for producing code that is portable across a wide number of
platforms. Since the Cx51 Compiler is a cross compiler, some aspects of the C
programming language and standard libraries are altered or enhanced to address
the peculiarities of an embedded target processor.

CONCLUSION OF THE PROJECT


It can be concluded that the circuit clearly indicates the presence or
absence of an Obstacle. Whenever an obstacle or object comes, the obstacle is
detected and avoids the obstacle and goes in its way.

76
CHAPTER - 8

Bibliography

1. 8051 programming and applications - by K.J.Ayal


2. 8051 microcontroller ans embedded systems- by mazidi
3. Microprocessors and interfacing - by Douglas V.Hall
4.. Linear Integrated Circuits - By: D. Roy Choudhury,
5.www.nationalsemiconductor.com
6. www.atmel.com
7.www.robotroom.com

8. www.maxim.com

77
9. www.ir.com
10. www.stepperworld.com
11.www.keil.com
12. www.electronictimers.com
13.www.atmel.com
14.www.microcontroller.com
15 www.8051.com
16.www.8052.com
17.The 8051 Microcontroller by Kenneth J.Ayala

78

Anda mungkin juga menyukai