You are on page 1of 55

CHAPTER-1

INTRODUCTION
1.1 EMBEDDED SYSTEMS
Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real time performance
constraints that must be met, for reason such as safety and usability; others may have
low or no performance requirements, allowing the system hardware to be simplified
to reduce costs.
An embedded system is not always a separate block - very often it is
physically built-in to the device it is controlling. The software written for embedded
systems is often called firmware, and is stored in read-only memory or flash
convector chips rather than a disk drive. It often runs with limited computer hardware
resources: small or no keyboard, screen, and little memory.
Wireless communication has become an important feature for commercial
products and a popular research topic within the last ten years. There are now more
mobile phone subscriptions than wired-line subscriptions. Lately, one area of
commercial interest has been low-cost, low-power, and short-distance wireless
communication used for personal wireless networks". Technology advancements are
providing smaller and more cost effective devices for integrating computational
processing, wireless communication, and a host of other functionalities. These
embedded communications devices will be integrated into applications ranging from
homeland security to industry automation and monitoring. They will also enable
custom tailored engineering solutions, creating a revolutionary way of disseminating
and processing information. With new technologies and devices come new business
activities, and the need for employees in these technological areas. Engineers who
have knowledge of embedded systems and wireless communications will be in high
demand. Unfortunately, there are few adorable environments available for
development and classroom use, so students often do not learn about these
technologies during hands-on lab exercises. The communication mediums were
twisted pair, optical fiber, infrared, and generally wireless radio.

1.2 OVERVIEW OF EMBEDDED SYSTEM ARCHITECTURE:


Every Embedded system consists of a custom-built hardware built around a
central processing unit. This hardware also contains memory chips onto which the
software is loaded.
Application
S/W

Operating System
H/W

Figure1.1: Overview of embedded system architecture


The operating system runs above the hardware and the application software
runs above the operating system. The same architecture is applicable to any computer
including desktop computer. However these are significant differences. It is not
compulsory to have an operating system in every embedded system. For small
applications such as remote control units, air conditioners, toys etc.

1.3 APPLICATIONS OF EMBEDDED SYSTEMS:


Some of the most common embedded systems used in everyday life are
Small embedded controllers: 8-bit CPUs dominate, simple or no operating
system (e.g., thermostats)
Control systems: Often use DSP chip for control computations(e.g.,
automotive engine control)
Distributed embedded control: Mixture of large and small nodes on a realtime Embedded networks. (e.g., cars, elevators, factory automation)
System on chip: ASIC design tailored to application area. (e.g., consumer
electronics, set-top boxes)
Network equipment: Emphasis on data movement/packet flow. (e.g., network
switches; telephone switches)
Critical systems: Safety and mission critical computing. (e.g., pacemakers,
automatic trains)

Signal processing: Often use DSP chips for vision, audio, or other signal
Processing (e.g., face recognition)
Robotics: Uses various types of embedded computing (especially Vision and
control) (e.g., autonomous vehicles)
Computer peripherals: Disk drives, keyboards, laser printers, etc.
Wireless systems: Wireless network-connected sensor networks and
Motes to gather and report information
Embedded PCs: Palmtop and small form factor PCs embedded into
Equipment
Command and control:

Often huge military systems and systems of

systems (e.g., a fleet of warships with interconnected Computers)


Home Appliances: intercom, telephones, security systems, garage door
openers, answering machines, fax machines, home computers, TVs, cable TV
tuner, VCR, camcorder, remote controls, video games, cellular phones,
musical instruments, sewing machines, lighting control, paging, camera,
pinball machines, toys, exercise equipment.
Office Telephones, computers, security systems, fax machines, microwave,
copier, laser printer, color printer, paging
Auto Trip computer, engine control, air bag, ABS, instrumentation, security
system, transmission control, entertainment, climate control, cellular phone,
keyless entry.

1.4 OBJECTIVE OF THE PROJECT


The main objective of the metal detector robot is used to detect the metal and
if the sensor found metal near to it, the robot stop moving and on LCD screen it is
displayed as metal detected.

1.5 HARDWARE REQUIREMENTS


Micro Controller (AT89S52).
Metal sensor.
LCD

L293D
Gear Motors
Regulated Power Supply

1.6 SOFTWARE REQUIREMENTS


The KEIL MICRO VISION IDE where KEIL C51 Product is a complete
software development environment for the8051 microcontroller family.
MICRO C Flash+ Ver. 4.0.0 programmer for MCS51 microcontrollers
developed by UC micro systems

CHAPTER-2
IMPLEMENTATION DETAILS
2.1 BLOCK DIAGAM FOR THE PROPOSED SYSTEM
POWER
SUPPLY

AT89S52

LCD

MICRO
CONTROLLER
METAL
DETECTOR

MOTOR
DRIVER IC

GEAR
MOTORS

Figure 2.1: Block Diagram for the Proposed System


OPERATION:
Regulated Power Supply feeds power required for Metal Sensor, Micro
controller, LCD unit +5V DC source, Motor Driver IC and Gear Motors requires
+12V DC power source. A Metal Sensor is used to scan for a metal identification,
LCD is used for Display about the status of operation of the system, Gear motors are
attached to Robot to make the Robot body to move in different directions, to drive
motors in different directions and to ON and OFF a driver IC is used, a Micro
Controller is used as a control unit to activate the sensor and drive input and output
devices.
When the system is initiated by the regulated power supply then micro
controller activates the motor driver IC so that the motors comes to ON state and
5

make the Robot to move in forward direction as programmed for Micro controller.
The Micro controller makes the Robot to move, parallel it monitors the metal sensor.
When the metal sensor identifies any metal in front of it then the signal is fed to micro
controller, which in turn makes the motors OFF such that the Robot waits for few
seconds and later it keeps moving as usual. If metal sensor dont identify any metal in
front of it then the controller makes robot to move as usual.

2.2 REGULATED POWER SUPPLY


The power supplies are designed to convert high voltage AC mains electricity
to a suitable low voltage supply for electronic circuits and other devices. A RPS
(Regulated Power Supply) is the Power Supply with Rectification, Filtering and
Regulation being done on the AC mains to get a Regulated power supply for
Microcontroller and for the other devices being interfaced to it.
A power supply can by broken down into a series of blocks, each of which
performs a particular function. A dc power supply which maintains the output voltage
constant irrespective of ac mains fluctuations or load variations is known as
Regulated D.C Power Supply

Figure 2.2: Block Diagram of Regulated power supply

2.2.1 Transformer
A transformer is an electrical device which is used to convert electrical power
from one Electrical circuit to another without change in frequency. Transformers convert
AC electricity from one voltage to another with little loss of power. Transformers
work only with AC and this is one of the reasons why mains electricity is AC. Stepup transformers increase in output voltage, step-down transformers decrease in output
voltage. Most power supplies use a step-down transformer to reduce the dangerously
high mains voltage to a safer low voltage. The input coil is called the primary and
the output coil is called the secondary. There is no electrical connection between the
two coils; instead they are linked by an alternating magnetic field created in the softiron core of the transformer. The two lines in the middle of the circuit symbol
represent the core. Transformers waste very little power down current is stepped up.
The ratio of the number of turns on each coil, called the turns ratio, determines the
ratio of the voltages. A step-down transformer has a large number of turns on its
primary (input) coil which is connected to the high voltage mains supply, and a small
number of turns on its secondary (output) coil to give a low output voltage.

Figure2.3: An Electrical Transformer

Turns ratio = Vp/ VS = Np/NS

Power Out= Power In

VS X IS=VP X IP

Vp = primary (input) voltage


Np = number of turns on primary coil
Ip = primary (input) current

2.2.2 RECTIFIER:
A circuit which is used to convert ac to dc is known as RECTIFIER. The
process of conversion ac to dc is called Rectification
TYPES OF RECTIFIERS:

Half wave Rectifier

Full wave rectifier


1. Centre tap full wave rectifier.
2. Bridge type full bridge rectifier.

Comparison of rectifier circuits:


Table 2.1 Comparison of rectifier circuits:

Type of Rectifier
Parameter

Half

wave

Full

wave

Bridge
Number of diodes
PIV of diodes
D.C output voltage
Vdc at no-load
Ripple factor
Ripple Frequency
Rectification Efficiency
Transformer Utilization Factor (TUF)
RMS voltage Vrms

1
Vm
Vm/
.318Vm
1.21
f
0.406
0.287
Vm/2

2
2Vm
Vm/
0.636Vm
0.482
2f
0.812
0.693
Vm/2

4
Vm
2Vm/
0.636Vm
0.482
2f
0.812
0.812
Vm/2

Bridge Rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve
full-wave rectification. This is a widely used configuration, both with individual
diodes wired as shown and with single component bridges where the diode bridge is
wired internally.

Figure 2.4:Bridge rectifier

Operation:
During positive half cycle of secondary, the diodes D2 and D3 are in forward
biased while D1 and D4 are in reverse biased as shown in the figure 2.4(a). The
current flow direction is shown in the figure 2.4(a) with dotted arrows.

Figure 2.4(a): Operation of positive half cycle


During negative half cycle of secondary voltage, the diodes D1 and D4 are in
forward biased while D2 and D3 are in reverse biased as shown in the fig(c). The
current flow direction is shown in the fig (c) with dotted arrows.

Figure 2.4(b): operation of negative half cycle

2.2.3 Filter:
A Filter is a device which removes the a.c. component of rectifier output but
allows the d.c. component to reach the load.
Capacitor Filter: We have seen that the ripple content in the rectified output of half
wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is

48% such high percentages of ripples is not acceptable for most of the applications.
Ripples can be removed by one of the following methods of filtering.
(a) A capacitor, in parallel to the load, provides an easier by pass for the ripples
voltage though it due to low impedance. At ripple frequency and leave the D.C. to
appear at the load.
(b) An inductor, in series with the load, prevents the passage of the ripple current (due
to high impedance at ripple frequency) while allowing the d.c (due to low resistance
to d.c)
(c) Various combinations of capacitor and inductor, such as L-section filter

section

filter, multiple section filter etc. which make use of both the properties mentioned in
(a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and
another with full wave rectifier.
Filtering is performed by a large value electrolytic capacitor connected across
the DC supply to act as a reservoir, supplying current to the output when the varying
DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of
the varying DC, and then discharges as it supplies current to the output. Filtering
significantly increases the average DC voltage to almost the peak value (1.4 RMS
value).
To calculate the value of capacitor(C),
C = *3*f*r*Rl
Where,
f = supply frequency,
r = ripple factor,
Rl = load resistance
Note: In our circuit we are using 1000F hence large value of capacitor is placed to
reduce ripples and to improve the DC component.
2.2.4 Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable
output voltages. The maximum current they can pass also rates them. Negative
voltage regulators are available, mainly for use in dual supplies. Most regulators

10

include some automatic protection from excessive current ('overload protection') and
overheating ('thermal protection'). Many of the fixed voltage regulators ICs have 3
leads and look like power transistors, such as the 7805 +5V 1A regulator shown on
the right. The LM7805 is simple to use. You simply connect the positive lead of your
unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin,
connect the negative lead to the Common pin and then when you turn on the power,
you get a 5 volt supply from the output pin.

Figure 2.5: Voltage Regulator

78XX:
The Bay Linear LM78XX is integrated linear positive regulator with three
terminals. The LM78XX offer several fixed output voltages making them useful in
wide range of applications. When used as a zener diode/resistor combination
replacement, the LM78XX usually results in an effective output impedance
improvement of two orders of magnitude, lower quiescent current. The LM78XX is
available in the TO-252, TO-220 & TO-263packages,

Features:
Output Current of 1.5A
Output Voltage Tolerance of 5%
Internal thermal overload protection
Internal Short-Circuit Limited
Output Voltage 5.0

2.3 CONTROL UNIT (AT89S52):


Microcontroller versus Microprocessor: What is the difference between a
Microprocessor and Microcontroller? By microprocessor is meant the general purpose
Microprocessors such as Intel's X86 family (8086, 80286, 80386, 80486, and the
Pentium) or Motorola's 680X0 family (68000, 68010, 68020, 68030, 68040, etc).

11

These microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself.
For this reason, they are commonly referred to as general-purpose Microprocessors.
2.3.1 MICROPROCESSORS Vs MICROCONTROLLERS:
Microprocessor has following instructions to perform:
1. Reading instructions or data from program memory ROM.
2. Interpreting the instruction and executing it.
3. Microprocessor Program is a collection of instructions stored in a Nonvolatile
memory.
4. Read Data from I/O device
5. Process the input read, as per the instructions read in program memory.
6. Read or write data to Data memory
A system designer using a general-purpose microprocessor such as the
Pentium or the 68040 must add RAM, ROM, I/O ports, and timers externally to make
them functional. Although the addition of external RAM, ROM, and I/O ports makes
these systems bulkier and much more expensive, they have the advantage of
versatility such that the designer can decide on the amount of RAM, ROM and I/O
ports needed to fit the task at hand. This is not the case with Microcontrollers.
Typical Micro controller Features:
8/16/32 CPU
Instruction set rich in I/O & bit operations.
One or more I/O ports.
One or more timer/counters.
One or more interrupt inputs and an interrupt controller
One or more serial communication ports.
Analog to Digital /Digital to Analog converter
One or more PWM output
Network controlled interface
A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount
of RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the
12

processor, the RAM, ROM, I/O ports and the timer are all embedded together on one
chip; therefore, the designer cannot add any external memory, I/O ports, or timer to it.
The fixed amount of on-chip ROM, RAM, and number of I/O ports in
Microcontrollers makes them ideal for many applications in which cost and space are
critical.
In many applications, for example a TV remote control, there is no need for the
computing power of a 486 or even an 8086 microprocessor. These applications most
often require some I/O operations to read signals and turn on and off certain bits.
2.3.2 A BRIEF HISTORY OF 8051
In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051.
This microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one
serial port, and four ports all on a single chip. At the time it was also referred as A
SYSTEM ON A CHIP
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller
with 8K bytes of in-system programmable Flash memory. The device is manufactured
using Atmels high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile
memory pro-grammar. By combining a versatile 8-bit CPU with in-system
programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller, which provides a highly flexible and cost-effective solution to many,
embedded control applications. The AT89S52 provides the following standard
features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two
data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture,
a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the
AT89S52 is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode stops the CPU
while allowing the RAM, timer/counters, serial port, and interrupt system to continue
functioning. The Power-down mode saves the RAM con-tents but freezes the
oscillator, disabling all other chip functions until the next interrupt

13

Figure 2.6: Micro controller overview

14

Figure 2.7: BLOCK DIAGRAM OF AT89S52


8031 has 128 bytes of RAM, two timers and 6 interrupts.
8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts.
8052 has 8K ROM, 256 bytes of RAM, three timers and 8 interrupts.
Of the three microcontrollers, 8051 is the most preferable. Microcontroller
supports both serial and parallel communication. In the concerned project 8052
microcontroller is used. Here microcontroller used is AT89S52, which is
manufactured by ATMEL laboratories.
The 8051 is the name of a big family of microcontrollers. The device which
we are going to use along this tutorial is the 'AT89S52' which is a typical 8051
microcontroller manufactured by Atmel. Note that this part doesn't aim to explain
15

the functioning of the different components of a 89S52 microcontroller, but rather to


give you a general idea of the organization of the chip and the available features,
which shall be explained in detail along this tutorial.
This figures shows the main features and components that the designer can
interact with. You can notice that the 89S52 has 4 different ports, each one having 8
Input/output lines providing a total of 32 I/O lines. Those ports can be used to output
DATA and orders do other devices, or to read the state of a sensor, or a switch. Most
of the ports of the 89S52 have 'dual function' meaning that they can be used for two
different functions: the fist one is to perform input/output operations and the second
one is used to implement special features of the microcontroller like counting external
pulses, interrupting the execution of the program according to external events,
performing serial data transfer or connecting the chip to a computer to update the
software.

Introduction to AT89S52
The system requirements and control specifications clearly rule out the use of
16, 32 or 64 bit micro controllers or microprocessors. Systems using these may be
earlier to implement due to large number of internal features. They are also faster and
more reliable but, the above application is satisfactorily served by 8-bit micro
controller. Using an inexpensive 8-bit Microcontroller will doom the 32-bit product
failure in any competitive market place. Coming to the question of why to use 89S52
of all the 8-bit Microcontroller available in the market the main answer would be
because it has 8kB Flash and 256 bytes of data RAM32 I/O lines, three 16-bit
timer/counters, a Eight-vector two-level interrupt architecture, a full duplex serial
port, on-chip oscillator, and clock circuitry.
In addition, the AT89S52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port, and
interrupt system to continue functioning. The Power Down Mode saves the RAM
contents but freezes the oscillator, disabling all other chip functions until the next
hardware reset. The Flash program memory supports both parallel programming and
in Serial In-System Programming (ISP). The 89S52 is also In-Application
16

Programmable (IAP), allowing the Flash program memory to be reconfigured even


while the application is running.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
Atmel AT89S52 is a powerful microcomputer which provides a highly flexible and
cost effective solution to many embedded control applications.

2.3.3 FEATURES
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
4.0V to 5.5V Operating Range
Full Duplex UART Serial Channel
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)

17

2.3.4 PIN DIAGRAM

Figure 2.8: Pin diagram of AT89S52

2.3.5 PIN DESCRIPTION


VCC: Supply voltage.
GND: Ground
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 can 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 pullups are required during program verification.

18

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. In addition, P1.0 and P1.1 can be configured to be the timer/counter
2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX),
respectively, as shown in the following table. Port 1 also receives the low-order
address bytes during Flash programming and verification.
Table 2.2: Port 1 Pin Functions

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 uses 16-bit addresses
(MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses 8-bit addresses
(MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2
also receives the high-order address bits and some control signals during Flash
programming and verification.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. 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 AT89S52,

19

as shown in the following table. Port 3 also receives some control signals for Flash
programming and verification.
Table 2.3: Port 1 Pin Functions

RST:Resetinput.Ahighonthispinfortwomachinecycleswhiletheoscillatoris
runningresetsthedevice. This pindrives Highfor96oscillator periods afterthe
Watchdogtimesout.TheDISRTObitinSFRAUXR(address8EH)canbeusedto
disablethisfeature.InthedefaultstateofbitDISRTO,theRESETHIGHoutfeature
isenabled.
ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low
byte of the address input (PROG) during Flash programming. In normal operation,
ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for
external timing or clocking purposes. Note, however, that one ALE pulse is skipped
during each access to external data memory. If desired, ALE operation can be disabled
by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a
MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the
ALE-disable bit has no effect if the microcontroller is in external execution mode.
PSEN: Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.
EA/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
20

pin also receives the 12-volt programming enable voltage (VPP) during Flash
programming.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2: Output from the inverting oscillator amplifier during accesses to external
memory. This pin is also the program pulse

Figure 2.9: Functional block diagram of micro controller

8052 Oscillator and Clock: The heart of the 8051 circuitry that generates the clock pulses
by which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is
provided for connecting a resonant network to form an oscillator. Typically a quartz crystal
and capacitors are employed. The crystal frequency is the basic internal clock frequency of
the microcontroller. The manufacturers make 8051 designs that run at specific minimum and
maximum frequencies typically 1 to 16 MHz.

2.3.6 MEMORIES
Types of memory:

21

The 8052 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically
existing memory on the micro controller itself. External code memory is the code
memory that resides off chip. This is often in the form of an external EPROM.
External RAM is the Ram that resides off chip. This often is in the form of standard
static RAM or flash RAM.
a) Code memory
Code memory is the memory that holds the actual 8052 programs that is to be
run. This memory is limited to 64K. Code memory may be found on-chip or off-chip.
It is possible to have 8K of code memory on-chip and 60K off chip memory
simultaneously. If only off-chip memory is available then there can be 64K of off chip
ROM. This is controlled by pin provided as EA
b) Internal RAM
The 8052 have a bank of 256 bytes of internal RAM. The internal RAM is found
on-chip. So it is the fastest Ram available. And also it is most flexible in terms of
reading and writing. Internal Ram is volatile, so when 8051 is reset, this memory is
cleared. 256 bytes of internal memory are subdivided. The first 32 bytes are divided
into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 256
bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each
individual bit of a byte can be addressed by the user. They are numbered 00h to FFh.
The user may make use of these variables with commands such as SETB and CLR.

2.4 METAL DETECTOR


INDUCTIVE PROXIMITY SENSORS

Figure 2.10:Different types of metal sensors

22

Sense ferrous & non-ferrous metal objects to "zero speed"


2-wire current source (NAMUR) & 3-wire npn true open collector outputs
5 sizes & 3 sensing distances for application versatility
LED Target indicator (psa 2b, 6b, 7b, & 8b)

Figure 2.11: Operational view of metal sensor


Inductive Proximity Sensors detect the presence of metal objects which come within
range of their oscillating field and provide target detection to "zero speed". Internally,
an oscillator creates a high frequency electromagnetic field (RF) which is radiated
from the coil and out from the sensor face (See Figure 1). When a metal object enters
this field, eddy currents are induced into the object.

23

Figure 2.12: Dimensions of metal sensor


As the metal moves closer to the sensor, these eddy currents increase and
result in an absorption of energy from the coil which dampens the oscillator
amplitude until it finally stops.

MODELS PSA-1B & 2B

Figure 2.13 (a) : Model of metal sensors (PSA 1B, 2B)

The 2-wire Models PSA-1B and 2B contain only the coil and oscillator circuit
(See Figure 2). With no metal object being sensed, the circuit oscillates and draws
greater than 2.2 mA of supply current. As a metal object of sufficient size is brought
into the sensing field, the oscillator amplitude dampens and finally stops, resulting in
less than 1 mA of circuit current being drawn. This greater than 2.2 mA to less than 1
mA change in circuit current between oscillating and non-oscillating conditions is
converted into a usable voltage signal (VS) by placing a resistor (RS) in series with the
sensor leads.
Table 2.4 Metal Sensor specifications
1. Power Supply:

PSA-1B | PSA-2B
+5 to +30 VDC
2. Maximum Switching Frequency:
5 KHz | 500 Hz
3. Output:
Less than 1 mA Target Sensed; Greater than
4. Maximum Sensing Distance:
5. Wire Color Code:
6. Operating Temperature:
7. Construction:

2.2 mA No Target.
0.059" (1.5 mm) | 0.394" (10 mm)
Brown = +VDC; Blue = Count
-25C to +70C (-14F to +158F)
NEMA 1, 3, 4, 6, 13, and IEC IP 67.

24

In addition to the coil and oscillator circuit, the 3-wire Models PSA-6B, 7B,
and 8B each contain a Detector Circuit and NPN Transistor Output (See Figure 3). In
these units, the Detector Circuit senses when the oscillator stops, and turns on the
Output Transistor which controls the load. The Detector Circuit also turns on an
integrally case mounted L.E.D., visually indicating when a metal object is sensed.

PSA-6B, 7B, & 8B


These Inductive Proximity Sensors have a maximum sensing distance of
0.059" (1.5 mm), 0.197" (5 mm) and 0.394" (10 mm) respectively, and operate over a
wide power supply range (See Specifications Below). They are each housed in
threaded metal cases and are supplied with 2 metal jam nuts for mounting. The NPN
transistor outputs are true open collector and are compatible with most RLC counter
and rate input circuits. Maximum sensing frequencies are 2 KHz, 1 KHz, and 500 Hz
respectively. In addition, the outputs are overload and short circuit protected. These
sensors are shielded for flush mounting in metal applications.

Figure 2.13 (a) : Model of metal sensors (PSA 1B, 2B)

SELECTION & APPLICATION OF PROXIMITY SENSORS


Selection of the proper proximity sensor depends on the size, material, and
spacing of the target being sensed and the sensing distance that can be maintained.
The maximum sensing distance is defined as the distance in which the sensor is just
close enough to detect a ferrous target whose diameter is equal to or greater than the
sensor diameter. In actual application, the sensing distance should be between 50 to
80% of the maximum sensing range to assure reliable detection. For target sizes
smaller than the sensor diameter, the maximum sensing distance can be estimated
from the curve (See Figure 4). A further reduction factor must also be applied if the
target material is non-ferrous metal (See Figure 5). Ideally, spacing between adjacent
targets should be at least one sensor diameter so that the first target completely leaves
25

the sensors field before the next target appears. Individual targets can still be resolved
as separate objects if this spacing is reduced to 70 or 75% of the sensor diameter,
however, this can introduce a minimum limit on sensing distance that makes
adjustment more critical. All Proximity sensors are internally shielded which allows
the sensor face to be flush mounted in metal applications without reducing sensing
distance. In applications where proximity sensors must be placed next to each other, a
distance of at least 1 sensor diameter should separate sensors to eliminate any
frequency interference (See Figure 6).

Figure 2.14: Metal Sensor Ranges

Note: PSA-6B, 7B, and 8B outputs are NPN open collector outputs. A PSA-6B, 7B,
or 8B may be used as an input to more than 1 indicator or control only if the
respective power supplies of each unit are "unregulated" and can load share. It is
recommended to use only one power supply for sensor power. An indicator or control
with a regulated power supply may not be paralleled.

2.5 LCD (Liquid Crystal Display):


A liquid crystal display (LCD) is a thin, flat display device made up of any
number of color or monochrome pixels arrayed in front of a light source or reflector.
Each pixel consists of a column of liquid crystal molecules suspended between two
transparent electrodes, and two polarizing filters, the axes of polarity of which are
perpendicular to each other. Without the liquid crystals between them, light passing
through one would be blocked by the other. The liquid crystal twists the polarization
of light entering one filter to allow it to pass through the other.
26

A program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices
attached to an controller is an LCD display. Some of the most common LCDs
connected to the contollers are 16X1, 16x2 and 20x2 displays. This means 16
characters per line by 1 line 16 characters per line by 2 lines and 20 characters per line
by 2 lines, respectively.
Many microcontroller devices use 'smart LCD' displays to output visual
information.

LCD displays designed around LCD NT-C1611 module, are

inexpensive, easy to use, and it is even possible to produce a readout using the 5X7
dots plus cursor of the display. They have a standard ASCII set of characters and
mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus
10 I/O lines (RS RW D7 D6 D5 D4 D3 D2 D1 D0).

For a 4-bit data bus it only

requires the supply lines plus 6 extra lines(RS RW D7 D6 D5 D4). When the LCD
display is not enabled, data lines are tri-state and they do not interfere with the
operation of the microcontroller.
Features:
(1) Interface

with either 4-bit or 8-bit microprocessor.

(2) Display data RAM


(3) 80x8 bits (80 characters).
(4) Character generator ROM
(5). 160 different 5X7 dot-matrix character patterns.
(6). Character generator RAM
(7) 8 different user programmed 5X7 dot-matrix patterns.
(8).Display data RAM and character generator RAM may be accessed by
the

microprocessor.

(9) Numerous instructions


(10) Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,
Blink Character, Cursor Shift, Display
(11). Built-in reset circuit is
(12). Built-in

triggered

Shift.

at power

ON.

oscillator.

27

Data can be placed at any location on the LCD. For 161 LCD, the address
locations are:

Figure 2.15:: Address locations for a 1x16 line LCD

Figure 2.16: Different Models of LCD


Even limited to character based modules, there is still a wide variety of shapes and sizes
available. Line lenghs of 8,16,20,24,32 and 40 characters are all standard, in one, two and
four line versions. Several different LC technologies exists. supertwist types, for example,
offer Improved contrast and viewing angle over the older twisted nematic types. Some
modules are available with back lighting, so so that they can be viewed in dimly-lit
conditions. The back lighting may be either electro-luminescent, requiring a high voltage
inverter circuit, or simple LED illumination.

28

2.5.1 PIN DESCRIPTION of LCD:


PIN DESCRIPTIONS:
While Vcc & Vss provide +5V and ground respectively, Vee is used for
controlling LCD contrast.
Table 2.5: Pin Description of LCD
PIN
1
2
3
4

SYMBOL
Vss
Vcc
Vee
RS

I/O
----

DESCRIPTION
Ground
+5V power supply
Power supply to

control contrast
RS=0 to select
command register
RS=1

R/W

to

select

data register
R/W=0 for write

R/W=1 for read


6
EN
I/O
Enable
7
DB0
I/O
The 8-bit data bus
8
DB1
I/O
The 8-bit data bus
9
DB2
I/O
The 8-bit data bus
10
DB3
I/O
The 8-bit data bus
11
DB4
I/O
The 8-bit data bus
12
DB5
I/O
The 8-bit data bus
13
DB6
I/O
The 8-bit data bus
14
DB7
I/O
The 8-bit data bus
The ASCII code to be displayed is eight bits long and is sent to the LCD either
four or

eight bits at a time.


If four bit mode is used, two "nibbles" of data (Sent high four bits and then
low four bits with an "E" Clock pulse with each nibble) are sent to make up a
full eight bit transfer.

The "E" Clock is used to initiate the data transfer within the LCD.

Deciding how to send the data to the LCD is most critical decision to be made
for an LCD interface application.

Eight-bit mode is best used when speed is required in an application and at


least ten I/O pins are available.
29

The "R/S" bit is used to select whether data or an instruction is being


transferred between the microcontroller and the LCD.

If the Bit is set, then the byte at the current LCD "Cursor" Position can be
reader written.

When the Bit is reset, either an instruction is being sent to the LCD or the
execution status of the last instruction is read back.

Figure 2.17: Pin Diagram of LCD

CONTROL LINES:
EN: Line is called "Enable." This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus. When
the other lines are completely ready, bring EN high (1) and wait for the minimum
amount of time required by the LCD datasheet (this varies from LCD to LCD), and
end by bringing it low (0) again.
RS: Line is the "Register Select" line. When RS is low (0), the data is to be treated as
a command or special instruction (such as clear screen, position cursor, etc.). When
RS is high (1), the data being sent is text data which sould be displayed on the screen.
For example, to display the letter "T" on the screen you would set RS high.

30

RW: Line is the "Read/Write" control line. When RW is low (0), the information on
the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is
a read command. All others are write commands, so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of
operation selected by the user). In the case of an 8-bit data bus, the lines are referred
to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
Logic status on control lines:
E - 0 Access to LCD disabled

E- 1 Access to LCD enabled

R/W - 0 Writing data to LCD

R/W - 1 Reading data from LCD

RS - 0 Instructions

RS -1 Character

2.6 Gear motor:


What Is a Gear Motor? Gear motors are complete motive force systems consisting
of an electric motor and a reduction gear train integrated into one easy-to-mount and
-configure package. This greatly reduces the complexity and cost of designing and
constructing power tools, machines and appliances calling for high torque at relatively
low shaft speed or RPM. Gear motors allow the use of economical low-horsepower
motors to provide great motive force at low speed such as in lifts, winches, medical
tables, jacks and robotics. They can be large enough to lift a building or small enough
to drive a tiny clock.

.
Figure2.18 : 12V DC GEAR MOTOR

31

Operation Principle
Most synchronous AC electric motors have output ranges of from 1,200 to
3,600 revolutions per minute. They also have both normal speed and stall-speed
torque specifications. The reduction gear trains used in gear motors are designed to
reduce the output speed while increasing the torque. The increase in torque is
inversely proportional to the reduction in speed. Reduction gearing allows small
electric motors to move large driven loads, although more slowly than larger electric
motors. Reduction gears consist of a small gear driving a larger gear. There may be
several sets of these reduction gear sets in a reduction gear box.

Gear: Toothed wheel that transmits the turning movement of one shaft to another
shaft. Gear wheels may be used in pairs or in threes if both shafts are to turn in
the same direction. The gear ratio the ratio of the number of teeth on the two
wheels determines the torque ratio, the turning force on the output shaft
compared with the turning force on the input shaft. The ratio of the angular
velocities of the shafts is the inverse of the gear ratio.
The common type of gear for parallel shafts is the spur gear, with straight
teeth parallel to the shaft axis. The helical gear has teeth cut along sections of a helix
or corkscrew shape; the double form of the helix gear is the most efficient for energy
transfer. Bevel gears, with tapering teeth set on the base of a cone, are used to connect
intersecting shafts.

Figure2.19: Internal structure of DC GEAR MOTOR

32

The toothed and interlocking wheels which make up a typical gear movement.
Gear ratio is calculated by dividing the number of teeth on the driver gear by the
number of teeth on the driven gear (gear ratio = driver/driven); the idler gears are
ignored. Idler gears change the direction of rotation but do not affect speed. A high
driven to driver ratio (middle) is a speed-reducing ratio.

Different gears are used to perform different engineering functions depending


on the change in direction of motion that is needed. Rack and pinion gears are the
commonest gears and are used in car steering mechanics.

Speed Reduction

Sometimes the goal of using a gear motor is to reduce the rotating shaft speed
of a motor in the device being driven, such as in a small electric clock where
the tiny synchronous motor may be spinning at 1,200 rpm but is reduced to
one rpm to drive the second hand, and further reduced in the clock mechanism
to drive the minute and hour hands. Here the amount of driving force is
irrelevant as long as it is sufficient to overcome the frictional effects of the
clock mechanism.

Torque Multiplication

Another goal achievable with a gear motor is to use a small motor to generate
a very large force albeit at a low speed. These applications include the lifting
mechanisms on hospital beds, power recliners, and heavy machine lifts where
the great force at low speed is the goal.

Motor Varieties

Most industrial gear motors are AC-powered, fixed-speed devices, although


there are fixed-gear-ratio, variable-speed motors that provide a greater degree
of control. DC gear motors are used primarily in automotive applications such
as power winches on trucks, windshield wiper motors and power seat or power
window motors.

Many Applications

What power can openers, garage door openers, stair lifts, rotisserie motors,
timer cycle knobs on washing machines, power drills, cake mixers and
electromechanical clocks have in common is that they all use various
33

integrations of gear motors to derive a large force from a relatively small


electric motor at a manageable speed. In industry, gear motor applications in
jacks, cranes, lifts, clamping, robotics, conveyance and mixing are too
numerous to count.

2.7 L293D IC:


L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers
act as current amplifiers since they take a low-current control signal and provide a
higher-current signal. This higher current signal is used to drive the motors.
L293D contains two inbuilt H-bridge driver circuits. In its common mode of
operation, two DC motors can be driven simultaneously, both in forward and reverse
direction. The motor operations of two motors can be controlled by input logic at pins
2 & 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01
and 10 will rotate it in clockwise and anticlockwise directions, respectively. Enable
pins 1 and 9 (corresponding to the two motors) must be high for motors to start
operating.
When an enable input is high, the associated driver gets enabled. As a result,
the outputs become active and work in phase with their inputs. Similarly, when the
enable input is low, that driver is disabled, and their outputs are off and in the highimpedance state. The L293D is a quadruple push-pull 4 channel driver capable of
delivering 600 mA (1.2 A peak surge) per channel. The L293D is ideal for controlling
the forward/reverse/brake motions of small DC motors controlled by a
microcontroller such as a PIC or BASE stamp.
Features Include:

600 mA Output Current Capability Per Driver

Pulsed Current 1.2 A / Driver

Wide Supply Voltage Range: 4.5 V to 36 V

Separate Input-Logic Supply

NE Package Designed for Heat Sinking

34

Thermal Shutdown & Internal ESD Protection

High-Noise-Immunity Inputs

DualHbridgeMotorDriverL293DIC
Generally, even the simplest robot requires a motor to rotate a wheel or
performs particular action. Since motors require more current then the
microcontroller pin can typically generate, you need some type of a
switch (Transistors, MOSFET, Relay etc.,) which can accept a small
current, amplify it and generate a larger current, which further drives a motor. This
entire process is done by what is known as a motor driver.
Motor driver is basically a current amplifier which takes a low-current signal
from the microcontroller and gives out a proportionally higher current signal which
can control and drive a motor. In most cases, a transistor can act as a switch and
perform this task which drives the motor in a single direction.
Turning a motor ON and OFF requires only one switch to control a single
motor in a single direction. What if you want your motor to reverse its direction? The
simple answer is to reverse its polarity. This can be achieved by using four switches
that are arranged in an intelligent manner such that the circuit not only drives the
motor, but also controls its direction. Out of many, one of the most common and
clever design is a H-bridge circuit where transistors are arranged in a shape that
resembles the English alphabet "H".
As you can see in the image, the circuit has four switches A, B, C and D.
Turning these switches ON and OFF can drive a motor in different ways.
1. Turning on Switches A and D makes the motor rotate clockwise
2. Turning on Switches B and C makes the motor rotate anti-clockwise
3. Turning on Switches A and B will stop the motor (Brakes)
4. Turning off all the switches gives the motor a free wheel drive
5. Lastly turning on A & C at the same time or B & D at the same time shorts
your entire circuit. So, do not attempt this.

35

Specifications

Supply Voltage Range 4.5V to 36V

600-mA Output current capability per driver

Separate Input-logic supply

It can drive small DC-geared motors, bipolar stepper motor.

Pulsed Current 1.2-A Per Driver

Thermal Shutdown

Internal ESD Protection

High-Noise-Immunity Inputs

Applications
DC and stepper motor drives
Position and velocity servomechanisms

36

CHAPTER-3
SOFTWARE TOOLS
3.1 Software tools used

Keil micro vision for writing source code

Flash Magic for dumping the code

Programming Language
Programming language used in this project is C. C is a general purpose
structured programming language that is powerful, efficient and compact. It has
emerged as the language of choice for most applications due to speed, portability and
compactness of code. The C compiler combines the capabilities of an assembler
language with the features of high level language.
C is highly portable. This means that C programs written for one computer can
be on another with little or no modification. Portability is important if we plan to use a
new computer with a different operating system.
C language is well suited for structured programming thus requiring the user
to think of a problem in terms of function modules and blocks. A proper collection of
these modules make a complete program. This modular structure makes program
debugging, testing and maintenance easier.
Another important feature of C is its ability to extend itself. A C program is
basically a collection of functions that are supported by the C library. We can
continuously add our own functions to the C library. With the availability of a large
number of functions, the programming task becomes simple.
3.2 KEIL SOFTWARE
Vision3
Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and
debug embedded programs. It encapsulates the following components:

A project manager.
37

A make facility.

Tool configuration.

Editor.

A powerful debugger.

To help you get started, several example programs (located in the \C51\Examples,
\C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.
HELLO is a simple program that prints the string "Hello World" using the Serial
Interface.

Building an Application in Vision2


To build (compile, assemble, and link) an application in Vision2, you must:
1. Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.
Vision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in Vision2


To create a new project in Vision2, you must:
1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the
Device Database.
4. Create source files to add to the project.
5. Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and add the
source files to the project.
6. Select Project - Options and set the tool options. Note when you select the target
device from the Device Database all special options are set automatically. You
typically only need to configure the memory map of your target hardware. Default
memory model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.

Debugging an Application in Vision2


To debug an application created using Vision2, you must:
1. Select Debug - Start/Stop Debug Session.
2. Use the Step toolbar buttons to single-step through your program. You may enter G,
main in the Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.
38

Debug your program using standard options like Step, Go, Break, and so on.
Starting Vision2 and creating a Project
Vision2 is a standard Windows application and started by clicking on the program icon. To
create a new project file select from the Vision2 menu
Project New Project. This opens a standard Windows dialog that asks you for the new
project file name.
We suggest that you use a separate folder for each project. You can simply use the icon Create
New Folder in this dialog to get a new empty folder. Then select this folder and enter the file
name for the new project, i.e. Project1.
Vision2 creates a new project file with the name PROJECT1.UV2 which contains a default
target and file group name. You can see these names in the Project
Window Files.
Now use from the menu Project Select Device for Target and select a CPU for your project.
The Select Device dialog box shows the Vision2 device database. Just select the
microcontroller you use. We are using for our examples the Philips 80C51RD+ CPU. This
selection sets necessary tool options for the 80C51RD+ device and simplifies in this way the
tool Configuration
Building Projects and Creating a HEX Files
Typical, the tool settings under Options Target are all you need to start a new application.
You may translate all source files and line the application with a click on the Build Target
toolbar icon. When you build an application with syntax errors, Vision2 will display errors
and warning messages in the Output
Window Build page. A double click on a message line opens the source file on the correct
location in a Vision2 editor window.
Once you have successfully generated your application you can start debugging.
CPU Simulation
Vision2 simulates up to 16 Mbytes of memory from which areas can be mapped for read,
write, or code execution access. The Vision2 simulator traps and reports illegal memory
accesses being done.
Database selection
You have made when you create your project target. Refer to page 58 for more Information
about selecting a device. You may select and display the on-chip peripheral components using
the Debug menu. You can also change the aspects of each peripheral using the controls in the
dialog boxes.

39

Start Debugging

You start the debug mode of Vision2 with the Debug Start/Stop Debug Session
command. Depending on the Options for Target Debug Configuration, Vision2
will load the application program and run the startup code Vision2 saves the editor
screen layout and restores the screen layout of the last debug session. If the program
execution stops, Vision2 opens an editor window with the source text or shows CPU
instructions in the disassembly window. The next executable statement is marked with
a yellow arrow. During debugging, most editor features are still available.
Disassembly Window

The Disassembly window shows your target program as mixed source and assembly
program or just assembly code. A trace history of previously executed instructions
may be displayed with Debug View Trace Records. To enable the trace history, set
Debug Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step
commands work on CPU instruction level rather than program source lines. You can
select a text line and set or modify code breakpoints using toolbar buttons or the
context menu commands.
3.2.1 STEPS TO USE KEIL U VISION:

1.

Click on the Keil uVision Icon on Desktop

2.

The following jjfig will appear

40

3.

Click on the Project menu from the title bar

4.

Then Click on New Project

5.

Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\

6.

Then Click on save button above.


41

7.

Select the component for u r project. i.e. Atmel

8.

Click on the + Symbol beside of Atmel

9.

Select AT89C51 as shown below

10.

Then Click on OK

42

11.

The Following fig will appear

12.

Then Click NO for copy of standard code

13.

Now your project is ready to USE

14.

Now double click on the Target1, you would get another option Source group 1
as shown in next page.

43

15.

Click on the file option from menu bar and select new

16.

The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.

17.

Now start writing program in either in C or ASM

44

18.

For a program written in Assembly, then save it with extension . asm and for
C based program save it with extension .C

19.

Now right click on Source group 1 and click on Add files to Group
Source

45

20.

Now you will get another window, on which by default C files will
appear.

21.

Now select as per your file extension given while saving the file

22.

Click only one time on option ADD

23.

Now Press function key F7 to compile. Any error will appear if so happen.

46

24.

If the file contains no error, then press Control+F5 simultaneously.

25.

The new window is as follows

26.

Then Click OK

27.

Now Click on the Peripherals from menu bar, and check your required port
as shown in fig below

47

28.

Drag the port a side and click in the program file.

29.

Now keep Pressing function key F11 slowly and observe.

30.

You are running your program successfully

3.3 Flash Magic


Introduction
Flash Magic is Windows software from the Embedded Systems Academy that
allows easy access to all the ISP features provided by the devices. These features
include:
Erasing the Flash memory (individual blocks or the whole device)
Programming the Flash memory
Modifying the Boot Vector and Status Byte
Reading Flash memory
Performing a blank check on a section of Flash memory
Reading the signature bytes
Reading and writing the security bits
Direct load of a new baud rate (high speed communications)
Sending commands to place device in Boot loader mode
Flash Magic provides a clear and simple user interface to these features and more as
described in the following sections. Under Windows, only one application may have
access the COM Port at any one time, preventing other applications from using the
COM Port. Flash Magic only obtains access to the selected COM Port when ISP
operations are being performed. This means that other applications that need to use
the COM Port, such as debugging tools, may be used while Flash Magic is loaded.
The screenshot of the main Flash Magic window is as shown in the figure. The
appearance may differ slightly depending on the device selected. It contains five
blocks. The five blocks are explained as follows:

3.3.1 Five Step Programming:


Step 1 Connection Settings Select the desired COM port from the drop down list or

type the desired COM port directly into the box.

48

If you enter the COM port yourself then you must enter it in one of the following
formats:
COM n
n
Select the baud rate to connect at. Try a low speed first. The maximum speed
that can be used depends on the crystal frequency on your hardware.

Recommendation: Try 9600 baud first. If it does not work or does not work
reliably then try 7200 baud.
Select the device being used from the drop down list. Ensure you select the
correct one as different devices have different feature sets and different methods of
setting up the serial communications.
Select the interface being used, if any. An interface is a device that connects
between your PC and the target hardware. If you simply have a serial cable or USB to
serial cable connecting your COM port to the target hardware, then chooses "None
(ISP)". Choosing the correct interface will automatically configure Flash Magic for
that interface, along with enabling and disabling the relevant features.
Enter the oscillator frequency used on the hardware. Do not round the
frequency, instead enter it as precisely as possible. Some devices do not require the
oscillator frequency to be entered, so this field will not be displayed.

Step 2 Erasing
This step is optional, however if you attempt to program the device without
first erasing at least one Flash block, then Flash Magic will warn you and ask you if
you are sure you want to program the device. Select each Flash block that you wish to
erase by clicking on its name. If you wish to erase all the Flash then check that option.

If you want to erase a Flash block and all the Flash then the Flash block will
not be erased individually. If you wish to erase only the Flash blocks used by the hex
file you are going to select, then check that option.

49

Step 3 Selecting the Hex File


This step is optional. If you do not wish to program a Hex File then do not
select one. You can either enter a path name in the text box or click on the Browse

button to select a Hex File by browsing to it. Also you can choose Open from the
File menu. Note that the Hex file is not loaded or cached in any way. This means that
if the Hex File is modified, you do not have to reselect it in Flash Magic. Every time
the Hex File is programmed it is first re-read from the location specified in the main
window. This information is updated whenever the hex file is modified.

Step 4 Options
This section is optional, however Verify After Programming, Fill Unused Flash and
Gen Block Checksums may only be used if a Hex File is selected (and therefore being
programmed), as they all need to know either the Hex File contents or memory
locations used by the Hex File.

Checking the Execute option will cause the downloaded firmware to be executed
automatically after the programming is complete. Note that this will not work if using
the Hardware Reset option or a device that does not support this feature.

Step 5 Performing the Operations


Clicking the Start button will result in all the selected operations in the main
window taking place. They will be in order:
Erasing Flash
Programming the Hex File
Verifying the Hex File
Filling Unused Flash
Executing the firmwar

50

51

CHAPTER-4
RESULT ANALYSIS

Figure 4.1: Top View of the Designed system

52

Figure 4.2: System when ON State

Figure 4.3: System when Metal Detected

53

CHAPTER-5
CONCLUSION
5.1 APPLICATIONS

Used in military applications

Used in industrial applications

Used to detect land mines

5.2 CONCLUSION
The Metal Detection Robot system is successfully designed and executed. The
hardware components are selected based on required, it is low cost and easy to use .It
is designed and well tested. The micro controller is programmed efficiently in
Embedded C language using KEIL Micro Vision software. The system is designed to
the level of identifying the metal when the metal is found in front of the metal sensor.
When the metal is found it makes the Robot OFF, and displays on LCD screen that a
metal is detected.

54

CHAPTER-6
BIBLIOGRAPHY
WEB SITES:
1. WWW.MITEL.DATABOOK.COM
2. WWW.ATMEL.DATABOOK.COM
3. WWW.FRANKLIN.COM
4. WWW.KEIL.COM

REFERENCES:
1. "The 8051 Microcontroller Architecture, Programming &

Applications"
By Kenneth J Ayala.
2. "The 8051 Microcontroller & Embedded Systems" by
Mohammed Ali Mazidi and

Janice Gillispie Mazidi

3. "Power Electronics by M D Singh and K B Khanchandan


4. "Linear Integrated Circuits by D Roy Choudary & Shail Jain
5. "Electrical Machines by S K Bhattacharya
6. "Electrical Machines II by B L Thereja
7. www.8051freeprojectsinfo.com

55

You might also like