You are on page 1of 78

CHAPTER 1

INTRODUCTION

1.1 Objective:
The objective of this project is to control Robot movement and direction for an application as per
the instruction given to microcontroller through wireless keypad using RF communication. As
well as, it detects the leakage of gas and intimates through alarm.
In this project wireless control section consists of keypad, encoder and RF transmitter.
The keypad consists of several buttons representing the one operation such as forward, reverse
movement and left, right direction. The keypad entered signal is encoded and given to RF
transmitter in which the signal is modulated with carrier frequency. After the modulation the
encoded signal is transmitted through RF transmitter.
The receiver section consists of RF receiver, Decoder, Microcontroller and Robot model.
The received signal is demodulated in the RF receiver in which the carrier signal is removed then
given to decoder. In the decoder the encoded signal is decoded into original signal as per
transmitted from the control section. Then the signal is given to microcontroller. Along with that,
our robot is having the capability to detect the gas leakage.

1.2 Embedded System:


An embedded system is a special-purpose computer system designed to perform one or a
few dedicated functions, sometimes with real-time computing constraints. It is usually embedded
as part of a complete device including hardware and mechanical parts. In contrast, a generalpurpose 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.

Since the embedded system is dedicated to specific tasks, design engineers can optimize
it, reducing the size and cost of the product, or increasing the reliability and performance. Some
embedded systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants. Complexity varies from low, with a single microcontroller
chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or
enclosure.
In general, "embedded system" is not an exactly defined term, as many systems have
some element of programmability. For example, Handheld computers share some elements with
embedded systems such as the operating systems and microprocessors which power them but are
not truly embedded systems, because they allow different applications to be loaded and
peripherals to be connected.
An embedded system is some combination of computer hardware and software, either
fixed in capability or programmable, that is specifically designed for a particular kind of
application device. Industrial machines, automobiles, medical equipment, cameras, household
appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone
and PDA) are among the myriad possible hosts of an embedded system. Embedded systems that
are programmable are provided with a programming interface, and embedded systems
programming is a specialized occupation.
Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, some low-end consumer
products use very inexpensive microprocessors and limited storage, with the application and
operating system both part of a single program. The program is written permanently into the
system's memory in this case, rather than being loaded into RAM (Random Access Memory), as
programs on a personal computer.
In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details about
latest technologies, new devices; fast applications which make you believe that your basic

survival is controlled by these embedded products. Now you can agree to the fact that these
embedded products have successfully invaded into our world. You must be wondering about
these embedded controllers or systems. The computer you use to compose your mails, or create a
document or analyze the database is known as the standard desktop computer. These desktop
computers are manufactured to serve many purposes and applications.
You need to install the relevant software to get the required processing facility. So, these
desktop computers can do many things. In contrast, embedded controllers carryout a specific
work for which they are designed. Most of the time, engineers design these embedded controllers
with a specific goal in mind. So these controllers cannot be used in any other place.
Theoretically, an embedded controller is a combination of a piece of microprocessor
based hardware and the suitable software to undertake a specific task.
These days designers have many choices in microprocessors/microcontrollers.
Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced
designer. Selecting a right microprocessor may turn out as a most difficult first step and it is
getting complicated as new devices continue to pop-up very often.

1.3 Basic Blocks of Embedded System:


Now, the details of the various building blocks of the hardware of an embedded system as
shown in Fig 1.1 are
. Central Processing Unit (CPU)
Memory (Read-only Memory and Random Access Memory)
Input Devices
Output devices
Communication interfaces
Application-specific circuitry
Central Processing Unit (CPU):

The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a lowcost processor. Its main attraction is that on the chip itself, there will be many other components
such as memory, serial communication interface, analog-to digital converter etc. So, for small
applications, a micro-controller is the best choice as the number of external components required
will be very less. On the other hand, microprocessors are more powerful, but you need to use
many external components with them. DSP is used mainly for applications in which signal
processing is involved such as audio and video processing.

Figure.1.1: Block Diagram of Embedded System

Memory:
The memory is categorized as Random Access Memory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas
ROM retains the contents even if the power is switched off. So, the firmware is stored in the
ROM. When power is switched on, the processor reads the ROM; the program is executed.
Input devices:
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the embedded
system is not an easy task. Many embedded systems will have a small keypad-you press one key
to give a specific command. A keypad may be used to input only the digits. Many embedded
systems used in process control do not have any input device for user interaction; they take
inputs from sensors or transducers and produce electrical signals that are in turn fed to other
systems.
Output devices:
The output devices of the embedded systems also have very limited capability. Some
embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of
the system modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD)
may also be used to display some important parameters.
Communication interfaces:
The embedded systems may need to, interact with other embedded systems at they may
have to transmit data to a desktop. To facilitate this, the embedded systems are provided with one
or a few communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB),
and IEEE 1394, Ethernet etc.
Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required for an
embedded system, depending on its application. This circuitry interacts with the processor to
carry out the necessary work. The entire hardware has to be given power supply either through

the 230 volts main supply or through a battery. The hardware has to design in such a way that the
power consumption is minimized.
Security is the condition of being protected against danger or loss. In the general sense,
security is a concept similar to safety. The nuance between the two is an added emphasis on
being protected from dangers that originate from outside. Individuals or actions that encroach
upon the condition of protection are responsible for the breach of security. The word "security" in
general usage is synonymous with "safety," but as a technical term "security" means that
something not only is secure but that it has been secured. One of the best options for providing
good security is by using a technology named EMBEDDED SYSTEMS.

1.4 Microcontroller:
In the Literature discussing microprocessors, we often see the term Embedded System.
Microprocessors and Microcontrollers are widely used in embedded system products. An
embedded system product uses a microprocessor (or Microcontroller) to do one task only. A
printer is an example of embedded system since the processor inside it performs one task only,
namely getting the data and printing it. Contrast this with a Pentium based PC can be used for
any number of applications such as word processor, print-server, bank teller terminal, Video
game, network server, or Internet terminal. Software for a variety of applications can be loaded
and run. Of course the reason a pc can perform myriad tasks is that it has RAM memory and an
operating system that loads the application software into RAM memory and lets the CPU run it.
In an Embedded system, there is only one application software that is typically burned
into ROM. An x86 PC contains or is connected to various embedded products such as keyboard,
printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each one of
these peripherals has a Microcontroller inside it that performs only one task. For example, inside
every mouse there is a Microcontroller to perform the task of finding the mouse position and
sending it to the PC.
Application Areas
Nearly 99 per cent of the processors manufactured end up in embedded systems. The
embedded system market is one of the highest growth areas as these systems are used in very

market segment- consumer electronics, office automation, industrial automation, biomedical


engineering, wireless communication, data communication, telecommunications, transportation,
military and so on.
Consumer appliances: At home we use a number of embedded systems which include digital
camera, digital diary, DVD player, video recorders etc.
Office automation: The office automation products using embedded systems are copying
machine, fax machine, key telephone, modem, printer, scanner etc
Industrial automation: Today a lot of industries use embedded systems for process control. In
hazardous industrial environment, where human presence has to be avoided, robots are used,
which are programmed to do specific jobs.
Medical electronics: Almost every medical equipment in the hospital is an embedded system.
These equipments include diagnostic aids such as ECG, EEG, blood pressure measuring devices,
radiation, colonoscopy, endoscopy etc.
Computer networking: Computer networking products such as bridges, routers, Integrated
Services Digital Networks (ISDN), Asynchronous Transfer Mode (ATM), X.25 and frame relay
switches are embedded systems which implement the necessary data communication protocols
Telecommunications: In the field of telecommunications, the embedded systems can be
categorized as subscriber terminals and network equipment. The subscriber terminals such as key
telephones, ISDN phones, terminal adapters, web cameras are embedded systems. The network
equipment includes multiplexers, multiple access systems, Packet Assemblers Dissemblers
(PADs), sate11ite modems etc.
Security: Security of persons and information has always been a major issue. We need to
protect our homes and offices; and also the information we transmit and store. Developing
embedded systems for devices at homes, offices, airports etc. for authentication and verification
are embedded systems security applications is one of the most lucrative businesses nowadays.
Microprocessors Vs Microcontrollers:
Microprocessors are single-chip CPUs used in microcomputers.

Microcontrollers and microprocessors are different in 3 main aspects: hardware architecture,


applications, and instruction set features.
Hardware architecture: A microprocessor is a single chip CPU while a microcontroller is a
single IC contains a CPU and much of remaining circuitry of a complete computer (e.g., RAM,
ROM, serial interface, parallel interface, timer, interrupt handling circuit).
Applications: Microprocessors are commonly used as a CPU in computers while
microcontrollers are found in small, minimum component designs performing control oriented
activities.
Microprocessor instruction sets are processing Intensive.
Their instructions operate on nibbles, bytes, words, or even double words.
Addressing modes provide access to large arrays of data using pointers and offsets.
They have instructions to set and clear individual bits and perform bit operations.
They have instructions for input/output operations, event timing, enabling and setting priority
levels for interrupts caused by external stimuli.
Processing power of a microcontroller is much less than a microprocessor.
Difference between 8051 and 8052:
The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful
microcontroller, sporting a number of additional features which the developer may make use of:

256 bytes of Internal RAM (compared to 128 in the standard 8051).

A third 16-bit timer, capable of a number of new operation modes and 16-bit reloads.

Additional SFRs to support the functionality offered by the third timer.

8051 Architecture:

The generic 8051 architecture supports a Harvard architecture, which contains


two separate buses for both program and data. So, it has two distinctive memory spaces of
64K X 8 size for both programmed and data. It is based on an 8 bit central processing
unit with an 8 bit Accumulator and another 8 bit B register as main processing blocks.
Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit
memory locations.
Each 8051 device has some amount of data RAM built in the device for internal
processing. This area is used for stack operations and temporary storage of data.
This bus architecture is supported with on-chip peripheral functions like I/O ports,
timers/counters, versatile serial communication port. So it is clear that this 8051
architecture was designed to cater many real time embedded needs.

Figure.1.2: Block Diagram of the 8051 microcontroller


Now we may be wondering about the non-mentioning of memory space meant
for the program storage, the most important part of any embedded controller. Originally

this 8051 architecture was introduced with on-chip, one time programmable version
of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051)
with users program fused inside the device. The memory portion was mapped at the
lower end of the Program Memory area. But, after getting devices, customers couldnt
change anything in their program code, which was already made available inside
during device fabrication.

So, very soon Intel introduced the 8051 devices with re-programmable type of Program
Memory using built-in EPROM of size 4K X 8.
Like a regular EPROM, this memory can be re-programmed many times. Later on
Intel started manufacturing these 8031 devices without any on chip Program Memory.
The major Features of 8-bit Micro controller ATMEL 89S52:
8 Bit CPU optimized for control applications
Extensive Boolean processing (Single - bit Logic ) Capabilities.
On - Chip Flash Program Memory
On - Chip Data RAM
Bi-directional and Individually Addressable I/O Lines
Multiple 16-Bit Timer/Counters
Full Duplex UART
Multiple Source / Vector / Priority Interrupt Structure
On - Chip Oscillator and Clock circuitry.
On - Chip EEPROM
SPI Serial Bus Interface

1.5 Circuit Diagram:


Figure 1.3:S

CHAPTER-2

MICROCONTROLLER AT89C51
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes
of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured
using Atmel is high density nonvolatile memory technology and is compatible with the industry
standard MCS-51 instruction set and pinout.
PIN OUT DIAGRAM OF THE 8051

Figure 2.1:PIN DIAGRAM OF 8051

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 AT89C51 is a powerful microcomputer which provides a highly
flexible and cost effective solution to many embedded control applications

2.1 PIN DESCRIPTION


2.1.1 VCC
It is a 5v supply voltage.
2.1.2 GND
It is a ground pin.
2.1.3 Port 0
Port 0 is an 8-bit open drain bidirectional 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.
2.1.4 Port 1
Port 1 is an 8-bit bidirectional 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.
2.1.5 Port 2
Port 2 is an 8-bit bidirectional 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 external data memory
that use 16-bit addresses (MOVX @ DPTR). In this application it uses strong internal pull-ups
when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @

RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the highorder address bits and some control signals during Flash programming and verification.
2.1.6 Port 3
Port 3 is an 8-bit bidirectional 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:

Table 2.1: Alternate functions of port3


Port 3 also receives some control signals for Flash programming and verification.
2.1.7 RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
2.1.8 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.
2.1.9 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.
2.1.10 EA/VPP
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. 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.
This pin also receives the 12-volt programming enable voltage (VPP) during Flash
programming, for parts that require 12-volt VPP.
2.1.11 XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
2.1.12 XTAL2
Output from the inverting oscillator amplifier. It should be noted that when idle is
terminated by a hard ware reset, the device normally resumes program execution, from where it
left off, up to two machine cycles before the internal reset algorithm takes control. On-chip
hardware inhibits access to internal RAM in this event, but access to the port pins is not
inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is
terminated by reset, the instruction following the one that invokes Idle should not be one that
writes to a port pin or to external memory.

2.2. OSCILLATOR AND CLOCK CIRCUITS

The heart of the 8051 is the circuitry that generates the clock pulse by which all internal
operations are synchronized. Pins XTAL1 and XTAL2 are provided for connecting a resonant
network to form an oscillator. The crystal frequency is the basic internal clock frequency of the
microcontroller. The manufactures make available 8051 designs that can run at specified
maximum and minimum frequencies, typically 1 megahertz to 24 megahertz. Minimum
frequencies imply that some internal memories are dynamic and must always operate above a
minimum frequency or data will be lost. Serial data communication needs often state the
frequency of the oscillator because of the requirement that internal counters must divide the basic
clock frequency is not divisible without a remainder, and then the resulting communication
frequency is not standard.
Ceramic resonators may be used as low-cost alternative to crystal resonators. However, decreases
in frequency stability data accuracy make the ceramic resonator a poor choice if high-speed
serial data communication with the systems, or critical timing, is to be done.
The oscillator formed by the crystal, capacitors, and an on-chip inverter microcontroller, called
the pulse, P, time. The smallest interval of time to accomplish any simple instruction, or part of a
complex instruction, however, is the machine cycle. The machine cycle is itself made up of six
states. A state is the basic time interval for discrete operations of the microcontroller such as
fetching an opcode byte, decoding an opcode, executing an opcode, or writing a data byte. Two
oscillator pulses define each state.
Program instructions may require one, two, or four machine cycles to the executed,
depending on the type of instruction. Instructions are fetched and executed by the
microcontroller automatically, beginning with the instruction located by the microcontroller
automatically; beginning with the instruction located at ROM memory address 0000h at the time
the microcontroller is first reset.
To calculate the time any particular instruction will take to be executed, find the number of
cycles, C, The time to execute that instruction is then found by multiplying C by 12 and dividing
the product by the crystal frequency:
C x 12

T inst = --------------------------------------------

------------------(2.1)

Crystal frequency
For example, if the crystal frequency is 16 megahertz, then the time to execute an ADD A, R1
one-cycle instructions is .75 microseconds. A 12-megahertz crystal yields the convenient time of
1 microsecond per cycle.
Oscillator frequency (f)
P2

P1

State 1

P2

P1

P2

State 2

P1

State 3

P2

P1

P2

State 4

P1

State 5

P2

P1

P2

State 6

One machine cycle

Address
Latch
Enable

8051 Timing

Figure 2.2: Oscillator frequency (f) &ALE pulse per machine cycle
There are two ALE pulse per machine cycle. The ALE pulse, which is primarily used as a
timing pulse for external memory access, indicates when every instruction byte is fetched. Two
bytes of a single instruction may thus be fetched, and executed, in one machine cycle. Single
byte instructions are nor executed in a half cycle, however, Single-byte instructions "throwaway" the second byte (which is the first byte of the next instruction.)

2.3 IDLE MODE:

The CPU is turned off while the RAM and other on - chip peripherals continue operating.
Inn this mode current draw is reduced to about 15 percent of the current drawn when the device
is fully active.

2.4POWER DOWN MODE:


All on-chip activities are suspended while the on chip RAM continues to hold its data.
In this mode, the device typically draws less than 15 Micro Amps and can be as low as 0.6 Micro
Amps

2.5POWER ON RESET:
When power is turned on, the circuit holds the RST pin high for an amount of time that
depends on the capacitor value and the rate at which it charges.
To ensure a valid reset, the RST pin must be held high long enough to allow the oscillator to start up plus
two machine cycles. On power up, VCC should rise within approximately 10ms. The oscillator start-up time
depends on the oscillator frequency. For a 10 MHz crystal, the start-up time is typically 1ms.With the given
circuit, reducing VCC quickly to 0 causes the RST pin voltage to momentarily fall below 0V. How ever, this
voltage is internally l limited and will not harm the device.
2. 6 CPU REGISTERS
The 8051 contain 34 general-purpose, or working, registers. Two of these, registers A and
B hold results of many instructions, particularly for arithmetical and logical operations. The other
32 are arranged as part of internal RAM in four banks, Bank0-Bank3, of eight registers each.
2.6.1 PROGRAM COUNTER (PC)
The 8051 contain two 16-bit registers: the program counter (PC) and the data pointer
(DPTR). Each is used to hold the address of a word in memory.
Program instruction bytes are fetched from locations in memory that are addressed by the
PC. Program ROM may be on the chip at addresses 000h to FFFh, external to the chip for
address that exceed FFFh, or totally external for all address from 0000h to FFFFh. The PC is

automatically incremented after every instruction byte is fetched and may also be altered by
certain instructions. The PC is the only register that does not have an internal address.
The Program Counter (PC) is a 2-byte address that tells the 8051 where the next instruction
to execute is found in memory. When the 8051 is initialized PC always starts at 0000h and is
incremented each time an instruction is executed. It is important to note that PC isnt always
incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by
2 or 3 in these cases.
There is no way to directly modify its value. The Program Counter is special in that. That
is to say, you cant do something like PC=2430h. On the other hand, if you execute LJMP 2340h
youve effectively accomplished the same thing.
It is also interesting to note that while you may change the value of PC (by executing a
jump instruction, etc.) there is no way to read the value of PC. That is to say, there is no way to
ask the 8051 "What address are you about to org 00h
2.6.2 DATA POINTER (DPTR)
The DPTR register is made up of two 8-bit registers, named DPH and DPL, which are used
to furnish memory addresses for internal and external code access and external data access. The
DPTR is under the control of program instructions name, DPH and DPL. DPTR does not have a
single internal address; DPH and DPL are each assigned an address.
The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register.
DPTR, as the name suggests, is used to point to address something like HL register pair in 8085
microprocessor. It is used by a number of commands that allow the 8051 to access external
memory and internal memory.
While DPTR is most often used to point to data in external memory, many programmers
often take advantage of the fact that its the only true 16-bit register available. It is often used to
store 2-byte values that have nothing to do with memory locations.
2.6.3 PROGRAM STATUS WORD (PSW)

Flags are 1-bit registers provided to store the results of certain prog ram instructions. Other
instructions can test the condition of the flags and make decisions based on the flag states. In order that
the flags may be conveniently addressed, they are grouped inside the program status word (PSW) and the
power control (PCON) registers.
The 8051 have four math flags that respond automatically to the outcomes of math operations and
three general-purpose user flags that can be set to 1 or cleared to 0 by the programmer as desired. The
math flags include Carry (CY), Auxiliary Carry (AC), Overflow (OV), and Parity (P). User flag is named
F0; this general-purpose flags that may be used by the programmer to record some event in the program.
Register bank selection may be done by the use of RS0 and RS1 Note that all of the flags can be set
and cleared by the programmer at will. The math flags, however, are also affected by math operations.
The program status word is shown below. The PSW contains the math flags, user program flag F0,
and the register select bits RS0, RS1 that identify which of the four general-purpose register banks is
currently in use by the program.

Program Status Word (PSW) Register:

Fi
g 2.3: PSW Register Format
PSW register is one of the most important SFRs. It contains several status bits that reflect
the current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two
register bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit: If a number stored in the accumulator is even then this bit will be automatically
set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via
serial communication.
Bit 1. This bit is intended to be used in the future versions of microcontrollers.
OV Overflow: occurs when the result of an arithmetical operation is larger than 255 and cannot
be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be
cleared (0).

RS0, RS1 - Register bank select bits. These two bits are used to select one of four register
banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks
of RAM.
RS1

RS2

S PAC E I N R A M

Bank0 00h-07h

Bank1 08h-0Fh

Bank2 10h-17h

Bank3 18h-1Fh
Table.2.2: Register formats of PSW

F0 - Flag 0: This is a general-purpose bit available for use.


AC - Auxiliary Carry Flag: This is used for BCD operations only.
CY - Carry Flag: Is the (ninth) auxiliary bit used for all arithmetical operations and shift
instructions.

2.6.4 THE STACK AND THE STACK POINTER


The stack refers to an area of internal RAM that is used in conjunction with certain
opcodes to store and retrieve data quickly. The 8-bit Stack Pointer (SP) register is used by the
8051 to hold an internal RAM addresses that is called the top of the stack. The address held in
the SP register is the location in internal RAM where the last byte of data was stored by a stack
operation.
When data is to be placed on the stack, the SP increments before storing data on the stack so
that the stack grows up as data is stored. As data is retrieved from the stack, the byte is read from
the stack, and then the SP decrements to point to the next available byte of stored data.
The stack is limited in height to the size of the internal RAM. The stack has the potential (if
the programmer is not careful to limit its growth) to over write valuable data in the register

banks, bit-addressable RAM, and general purpose (scratchpad) RAM areas. The programmer is
responsible for making sure the stack does not grow beyond predefined bounds!
The stack is normally placed high in internal RAM, by an appropriate choice of the number
placed in the SP register, to avoid conflict with the register, bit and scratch-pad internal RAM
areas.
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 8051 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 8051 returns the value from the memory location
indicated by SP, and then decrements the value of SP. That is last in first out method (LIFO)
This order of operation is important. When the 8051 is initialized SP will be initialized to
07h. If you immediately push a value onto the stack, the value will be stored in Internal RAM
address 08h. This makes sense taking into account what were mentioned two paragraphs above:
First the 8051 will increment the value of SP (from 07h to 08h) and then will store the pushed
value at that memory address (08h).
SP is modified directly by the 8051 by six instructions: PUSH, POP, ACALL, LCALL,
RET, and RETI. It is also used intrinsically whenever an interrupt is triggered. (More on
interrupts later).

2.7 THIRTY-TWO INPUT / OUTPUT PINS


All four ports in the 8051 are bi-directional each contains a latch, an output driver and
input buffer. The output drivers of port0 and 2, and the input buffers of port 0 are used in access
to external memory. In this application port 0 is used as a lower byte of the external memory

address multiplexed with data bus and port 2 is used as a higher byte of the external memory
address when address is sixteen bit wide. Otherwise it can be used as general purpose I/O

2.8 INTERNAL MEMORY


A functioning computer must have memory for program codes, commonly in ROM, and
RAM memory for variable data that can be altered as the program runs. The 8051 has
internal RAM and ROM memory

for

these functions. Additional memory can be added

externally using suitable circuits.


Unlike Microcontrollers with Von Neumann architectures, which can use a single memory
address for either program code or data, but not for both, the 8051 has a Harvard architecture,
which uses the same address, in different memories, for code and data. Internal circuitry accesses
the correct memory based on the nature of the operation in progress. Harvard architecture uses
separate buses to fetch the data and the address
2.8.1 INTERNAL ROM
The 8051 is organized so that data memory and program code memory can be in two
entirely different physical memory entities. Each has the same address range. The structure of
the internal RAM will be discussed later. Generally 8051 microcontroller is available with 4Kilo
Bytes internal ROM.
A corresponding block of internal program code, contained in an internal ROM, occupies
code address space 000h to FFFh. The Program Counter is ordinarily used to address program
code bytes from address 0000h to FFFFh. Program addresses higher than 0FFFh, which exceed
the internal ROM capacity, will cause the 8051 to automatically fetch code bytes from external
program memory.
Code bytes can also be fetched exclusively from an external memory, address 0000h to
FFFFh, by connecting the external access pin (EA pin no 31 on the DIP) to ground. The PC does
not care where the code is, the circuit designer decides whether the code is found totally in
internal ROM, totally in external ROM, or in a combination of internal and external ROM.
Each register bank address are

Bank 0

00h-07h

Bank 1

08h-0fh

Bank 2

10h-17h

Bank 3

18h-1fh

8051 microcontroller has 16-bit address bus and 8 bit data bus, with 16-bit address bus we can
address maximum of 64Kilobytes of external memory that is from 0000h to FFFF.
8051 is available with 4kilobytes of internal ROM its derivatives 8751, 8951 are available
with EPROM, FLASH ROM respectively with 4kilobytes capacity.
2.8.2 INTERNAL RAM OF 128BYTES :
As mentioned at the beginning of this chapter, the 8051 includes a certain amount of onchip memory. On-chip memory is really one of two types: Internal RAM and Special Function
Register (SFR) memory. The layout of the 8051's internal RAM is presented.
As is illustrated in this map, the 8051 has a bank of 128 bytes of Internal RAM. This
Internal RAM is found on-chip on the 8051 so it is the fastest RAM available , and it is also the
most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile,
so when the 8051 is switched off this memory is cleared.
The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8
bytes (00h - 07h) are "register bank 0". By manipulating certain SFRs, a program may choose to
use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in
addresses 08h through 1Fh. So the registers are part of internal RAM.
Figure 2.4: INTERNAL RAM ORGANIZATION
1F

R7

7F

R6
R5
Bank 3

R4
R3
R2

18
Bank 1
017
2
10
0F
07
08
00

2F

R1
R0
R7
R6
R5
R4
R3
R2
R1
R0
R7

7F

R6
R5

77
6F

R4
R3

67
5F

R2
R1

57

R0

47
3F
37

4F

R7
R6
R5
R4

2F
27

R3
R2

1F
17

R1

0F

R0

07

Bit Memory also lives and is part of

2
0
internal

3
0

RAM. Bit memory actually resides in internal

RAM, from addresses 20h through 2Fh. It can be bit addressed from 00h to 7fh (totally 128 bits)
The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used
by user variables that need to be accessed frequently or at high-speed. This area is also utilized
by the microcontroller as a storage area for the operating stack.This fact severely limits the
8051s stack since, as illustrated in the memory map, the area reserved for the stack is only 80
bytes and usually it is less since these 80 bytes has to be shared between the stack and user
variables.

REGISTER BANKS
The 8051 use 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. For example, to add the value of R4 to the Accumulator, we would execute the
following instruction:
ADD A, R4
Thus if the Accumulator (A) contained the value 3 and R4 contained the value 3, the
Accumulator would contain the value 6 after this instruction was executed.
However, as the memory map shows, the "R" Register R4 is really part of Internal RAM.
Specifically, R4 is address 04h. Thus the above instruction accomplishes the same thing as the
following operation:
ADD A, 04h
This instruction adds the value found in Internal RAM address 04h to the value of the
Accumulator, leaving the result in the Accumulator. Since R4 is really Internal RAM 04h, the
above instruction effectively accomplished the same thing.
But watch out! As the memory map shows, the 8051 has four distinct register banks. When the
8051 is first booted up, register bank 0 (addresses 00h through 07h) is used by default. However,
your program may instruct the 8051 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 8051 to use register bank 3, "R" register R4 will now be
synonymous with Internal RAM address 1Ch.
The concept of register banks adds a great level of flexibility to the 8051, 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. Register banks can be selected
with the help of RS0, RS1 bits in the program status word (PSW).If you only use the first register
bank (i.e. bank 0), you may use Internal RAM locations 08h through 1Fh for your own use. But

if you plan to use register banks 1, 2, or 3, be very careful about using addresses below 20h as
you may end up overwriting the value of your "R" registers!

2.9 INTERRUPTS
An interrupt is a special feature, which allows the 8051 to provide the illusion of "multitasking," although in reality the 8051 is only doing one thing at a time. The word "interrupt" can
often be substituted with the word "event." An interrupt is triggered whenever a corresponding
event occurs. When the event occurs, the 8051 temporarily puts "on hold" the normal execution
of the program and executes a special section of code referred to as an interrupt handler. The
interrupt handler performs whatever special functions are required to handle the event and then
returns control to the 8051 at which point program execution continues as if it had never been
interrupted.
Five interrupts are provided in the 8051. Three of these are generated automatically by internal
operations: Timer flag 0, Timer flag 1, and the serial port interrupt (RI or TI). Two interrupts are
triggered by external signals provided by circuitry that is connected to pins INT0 and INT1 (port
pins P3.2 and P3.3)
After the Interrupt has been handled by the interrupt subroutine, which is placed by the
programmer at the interrupt location in program memory, the interrupt program must resume
operation at the instruction where the interrupt took place. Program resumption is done by
storing the interrupted PC address on the stack in RAM before changing the PC to the interrupt
address in ROM. The PC address will be restored from the stack after an RETI instruction is
executed at the end of the interrupt subroutine.

CHAPTER-3

Basic electronic, electrical, Sensing & wireless transmitting and


receiving elements
3.1 Transformer

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductorsthe transformer's coils. A varying current in the first or
primary winding creates a varying magnetic flux in the transformer's core and thus a varying
magnetic field through the secondary winding. This varying magnetic field induces a varying
electromotive force (EMF), or "voltage", in the secondary winding. This effect is called inductive
coupling.
If a load is connected to the secondary, current will flow in the secondary winding, and
electrical energy will be transferred from the primary circuit through the transformer to the load.
In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the
primary voltage (Vp) and is given by the ratio of the number of turns in the secondary (Ns) to the
number of turns in the primary (Np) as follows:

----------------------(3.1) (ideal transformer equation)


By appropriate selection of the ratio of turns, a transformer thus enables an alternating current
(AC) voltage to be "stepped up" by making Ns greater than Np, or "stepped down" by making Ns
less than Np.
In the vast majority of transformers, the windings are coils wound around a ferromagnetic core,
air-core transformers being a notable exception.
Transformers range in size from a thumbnail-sized coupling transformer hidden inside a stage
microphone to huge units weighing hundreds of tons used to interconnect portions of power
grids. All operate on the same basic principles, although the range of designs is wide.
While new technologies have eliminated the need for transformers in some electronic
circuits, transformers are still found in nearly all electronic devices designed for household
("mains") voltage. Transformers are essential for high-voltage electric power transmission, which
makes long-distance transmission economically practical.

Basic principles

Figure:3.1 An ideal transformer.

The secondary current arises from the action of the secondary EMF on the (not shown) load
impedance.The transformer is based on two principles: first, that an electric current can produce
a magnetic field (electromagnetism) and second that a changing magnetic field within a coil of
wire induces a voltage across the ends of the coil (electromagnetic induction). Changing the
current in the primary coil changes the magnetic flux that is developed. The changing magnetic
flux induces a voltage in the secondary coil.
An ideal transformer is shown in the adjacent figure. Current passing through the primary coil
creates a magnetic field. The primary and secondary coils are wrapped around a core of very
high magnetic permeability, such as iron, so that most of the magnetic flux passes through both
the primary and secondary coils. If a load is connected to the secondary winding, the load current
and voltage will be in the directions indicated, given the primary current and voltage in the
directions indicated (each will be alternating current in practice).

Induction law
The voltage induced across the secondary coil may be calculated from Faraday's law of
induction, which states that:

where Vs is the instantaneous voltage, Ns is the number of turns in the secondary coil and is
the magnetic flux through one turn of the coil. If the turns of the coil are oriented
perpendicularly to the magnetic field lines, the flux is the product of the magnetic flux
density B and the area A through which it cuts. The area is constant, being equal to the crosssectional area of the transformer core, whereas the magnetic field varies with time according
to the excitation of the primary. Since the same magnetic flux passes through both the
primary and secondary coils in an ideal transformer,[28] the instantaneous voltage across the
primary winding equals

Taking the ratio of the two equations for Vs and Vp gives the basic equation[29] for
stepping up or stepping down the voltage

Np/Ns is known as the turns ratio, and is the primary functional characteristic of any transformer.
In the case of step-up transformers, this may sometimes be stated as the reciprocal, Ns/Np. Turns
ratio is commonly expressed as an irreducible fraction or ratio: for example, a transformer with
primary and secondary windings of, respectively, 100 and 150 turns is said to have a turns ratio
of 2:3 rather than 0.667 or 100:150.

Ideal power equation

Figure 3.2 The ideal transformer as a circuit element


If the secondary coil is attached to a load that allows current to flow, electrical power is
transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly
efficient. All the incoming energy is transformed from the primary circuit to the magnetic field
and into the secondary circuit. If this condition is met, the input electric power must equal the
output power:

giving the ideal transformer equation

Transformers normally have high efficiency, so this formula is a reasonable approximation.


If the voltage is increased, then the current is decreased by the same factor. The impedance in
one circuit is transformed by the square of the turns ratio.[28] For example, if an impedance Zs is
attached across the terminals of the secondary coil, it appears to the primary circuit to have an
impedance of (Np/Ns)2Zs. This relationship is reciprocal, so that the impedance Zp of the primary
circuit appears to the secondary to be (Ns/Np)2Zp.

3.2 Rectifiers
A rectifier is an electrical device that converts alternating current (AC), which periodically
reverses direction, to direct current (DC), which flows in only one direction. The process is
known as rectification. Physically, rectifiers take a number of forms, including vacuum tube
diodes, mercury-arc valves, solid-state diodes, silicon-controlled rectifiers and other siliconbased semiconductor switches.

Rectifier devices
Before the development of silicon semiconductor rectifiers, vacuum tube diodes and copper(I)
oxide or selenium rectifier stacks were used. High power rectifiers, such as are used in highvoltage direct current power transmission, now uniformly employ silicon semiconductor devices
of various types. These are thyristors or other controlled switching solid-state switches which
effectively function as diodes to pass current in only one direction.

Half-wave rectification
In half wave rectification, either the positive or negative half of the AC wave is passed, while the
other half is blocked. Because only one half of the input waveform reaches the output, it is very
inefficient if used for power transfer.

Figure3.3 Half-wave rectifier


Half-wave rectification can be achieved with a single diode in a one-phase supply, or with three
diodes in a three-phase supply.
Half wave rectifiers yield a unidirectional but pulsating direct current.The output DC voltage of a
half wave rectifier can be calculated with the following two ideal equations

-------------------------------(3.2)

------------------------------------(3.3)

Full-wave rectification
A full-wave rectifier converts the whole of the input waveform to one of constant polarity
(positive or negative) at its output. Full-wave rectification converts both polarities of the input
waveform to DC (direct current), and is more efficient. However, in a circuit with a non-center
tapped transformer, four diodes are required instead of the one needed for half-wave rectification
(see semiconductors and diode). Four diodes arranged this way are called a diode bridge or
bridge rectifier.

Figure 3.4 Graetz bridge rectifier: a full-wave rectifier using 4 diodes.


3.3 Transistor
A transistor is a semiconductor device used to amplify and switch
electronic signals and power. It is composed of a semiconductor material with at
least three terminals for connection to an external circuit. A voltage or current
applied to one pair of the transistor's terminals changes the current flowing through
another pair of terminals. Because the controlled (output) power can be much more
than the controlling (input) power, a transistor can amplify a signal. Today, some
transistors are packaged individually, but many more are found embedded in
integrated circuits.

The transistor is the fundamental building block of modern electronic devices, and is
ubiquitous in modern electronic systems. Following its release in the early 1950s the transistor
revolutionized the field of electronics, and paved the way for smaller and cheaper radios,
calculators, and computers, among other things.

Figure 3.5:Basic transister


Transistor as a switch
Transistors are commonly used as electronic switches, both for high-power applications
such as switched-mode power supplies and for low-power applications such as logic gates.In a
grounded-emitter transistor circuit, such as the light-switch circuit shown, as the base voltage
rises, the base and collector current rise exponentially. The collector voltage drops because of the
collector load resistance (in this example, the resistance of the light bulb). If the collector voltage
was zero, the collector current would be limited only by the light bulb resistance and the supply
voltage. The transistor is then said to be saturated - it will have a very small voltage from
collector to emitter. Providing sufficient base drive current is a key problem in the use of bipolar
transistors as switches. The transistor provides current gain, allowing a relatively large current in
the collector to be switched by a much smaller current into the base terminal. The ratio of these
currents varies depending on the type of transistor, and even for a particular type, varies
depending on the collector current. In the example light-switch circuit shown, the resistor is
chosen to provide enough base current to ensure the transistor will be saturated.
In any switching circuit, values of input voltage would be chosen such that the output is either
completely off,[21] or completely on. The transistor is acting as a switch, and this type of
operation is common in digital circuits where only "on" and "off" values are relevant.

Transistor as an amplifier
The common-emitter amplifier is designed so that a small change in voltage in (Vin)
changes the small current through the base of the transistor; the transistor's current amplification
combined with the properties of the circuit mean that small swings in Vin produce large changes
in Vout.

Figure 3.6:Amplifier circuit, common-emitter configuration.


Various configurations of single transistor amplifier are possible, with some providing current
gain, some voltage gain, and some both.
From mobile phones to televisions, vast numbers of products include amplifiers for sound
reproduction, radio transmission, and signal processing. The first discrete transistor audio
amplifiers barely supplied a few hundred milliwatts, but power and audio fidelity gradually
increased as better transistors became available and amplifier architecture evolved.
Modern transistor audio amplifiers of up to a few hundred watts are common and relatively
inexpensive.

3.4 Relay

Figure 3.7: Realay circuit diagram


A relay is an electrically operated switch. Current flowing through the coil of the relay creates a
magnetic field which attracts a lever and changes the switch contacts. The coil current can be on
or off so relays have two switch positions and they are double throw (changeover) switches.
Relays allow one circuit to switch a second circuit which can be completely separate from the
first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains
circuit. There is no electrical connection inside the relay between the two circuits; the link is
magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it
can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips)
cannot provide this current and a transistor is usually used to amplify the small IC current to the

larger value required for the relay coil. The maximum output current for the popular 555 timer IC
is 200mA so these devices can supply relay coils directly without amplification.

Figure 3.8: practical relays


Relays are usually SPDT or DPDT but they can have many more sets of switch contacts,
for example relays with 4 sets of changeover contacts are readily available. Most relays are
designed for PCB mounting but you can solder wires directly to the pins providing you take care
to avoid melting the plastic case of the relay. The animated picture shows a working relay with
its coil and switch contacts. You can see a lever on the left being attracted by magnetism when
the coil is switched on. This lever moves the switch contacts. There is one set of contacts (SPDT)
in the foreground and another behind them, making the relay DPDT.

The relay's switch connections are usually labeled COM, NC and NO:

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

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

Circuit description:
This circuit is designed to control the load. The load may be motor or any other load.
The load is turned ON and OFF through relay. The relay ON and OFF is controlled by the pair
of switching transistors (BC 547). The relay is connected in the Q2 transistor collector terminal.
A Relay is nothing but electromagnetic switching device which consists of three pins. They are
Common, Normally close (NC) and Normally open (NO).
The relay common pin is connected to supply voltage. The normally open (NO) pin
connected to load. When high pulse signal is given to base of the Q1 transistors, the transistor is
conducting and shorts the collector and emitter terminal and zero signals is given to base of the
Q2 transistor. So the relay is turned OFF state.
When low pulse is given to base of transistor Q1 transistor, the transistor is turned
OFF. Now 12v is given to base of Q2 transistor so the transistor is conducting and relay is turned
ON. Hence the common terminal and NO terminal of relay are shorted. Now load gets the supply
voltage through relay.

Voltage Signal from

Transistor Q1

Transistor Q2

Relay

Microcontroller or PC
1

on

off

off

off

on

on

3.5 DC Motors
The direct current (DC) motor is one of the first machines devised to convert electrical
power into mechanical power. Permanent magnet (PM) direct current converts electrical energy
into mechanical energy through the interaction of two magnetic fields.

Figure 3.9: Dc motor


One field is produced by a permanent magnet assembly; the other field is produced by an
electrical current flowing in the motor windings. These two fields result in a torque which tends
to rotate the rotor. As the rotor turns, the current in the windings is commutated to produce a
continuous torque output.
The stationary electromagnetic field of the motor can also be wire-wound like the armature
(called a wound-field motor) or can be made up of permanent magnets (called a permanent
magnet motor).
In either style (wound-field or permanent magnet) the commutator. acts as half of a
mechanical switch and rotates with the armature as it turns. The commutator is composed of
conductive segments (called bars), usually made of copper, which represent the termination of
individual coils of wire distributed around the armature.

The second half of the mechanical switch is completed by the brushes. These brushes
typically remain stationary with the motor's housing but ride (or brush) on the rotating
commutator. As electrical energy is passed through the brushes and consequently through the
armature a torsional force is generated as a reaction between the motor's field and the armature
causing the motor's armature to turn.
As the armature turns, the brushes switch to adjacent bars on the commutator. This
switching action transfers the electrical energy to an adjacent winding on the armature which in
turn perpetuates the torsional motion of the armature.
Permanent magnet (PM) motors are probably the most commonly used DC motors, but
there are also some other type of DC motors(types which use coils to make the permanent
magnetic field also) .DC motors operate from a direct current power source. Movement of the
magnetic field is achieved by switching current between coils within the motor. This action is
called "commutation". Very many DC motors (brush-type) have built-in commutation, meaning
that as the motor rotates, mechanical brushes automatically commutate coils on the rotor. You
can use dc-brush motors in a variety of applications.
A simple, permanent-magnet dc motor is an essential element in a variety of products,
such as toys, servo mechanisms, valve actuators, robots, and automotive electronics. There are
several typical advantages of a PM motor. When compared to AC or wound field DC motors, PM
motors are usually physically smaller in overall size and lighter for a given power rating.
Furthermore, since the motor's field, created by the permanent magnet, is constant, the
relationship between torque and speed is very linear. A PM motor can provide relatively high
torque at low speeds and PM field provides some inherent self-braking when power to the motor
is shutoff. There are several disadvantages through, those being mostly being high current during
a stall condition and during instantaneous reversal. Those can damage some motors or be
problematic to control circuitry. Furthermore, some magnet materials can be damaged when
subjected to excessive heat and some loose field strength if the motor is disassembled.
High-volume everyday items, such as hand drills and kitchen appliances, use a dc
servomotor known as a universal motor. Those universal motors are series-wound DC motors,
where the stationary and rotating coils are wires in series. Those motors can work well on both
AC and DC power. One of the drawbacks/precautions about series-wound DC motors is that if

they are unloaded, the only thing limiting their speed is the windage and friction losses. Some
can literally tear themselves apart if run unloaded.
A brushless motor operates much in the same way as a traditional brush motor.
However, as the name implies there are no brushes (and no commutator). The mechanical
switching function, implemented by the brush and commutator combination in a brush-type
motor, is replaced by electronic switching in a brushless motor. In a typical brushless motor the
electromagnetic field, created by permanent magnets, is the rotating member of the motor and is
called a rotor.
The rotating magnetic field is generated with a number of electromagnets
commutatated with electronics switches (typically transistors or FETs) in a right order at right
speed. In a brushless motor, the trick becomes to know when to switch the electrical energy in
the windings to perpetuate the rotating motion. This is typically accomplished in a brushless-type
motor by some feedback means designed to provide an indication of the position of the magnet
poles on the rotor relative to the windings.
A hall effect device (HED) is a commonly used means for providing this positional
feedback. In some applications brushless motors are commutated without sensors or with the use
of an encoder for positional feedback. A brushless motor is often used when high reliability, long
life and high speeds are required. The bearings in a brushless motor usually become the only
parts to wear out.
In applications where high speeds are required (usually above 30,000 RPM) a brushless
motor is considered a better choice (because as motor speed increases so does the wear of the
brushes on traditional motors). A brushless motor's commutation control can easily be separated
and integrated into other required electronics, thereby improving the effective power-to-weight
and/or power-to-volume ratio. A brushless motor package (motor and commutation controller)
will usually cost more than a brush-type, yet the cost can often be made up in other advantages.
For example, in applications where sophisticated control of the motor's operation is required.
Brushless motors are seen nowadays in very many computer application, they for example rotate
normal PC fans,hard disks and disk drives.
Sometimes the rotation direction needs to be changed. In normal permanent magnet
motors, this rotation is changed by changing the polarity of operating power (for example by

switching from negative power supply to positive or by inter-changing the power terminals going
to power supply). This direction changing is typically implemented using relay or a circuit called
an H bridge. There are some typical characteristics on "brush-type" DC motors.
When a DC motor is straight to a battery (with no controller), it draws a large surge
current when connected up. The surge is caused because the motor, when it is turning, acts as a
generator. The generated voltage is directly proportional to the speed of the motor. The current
through the motor is controlled by the difference between the battery voltage and the motor's
generated voltage (otherwise called back EMF).
When the motor is first connected up to the battery (with no motor speed controller)
there is no back EMF. So the current is controlled only by the battery voltage, motor resistance
(and inductance) and the battery leads. Without any back emf the motor, before it starts to turn,
therefore draws the large surge current. When a motor speed controller is used, it varies the
voltage fed to the motor. Initially, at zero speed, the controller will feed no voltage to the motor,
so no current flows.
As the motor speed controller's output voltage increases, the motor will start to turn. At
first the voltage fed to the motor is small, so the current is also small, and as the motor speed
controller's voltage rises, so too does the motor's back EMF. The result is that the initial current
surge is removed, acceleration is smooth and fully under control.
Motor speed control of DC motor is nothing new. A simplest method to control the rotation speed
of a DC motor is to control it's driving voltage. The higher the voltage is, the higher speed the
motor tries to reach. In many applications a simple voltage regulation would cause lots of power
loss on control circuit, so a pulse width modulation method (PWM)is used in many DC motor
controlling applications.
In the basic Pulse Width Modulation (PWM) method, the operating power to the motors is
turned on and off to modulate the current to the motor. The ratio of "on" time to "off" time is
what determines the speed of the motor. When doing PWM controlling, keep in mind that a
motor is a low pass device. The reason is that a motor is mainly a large inductor. It is not capable
of passing high frequency energy, and hence will not perform well using high frequencies.
Reasonably low frequencies are required, and then PWM techniques will work. Lower

frequencies are generally better than higher frequencies, but PWM stops being effective at too
low a frequency. The idea that a lower frequency PWM works better simply reflects that the "on"
cycle needs to be pretty wide before the motor will draw any current (because of motor
inductance).
A higher PWM frequency will work fine if you hang a large capacitor across the
motor or short the motor out on the "off" cycle (e.g. power/brake pwm) The reason for this is that
short pulses will not allow much current to flow before being cut off. Then the current that did
flow is dissipated as an inductive kick - probably as heat through the fly-back diodes. The
capacitor integrates the pulse and provides a longer, but lower, current flow through the motor
after the driver is cut off.
There is not inductive kick either, since the current flow isn't being cut off. Knowing
the low pass roll-off frequency of the motor helps to determine an optimum frequency for
operating PWM. Try testing your motor with a square duty cycle using a variable frequency, and
then observe the drop in torque as the frequency is increased. This technique can help determine
the roll off point as far as power efficiency is concerned.

3.6 IC voltage regulators


Voltage regulators comprise a class of widely used ICs. Regulator IC units contain
the circuitry for reference source, comparator amplifier, control device, and overload protection
all in a single IC. IC units provide regulation of either a fixed positive voltage, a fixed negative
voltage, or an adjustably set voltage. The regulators can be selected for operation with load
currents from hundreds of milli amperes to tens of amperes, corresponding to power ratings from
milli watts to tens of watts.
A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi, applied
to one input terminal, a regulated dc output voltage, Vo, from a second terminal, with the third
terminal connected to ground.
The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts.
Similarly, the series 79 regulators provide fixed negative regulated voltages from 5 to 24 volts.

THREE-TERMINAL VOLTAGE REGULATORS:


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. 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).

Figure 3.10 Fixed Positive Voltage Regulators:


IN
OUT
From

7805

Transformer
secondry

GND
The series 78 regulators provide fixed regulated voltages from 5 to 24 V.
Figure 3.1 shows how one such IC, a 7812, is connected to provide voltage
regulation with output from this unit of +12V dc. An unregulated input
voltage Vi is filtered by capacitor C1 and connected to the ICs IN terminal.
The ICs OUT terminal provides a regulated + 12V which is filtered by
capacitor C2 (mostly for any high-frequency noise). The third IC terminal is
connected to ground (GND).

While the input voltage may vary over some permissible voltage range, and the output load may
vary over some acceptable range, the output voltage remains constant within specified voltage
variation limits.

Table 3.1. Positive Voltage Regulators in 7800 series


Output Voltage

IC Part

Minimum Vi (V)

(V)

7805

+5

7.3

7806

+6

8.3

+8

10.5

+10

12.5

+12

14.6

+15

17.7

+18

21.0

+24

27.1

808

810

812

815

818

824

These limitations are spelled out in the manufacturers specification


sheets. A table of positive voltage regulated ICs is provided in table 3.1.

3.7 Gas sensor

Figure 3.11 Gas sensor


3.7.1 Gas Sensor:
Ideal sensor for use to detect the presence of a dangerous LPG leak in your car or in
a service station, storage tank environment. This unit can be easily incorporated into an alarm
unit, to sound an alarm or give a visual indication of the LPG concentration. The sensor has
excellent sensitivity combined with a quick response time. The sensor can also sense iso-butane,
propane, LNG and cigarette smoke.

Features:
High Sensitivity
Detection Range: 100 - 10,000 ppm iso-butane propane
Fast Response Time: <10s
Heater Voltage: 5.0V
Dimensions: 18mm Diameter, 17mm High excluding pins, Pins - 6mm High

3.7.2 Circuit Description:

The gas sensor is the special sensor which designed for sense the gas leakage. In the gas
sensor the supply voltage is given to input terminal. The gas sensor output terminals are
connected to non inverting input terminal of the comparator.
Here the comparator is constructed with operational amplifier LM 358. The reference
voltage is given to inverting input terminal. The reference voltage is depends on the desired gas
intensity.
When there is no leakage the non inverting input is grater then inverting input so the
output of the comparator is positive voltage which is given to the base of the switching transistor
BC 547. Hence the transistor is conducting.
Here the transistor is act as switch so the collector and emitter will be closed. The
output is taken from collector terminal. Now the output is zero which is given to hex inverter
40106.
When there is gas leakage the inverting input voltage is grater than non inverting input.
Now the comparator output is -12V so the transistor is cutoff region. The 5v is given to hex
inverter 40106 IC. Then the final output data is directly given to microcontroller to determine the
gas leakage.

3.8 Alarm

Figure 3.12 Buzzer circuit


3.8.1Buzzer:
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-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.

3.8.2 Circuit description:


The circuit is designed to control the buzzer. The buzzer ON and OFF is controlled by the
pair of switching transistors (BC 547). The buzzer is connected in the Q2 transistor collector
terminal.
When high pulse signal is given to base of the Q1 transistors, the transistor is conducting
and close the collector and emitter terminal so zero signals is given to base of the Q2 transistor.
Hence Q2 transistor and buzzer is turned OFF state.
When low pulse is given to base of transistor Q1 transistor, the transistor is turned
OFF. Now 12v is given to base of Q2 transistor so the transistor is conducting and buzzer is
energized and produces the sound signal.
Voltage Signal from

Transistor Q1

Transistor Q2

Buzzer

Microcontroller or PC

on

off

off

off

on

on

3.9 Liquid Crystal Display:


The LCD is used for the purpose of displaying the words which we are given in the
program code. This code will be executed on microcontroller chip. By following the instructions
in code the LCD display the related words. Fig.5.6 shows the LCD display.

3.9.1 Introduction

Figure. 3.13: LCD Display


The LCD display consists of two lines, 20 characters per line that is interfaced with
the PIC16F73.The protocol (handshaking) for the display is as shown in Fig. The display
contains two internal byte-wide registers, one for commands (RS=0) and the second for
characters to be displayed (RS=1). It also contains a user-programmed RAM area (the
character RAM) that can be programmed to generate any desired character that can be formed
using a dot matrix. To distinguish between these two data areas, the hex command byte 80
will be used to signify that the display RAM address 00h will be chosen Port1 is used to
furnish the command or data type, and ports 3.2 to 3.4 furnish register select and read/write
levels.

Theory:
A liquid crystal is a material (normally organic for LCDs) that will flow like a liquid but
whose molecular structure has some properties normally associated with solids. The Liquid
Crystal Display (LCD) is a low power device. The power requirement is typically in the order of
microwatts for the LCD. However, an LCD requires an external or internal light source. It is
limited to a temperature range of about 0C to 60C and lifetime is an area of concern, because
LCDs can chemically degrade.
There are two major types of LCDs which are:
1. Dynamic-scattering LCDs and
2. Field-effect LCDs
The turn-on and turn-off time is an important consideration in all displays. The response
time of LCDs is in the range of 100 to 300ms.The lifetime of LCDs is steadily increasing beyond
10,000+hours limit. Since the color generated by LCD units is dependent on the source of
illumination, there is a wide range of color choice.

3.9.2 Pin Diagram


The Pin diagram for LCD is shown in the following fig 3.14 and the pin description is also
explained in Table 3.2.
GND

+5v VDD

15

16

2x16 Liquid Crystal Display


4

RSR/wwwwow
En

D0 0D6
D1 D2
0

10 11

D3 D4

12 13 14

D5 D6 D7

Figure. 3.14: Pin Diagram of LCD

Table 3.2: Pin Description of LCD


Pins

Description

"Vss"

Ground

"Vcc"

+5v power supply

"Vee"

Contrast Voltage

"R/S"

Instruction/Register Select

"R/W"

Read/Write LCD Registers

"E"

Enable

7 - 14

Data I/O Pins

Pin Description
Vcc, Vss, VEE
While Vcc and Vss provide +5v and ground, respectively, Vee is used for controlling
LCD contrast.
RS, Register Select
There are two very important registers inside the LCD. The RS pin is used for their
selection as follows.
If RS = 0, the instruction command code register is selected, allowing the user to send
as command code register is selected, allowing the user to send a command such as clear
display, cursor at home, etc.
If RS = 1 the data register is selected, allowing the user to send data to be displayed on
the LCD.

R/W, Read/Write
R/W input allows the user to write information to the LCD or read information from it.
R/W = 1 when reading;
R/W = 0 when writing.
E, Enable
The enable pin is used by the LCD to latch information presented to its data pins. When
data is supplied to data pins, a high - to - low pulse must be applied to this pin in order for the
LCD latch in the data pins. This pulse must be a minimum of 450 ns wide.
D0 - D7
The 8 - bit data pins, D0 - D7, are used to send information to the LCD or read the
contents of the LCD's internal registers.
To display letters and numbers, send ASCII codes for the letters A - Z, a - z, and numbers
0 - 9 to these pins while RS = 1. When RS = 0 to check the busy flag bit to see if the LCD is
ready to receive information. The busy flag is D7 and can be read when R/W = 1 and RS = 0, as
follows: if R/W = 1, RS = 0. When D7 =1 (busy flag = 1), the LCD is busy taking care of
internal operation and will not accept any new information. The description of the pins is shown
in Table 3.3.

3.9.3 LCD Commands Description


Table 3.3: LCD Commands
R
S

R/
W

D
7

D
6

D
5

D
4

D3

D2 D
1

D
0

Function

Clear LCD &memory,

Home cursor
0

Clear and home cursor


only

1/
0

Screen
action
display character

as

Written
S=1/0:shift
screen/ cursor
0

D=1/0: Screen on/of


C=1/0: Cursor on/of
B=1/0: Cursor blink/no
blinks

S/C R/
L

S/C=1/0:
Screen/Cursor
R/L==1/0:
space R/L

D
L

Character address
Display data address

Shift

one

DL=1/0: 8/4 bits per


character N=1/0: 2/1
Rows of characters
F=1/0:
5*10/5*7dots/characte
r
Write
to
character
RAM address after this
Write to display RAM
address after this

BF

Current addresses

BF=1/0:busy/Not busy

Character type

WritebytetolastRAMch
osen

Handling the EN Control Line


As mentioned above, the EN line is used to tell the LCD that it is ready to execute an
instruction that prepared on the data bus and on the other control lines. Note that the EN line
must be raised/lowered before/after each instruction sent to the LCD regardless of whether that
instruction is read or write, text or instruction. In short, someone must always manipulate EN
when communicating with the LCD. EN is the LCD's way of knowing that someone is talking to
it. If one doesnt raise/lower EN, the LCD doesn't know that someone is talking to it on the other
lines.

Checking the Busy Status of the LCD


As previously mentioned, it takes a certain amount of time for each instruction to be
executed by the LCD. The delay varies depending on the frequency of the crystal attached to the
oscillator input of the controller as well as the instruction which is being executed. While it is
possible to write code that waits for a specific amount of time to allow the LCD to execute
instructions, this method of "waiting" is not very flexible. If the crystal frequency is changed, the
software will need to be modified. Additionally, if the LCD itself is changed for another LCD
which, although 44780 compatible, requires more time to perform its operations, the program
will not work until it is properly modified.
A more robust method of programming is to use the "Get LCD Status" command to
determine whether the LCD is still busy executing the last instruction received.
The "Get LCD Status" command will return to the user two bits of information; the
information that is useful to the user right now is found in DB 7. In summary, when user issue the
"Get LCD Status" command the LCD will immediately raise DB 7 if it's still busy executing a
command or lower DB7 to indicate that the LCD is no longer occupied. Thus the program can
query the LCD until DB7 goes low, indicating the LCD is no longer busy. At that point user is
free to continue and send the next command.

Initializing the LCD


LCD must be initialized and configured before using. This is accomplished by sending a
number of initialization instructions to the LCD.
The first instruction send must tell the LCD whether it is to be communicated with an 8bit or 4-bit data bus. 5x8 dot character font should also be selected. These two options are
selected by sending the command 38h to the LCD as a command.

a) Clearing the Display


When the LCD is first initialized, the screen should automatically be cleared by the
controller.

b) Writing Text into the LCD


The data to be displayed is send to the LCD through data bus.

c) Cursor Positioning
The cursor positioning in a LCD can be done in the right entry mode or left entry mode.
As left entry mode is flexible it is implemented.

3.10 Encoder with RF Transmitter:

Figure 3.15. Encoder with RF Transmitter


3.10.1 Encoder:
In this circuit HT 640 is used as encoder. The 3 18 encoders are a series of CMOS LSIs for
remote control system application. They are capable of encoding 18 bits of information which

consists of N address bit and 18-N data bits. Each address/data input is externally trinary
programmable if bonded out. It is otherwise set floating internally.
Various packages of the 3 18 encoders offer flexible combination of programmable
address/data is transmitted together with the header bits via an RF or an infrared transmission
medium upon receipt of a trigger signal. The capability to select a TE trigger type further
enhances the application flexibility of the 318 series of encoders.
In this circuit the input signal to be encoded is given to AD7-AD0 input pins of
encoder. Here the input signal may be from key board, parallel port, microcontroller or any
interfacing device. The encoder output address pins are shorted so the output encoded signal is
the combination of (A0-A9) address signal and (D0-D7) data signal. The output encoded signal
is taken from 8th which is connected to RF transmitter section.

3.10.2 RF Transmitter:
When ever the high output pulse is given to base of the transistor BF 494, the
transistor is conducting so tank circuit is oscillated. The tank circuit is consists of L2 and C4
generating 433 MHz carrier signal. Then the modulated signal is given LC filter section. After
the filtration the RF modulated signal is transmitted through antenna.

3.11 Decoder with RF Receiver:

Figure:3.16 Decoder with RF Receiver

3.11.1 RF Receiver:
The RF receiver is used to receive the encoded data which is transmitted by the
RF transmitter. Then the received data is given to transistor which acts as amplifier. Then the
amplified signal is given to carrier demodulator section in which transistor Q1 is turn on and turn
off conducting depends on the signal. Due to this the capacitor C14 is charged and discharged so
carrier signal is removed and saw tooth signal is appears across the capacitor. Then this saw tooth
signal is given to comparator. The comparator circuit is constructed by LM558. The comparator
is used to convert the saw tooth signal to exact square pulse. Then the encoded signal is given to
decoder in order to get the decoded original signal.

3.11.2 Decoder:
In this circuit HT648 is used as decoder. The 3 18 decoder are a series of CMOS LSIs
for remote control system application. They are paired with 3 18 series of encoders. For proper
operation a pair of encoder/decoder pair with the same number of address and data format should
be selected.
The 3 18 series of decoder receives serial address and data from that series of
encoders that are transmitted by a carrier using an RF or an IR transmission medium. It then
compares the serial input data twice continuously with its local address.
If no errors or unmatched codes are encountered, the input data codes are
decoded and then transferred to the output pins. The VT pin also goes high to indicate a valid
transmission.
The 318 decoders are capable of decoding 18 bits of information that consists of N bits of
address and 18-N bits of data. To meet various applications they are arranged to provide a
number of data pins whose range is from 0 t08 and an address pin whose range is from 8 to 18.
In addition, the 318 decoders provide various combinations of address/ data numbering different
package.
In this circuit the received encoded signal is 9th pin of the decoder. Now the decoder separate
the address (A0-A9) and data signal (D0-D7). Then the output data signal is given to
microcontroller or any other interfacing device.

CHAPTER-4

WORKING OF THE SYSTEM


4.1 POWER SUPPLIES
INTRODUCTION:
The present chapter introduces the operation of power supply circuits built using
filters, rectifiers, and then voltage regulators. Starting with an ac voltage, a steady dc voltage is
obtained by rectifying the ac voltage, then filtering to a dc level, and finally, regulating to obtain
a desired fixed dc voltage. The regulation is usually obtained from an IC voltage regulator unit,
which takes a dc voltage and provides a somewhat lower dc voltage, which remains the same
even if the input dc voltage varies, or the output load connected to the dc voltage changes.

4.1.1 Block diagram


The ac voltage, typically 220V rms, is connected to a transformer, which steps that ac
voltage down to the level of the desired dc output. A diode rectifier then provides a full-wave
rectified voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This
resulting dc voltage usually has some ripple or ac voltage variation.

TRANSFORME
R

RECTIFIER

FILTER

IC REGULATOR

LOAD

Figure4.1: Block diagram (Power supply)


A regulator circuit removes the ripples and also remains the same dc value even if the
input dc voltage varies, or the load connected to the output dc voltage changes. This voltage
regulation is usually obtained using one of the popular voltage regulator IC units.

4.1.2 Working principle


4.1.2.1 Transformer
The potential transformer will step down the power supply voltage (0-230V) to (0-6V)
level. Then the secondary of the potential transformer will be connected to the precision rectifier,
which is constructed with the help of opamp. The advantages of using precision rectifier are it
will give peak voltage output as DC, rest of the circuits will give only RMS output.

4.1.2.2 Bridge rectifier


When four diodes are connected as shown in figure, the circuit is called as bridge
rectifier. The input to the circuit is applied to the diagonally opposite corners of the network, and
the output is taken from the remaining two corners.
Let us assume that the transformer is working properly and there is a positive potential, at
point A and a negative potential at point B. the positive potential at point A will forward bias D3
and reverse bias D4.
The negative potential at point B will forward bias D1 and reverse D2. At this time D3
and D1 are forward biased and will allow current flow to pass through them; D4 and D2 are
reverse biased and will block current flow.
The path for current flow is from point B through D1, up through RL, through D3,
through the secondary of the transformer back to point B. this path is indicated by the solid
arrows. Waveforms (1) and (2) can be observed across D1 and D3.
One-half cycle later the polarity across the secondary of the transformer reverse, forward
biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now be from point A
through D4, up through RL, through D2, through the secondary of T1, and back to point A. This
path is indicated by the broken arrows. Waveforms (3) and (4) can be observed across D2 and
D4. The current flow through RL is always in the same direction. In flowing through RL this
current develops a voltage corresponding to that. Since current flows through the load (RL)
during both half cycles of the applied voltage, this bridge rectifier is a full-wave rectifier.

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


rectifier is that with a given transformer the bridge rectifier produces a
voltage output that is nearly twice that of the conventional full-wave circuit.
This may be shown by assigning values to some of the components
shown in views A and B. assume that the same transformer is used in both
circuits. The peak voltage developed between points X and y is 1000 volts in
both circuits. In the conventional full-wave circuit shownin view A, the peak
voltage from the center tap to either X or Y is 500 volts. Since only one diode
can conduct at any instant, the maximum voltage that can be rectified at
any instant is 500 volts.
The maximum voltage that appears across the load resistor is nearlybut never exceeds-500 v0lts, as result of the small voltage drop across the
diode. In the bridge rectifier shown in view B, the maximum voltage that can
be rectified is the full secondary voltage, which is 1000 volts. Therefore, the
peak output voltage across the load resistor is nearly 1000 volts. With both
circuits using the same transformer, the bridge rectifier circuit produces a
higher output voltage than the conventional full-wave rectifier circuit.

4.1.2.3 IC voltage regulators


Voltage regulators comprise a class of widely used ICs. Regulator IC units contain
the circuitry for reference source, comparator amplifier, control device, and overload protection
all in a single IC. IC units provide regulation of either a fixed positive voltage, a fixed negative
voltage, or an adjustably set voltage. The regulators can be selected for operation with load
currents from hundreds of milli amperes to tens of amperes, corresponding to power ratings from
milli watts to tens of watts. A fixed three-terminal voltage regulator has an unregulated dc input
voltage, Vi, applied to one input terminal, a regulated dc output voltage, Vo, from a second
terminal, with the third terminal connected to ground.

Figure4.2: Circuit diagram (Power supply)


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

For ICs, microcontroller, LCD --------- 5 volts

For alarm circuit, op-amp, relay circuits ---------- 12 volts

4.2 Sensing,Controlling & Displaying elements:


In this project we use gas sensor for sensing and micro controller(AT89C51) for controlling
the operations of all the other devices and LCD for displaying purposes.

CHAPTER-5

OVERALL VIEW OF THE PROJECT


5.1 Operation
This project is designed with
Microcontroller
Driver Circuits along with Motors
Robot Model
Encoder
Decoder
RF transmitter and receiver
Keypad
Gas sensor
Alaram

Figure 5.1 :Block diagram of our project

In this project wireless control section consists of keypad, encoder and RF transmitter. The
keypad consists of several buttons representing the one operation such as forward, reverse
movement and left, right direction. The keypad entered signal is encoded and given to RF
transmitter in which the signal is modulated with carrier frequency. After the modulation the
encoded signal is transmitted through RF transmitter.
The receiver section consists of RF receiver, Decoder, Microcontroller and Robot model. The
received signal is demodulated in the RF receiver in which the carrier signal is removed then
given to decoder. In the decoder the encoded signal is decoded into original signal as per
transmitted from the control section. Then the signal is given to microcontroller. Along with that,
our robot is having the capability to detect the gas leakage
Here the microcontroller is the flash type reprogrammable microcontroller in which we have
already programmed with our objective. The microcontroller activates the driver circuit as per
the instruction from the control side.
For example when you press the forward key in the control section, the microcontroller
activates the corresponding driver circuit. The driver circuit controls the motor which is attached
in the robot model. Now the robot is moving in the forward direction.
Similarly we can control the robot remotely in reverse and left, right direction as per the
instruction from the wireless keypad.
The gas sensor is the special sensor which designed for sense the gas leakage. In the gas sensor
the supply voltage is given to input terminal. The gas sensor output terminals are connected to
non inverting input terminal of the comparator.
Here the comparator is constructed with operational amplifier LM 358. The reference
voltage is given to inverting input terminal. The reference voltage is depends on the desired gas
intensity. When there is no leakage the non inverting input is grater then inverting input so the
output of the comparator is positive voltage which is given to the base of the switching transistor
BC 547. Hence the transistor is conducting. Here the transistor is act as switch so the collector
and emitter will be closed. The output is taken from collector terminal. Now the output is zero
which is given to hex inverter 40106.

When there is gas leakage the inverting input voltage is grater than non inverting input.
Now the comparator output is -12V so the transistor is cutoff region. The 5v is given to hex
inverter 40106 IC. Then the final output data is directly given to microcontroller to determine the
gas leakage.
When microcontroller detect gas then it send signals to a circuit which control the
buzzer .The circuit is designed to control the buzzer. The buzzer ON and OFF is controlled by
the pair of switching transistors (BC 547). The buzzer is connected in the Q2 transistor collector
terminal.
When high pulse signal is given to base of the Q1 transistors, the transistor is conducting
and close the collector and emitter terminal so zero signals is given to base of the Q2 transistor.
Hence Q2 transistor and buzzer is turned OFF state.When low pulse is given to base of transistor
Q1 transistor, the transistor is turned OFF. Now 12v is given to base of Q2 transistor so the
transistor is conducting and buzzer is energized and produces the sound signal.

5.2 Advantages & Applications


Advantages
The Advantages of our project are
1.High portability
2. Less Density
3. Reconfigurability

Applications
1. INDUSTRIAL APPLICATIONS
2. SECURITY APPLICATIONS

CHAPTER-6
CONCLUSION &FUTURE SCOPE
CONCLUSION
Embedded Systems plays a vital role in our day today life. They are used for household
appliances like microwave oven to the satellite applications. They provide good man to machine
interface. Automation is the further step in the world of Embedded Systems, which includes the
elimination of the human being in the mundane applications. They are cost effective, accurate
and can work in any conditions and round the clock.
Our project industial oriented Gas detecting robot is very usefull to save the lifes of
workers in mines by detecting dangerous gases .The advantage of our project is it can be
controlled by a remot so that it can cover wide area to detect gases.

FUTURE SCOPE
In our project, the automation of robot takes place in certain limit only .This project can be
extended further by using G.S.M(Global System For Mobile Communication).By extending
this project ROBOT is controlled from any part of the world.

APPENDIX 1
SOURCE CODE:
#include <AT89X51.H>
void lcd_read(unsigned char);
void lcd_write(unsigned char);
void lcd_display(unsigned char *,unsigned char);
void hex_dec(unsigned int val);
void delay(unsigned int);
void lcd_init();
sbit rs = P2^7;
sbit rw = P2^6;
sbit en = P2^5;
sbit gas=P1^7;
sbit buzzer=P1^6;
sbit f=P2^0;
sbit b=P2^1;
sbit l=P2^2;
sbit r=P2^3;
sbit r1=P1^0;
sbit r2=P1^1;
sbit r3=P1^2;
sbit r4=P1^3;
unsigned char aa,bb,cc,dd,count1,count2,enter,exit,total,temp,temp1;
unsigned int d1,d2,d3,temp_var,i;
void forward();
void back();

void left();
void right();
void stop();
void main()
{
lcd_init();
lcd_read(0x80);
lcd_display("WIRLESS ROBO

",16);

lcd_read(0xc0);
lcd_display("FOR INDUSTRIES ",16);
buzzer=0;
r1=1;
r2=1;
r3=1;
r4=1;
delay(6500);
delay(6500);
delay(6500);
delay(6500);
delay(6500);
delay(6500);
while(1)
{
while(!f)
{
lcd_read(0x80);
lcd_display(" FORWARD
",16);
lcd_read(0xc0);
lcd_display("
",16);
forward();
}
while(!b)
{
lcd_read(0x80);
lcd_display(" BACK
",16);

lcd_read(0xc0);
lcd_display("
",16);
back();
}
while(!l)
{
lcd_read(0x80);
lcd_display(" LEFT
",16);
lcd_read(0xc0);
lcd_display("
",16);
left();
}
while(!r)
{
lcd_read(0x80);
lcd_display(" RIGHT
",16);
lcd_read(0xc0);
lcd_display("
",16);
right();
}
if(gas)
{
lcd_read(0x80);
lcd_display(" GAS DETECTED ",16);
lcd_read(0xc0);
lcd_display(" BUZZER ON ",16);
buzzer=1;
}
if(!gas)
{
lcd_read(0x80);
lcd_display("GAS NOT DETECTED",16);
lcd_read(0xc0);
lcd_display(" BUZZER OFF ",16);
buzzer=0;
}
}
}
void lcd_read(unsigned char y)
{

P0=y;
rs=0;
en=1;
rw=0;
delay(4000);
en=0;
}
void forward()
{
r1=0;
//0n
r2=1;
//of
r3=0;
r4=1;
}
void back()
{
r1=1;
r2=0;
r3=1;
r4=0;
}
void left()
{
r1=1;
r2=0;
r3=0;
r4=1;
}
void right()
{
r1=0;
r2=1;
r3=1;
r4=0;
}
void stop()

{
r1=1;
r2=1;
r3=1;
r4=1;
}
void lcd_write(unsigned char y)
{
P0=y;
rw=0;
rs=1;
en=1;
delay(600);
en=0;
}
void lcd_init()
{
lcd_read(0x38);
lcd_read(0x06);
lcd_read(0x0c);
}
void lcd_display(unsigned char *dis,unsigned char rr)
{
unsigned char m;
for(m=0;m<rr;m++)
{

lcd_write(dis[m]);
}
}

APPENDIX 2
KEIL SOFTWARE
Keil compiler is software used where the machine language code is written and compiled.
After compilation, the machine source code is converted into hex code which is to be dumped
into the microcontroller for further processing. Keil compiler also supports C language code.
STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL AND HOW TO
COMPILE IT:

1. Install the Keil Software in the PC in any of the drives.


2. After installation, an icon will be created with the name Keil uVision3. Just drag this
icon onto the desktop so that it becomes easy whenever you try to write programs in keil.
3. Double click on this icon to start the keil compiler.
4. A page opens with different options in it showing the project workspace at the leftmost
corner side, output window in the bottom and an ash coloured space for the program to be
written.
5. Now to start using the keil, click on the option project.
6. A small window opens showing the options like new project, import project, open project
etc. Click on New project.
7. A small window with the title bar Create new project opens. The window asks the user
to give the project name with which it should be created and the destination location. The
project can be created in any of the drives available. You can create a new folder and then
a new file or can create directly a new file.
8. After the file is saved in the given destination location, a window opens where a list of
vendors will be displayed and you have to select the device for the target you have
created.

9. The most widely used vendor is Atmel. So click on Atmel and now the family of
microcontrollers manufactured by Atmel opens. You can select any one of the
microcontrollers according to the requirement.
10. When you click on any one of the microcontrollers, the features of that particular
microcontroller will be displayed on the right side of the page. The most appropriate
microcontroller with which most of the projects can be implemented is the AT89C51.
Click on this microcontroller and have a look at its features. Now click on OK to select
this microcontroller.
11. A small window opens asking whether to copy the startup code into the file you have
created just now. Just click on No to proceed further.
12. Now you can see the TARGET and SOURCE GROUP created in the project workspace.
13. Now click on File and in that New. A new page opens and you can start writing
program in it.
14. After the program is completed, save it with any name but with the .asm extension. Save
the program in the file you have created earlier.
15. You can notice that after you save the program, the predefined keywords will be
highlighted in bold letters.
16. Now add this file to the target by giving a right click on the source group. A list of
options open and in that select Add files to the source group. Check for this file where
you have saved and add it.
17. Right click on the target and select the first option Options for target. A window opens
with different options like device, target, output etc. First click on target.
18. Since the set frequency of the microcontroller is 11.0592 MHz to interface with the PC,
just enter this frequency value in the Xtal (MHz) text area and put a tick on the Use onchip ROM. This is because the program what we write here in the keil will later be
dumped into the microcontroller and will be stored in the inbuilt ROM in the
microcontroller.
19. Now click the option Output and give any name to the hex file to be created in the
Name of executable text area and put a tick to the Create HEX file option present in

the same window. The hex file can be created in any of the drives. You can change the
folder by clicking on Select folder for Objects.

20. Now to check whether the program you have written is errorless or not, click on the icon
exactly below the Open file icon which is nothing but Build Target icon. You can even
use the shortcut key F7 to compile the program written.
21. To check for the output, there are several windows like serial window, memory window,
project window etc. Depending on the program you have written, select the appropriate
window to see the output by entering into debug mode.
22. The icon with the letter d indicates the debug mode.
23. Click on this icon and now click on the option View and select the appropriate window
to check for the output.
24. After this is done, click the icon debug again to come out of the debug mode.
25.The hex file created as shown earlier will be dumped into the microcontroller.

BIBLIOGRAPHY
The 8051 Micro controller and EmbeddedSystems
-Muhammad Ali Mazidi
-Janice Gillispie Mazidi
The 8051 Micro controller Architecture,Programming & Applications
-Kenneth J.Ayala
Fundamentals Of Micro processors andMicro computers
-B.Ram
Electronic Components -D.V.Prasad
Wireless Communications - Theodore S. Rappaport
EMBEDDED SYSTEM BY RAJ KAMAL
Magazines

Web References:

www.national.com

www.nxp.com

www.microsoftsearch.com

www.geocities.com

WWW.Electronic projects.com

You might also like