0% found this document useful (0 votes)
408 views105 pages

Accident Sms Alert System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
408 views105 pages

Accident Sms Alert System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 105

GPS AND GSM BASED ACCIDENT ALARM SYSTEM

ABSTRACT:

The project titled as’ Collide Vehicle Information Capturing Using GPS and GSM Technologies
is an embedded based system. By this advanced technology we can get accurate information about the
victim This system combines advanced hardware design and sophisticated electronic control technology
into a compact, reliable package.

In this project a vibration sensor is used as an accident detector. When the vehicle meets
with an accident, the vibrating sensors generate the signal, this signal is being compared with the
threshold values. If the value generated exceeds the threshold it is recognized as accident and this
information is immediately informed to their relative persons through GSM as a message to
mobile.

In this system vibration sensors are used for detecting range of collision. Sensor data will
be in analog form so it needs to be converted to digital, which is fulfilled through A/D Converter,
and this digital data is being sent to microcontroller there it is compared with the threshold
values, if it exceeds the threshold values then only data will be sent to GSM (global system for
mobile communication) & location data is captured with the help of GPS (Global Positioning
System). Here we are making use of the GPS which gives exact location of the collide vehicle.
BLOCK DIAGRAM:

LCD

Accident
Detector ADC
MMA7361 MCP3201
Buzzer

Embedded
Controller
AT89C51

GPS
ENGINE

GSM Mobile

UNDERSTANDING OF: Embedded Controller, AT Keyboard, GPS Receiver, Vibration Sensor, LCD
Module, GSM Modem, Serial Communication, Keil Compiler.
SCHEMATIC DIAGRAM:
INTRODUCTION TO EMBEDDED SYSTEMS:

Embedded systems are electronic devices that incorporate microprocessors


with in Their implementations. The main purposes of the microprocessors are to
simplify the system design and provide flexibility. Having a microprocessor in the
device means that removing the bugs, making modifications, or adding new
features are only matters of rewriting the software that controls the device. Or in
other words embedded computer systems are electronic systems that include a
microcomputer to perform a specific dedicated application. The computer is hidden
inside these products. Embedded systems are ubiquitous. Every week millions of
tiny computer chips come pouring out of factories finding their way into our
everyday products.
Embedded systems are self-contained programs that are embedded within a piece
of hardware. Whereas a regular computer has many different applications and
software that can be applied to various tasks, embedded systems are usually set to a
specific task that cannot be altered without physically manipulating the circuitry.
Another way to think of an embedded system is as a computer system that is
created with optimal efficiency, thereby allowing it to complete specific functions
as quickly as possible.
Embedded systems designers usually have a significant grasp of hardware
technologies. They used specific programming languages and software to develop
embedded systems and manipulate the equipment. When searching online,
companies offer embedded systems development kits and other embedded
systems tools for use by engineers and businesses.
Embedded systems technologies are usually fairly expensive due to the necessary
development time and built in efficiencies, but they are also highly valued in
specific industries. Smaller businesses may wish to hire a consultant to determine
what sort of embedded systems will add value to your organization.
Characteristics
Two major areas of differences are cost and power consumption. Since many
embedded systems are produced in the tens of thousands to millions of units range,
reducing cost is a major concern. Embedded systems often use a (relatively) slow
processor and small memory size to minimize costs.
The slowness is not just clock speed. The whole architecture of the computer is
often intentionally simplified to lower costs. For example, embedded systems often
use peripherals controlled by synchronous serial interfaces, which are ten to
hundreds of times slower than comparable peripherals used in PCs.
Programs on an embedded system often must run with real-time constraints with
limited hardware resources: often there is no disk drive, operating system,
keyboard or screen.
A flash drive may replace rotating media, and a small keypad and LCD screen may
be used instead of a PC's keyboard and screen.
Firmware is the name for software that is embedded in hardware devices, e.g. in
one or more ROM/Flash memory IC chips.
Embedded systems are routinely expected to maintain 100% reliability while
running continuously for long periods, sometimes measured in years. Firmware is
usually developed and tested too much stricter requirements than is general-
purpose software, which can usually be easily restarted if a problem occurs.

Platform
There are many different CPU architectures used in embedded designs. This in
contrast to the desktop computer market, which as of this writing (2003) is limited
to just a few competing architectures, mainly the Intel/AMD x86, and the
Apple/Motorola/IBM PowerPC, used in the Apple Macintosh.
One common configuration for embedded systems is the system on a chip, an
application-specific integrated circuit, for which the CPU was purchased as
intellectual property to add to the IC's design.
Tools
Like a typical computer programmer, embedded system designers use compilers,
assemblers and debuggers to develop an embedded system.
Those software tools can come from several sources:
Software companies that specialize in the embedded market Ported from the
GNU software development tools.
Sometimes, development tools for a personal computer can be used if the
embedded processor is a close relative to a common PC processor.
Embedded system designers also use a few software tools rarely used by typical
computer programmers.
Some designers keep a utility program to turn data files into code, so that they can
include any kind of data in a program.
Most designers also have utility programs to add a checksum or CRC to a program,
so it can check its program data before executing it.

Operating system
They often have no operating system, or a specialized embedded operating system
(often a real-time operating system), or the programmer is assigned to port one of
these to the new system.

Debugging
Debugging is usually performed with an in-circuit emulator, or some type of
debugger that can interrupt the micro controller’s internal microcode.
The microcode interrupt lets the debugger operate in hardware in which only the
CPU works. The CPU-based debugger can be used to test and debug the
electronics of the computer from the viewpoint of the CPU. This feature was
pioneered on the PDP-11.
Developers should insist on debugging which shows the high-level language, with
breakpoints and single stepping, because these features are widely available. Also,
developers should write and use simple logging facilities to debug sequences of
real-time events.
PC or mainframe programmers first encountering this sort of programming often
become confused about design priorities and acceptable methods. Mentoring, code-
reviews and ego less programming are recommended.

Design of embedded systems


The electronics usually uses either a microprocessor or a micro controller. Some
large or old systems use general-purpose mainframes computers or minicomputers.

Start-up
All embedded systems have start-up code. Usually it disables interrupts, sets up
the electronics, tests the computer (RAM, CPU and software), and then starts the
application code. Many embedded systems recover from short-term power failures
by restarting (without recent self-tests). Restart times under a tenth of a second are
common.
Many designers have found one of more hardware plus software-controlled LEDs
useful to indicate errors during development (and in some instances, after product
release, to produce troubleshooting diagnostics). A common scheme is to have the
electronics turn off the LED(s) at reset, whereupon the software turns it on at the
first opportunity, to prove that the hardware and start-up software have performed
their job so far. After that, the software blinks the LED(s) or sets up light patterns
during normal operation, to indicate program execution progress and/or errors.
This serves to reassure most technicians/engineers and some users.

The control loop


In this design, the software simply has a loop. The loop calls subroutines. Each
subroutine manages a part of the hardware or software. Interrupts generally set
flags, or update counters that are read by the rest of the software.
A simple API disables and enables interrupts. Done right, it handles nested calls in
nested subroutines, and restores the preceding interrupt state in the outermost
enable. This is one of the simplest methods of creating an exokernel.
Typically, there's some sort of subroutine in the loop to manage a list of software
timers, using a periodic real time interrupt. When a timer expires, an associated
subroutine is run, or flag is set.
Any expected hardware event should be backed-up with a software timer.
Hardware events fail about once in a trillion times. That's about once a year with
modern hardware. With a million mass-produced devices, leaving out a software
timer is a business disaster.

State machines may be implemented with a function-pointer per state-machine (in


C++, C or assembly, anyway). A change of state stores a different function into the
pointer. The function pointer is executed every time the loop runs.
Many designers recommend reading each IO device once per loop, and storing the
result so the logic acts on consistent values.
Many designers prefer to design their state machines to check only one or two
things per state. Usually this is a hardware event, and a software timer.
Designers recommend that hierarchical state machines should run the lower-level
state machines before the higher, so the higher run with accurate information.
Complex functions like internal combustion controls are often handled with multi-
dimensional tables. Instead of complex calculations, the code looks up the values.
The software can interpolate between entries, to keep the tables small and cheap.
One major weakness of this system is that it does not guarantee a time to respond
to any particular hardware event. Careful coding can easily assure that nothing
disables interrupts for long. Thus interrupt code can run at very precise timings.
Another major weakness of this system is that it can become complex to add new
features. Algorithms that take a long time to run must be carefully broken down so
only a little piece gets done each time through the main loop.
This system's strength is its simplicity, and on small pieces of software the loop is
usually so fast that nobody cares that it is not predictable.
Another advantage is that this system guarantees that the software will run. There
is no mysterious operating system to blame for bad behavior.

User interfaces

User interfaces for embedded systems vary wildly, and thus deserve some special
comment. Designers recommend testing the user interface for usability at the
earliest possible instant. A quick, dirty test is to ask an executive secretary to use
cardboard models drawn with magic markers, and manipulated by an engineer. The
videotaped result is likely to be both humorous and very educational. In the tapes,
every time the engineer talk, the interface has failed: It would cause a service call.
Exactly one person should approve the user interface. Ideally, this should be a customer,
the major distributor or someone directly responsible for selling the system. The decision
maker should be able to decide. The problem is that a committee will never make up its
mind, and neither will some people. Not doing this causes avoidable, expensive delays. A
usability test is more important than any number of opinions.

Interface designers at PARC, Apple Computer, Boeing and HP minimize the


number of types of user actions. For example, use two buttons (the absolute
minimum) to control a menu system (just to be clear, one button should be "next
menu entry" the other button should be "select this menu entry"). A touch-screen
or screen-edge buttons also minimize the types of user actions.
Another basic trick is to minimize and simplify the type of output. Designs should
consider using a status light for each interface plug, or failure condition, to tell
what failed. A cheap variation is to have two light bars with a printed matrix of
errors that they select- the user can glue on the labels for the language that she
speaks.
For example, Boeing's standard test interface is a button and some lights. When
you press the button, all the lights turn on. When you release the button, the lights
with failures stay on. The labels are in Basic English.
For another example, look at a small computer printer. You might have one next to
your computer. Notice that the lights are labeled with stick-on labels that can be
printed in any language. Really look at it.
Designers use colors. Red means the users can get hurt- think of blood. Yellow
means something might be wrong. Green means everything's OK.
Another essential trick is to make any modes absolutely clear on the user's display.
If an interface has modes, they must be reversible in an obvious way.
Most designers prefer the display to respond to the user. The display should change
immediately after a user action. If the machine is going to do anything, it should
start within 7 seconds, or give progress reports.
If a design needs a screen, many designers use plain text. It can be sold as a
temporary expedient. Why is it better than pictures? Users have been reading signs
for years. A GUI is pretty and can do anything, but typically adds a year from
artist, approval and translator delays and one or two programmers to a project's
cost, without adding any value. Often, a clever GUI actually confuses users.
If a design needs to point to parts of the machine (as in copiers), these are labeled
with numbers on the actual machine, that are visible with the doors closed.
A network interface is just a remote screen. It needs the same caution as any other
user interface.
One of the most successful general-purpose screen-based interfaces is the two
menu buttons and a line of text in the user's native language. It's used in pagers,
medium-priced printers, network switches, and other medium-priced situations that
require complex behavior from users.
When there's text, there are languages. The default language should be the one
most widely understood. Right now this is English. French and Spanish follow.
Most designers recommend that one use the native character sets, no matter how
painful. People with peculiar character sets feel coddled and loved when their
language shows up on machinery they use.
Text should be translated by professional translators, even if native speakers are on
staff. Marketing staff have to be able to tell foreign distributors that the translations
are professional.

A foreign organization should give the highest-volume distributor the duty to


review and correct any translations in his native language. This stops critiques by
other native speakers, who tend to believe that no foreign organization will ever
know their language as well as they.

MICROCONTROLLER 89S52:

AT89S52
2.2.1 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”

AT89S52:

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 Atmel’s high-density nonvolatile
memory technology and is compatible with the industry-standard 80C51 instruction set and pinout 9843.
The on-chip Flash allows the program memory to be reprogrammed in-

BD268system or by a conventional nonvolatile memory pro-grammer. 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
 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 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.

The block diagram provided by Atmel™ in their datasheet showing the architecture the 89S52 device can
seem very complicated, and since we are going to use the C high level language to program it, a simpler
architecture can be represented as the figure 1.2.A.

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.

NECESSITY OF MICROCONTROLLERS:

Microprocessors brought the concept of programmable devices and made many applications of
intelligent equipment. Most applications, which do not need large amount of data and program memory,
tended to be costly.

The microprocessor system had to satisfy the data and program requirements so, sufficient RAM
and ROM are used to satisfy most applications .The peripheral control equipment also had to be satisfied.
Therefore, almost all-peripheral chips were used in the design. Because of these additional peripherals
cost will be comparatively high.

An example:
8085 chip needs:

An Address latch for separating address from multiplex address and data.32-KB RAM and 32-KB
ROM to be able to satisfy most applications. As also Timer / Counter, Parallel programmable port, Serial
port, and Interrupt controller are needed for its efficient applications.

In comparison a typical Micro controller 8051 chip has all that the 8051 board has except a
reduced memory as follows.
4K bytes of ROM as compared to 32-KB, 128 Bytes of RAM as compared to 32-KB.

Bulky:
On comparing a board full of chips (Microprocessors) with one chip with all components in it
(Microcontroller).

Debugging:

Lots of Microprocessor circuitry and program to debug. In Micro controller there is no


Microprocessor circuitry to debug.

Slower Development time: As we have observed Microprocessors need a lot of debugging at board level
and at program level, where as, Micro controller do not have the excessive circuitry and the built-in
peripheral chips are easier to program for operation.

So peripheral devices like Timer/Counter, Parallel programmable port, Serial Communication


Port, Interrupt controller and so on, which were most often used were integrated with the Microprocessor
to present the Micro controller .RAM and ROM also were integrated in the same chip. The ROM size was
anything from 256 bytes to 32Kb or more. RAM was optimized to minimum of 64 bytes to 256 bytes or
more.

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.

7. Write data to I/O device and output the result of processing to O/P device.

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

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)

PIN DIAGRAM

FIG-2 PIN DIAGRAM OF 89S52 IC


2.1.4 PIN DESCRIPTION

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 highimpedance inputs.Port 0 can also be

configured to be the multiplexed loworder address/data bus during accesses to external program and data

memory. In this mode, P0 has internal pullups. 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.

Port 1

Port 1 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups 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 pullups. 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.
Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pullups.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 pullups 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 pullups. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to external data memory that use 16-bit
addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s.
During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the
contents of the P2 Special Function Register. Port 2 also receives the 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 pullups.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 pullups and can
be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pullups. Port 3 also serves the functions of various special features of the AT89S52, as
shown in the following table. Port 3 also receives some control signals for Flash programming and
verification.
RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR
AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET
HIGH out feature is enabled. ALE/PROG Address Latch Enable (ALE) is an output pulse for latching the
low byte of the address during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the
oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one
ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be
disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or
MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if
the microcontroller is in external execution mode.

PSEN

Program Store Enable (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 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.

FIG-3 Functional block diagram of micro controller

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

Fig-4 Oscillator and timing circuit

MEMORIES

Types of memory:

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.

Special Function registered memory:

Special function registers are the areas of memory that control specific functionality of the 8052
micro controller.

a) Accumulator (0E0h)

As its name suggests, it is used to accumulate the results of large no of instructions. It can hold 8
bit values.

b) B registers (0F0h)

The B register is very similar to accumulator. It may hold 8-bit value. The b register is only used
by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets stored in B
register. In div AB the quotient gets stored in B with the remainder in A.
c) Stack pointer (81h)
The stack pointer holds 8-bit value. This is used to indicate where the

next value to be removed from the stack should be taken from. When a value is to be pushed onto the
stack, the 8052 first store the value of SP and then store the value at the resulting memory location.
When a value is to be popped from the stack, the 8052 returns the value from the memory location
indicated by SP and then decrements the value of SP.

d) Data pointer

The SFRs DPL and DPH work together work together to represent a 16-bit value called the data
pointer. The data pointer is used in operations regarding external RAM and some instructions code
memory. It is a 16-bit SFR and also an addressable SFR.

e) Program counter

The program counter is a 16 bit register, which contains the 2 byte address, which tells the 8052
where the next instruction to execute to be found in memory. When the 8052 is initialized PC starts at
0000h. And is incremented each time an instruction is executes. It is not addressable SFR.

f) PCON (power control, 87h)

The power control SFR is used to control the 8051’s power control modes. Certain operation
modes of the 8051 allow the 8051 to go into a type of “sleep mode” which consumes much lee power.

g) TCON (timer control, 88h)

The timer control SFR is used to configure and modify the way in which the 8051’s two timers
operate. This SFR controls whether each of the two timers is running or stopped and contains a flag to
indicate that each timer has overflowed. Additionally, some non-timer related bits are located in TCON
SFR. These bits are used to configure the way in which the external interrupt flags are activated, which
are set when an external interrupt occurs.

h) TMOD (Timer Mode, 89h)

The timer mode SFR is used to configure the mode of operation of each of the two timers. Using
this SFR your program may configure each timer to be a 16-bit timer, or 13 bit timer, 8-bit auto reload
timer, or two separate timers. Additionally you may configure the timers to only count when an external
pin is activated or to count “events” that are indicated on an external pin.

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

These two SFRs taken together represent timer 0. Their exact behavior depends on how the timer
is configured in the TMOD SFR; however, these timers always count up. What is configurable is how
and when they increment in value.

j) T1 (Timer 1 Low/High, address 8B/ 8D h)

These two SFRs, taken together, represent timer 1. Their exact behavior depends on how the timer
is configured in the TMOD SFR; however, these timers always count up..

k) P0 (Port 0, address 90h, bit addressable)

This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro controller. Any
data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P0.0, bit 7 is pin
p0.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to low level.

l) P1 (port 1, address 90h, bit addressable)

This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro controller. Any
data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P1.0, bit 7 is pin
P1.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to low level

m) P2 (port 2, address 0A0h, bit addressable):

This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro controller.
Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P2.0, bit 7 is
pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to low level.

n) P3 (port 3, address B0h, bit addressable) :

This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro controller. Any
data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P3.0, bit 7 is pin
P3.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas
a value of 0 will bring it to low level.

o) IE (interrupt enable, 0A8h):


The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits
of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable
or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of
whether an individual interrupt is enabled by setting a lower bit.

p) IP (Interrupt Priority, 0B8h)


The interrupt priority SFR is used to specify the relative priority of each interrupt. On
8051, an interrupt maybe either low or high priority. An interrupt may interrupt interrupts. For
e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt
always interrupts the system, even if another interrupt is currently executing. However, if a serial
interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since
the serial interrupt routine has the highest priority.

q) PSW (Program Status Word, 0D0h)


The program Status Word is used to store a number of important bits that are set and
cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the
parity flag and the overflow flag. Additionally, it also contains the register bank select flags,
which are used to select, which of the “R” register banks currently in use.

r) SBUF (Serial Buffer, 99h)


SBUF is used to hold data in serial communication. It is physically two registers. One is
writing only and is used to hold data to be transmitted out of 8052 via TXD. The other is read
only and holds received data from external sources via RXD. Both mutually exclusive registers
use address 99h.
2. INTRODUCTION TO GSM

A GSM modem is a specialized type of modem which accepts a SIM card, and operates over a
subscription to a mobile operator, just like a mobile phone. From the mobile operator perspective, a GSM
modem looks just like a mobile phone. When a GSM modem is connected to a computer, this allows the
computer to use the GSM modem to communicate over the mobile network. While these GSM modems
are most frequently used to provide mobile internet connectivity, many of them can also be used for
sending and receiving SMS and MMS messages. A GSM modem can be a dedicated modem device with
a serial, USB or Bluetooth connection, or it can be a mobile phone that provides GSM modem
capabilities.

A GSM modem exposes an interface that allows applications such as Now SMS to send and receive
messages over the modem interface. The mobile operator charges for this message sending and receiving
as if it was performed directly on a mobile phone. To perform these tasks, a GSM modem must support
an “extended AT command set” for sending/receiving SMS messages.

Fig2.0:GSM MODEM

GSM modems can be a quick and efficient way to get started with SMS, because a special subscription to
an SMS service provider is not required. In most parts of the world, GSM modems are a cost effective
solution for receiving SMS messages, because the sender is paying for the message delivery.
2.1 Architecture of GSM Network:

A GSM network is composed of several functional entities, whose functions and interfaces
are specified. Figure 1 shows the layout of a generic GSM network. The GSM network can be divided
into three broad parts. The Mobile Station is carried by the subscriber. The Base Station Subsystem
controls the radio link with the Mobile Station. The Network Subsystem, the main part of which is the
Mobile services Switching Center (MSC), performs the switching of calls between the mobile users, and
between mobile and fixed network users. The MSC also handles the mobility management operations.
Not shown are the Operations

A GSM network is composed of several functional entities, whose functions and interfaces
are specified. Figure shows the layout of a generic GSM network. The GSM network can be divided into
three broad parts. Subscriber carries the Mobile Station. The Base Station Subsystem controls the radio
link with the Mobile Station. The Network Subsystem, the main part of which is the Mobile services
Switching Center (MSC), performs the switching of calls between the mobile users, and between mobile
and fixed network users. The MSC also handles the mobility management operations. Not shown is the
Operations intendance Center, which oversees the proper operation and setup of the network. The Mobile
Station and the Base Station Subsystem communicate across the Um interface, also known as the air
interface or radio link. The Base Station Subsystem communicates with the Mobile services Switching
Center across the A interface.

Fig 2.1 General architecture of a GSM network

Mobile Station:
The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card called
the Subscriber Identity Module (SIM). The SIM provides personal mobility, so that the user can have
access to subscribed services irrespective of a specific terminal. By inserting the SIM card into another
GSM terminal, the user is able to receive calls at that terminal, make calls from that terminal, and receive
other subscribed services. The mobile equipment is uniquely identified by the International Mobile
Equipment Identity (IMEI). The SIM card contains the International Mobile Subscriber Identity (IMSI)
used to identify the subscriber to the system, a secret key for authentication, and other information. The
IMEI and the IMSI are independent, thereby allowing personal mobility. The SIM card may be protected
against unauthorized use by a password or personal identity number.

Base Station Subsystem:

The Base Station Subsystem is composed of two parts, the Base Transceiver Station (BTS)
and the Base Station Controller (BSC). These communicate across the standardized Abis interface,
allowing (as in the rest of the system) operation between components made by different suppliers. The
Base Transceiver Station houses the radio transceivers that define a cell and handles the radio-link
protocols with the Mobile Station. In a large urban area, there will potentially be a large number of BTSs
deployed, thus the requirements for a BTS are ruggedness, reliability, portability, and minimum cost. The
Base Station Controller manages the radio resources for one or more BTSs. It handles radio-channel
setup, frequency hopping, and handovers, as described below. The BSC is the connection between the
mobile station and the Mobile service Switching Center (MSC).

Network Subsystem

The central component of the Network Subsystem is the Mobile services Switching Center
(MSC). It acts like a normal switching node of the PSTN or ISDN, and additionally provides all the
functionality needed to handle a mobile subscriber, such as registration, authentication, location updating,
handovers, and call routing to a roaming subscriber. These services are provided in conjunction with
several functional entities, which together form the Network Subsystem. The MSC provides the
connection to the fixed networks (such as the PSTN or ISDN). Signalling between functional entities in
the Network Subsystem uses Signalling System Number 7 (SS7), used for trunk signalling in ISDN and
widely used in current public networks.

The Home Location Register (HLR) and Visitor Location Register (VLR), together with
the MSC, provide the call-routing and roaming capabilities of GSM. The HLR contains all the
administrative information of each subscriber registered in the corresponding GSM network, along with
the current location of the mobile. The location of the mobile is typically in the form of the signaling
address of the VLR associated with the mobile as a distributed database station. The actual routing
procedure will be described later. There is logically one HLR per GSM network, although it may be
implemented

The Visitor Location Register (VLR) contains selected administrative information from the
HLR, necessary for call control and provision of the subscribed services, for each mobile currently
located in the geographical area controlled by the VLR. Although each functional entity can be
implemented as an independent unit, all manufacturers of switching equipment to date implement the
VLR together with the MSC, so that the geographical area controlled by the MSC corresponds to that
controlled by the VLR, thus simplifying the signalling required. Note that the MSC contains no
information about particular mobile stations --- this information is stored in the location registers. The
other two registers are used for authentication and security purposes. The Equipment Identity Register
(EIR) is a database that contains a list of all valid mobile equipment on the network, where each mobile
station is identified by its International Mobile Equipment Identity (IMEI). An IMEI is marked as invalid
if it has been reported stolen or is not type approved. The Authentication Center (AuC) is a protected
database that stores a copy of the secret key stored in each subscriber's SIM card, which is used for
authentication and encryption over the radio channel.

2.2 GSM Network Operators

T-Mobile and Cingular operate GSM networks in the United States


on the 1,900 MHz band. GSM networks in other countries operate at 900, 1,800, or 1,900 MHz

2.3 GSM carrier frequencies

GSM networks operate in a number of different carrier frequency ranges


(separated into GSM frequency ranges for 2G and UMTS frequency bands for 3G), with most
2G GSM networks operating in the 900 MHz or 1800 MHz bands. Where these bands were
already allocated, the 850 MHz and 1900 MHz bands were used instead (for example in Canada
and the United States). In rare cases the 400 and 450 MHz frequency bands are assigned in some
countries because they were previously used for first-generation systems. Most 3G networks in
Europe operate in the 2100 MHz frequency band. Regardless of the frequency selected by an
operator, it is divided into timeslots for individual phones to use. This allows eight full-rate or
sixteen half-rate speech channels per radio frequency. These eight radio timeslots (or eight burst
periods) are grouped into a TDMA frame. Half rate channels use alternate frames in the same
timeslot. The channel data rate for all 8 channels is 270.833 Kbit/s, and the frame duration is
4.615 ms. The transmission power in the handset is limited to a maximum of 2 watts in
GSM850/900 and 1 watt in GSM1800/1900.

2.4 GSM ATCommands

AT Commands are used to perform different operations is GSM module

Short message commands

2.4.1Preferred Message Format +CMGF

Description:

The message formats supported are text mode and PDU mode. In PDU mode, a complete SMS
Message including all header information is given as a binary string (in hexadecimal format).Therefore,
only the following set of characters is allowed: {‘0’,’1’,’2’,’3’,’4’,’5’,’6’,’7’,’8’,’9’,
‘A’,‘B’,’C’,’D’,’E’,’F’}. Each pair or characters are converted to a byte (e.g.: ‘41’ is converted to
theASCII character ‘A’, whose ASCII code is 0x41 or 65). In Text mode, all commands and responses are
in ASCII characters. The format selected is stored in EEPROM by the +CSAS command.

Syntax : Command syntax: AT+CMGF

Command Possible responses

AT+CMGF? +CMGF=1

Ok

Note :possible message format Note :Text mode


2.4.2 Send message + CMGS

To send a message in text mode CMGS command used

Description:

The <address> field is the address of the terminal to which the message is sent. To send the
message, simply type, <ctrl-Z> character (ASCII 26). The text can contain all existing characters except
<ctrl-Z> and <ESC> (ASCII 27). This command can be aborted using the <ESC> character when
entering text. In PDU mode, only hexadecimal characters are used (‘0’…’9’,’A’…’F’).

Syntax:

In SMS text mode, the syntax of the +CMGS AT command is: (Optional parameters are enclosed
in square brackets.)

+CMGS=address[,address_type]<CR>sms_message_body<Ctrl+z>Before we discuss each of the


parameters, let's see an example that gives you some idea of how an actual command line should look
like:AT+CMGS="+85291234567",145<CR>This is an example for illustrating the syntax of the +CMGS
AT command in SMS text mode.<Ctrl+z>

The address Parameter

The first parameter of the +CMGS AT command, address, specifies the destination address to send
the SMS message to. Usually it is a mobile number formatted using the typical ISDN / telephony
numbering plan (ITU E.164/E.163). For example, "+85291234567", "91234567", etc. Note that the value
passed to the address parameter should be a string, i.e. it should be enclosed in double quotes.

The address_type Parameter

The second parameter of the +CMGS AT command, address_type, specifies the type of the
address assigned to the address parameter. Two values are commonly used. They are 129 and
145:

As address_type is an optional parameter, it can be omitted. If you do so, the GSM/GPRS


modem or mobile phone will use the default value of the address_type parameter, which is:
 129 if the value of address does not start with a "+" character. For example,
"85291234567".
 145 if the value of address starts with a "+" character. For example, "+85291234567".

The <CR> Character

<CR>, which represents the carriage return character, follows the address_type parameter. When
the GSM/GPRS modem or mobile phone receives the carriage return character, it will send back
a prompt formed by these four characters: the carriage return character, the linefeed character,
the ">" character and the space character.

The sms_message_body Parameter

The third parameter of the +CMGS AT command, sms_message_body, specifies the body of the
SMS message to be sent. Entering the <Esc> character will cancel the +CMGS AT command.

The <Ctrl+z> Character

When you finish entering the SMS message body, you have to enter the <Ctrl+z> character to
mark the end of the SMS message body. The GSM/GPRS modem or mobile phone will then
attempt to send the SMS message to the SMS center

5.5.3 Read message +CMGR

The AT command +CMGR (command name in text: Read Message) is used to read a
message from a message storage area. The location of the message to be read from the message
storage area is specified by an index number. The message to be retrieved by the AT command
+CMGR does not necessarily have to be an SMS message. It can be of other message types such
as status reports and cell broadcast messages, but we will only focus on SMS messages here.

Format of the Information Response of the +CMGR AT Command in SMS Text Mode

If the GSM/GPRS modem or mobile phone successfully reads the SMS message from message
storage, it will return an information response to the computer / PC. In SMS text mode, the
format of the information response of the +CMGR AT command is different for different
message types. In the sections that follow, we assume the message to be read is an SMS message
but not of other message types like status reports and cell broadcast messages.

Incoming SMS Messages and Outgoing SMS Messages

If the SMS message retrieved is an SMS message received from the SMS center (i.e. incoming
SMS message), the information response of the +CMGR AT command in SMS text mode has
the following format: (Optional fields are enclosed in square brackets.)

+CMGR:message_status,address,[address_text],service_center_time_stamp[,address_type,TPDU
_first_octet,protocol_identifier,data_coding_scheme,service_center_address,service_center_addr
ess_type,sms_message_body_length]<CR><LF>sms_message_body

For incoming SMS messages:

+CMGR:"RECREAD","+85291234567",,"07/04/20,10:08:02+32",145,4,0,0,"+85290000000",145,49
It is easy to read text messages via AT Commands

4. GLOBAL POSITION SYSTEM

4 Introduction
The Global Positioning System (GPS) is the most significant recent advance in navigation and
positioning technology .In the past, the stars was used for navigation. Today’s world requires greater
accuracy .The new constellation of with radius equal to the distance to the satellite. If two satellites are
used, then the receiver must be on the surface of both spheres, which is the intersection of the two spheres
or the perimeter of a circle. If a third satellite is used, then the location of the user is narrowed down to the
two points where the three spheres intersect. Three measurements are enough for land receivers since the
lower of the two points would be selected. But when in the air or space, four satellites are needed; the
intersection of all four spheres will be the receiver’s location. When more than four satellites are used,
greater accuracy can be achieved.

Global Positioning System satellites transmit signals to equipment on the ground, GPS receivers
passively receive satellite signals; they do not transmit. GPS receivers require unobstructed views of the
sky, so they are used only outdoors and they often do not perform well within forested areas or near tall
buildings. GPS operations depend on a very accurate time reference.

Figure 4.1 Satellite System

4.1 Satellites in Space:

The complete GPS space system includes 24 satellites, 11,000 nautical miles above the Earth,
which take 12 hours each to go around the Earth once (one orbit). Satellites are equipped with very
precise clocks that keep accurate time to within three nanoseconds - that’s 0.000000003, or three
billionths, of a second. This precision timing is important because the receiver must determine exactly
how long it takes for signals to travel from each GPS satellite. The receiver uses this information to
calculate its position. The first GPS satellite was launched in 1978. The first 10 satellites were
developmental satellites, called Block 1 and the first product for civilian consumers appeared in the mid
1980’s
4.2. NMEA input:

Some units also support an NMEA input mode. While not too many programs support
this mode it does provide a standardized way to update or add waypoint and route data. Note that
there is no handshaking or commands in NMEA mode so you just send the data in the correct
sentence and the unit will accept the data and add or overwrite the information in memory.
The most important NMEA sentences include the GGA which provides the current Fix
data, the RMC which provides the minimum gps sentences information, and the GSA which
provides the Satellite status data.
GGA - essential fix data which provide 3D location and accuracy data.
$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
GSA - GPS DOP and active satellites. This sentence provides details on the nature of the fix. It
includes the numbers of the satellites being used in the current solution and the DOP
$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39
RMC - NMEA has its own version of essential Gps pvt (position, velocity, time) data. It is called
RMC, The Recommended Minimum, which will look similar to:
$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

4.3 GPS Applications:

An One of the most significant and unique feature of the GPS is the fact that the positioning
signals available to users in any position worldwide at any time With a fully operational GPS system,
there are multiple applications,rangingfromsurveying,mapping,and navigation to GIS data capture. The
GPS will soon be apart of the overall utility of technology. There are countlessGPSapplications,a few
importantances are covered in the following passage
4.3.1 Surveying and Mapping: The high precision of GPS carrier phase measurements, together with
appropriate adjustment algorithms, provides an adequate tool for a variety of tasks for surveying and
mapping. Using DGPs methods,accurate and timely mapping of almost anything canbe carriedout.The
GPS is used to map cut blocks,road alignments,and environmental hazards suchas
landslides,forestfires,andoilspills.Applications,such as cadastral mapping, needing a high degree of
accuracy also can be carried out using high grade GPS receivers. Continuous kinematic techniques can be
used for topographic surveys and accurate linear mapping.

4.3.2. Navigation: Navigation using GPS can save countless hours in the field. Any feature, even if it is
under water, can be located up to one hundred meters simply by scaling coordinates from a map, entering
waypoints, and going directly to the site. Examples include road intersections, corner posts, plot canters,
accident sites, geological formations, and so on. GPS navigation in helicopters, in vehicles, or in a ship
can provide an easy means of navigation with substantial savings.

4.3.3. Remote Sensing and GIS: It is also possible to integrate GPS positioning into remote-
sensing methods such as photogrammetric and aerial scanning, magnetometer, and video technology.
Using DGPS or kinematic techniques, depending upon the accuracy required, real time or post-processing
will provide positions for the sensor which can be projected to the ground, instead of having ground
control projected to an image. GPS are becoming very effective tools for GIS data capture. The GIS user
community benefits from the use of GPS for location data capture in various GIS applications. The GPS
can easily be linked to a laptop computer in the field, and, with appropriate software, users can also have
all their data on a common base with every little distortion.

Liquid Crystal Display (LCD):

Liquid crystal display a type of display used in digital watches and many
portable computers.
LCD displays utilize two sheets of polarizing material with a liquid crystal
solution between them. An electric current passed through the liquid causes
the crystals to align so that light cannot pass through them. Each crystal,
therefore, is like a shutter, either allowing light to pass through or blocking
the light.

The liquid crystals can be manipulated through an applied electric


voltage so that light is allowed to pass or is blocked.

By carefully controlling where and what wavelength (color) of light is


allowed to pass, the LCD monitor is able to display images. A back light
provides LCD monitor’s brightness.

Other advances have allowed LCD’s to greatly reduce liquid crystal cell
response times.

Response time is basically the amount of time it takes for a pixel to “change
colors”. In reality response time is the amount of time it takes a liquid crystal
cell to go from being active to inactive

Here the LCD is used at both the Transmitter as well as the receiver side.
The input which we give to the microcontroller is displayed on the LCD of
the transmitter side and the message sent is received at the receiver side
which displays at the receiver end of the LCD and the corresponding
operation is performed

They make complicated equipment easier to operate. LCDs come in many


shapes and sizes but the most common is the 16 character x 4 line display
with no backlight.

It requires only 11 connections – eight bits for data (which can be reduced
to four if necessary) and three control lines (we have only used two here). It
runs off a 5V DC supply and only needs about 1mA of current.

The display contrast can be varied by changing the voltage into pin 3 of
the display,

Pin description of LCD:


From this description, the interface is a parallel bus, allowing simple and fast
reading/writing of data to and from the LCD. This waveform will write an
ASCII Byte out to the LCD's screen.

PIN DESCRIPTIONS
Vcc, Vss and Vee

While Vcc and Vss provide +5V and ground respectively, Vee is
used for controlling LCD contrast.

PIN SYMBOL I/O DESCRIPTION

1 Vss -- Ground

2 Vcc -- +5V power


supply

3 Vee -- Power supply to


control contrast

4 RS I RS=0 to select
command
register

RS=1 to select
data register

5 R/W I 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.

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

INTERFACING LCD WITH CONTROLLER:

P1.0 DB0
P1.1 DB1

8052 P1.2 DB2


HD447
μC P1.3 DB3 80
LCD
P1.4 DB4
Interfacing a LCD with a microcontroller.

Advantages:

LCD interfacing with 8051 is a real-world application. In recent


years the LCD is finding widespread use replacing LEDs (seven segment
LEDs or other multisegment LEDs).

This is due to following reasons:


1. The declining prices of LCDs.

2. The ability to display numbers, characters and graphics. This is in contrast


to LEDs, which are limited to numbers and a few characters. An intelligent
LCD display of two lines, 20 characters per line, which is interfaced to the
8051.
3. Incorporation of a refreshing controller into the LCD, thereby relieving
the CPU to keep displaying the data.
4. Ease of programming for characters and graphics.
Basic commands of LCD:

When LCD is powered up, the display should show a series of dark
squares, possibly only on part of display.

These characters are actually in their off state, so the contrast control
should be adjusted anti-clockwise until the squares are just visible.

The display module resets itself to an initial state when power is


applied, which curiously the display has blanked off so that even if
characters are entered, they cannot be seen.

It is therefore necessary to issue a command at this point, to switch


the display on.

Prototype circuit:

For a LCD module to be used effectively in any piece of equipment,


a microprocessor or a micro controller is usually required to drive it.

However, before attempting to wire the two together, some initial


experiments can be performed by connecting a series of switches to the pins
of the module.
This can be a quite beneficial step, if even you are thoroughly
conversant with the workings of microprocessors.

Circuit description of LCD experiment:


The circuit can be wired up on a “plug-in-style” prototyping board,
using dual-in-line switches for the data lines (S1-S8)

A toggle switch for the RS input (S10) and a momentary action switch (or
macro switch) for usage.

Most of the LCD modules conform to a standard interface


specification. A 14pin access is provided having eight data lines, three
control lines and three power lines.

The connections are laid out in one of the two common configurations,
either two rows of seven pins, or a single row of 14 pins.

One of the, pins are numbered on the LCD’s print circuit board (PCB), but if
not, it is quite easy to locate pin1.

Since this pin is connected to ground, it often has a thicker PCB track,
connected to it, and it is generally connected to metalwork at same point.

Pin description:

G +5V -5v

1 2 3
D0 D1 D2 D3 D4 D5 D6 D7 RS R/W EN

The LCD plays a major role in the entire operation as it has the ability to
display the certain data that the user has entitled.

LCD display varies from input to input as there is no specific outline for it to
operate.

MAX 232
RS-232 WAVEFORM

TTL/CMOS Serial Logic Waveform

The diagram above shows the expected waveform from the UART when using the common
8N1 format. 8N1 signifies 8 Data bits, No Parity and 1 Stop Bit. The RS-232 line, when idle is in the
Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then each bit is sent down
the line, one at a time. The LSB (Least Significant Bit) is sent first. A Stop Bit (Logic 1) is then appended
to the signal to make up the transmission.

The data sent using this method, is said to be framed. That is the data is framed between a
Start and Stop Bit.

RS-232 Voltage levels

 +3 to +25 volts to signify a "Space" (Logic 0)


 -3 to -25 volts for a "Mark" (logic 1).
 Any voltage in between these regions (i.e. between +3 and -3 Volts) is undefined.
The data byte is always transmitted least-significant-bit first.

The bits are transmitted at specific time intervals determined by the baud rate of the serial
signal. This is the signal present on the RS-232 Port of your computer, shown below.
RS-232 Logic Waveform

2.3.2 RS-232 LEVEL CONVERTER

Standard serial interfacing of microcontroller (TTL) with PC or any RS232C Standard device
, requires TTL to RS232 Level converter . A MAX232 is used for this purpose. It provides 2-channel
RS232C port and requires external 10uF capacitors.

The driver requires a single supply of +5V.

MAX-232 includes a Charge Pump, which generates +10V and -10V from a single 5v supply.

Serial communication

When a processor communicates with the outside world, it provides data in byte sized chunks.
Computers transfer data in two ways: parallel and serial. In parallel data transfers, often more lines are
used to transfer data to a device and 8 bit data path is expensive. The serial communication transfer uses
only a single data line instead of the 8 bit data line of parallel communication which makes the data
transfer not only cheaper but also makes it possible for two computers located in two different cities to
communicate over telephone.

Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers data at a time while the asynchronous transfers a single byte at a time.
There are some special IC chips made by many manufacturers for data communications. These chips are
commonly referred to as UART (universal asynchronous receiver-transmitter) and USART (universal
synchronous asynchronous receiver transmitter). The AT89C51 chip has a built in UART.

In asynchronous method, each character is placed between start and stop bits. This is called
framing. In data framing of asynchronous communications, the data, such as ASCII characters, are packed
in between a start and stop bit. We have a total of 10 bits for a character: 8 bits for the ASCII code and 1
bit each for the start and stop bits. The rate of serial data transfer communication is stated in bps or it can
be called as baud rate.

To allow the compatibility among data communication equipment made by various


manufacturers, and interfacing standard called RS232 was set by the Electronics industries Association in
1960. Today RS232 is the most widely used I/O interfacing standard. This standard is used in PCs and
numerous types of equipment. However, since the standard was set long before the advent of the TTL
logic family, its input and output voltage levels are not TTL compatible. In RS232, a 1 bit is represented
by -3 to -25V, while a 0 bit is represented +3 to +25 V, making -3 to +3 undefined. For this reason, to
connect any RS232 to a microcontroller system we must use voltage converters such as MAX232 to
connect the TTL logic levels to RS232 voltage levels and vice versa. MAX232 ICs are commonly
referred to as line drivers.
The RS232 cables are generally referred to as DB-9 connector. In labeling, DB-9P refers to
the plug connector (male) and DB-9S is for the socket connector (female). The simplest connection
between a PC and microcontroller requires a minimum of three pin, TXD, RXD, and ground. Many of the
pins of the RS232 connector are used for handshaking signals. They are bypassed since they are not
supported by the UART chip.

IBM PC/ compatible computers based on x86(8086, 80286, 386, 486 and Pentium)
microprocessors normally have two COM ports. Both COM ports have RS232 type connectors. Many
PCs use one each of the DB-25 and DB-9 RS232 connectors. The COM ports are designated as COM1
and COM2. We can connect the serial port to the COM 2 port of a PC for serial communication
experiments. We use a DB9 connector in our arrangement.
Light Emitting Diode (LED):

A light-emitting diode (LED) is a semiconductor diode that emits


incoherent narrow spectrum light when electrically biased in the forward
direction of the pn-junction, as in the common LED circuit. This effect is a
form of electroluminescence

While sending a message in the form of bits such as 1,the data is sent
to the receiver side correspondingly the LED glows representing the data is
being received simultaneously when we send 8 as a data the LED gets off .

Color Coding

Color Potential Difference

Infrared 1.6 V
Red 1.8 V to 2.1 V

Orange 2.2 V

Yellow 2.4 V

Green 2.6 V

Blue 3.0 V to 3.5 V

White 3.0 V to 3.5 V

Ultraviolet 3.5V

ADVANTAGES

 LEDs have many advantages over other technologies like lasers. As


compared to laser diodes or IR sources
 LEDs have several advantages over conventional incandescent lamps. For
one thing, they don't have a filament that will burn out, so they last much longer.
Additionally, their small plastic bulb makes them a lot more durable. They also fit
more easily into modern electronic circuits.
 The main advantage is efficiency. In conventional incandescent bulbs, the
light-production process involves generating a lot of heat (the filament must be
warmed). This is completely wasted energy, unless you're using the lamp as a
heater, because a huge portion of the available electricity isn't going toward
producing visible light.
 LEDs generate very little heat. A much higher percentage of the electrical
power is going directly to generating light, which cuts down on the electricity
demands considerably.
 LEDs offer advantages such as lower cost and longer service life. Moreover
LEDs have very low power consumption and are easy to maintain. Many functions
can be assigned to a robot easily using different colors of LEDs availible.

DISADVANTAGES OF LEDS

 LED performance largely depends on the ambient temperature of the


operating environment.
 LEDs must be supplied with the correct current.
 LEDs do not approximate a "point source" of light, so cannot be used
in applications needing a highly collimated beam.

But the disadvantages are quite negligible in this project as the negative
properties of LEDs do not apply and the advantages far exceed the
limitations. So we prefer to use the LED as our light source.
RELAYS SPDT

Overview OF Relays
A relay is an electrically operated switch used to isolate one electrical circuit from another. In its simplest
form, a relay consists of a coil used as an electromagnet to open and close switch contacts. Since the two
circuits are isolated from one another, a lower voltage circuit can be used to trip a relay, which will
control a separate circuit that requires a higher voltage or amperage. Relays can be found in early
telephone exchange equipment, in industrial control circuits, in car audio systems, in automobiles, on
water pumps, in high-power audio amplifiers and as protection devices.

Relay Switch Contacts


The switch contacts on a relay can be "normally open" (NO) or "normally closed" (NC)--that is, when the
coil is at rest and not energized (no current flowing through it), the switch contacts are given the
designation of being NO or NC. In an open circuit, no current flows, such as a wall light switch in your
home in a position that the light is off. In a closed circuit, metal switch contacts touch each other to
complete a circuit, and current flows, similar to turning a light switch to the "on" position. In the
accompanying schematic diagram, points A and B connect to the coil. Points C and D connect to the

switch. When you apply a voltage across the coil at points A and B, you create an electromagnetic field,
which attracts a lever in the switch, causing it to make or break contact in the circuit at points C and D
(depending if the design is NO or NC). The switch contacts remain in this state until you remove the
voltage to the coil. Relays come in different switch configurations. The switches may have more than one
"pole," or switch contact. The diagram shows a "single pole single throw" configuration, referred to as
SPST. This is similar to a wall light switch in your home. With a single "throw" of the switch, you close
the circuit.

The Single Pole Double Throw Relay


A single pole double throw (SPDT) relay configuration switches one common pole to two other poles,
flipping between them. As shown in the schematic diagram, the common point E completes a circuit with
C when the relay coil is at rest, that is, no voltage is applied to it.

This circuit is "closed." A gap between the contacts of point E and D creates an "open" circuit. When you
apply power to the coil, a metal level is pulled down, closing the circuit between points E and D and
opening the circuit between E and C. A single pole double throw relay can be used to alternate which
circuit a voltage or signal will be sent to.

SPDT Relay:

(Single Pole Double Throw Relay) an electromagnetic switch, consist of a coil (terminals 85 & 86), 1
common terminal (30), 1 normally closed terminal (87a), and one normally open terminal (87) (Figure 1).

When the coil of an SPDT relay (Figure 1) is at rest (not energized), the common terminal (30) and the
normally closed terminal (87a) have continuity. When the coil is energized, the common terminal (30)
and the normally open terminal (87) have continuity.

The diagram below center (Figure 2) shows an SPDT relay at rest, with the coil not energized. The
diagram below right (Figure 3) shows the relay with the coil energized. As you can see, the coil is an
electromagnet that causes the arm that is always connected to the common (30) to pivot when energized
whereby contact is broken from the normally closed terminal (87a) and made with the normally open
terminal (87).

When energizing the coil of a relay, polarity of the coil does not matter unless there is a diode across the
coil. If a diode is not present, you may attach positive voltage to either terminal of the coil and negative
voltage to the other, otherwise you must connect positive to the side of the coil that the cathode side (side
with stripe) of the diode is connected and negative to side of the coil that the anode side of the diode is
connected.

Why do I want to use a relay and do I really need to?

Anytime you want to switch a device which draws more current than is provided by an output of a switch
or component you'll need to use a relay. The coil of an SPDT or an SPST relay that we most commonly
use draws very little current (less than 200 milliamps) and the amount of current that you can pass
through a relay's common, normally closed, and normally open contacts will handle up to 30 or 40 amps.
This allows you to switch devices such as headlights, parking lights, horns, etc., with low amperage
outputs such as those found on keyless entry and alarm systems, and other components. In some cases
you may need to switch multiple things at the same time using one output. A single output connected to
multiple relays will allow you to open continuity and/or close continuity simultaneously on multiple
wires.

There are far too many applications to list that require the use of a relay, but we do show many of the
most popular applications in the pages that follow and many more in our Relay Diagrams - Quick
Reference application. If you are still unclear about what a relay does or if you should use one after you
browse through the rest of this section, please post a question in the12volt's install bay. (We recommend
Tyco (formerly Bosch) or Potter & Brumfield relays for all of the SPDT and SPST relay applications
shown on this site.)
DC MOTOR

DC motors are configured in many types and sizes, including brush less, servo, and gear motor
types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is
maintained using either permanent magnets or electromagnetic windings. DC motors are most
commonly used in variable speed and torque.
Motion and controls cover a wide range of components that in some way are used to
generate and/or control motion. Areas within this category include bearings and bushings, clutches and
brakes, controls and drives, drive components, encoders and resolves, Integrated motion control, limit
switches, linear actuators, linear and rotary motion components, linear position sensing, motors (both
AC and DC motors), orientation position sensing, pneumatics and pneumatic components, positioning
stages, slides and guides, power transmission (mechanical), seals, slip rings, solenoids, springs.

Motors are the devices that provide the actual speed and torque in a drive system. This
family includes AC motor types (single and multiphase motors, universal, servo motors, induction,
synchronous, and gear motor) and DC motors (brush less, servo motor, and gear motor) as well as
linear, stepper and air motors, and motor contactors and starters.

In any electric motor, operation is based on simple electromagnetism. A current-


carrying conductor generates a magnetic field; when this is then placed in an external magnetic field, it
will experience a force proportional to the current in the conductor, and to the strength of the external
magnetic field. As you are well aware of from playing with magnets as a kid, opposite (North and
South) polarities attract, while like polarities (North and North, South and South) repel. The internal
configuration of a DC motor is designed to harness the magnetic interaction between a current-
carrying conductor and an external magnetic field to generate rotational motion.
Let's start by looking at a simple 2-pole DC electric motor (here red represents a magnet or
winding with a "North" polarization, while green represents a magnet or winding with a "South"
polarization).

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, commutator, field
magnet(s), and brushes. In most common DC motors (and all that Beamers will see), the external
magnetic field is produced by high-strength permanent magnets1. The stator is the stationary part of
the motor -- this includes the motor casing, as well as two or more permanent magnet pole pieces. The
rotor (together with the axle and attached commutator) rotates with respect to the stator. The rotor
consists of windings (generally on a core), the windings being electrically connected to the
commutator. The above diagram shows a common motor layout -- with the rotor inside the stator
(field) magnets.

The geometry of the brushes, commutator contacts, and rotor windings are such
that when power is applied, the polarities of the energized winding and the stator magnet(s)
are misaligned, and the rotor will rotate until it is almost aligned with the stator's field
magnets. As the rotor reaches alignment, the brushes move to the next commutator contacts,
and energize the next winding. Given our example two-pole motor, the rotation reverses the
direction of current through the rotor winding, leading to a "flip" of the rotor's magnetic field,
and driving it to continue rotating.
In real life, though, DC motors will always have more than two poles (three is a very
common number). In particular, this avoids "dead spots" in the commutator. You can imagine how
with our example two-pole motor, if the rotor is exactly at the middle of its rotation (perfectly aligned
with the field magnets), it will get "stuck" there. Meanwhile, with a two-pole motor, there is a moment
where the commutator shorts out the power supply (i.e., both brushes touch both commutator contacts
simultaneously). This would be bad for the power supply, waste energy, and damage motor
components as well. Yet another disadvantage of such a simple motor is that it would exhibit a high
amount of torque” ripple" (the amount of torque it could produce is cyclic with the position of the
rotor).
So since most small DC motors are of a three-pole design, let's tinker with the workings of one
via an interactive animation (JavaScript required):

You'll notice a few things from this -- namely, one pole is fully energized at a time (but two
others are "partially" energized). As each brush transitions from one commutator contact to the next,
one coil's field will rapidly collapse, as the next coil's field will rapidly charge up (this occurs within a
few microsecond). We'll see more about the effects of this later, but in the meantime you can see that
this is a direct result of the coil windings' series wiring:

There's probably no better way to see how an average dc motor is put together, than by just
opening one up. Unfortunately this is tedious work, as well as requiring the destruction of a perfectly
good motor.
POWER SUPPLY

All digital circuits require regulated power supply. In this article we are going to learn how to get a
regulated positive supply from the mains supply.

Figure 1 shows the basic block diagram of a fixed regulated power supply. Let us go through each block.

TRANSFORMER

A transformer consists of two coils also called as “WINDINGS” namely PRIMARY & SECONDARY.

They are linked together through inductively coupled electrical conductors also called as CORE. A
changing current in the primary causes a change in the Magnetic Field in the core & this in turn induces
an alternating voltage in the secondary coil. If load is applied to the secondary then an alternating current
will flow through the load. If we consider an ideal condition then all the energy from the primary circuit
will be transferred to the secondary circuit through the magnetic field.

So

The secondary voltage of the transformer depends on the number of turns in the Primary as well as in the secondary.

Rectifier

A rectifier is a device that converts an AC signal into DC signal. For rectification purpose we use a diode,
a diode is a device that allows current to pass only in one direction i.e. when the anode of the diode is
positive with respect to the cathode also called as forward biased condition & blocks current in the
reversed biased condition.

Rectifier can be classified as follows:

1) Half Wave rectifier.


This is the simplest type of rectifier as you can see in the diagram a half wave rectifier consists of only
one diode. When an AC signal is applied to it during the positive half cycle the diode is forward biased &
current flows through it. But during the negative half cycle diode is reverse biased & no current flows
through it. Since only one half of the input reaches the output, it is very inefficient to be used in power
supplies.

2) Full wave rectifier.

Half wave rectifier is quite simple but it is very inefficient, for greater efficiency we would like to use
both the half cycles of the AC signal. This can be achieved by using a center tapped transformer i.e. we
would have to double the size of secondary winding & provide connection to the center. So during the
positive half cycle diode D1 conducts & D2 is in reverse biased condition. During the negative half cycle
diode D2 conducts & D1 is reverse biased. Thus we get both the half cycles across the load.

One of the disadvantages of Full Wave Rectifier design is the necessity of using a center tapped
transformer, thus increasing the size & cost of the circuit. This can be avoided by using the Full Wave
Bridge Rectifier.
3) Bridge Rectifier.

As the name suggests it converts the full wave i.e. both the positive & the negative half cycle into DC
thus it is much more efficient than Half Wave Rectifier & that too without using a center tapped
transformer thus much more cost effective than Full Wave Rectifier.

Full Bridge Wave Rectifier consists of four diodes namely D1, D2, D3 and D4. During the positive half
cycle diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct thus the
diodes keep switching the transformer connections so we get positive half cycles in the output.

If we use a center tapped transformer for a bridge rectifier we can get both positive & negative half cycles
which can thus be used for generating fixed positive & fixed negative voltages.
FILTER CAPACITOR

Even though half wave & full wave rectifier give DC output, none of them provides a constant output
voltage. For this we require to smoothen the waveform received from the rectifier. This can be done by
using a capacitor at the output of the rectifier this capacitor is also called as “FILTER CAPACITOR” or
“SMOOTHING CAPACITOR” or “RESERVOIR CAPACITOR”. Even after using this capacitor a small
amount of ripple will remain.

We place the Filter Capacitor at the output of the rectifier the capacitor will charge to the peak voltage during each half
cycle then will discharge its stored energy slowly through the load while the rectified voltage drops to zero, thus trying
to keep the voltage as constant as possible.

If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the costing will increase.
The value of the Filter capacitor depends on the current consumed by the circuit, the frequency of the waveform & the
accepted ripple.
Where,

Vr= accepted ripple voltage.( should not be more than 10% of the voltage)

I= current consumed by the circuit in Amperes.

F= frequency of the waveform. A half wave rectifier has only one peak in one cycle so F=25hz

Whereas a full wave rectifier has Two peaks in one cycle so F=100hz.

VOLTAGE REGULATOR

A Voltage regulator is a device which converts varying input voltage into a constant regulated output

voltage. Voltage regulator can be of two types

1) Linear Voltage Regulator

Also called as Resistive Voltage regulator because they dissipate the excessive voltage resistively as
heat.

2) Switching Regulators.

They regulate the output voltage by switching the Current ON/OFF very rapidly. Since their output is
either ON or OFF it dissipates very low power thus achieving higher efficiency as compared to linear
voltage regulators. But they are more complex & generate high noise due to their switching action. For
low level of output power switching regulators tend to be costly but for higher output wattage they are
much cheaper than linear regulators.

The most commonly available Linear Positive Voltage Regulators are the 78XX series where the XX
indicates the output voltage. And 79XX series is for Negative Voltage Regulators.
After filtering the rectifier output the signal is given to a voltage regulator. The maximum input voltage
that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the regulator so the input
voltage should be at least 2-3 Volts higher than the output voltage. If the input voltage gets below the
Vmin of the regulator due to the ripple voltage or due to any other reason the voltage regulator will not be
able to produce the correct regulated voltage.

3 Circuit diagram:

Fig 2.3. Circuit Diagram of power supply

IC 7805:

7805 is an integrated three-terminal positive fixed linear voltage regulator. It supports an input voltage of
10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp although lower current
models are available. Its output voltage is fixed at 5.0V. The 7805 also has a built-in current limiter as a
safety feature. 7805 is manufactured by many companies, including National Semiconductors and
Fairchild Semiconductors.

The 7805 will automatically reduce output current if it gets too hot.The last two digits represent the
voltage; for instance, the 7812 is a 12-volt regulator. The 78xx series of regulators is designed to work in
complement with the 79xx series of negative voltage regulators in systems that provide both positive and
negative regulated voltages, since the 78xx series can't regulate negative voltages in such a system.

The 7805 & 78 is one of the most common and well-known of the 78xx series regulators, as it's small
component count and medium-power regulated 5V make it useful for powering TTL devices.

Table 2.1. Specifications of IC7805

SPECIFICATIONS IC 7805

Vout 5V

Vein - Vout Difference 5V - 20V

Operation Ambient Temp 0 - 125°C

Output Imax 1A
A variable regulated power supply, also
called a variable bench power supply, is one where you can continuously adjust the output
voltage to your requirements. Varying the output of the power supply is the recommended way
to test a project after having double checked parts placement against circuit drawings and the
parts placement guide.

This type of regulation is ideal for having a simple variable bench power supply. Actually this is
quite important because one of the first projects a hobbyist should undertake is the construction
of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's
much handier to have a variable supply on hand, especially for testing.

Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need
to build a regulated 5 volt source. Usually you start with an unregulated power supply ranging
from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the
Microcontroller Beginner Kit.). To make a 5 volt power supply, we use a LM7805 voltage
regulator IC (Integrated Circuit). The IC is shown below.

POWER SUPPLY:
In my project I used9 volts transformer for continuous power supply. Why I am using this means
to continuous power will come. Otherwise If I use a battery some times the total currents will
loss so that’s way I am using A.C Transformer. A.C transformer is giving the input to Bridge
Rectifier. Bridge Rectifier converts A.C to D.C. After that we are using one filter capacitor
1000uf/25v electrolytic capacitor .We connecting this capacitor in parallel section. The main
purpose of this capacitor is if there is any alternate peaks we need to reduce that peaks. Nothing
but a filtering that repull’s. After that we are using LM7805 Regulator Most digital logic circuits
and processors need a 5 volt power supply. To use these parts we need to build a regulated 5 volt
source. We make a 5 volt power supply, The LM7805 is simple to use. First connect the positive
lead of our unregulated DC power supply Input pin, connect the negative lead to the Common
pin and then when we turn on the power, we get a 5 volt supply from the Output pin. Here we are
using one red color led to indicate the power.

7805
VCC
1

BRIDGE RECTIFIER 1
VIN VOUT
3
220 ohms
A.C TRANSFORMER I/P

- +
1000uf/25v

1 2 4
2
104pf
33pf

led
3

GND

We are using General purpose PCB. To mount or place the components on the PCB. After that
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.

7.2 CIRCUIT FEATURES:

 Brief description of operation: Gives out well regulated +5V output, output current capability of
100 mA
 Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too
hot
 Circuit complexity: Very simple and easy to build
 Circuit performance: Very stable +5V output voltage, reliable operation
 Availability of components: Easy to get, uses only very common basic components
 Design testing: Based on datasheet example circuit, I have used this circuit succesfully as part of
many electronics projects
 Applications: Part of electronics devices, small laboratory power supply
 Power supply voltage: Unreglated DC 8-18V power supply
 Power supply current: Needed output current + 5 mA
 Component costs: Few dollars for the electronics components + the input transformer cost

7.3 BLOCK DIAGRAM:


7.4 CIRCUIT DIAGRAM:

The power supply unit is used to provide constant 5 V dc supply to the peripherals.
The 230 V ac is converted into 9 V ac by using a transformer and then a bridge
rectifier rectifies it to a 9 V dc with ac ripples. This is then filtered by electrolytic
capacitors used across the rectifier output. LM7805 regulator is employed to obtain
a constant 5 V dc at the output.

Regulator LM7805.
This is a digital IC used as a regulator for regulating the output. LM7805 provides
a constant 5V dc supply as output. For this it needs at least 8V dc as input.

KEIL U V2 SOFTWARE

INTRODUCTION TO KIEL SOFT WARE:


Many companies provide the 8051 assembler, some of them provide
shareware version of their product on the Web, Kiel is one of them. We can
download them from their Websites. However, the size of code for these shareware
versions is limited and we have to consider which assembler is suitable for our
application.

Kiel u Vision2:

Kiel uVision2 is an IDE (Integrated Development Environment) that helps


you write, compile, and debug

Embedded programs. It encapsulates the following components:

. A project manager.

. A make facility.

. Tool configuration.

. Editor.

. A powerful debugger.

To help you get started, several example programs

Building an Application in uVision2:

To build (compile, assemble, and link) an application in uVision2, you must:

. Select Project–Open Project


(for example, \C166\EXAMPLES\HELLO\HELLO.UV2).

. Select Project - Rebuild all target files or Build target.

UVision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in uVision2:

To create a new project in uVision2, you must:

. Select Project - New Project.

. Select a directory and enter the name of the project file.

. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from
the Device

. Database

. Create source files to add to the project.

. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add
the source files to the project.

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

. Select Project - Rebuild all target files or Build target.


Debugging an Application in uVision2:

To debug an application created using uVision2, you must:

. Select Debug - Start/Stop Debug Session.

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

. Open the Serial Window using the Serial #1 button on the toolbar.

. Debug your program using standard options like Step, Go, Break, and so on.

Limitations of Evaluation Software:

The following limitations apply to the evaluation versions of the C51, C251, or
C166 tool chains.

C51 Evaluation Software Limitations:

. The compiler, assembler, linker, and debugger are limited to 2 Kbytes of object
code but source

Code may be any size. Programs that generate more than 2 Kbytes of object code
will not compile, assemble, or link.

. the startup code generated includes LJMP's and cannot be used in single-chip
devices supporting Less than 2 Kbytes of program space like the Philips
750/751/752.

. The debugger supports files that are 2 Kbytes and smaller.

. Programs begin at offset 0x0800 and cannot be programmed into single-chip


devices.
. No hardware support is available for multiple DPTR registers.

. No support is available for user libraries or floating-point arithmetic.

. The following components, which are present in the PK51 Full Version, are not
included in the C51

Evaluation Software:

. Code-Banking Linker/Locator.

. Library Manager.

. RTX-51 Tiny Real-Time Operating System.

C251 Evaluation Software Limitations:

The compiler, assembler, linker, and debugger are limited to 4 Kbytes of object
code but sourcecode may be any size. Programs that generate more than 4 Kbytes
of object code will not compile, assemble, or link. The debugger supports files that
are 4 Kbytes and smaller.

C166 Evaluation Software Limitations:

The compiler, assembler, linker, and debugger are limited to 4 Kbytes of object
code but source Code may be any size. Programs that generate more than 4 Kbytes
of object code will not compile, Assemble, or link The debugger supports files that
are 4 Kbytes and smaller.

Peripheral Simulation:
The u vision2 debugger provides complete simulation for the CPU and on
chip peripherals of most embedded devices. To discover which peripherals of a
device are supported, in u vision2. Select the Simulated Peripherals item from the
Help menu. You may also use the web-based device database. We are constantly
adding new devices and simulation support for on-chip peripherals so be sure to
check Device Database often.

KEIL SOFTWARE PROGRAMING PROCEDURE

How to write Embedded C Program in Keil Software.

Procedure Steps

Step-1:
Install Keil MicroVision-2 in your PC, Then after Click on that “Keil UVision-2” icon. After opening the
window go to toolbar and select Project Tab then close previous project.
Step-2:
Next select New Project from Project Tab.
Step-3:

Then it will open “Create New Project” window. Select the path where you want to save project
and edit project name.
Step-4:
Next it opens “Select Device for Target” window, It shows list of companies and here you can
select the device manufacturer company.

Step-5:

For an example, for your project purpose you can select the chip as 89c51/52 from Atmel Group.
Next Click OK Button, it appears empty window here you can observe left side a small window i.e,
“Project Window”. Next create a new file.
Step-6:

From the Main tool bar Menu select “File” Tab and go to New, then it will open a window, there
you can edit the program.

Step-7:

Here you can edit the program as which language will you prefer either Assembly or C.
Step-8:

After editing the program save the file with extension as “.c” or “.asm”, if you write a program in
Assembly Language save as “.asm” or if you write a program in C Language save as “.c” in the selected
path. Take an example and save the file as “test.c”.

Step-9:

Then after saving the file, compile the program. For compilation go to project window select
“source group” and right click on that and go to “Add files to Group”.
Step-9:

Here it will ask which file has to Add. For an example here you can add “test.c” as you saved
before.

Step-9:

After adding the file, again go to Project Window and right click on your “c file” then select
“Build target” for compilation. If there is any “Errors or Warnings” in your program you can check in
“Output Window” that is shown bottom of the Keil window.

Step-10:
Here in this step you can observe the output window for “errors and warnings”.

Step-11:

If you make any mistake in your program you can check in this slide for which error and where
the error is by clicking on that error.

Step-12:
After compilation then next go to Debug Session. In Tool Bar menu go to “Debug” tab and select
“Start/Stop Debug Session”.

Step-13:

Here a simple program for “Leds Blinking”. LEDS are connected to PORT-1. you can observe
the output in that port.

Step-14:
To see the Ports and other Peripheral Features go to main toolbar menu and select peripherals.

Step-15:

In this slide see the selected port i.e, PORT-1.

Step-16:
Start to trace the program in sequence manner i.e, step by step execution and observe the output
in port window.

Step-17:

After completion of Debug Session Create an Hex file for Burning the Processor. Here to create
an Hex file go to project window and right click on Target next select “Option for Target”.

Step-18:
It appears one window; here in “target tab” modify the crystal frequency as you connected to your
microcontroller.

Step-19:

Next go to “Output’ tab. In that Output tab click on “Create HEX File” and then click OK.

Step-20:
Finally Once again compile your program. The Created Hex File will appear in your path folder.

8.0.1 ISP Flash Microcontroller Programmer:


Features:

 Complete In-System Programming Solution for AVR Microcontrollers


 Covers All AVR Microcontrollers with In-System Programming Support
 Reprogram Both Data Flash and Parameter EEPROM Memories
 Complete Schematics for Low-cost In-System Programmer
 Simple Three-wire SPI Programming Interface

Introduction:

In-System Programming allows programming and reprogramming of any AVR


microcontroller Positioned inside the end system. Using a simple three-wire SPI
interface, the In-System Programmer communicates serially with the AVR
microcontroller, reprogramming all non-volatile memories on the chip.
In-System Programming eliminates the physical removal of chips from the system.

This will save time, and money, both during development in the lab, and when
updating

The software or parameters in the field. This application note shows how to design
the system to support In-System Programming. It also shows how a low-cost In-
System Programmer can be made, that will allow the target AVR microcontroller
to be programmed from any PC equipped with a regular 9-pin serial port.
Alternatively, the entire In-System Programmer can be built into the system allowing it to
reprogram itself.

The Programming Interface:


For In-System Programming, the programmer is connected to the target using as
few wires as possible. To program any AVR microcontroller in any target system,
a simple Six-wire interface is used to connect the programmer to the target PCB.
Below shows the connections needed.

The Serial Peripheral Interface (SPI) consists of three wires: Serial Clock (SCK),
Master In – Slave Out (MISO) and Master Out – Slave In (MOSI). When
programming the AVR, the In-System Programmer always operate as the Master,
and the target system Always operate as the Slave.

The In-System Programmer (Master) provides the clock for the communication on
the SCK Line. Each pulse on the SCK Line transfers one bit from the Programmer
(Master) To the Target (Slave) on the Master out – Slave in (MOSI) line.
Simultaneously, Each pulse on the SCK Line transfers one bit from the target
(Slave) to the Programmer (Master) on the Master in – Slave out (MISO) line.
SOFTWARE CODE

CODE:

#include <reg51.h>
#include<string.h>
#include<stdio.h>

#define BUFF_LEN 50
#define LCD P0
////////////////////////////////////////////////////////////////////////////
sbit DCLK = P1^0;
sbit SDAT= P1^1;
sbit CS =P1^2;

sbit buzz =P1^3;


sbit engine =P1^4;
/////////////////////////////////////////////////////////////////////////////
void init_lcd(void);
void cmd_lcd(unsigned char);
void write_lcd(unsigned char);
void display_lcd(unsigned char *);
void integer_lcd(int);
void float_lcd(float);
void delay_ms(unsigned int);
void adc_convert (void);
unsigned char byte_read(void);
unsigned char byte0,byte1;
unsigned int num;
float val;
/////////////////////////////////////////////////////////////////////////////////////////
void GSM_INIT(void);
void SEND_SMS_GPS(unsigned char *);
void RECEIVE_GPS(void);
void RECEIVE_GPGLL(unsigned long);
unsigned char RECEIVE_CHR(unsigned long);
void SEND_CHR(unsigned char);

void GSM_INIT(void)
{
cmd_lcd(0xC0);
display_lcd("GSM INITIALIZING");
SEND_STR("AT\r\n");
SEND_STR("AT\r\n");
SEND_STR("AT\r\n");
SEND_STR("ATE0\r\n");
SEND_STR("AT+CMGF=1\r\n");
delay_ms(10);
cmd_lcd(0x01);
cmd_lcd(0xC0);
SEND_STR("AT+CMGF=1\r\n");
delay_ms(10);
cmd_lcd(0x01);
cmd_lcd(0xC0);
SEND_STR("AT+CMGD=1\r\n");
delay_ms(10);
cmd_lcd(0x01);
cmd_lcd(0xC0);
display_lcd("MESSAGES DELETED");
delay_ms(10);
}
/////////////////////////////////////////////////////////////////////////////
void RECEIVE_GPS(void)
{
unsigned int i=0,j=0;
i=1;

while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
cmd_lcd(0X80);
display_lcd("LT:");

while((REC_BUFF[i]!=',')||(j++<1))
write_lcd(REC_BUFF[i++]);
//input=REC_BUFF[i++];
cmd_lcd(0XC0);
display_lcd("LN:");

i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
write_lcd(REC_BUFF[i++]);
//nput=REC_BUFF[i++];
}
///////////////////////////////////////////////////////////////////////////////////
void RECEIVE_GPGLL(unsigned long timeout)
{
unsigned int i=0;
char loop = 1;
while(loop)
{
while(RECEIVE_CHR(timeout) != '$');
if(RECEIVE_CHR(timeout) == 'G')
{
if(RECEIVE_CHR(timeout) == 'P')
{
if(RECEIVE_CHR(timeout) == 'R')
{
if(RECEIVE_CHR(timeout) == 'M')
{
RI)&&(--timeout > 0));
if(timeout)
temp = SBUF;
RI = 0;
return temp;
}
//////////////////////////////////////////////////////////////////////////////////
void adc_convert (void)
{
DCLK=1;
CS=1; //low to high to start conversion
CS=0;
byte1=byte_read(); //msb result from adc
byte0=byte_read(); //lsb result from adc
CS=1;
num=(byte1&0x1f); //
num=((num<<8)|byte0)>>1;
val=((num*5.00)/4096)*100;
float_lcd(val);
buzz =0;
engine =1;

if((val >= 180) & (val <= 200 ))


{
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("SMALL ACCIDENT");
buzz =1;
engine =0;
RECEIVE_GPGLL(1000);
cmd_lcd(0x01);
RECEIVE_GPS();
delay_ms(500);
cmd_lcd(0x01);
display_lcd("SENDING SMS...");
SEND_STR("AT+CMGS=");
SEND_CHR('"');
//SEND_STR("8950396869");
SEND_STR("7842358459");

SEND_CHR('"');
SEND_STR("\r\n");
delay_ms(500);
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
SEND_STR("ACCIDENT VECHILE INFORMATION");
SEND_STR("\r\n");
SEND_STR("SMALL ACCIDENT");
SEND_STR("\r\n");
SEND_STR("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);SEND_STR("\r\n");
SEND_STR(" LN:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);SEND_STR("\r\n");
SEND_CHR(0x1A);SEND_STR("\r\n");
delay_ms(2000);
cmd_lcd(0x01);
display_lcd("message sent...");

}
/////////////////////////////////////////////////////////////////////////
if((val >= 200) & (val <= 600 ))
{
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("FULL ACCIDENT");
buzz =1;
engine =0;
RECEIVE_GPGLL(1000);
cmd_lcd(0x01);
RECEIVE_GPS();
delay_ms(500);
cmd_lcd(0x01);
display_lcd("SENDING SMS...");
SEND_STR("AT+CMGS=");
SEND_CHR('"');
//SEND_STR("8950396869");
SEND_STR("7842358459");
SEND_CHR('"');
SEND_STR("\r\n");
delay_ms(500);
i=1;
while((REC_BUFF[i++]!=',')||(j++<1));
j=0;
SEND_STR("ACCIDENT VECHILE INFORMATION");
SEND_STR("\r\n");
SEND_STR("FULL ACCIDENT");
SEND_STR("\r\n");
SEND_STR("LT:");
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_STR("\r\n");
SEND_STR(" LN:");
i++;j=0;
while((REC_BUFF[i]!=',')||(j++<1))
SEND_CHR(REC_BUFF[i++]);
SEND_STR("\r\n");
SEND_CHR(0x1A);
delay_ms(2000);
SEND_STR("\r\n");
cmd_lcd(0x01);
display_lcd("message sent...");

}
}
/////////////////////////////////////////////////////////////////////
unsigned char byte_read (void)
{
unsigned char i,c=0,mask=0x80;
for (i=0;i<8;i++)
{
DCLK=0;
if (SDAT==1)
c|=mask;
DCLK=1;
mask>>=1;
}
return c;
}
//////////////////////////////////////////////////////////////////////////
void SEND_STR(unsigned char *s)
{
while(*s)
SEND_CHR(*s++);
}
void SEND_CHR(unsigned char c)
{
SBUF = c;
while(TI == 0);
TI = 0;
}

//////////////////////////////////////////////////////////////////////////////////
void init_lcd(void)
{
delay_ms(10);
cmd_lcd(0x28);
cmd_lcd(0x0e);
cmd_lcd(0x06);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char c)
{
unsigned char temp;
temp=c>>4;
LCD=temp<<4|0x08;
LCD=0;
LCD=c<<4|0x08;
LCD=0;
delay_ms(2);
}
void write_lcd(unsigned char c)
{
unsigned char temp;
temp=c>>4;
LCD=temp<<4|0x0a;
LCD=0;
LCD=c<<4|0x0a;
LCD=0;
delay_ms(2);
}
void display_lcd(unsigned char *str)
{
unsigned char i=0;
while(*str)
{
if(i++==16)
cmd_lcd(0xC0);
write_lcd(*str++);
}
}
/////////////////////////////////////////////////////////////////////////////////////
void integer_lcd(int n)
{
unsigned char c[6];
unsigned int i=0;
if(n<0)
{
write_lcd('-');
n=-n;
}
if(n==0)
write_lcd('0');
while(n>0)
{
c[i++]=(n%10)+48;
n/=10;
}
while(i-->=1)
write_lcd(c[i]);
}
/////////////////////////////////////////////////////////////////////////////////////////////
///
void float_lcd(float f)
{
int n;
float temp;
n=f;
integer_lcd(n);
write_lcd('.');
temp=f-n;
if(temp>=0.00&&temp<=0.09)
write_lcd('0');
f=temp*100;
n=f;
integer_lcd(n);
}
/////////////////////////////////////////////////////////////////////
void delay_ms(unsigned int i)
{
unsigned int j;
while(i-->0)
{
for(j=0;j<500;j++)
{
;
}
}
}

REFERENCE:

Text books refered:


1.“The 8051 Microcontroller and Embedded Systems” by Muhammad
Ali Mazidi and Janice Gillispie Mazidi. Pearson Education.

2.8051 Microcontroller Architecture, programming and application by


KENNETH JAYALA

3. ATMEL 89s52 Data sheets

4. Hand book for Digital IC’s from Analogic Devices

Websites viewed:

 www.atmel.com
 www.beyondlogic.org
 www.dallassemiconductors.com
 www.maxim-ic.com

You might also like