Professional Documents
Culture Documents
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.
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.
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.
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
A third 16-bit timer, capable of a number of new operation modes and 16-bit reloads.
8051 Architecture:
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
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
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:
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.
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
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.)
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.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.
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
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).
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
for
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
2
0
internal
3
0
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
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:
Basic principles
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.
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.
-------------------------------(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.
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.
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.
3.4 Relay
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.
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.
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.
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.
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.
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
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
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
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.
Transistor Q1
Transistor Q2
Buzzer
Microcontroller or PC
on
off
off
off
on
on
3.9.1 Introduction
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.
+5v VDD
15
16
RSR/wwwwow
En
D0 0D6
D1 D2
0
10 11
D3 D4
12 13 14
D5 D6 D7
Description
"Vss"
Ground
"Vcc"
"Vee"
Contrast Voltage
"R/S"
Instruction/Register Select
"R/W"
"E"
Enable
7 - 14
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.
R/
W
D
7
D
6
D
5
D
4
D3
D2 D
1
D
0
Function
Home cursor
0
1/
0
Screen
action
display character
as
Written
S=1/0:shift
screen/ cursor
0
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
BF
Current addresses
BF=1/0:busy/Not busy
Character type
WritebytetolastRAMch
osen
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.
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.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
TRANSFORME
R
RECTIFIER
FILTER
IC REGULATOR
LOAD
CHAPTER-5
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.
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:
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