You are on page 1of 82

HAND GESTURE DEVICE CONTROL SYSTEM

ABSTRACT

Micro electro mechanical systems (MEMS) (also written as micro-electro-mechanical,


Micro Electro Mechanical or microelectronic and micro electromechanical systems) is the
technology of very small mechanical devices driven by electricity and it merges at the nano scale
into nano electro mechanical systems (NEMS) and nanotechnology.
MEMS are separate and distinct from the hypothetical vision of molecular
nanotechnology or molecular electronics. MEMS are made up of components between 1 to 100
micro metres in size (i.e. 0.001 to 0.1 mm) and MEMS devices generally range in size from 20
micro metres (20 millionths of a meter) to a millimeter. They usually consist of a central unit that
processes data, the microprocessor and several components that interact with the outside such as
micro sensors. This MEMS works on i2c protocol and having SDA, SCL pins. Here
microcontroller acts as master and MEMS acts as a slave.
The aim of this project is to control the home appliances by using MEMS. The MEMS
will be tagged to the hand. Whenever the hand moves in a particular direction, the mechanical
movement of the hand will be recognized by MEMS. Here we consider 4 directions i.e. front,
back, left, right and stop. MEMS convert this mechanical hand movement into equivalent
electrical signals(X, Y, Z coordinates) and send it to the microcontroller. The communication
between microcontroller and MEMS takes place based on i2c protocol. In this protocol
microcontroller acts as a master and MEMS acts as a Slave. And the controller will also be
interfaced to 2 ac loads through relays. These loads will be controlled based on the signals
received by the MEMS, as per the code logic.
This project uses regulated 5V, 500mA power supply. Unregulated 12V DC is used for
relay. 7805 three terminal voltage regulator is used for voltage regulation. Full wave bridge
rectifier is used to rectify the ac output of secondary of 230/12V step down transformer.

CHAPTER - 1
BLOCK DIAGRAM:
1.1.

BLOCK DIAGRAM OF HAND GESTURE DEVICE CONTROL

MEMS

LCD
RELAY 1

RPS

AT
LOAD 1

89S52
CRYSTAL

RELAY 2

LOAD 1

POWER SUPPLY:

STEP DOWN
TRANSFORMER

BRIDGE

FILTER

REGULATOR

RECTIFIER

CIRCUIT

SECTION

1.2.

BLOCK DIAGRAM EXPLANATION

AT89S52: It is CMOS 8051 microcontroller unit which is a 40


pin dip IC. It has 256 bytes of internal ram, 8kb of in-system
flash ROM, 3 16 bit timers/counters, and 8 interrupts.

MEMS: It is a 3 axis accelerometer which identifies the


change in the twilit. Here MMA7361 sensor. It is an
analog device which generates analog signals. It operates

at

3.3V.

MCP3202: It is an ADC converter IC. It has two channels


as inputs and generates clock pulses. It is an 8 pin IC
requires +5v as supply voltage.
MAX 232: It is used for serial communication between
microcontroller and GSM modem. It converts CMOS logic
levels in to RS232 logic levels. It is bi-directional IC.

CRYSTAL OSCILLATOR: An external

crystal

oscillator is used for the completion of 2

machine

cycles. The frequency of crystal oscillator

is

11.0592MHz.

RPS: Regulated power supply is provided to constant and continuous + 5v. The
source of supply is taken from household 230v/ac and converted into +5v using
various converters.

LCD: A 16x2 Liquid crystal display unit is used to


display the text on screen. It has 16 characters per
line and 2 lines. It has font size of 5x7 matrix. It has
16 pins which divided into power supply pins, control
pins, data pins.

RELAY: It is a switching device works based on


electromagnetic principle. It has poles named as NC, COM and
NO. The movable arm (COM) is in continuity either with NC
or NO

CHAPTER II
CIRCUIT DIAGARM

2.1. CIRCUIT DIAGRAM OF HAND GESTURE DEVICE CONTROL

2.2. CIRCUIT EXPLANATION

MEMS sensor is an 3-axis accelerometer. It can easily wear on human hand. The mems sensor
changes the center of mass position and makes an intersecting point between x, y co-ordinates.
These are generated as analog signals and these signals are fed to ADC (MCP3202). The ADC
converts analog signals into digital signals. The digital signals are fed to microcontroller to the
port 1 (P1.0, P1.1, P1.2 and P1.3). The ADC gives continuous clock pulses to the microcontroller
of P1.0.
When microcontroller identifies the active high signal from Dout of ADC through P1.1, the
microcontroller gives active high output to the relay. The relays are interfaced to the P3.0, P3.1.
The buffers of driver IC takes the input from microcontroller and makes high amplified signal
and fed to relays through clamping diodes (output of driver IC) which switch the relay to get ON.
Then relay get continuity between COM (common) and NO (Normally open). The load is
connected NO of relay. Hence the load gets ON. If the direction of MEMS is changed, the
voltage level of ADC is changed and microcontroller identifies the change in the voltage levels
and gives active low signal to relay. Which in turn OFF the relay. Hence the load get OFF due to
open circuit between COM and load.

CHAPTER 1
EMBEDDED SYSTEMS
1.1 INTRODUCTION TO EMBEDDED SYSTEMS
Each day, our lives become more dependent on 'embedded systems', digital information
technology that is embedded in our environment. More than 98% of processors applied today are
in embedded systems, and are no longer visible to the customer as 'computers' in the ordinary
sense. An Embedded System is a special-purpose system in which the computer is completely
encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose
computer, such as a personal computer, an embedded system performs one or a few pre-defined
tasks, usually with very specific requirements. Since the system is dedicated to specific tasks,
design engineers can optimize it, reducing the size and cost of the product. Embedded systems
are often mass-produced, benefiting from economies of scale. The increasing use of PC hardware
is one of the most important developments in high-end embedded systems in recent years.
Hardware costs of high-end systems have dropped dramatically as a result of this trend, making
feasible some projects which previously would not have been done because of the high cost of
non-PC-based embedded hardware. But software choices for the embedded PC platform are not
nearly as attractive as the hardware.
Typically, an embedded system is housed on a single microprocessor board with the
programs stored in ROM. Virtually all appliances that have a digital interface -- watches,
microwaves, VCRs, cars -- utilize embedded systems. Some embedded systems include an
operating system, but many are so specialized that the entire logic can be implemented as a
single program.
Physically, Embedded Systems range from portable devices such as digital watches and MP3
players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants.

In terms of complexity embedded systems can range from very simple with a single
microcontroller chip, to very complex with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.
Definition of an Embedded System
Embedded system is defined as, For a particular/specific application implementing the
software code to interact directly with that particular hardware what we built. Software is used
for providing features and flexibility, Hardware = {Processors, ASICs, Memory,...} is used for
Performance (& sometimes security)
(or)
An embedded system is a special-purpose computer system designed to perform one or a
few dedicated functions, often with real-time computing constraints. It is usually embedded as
part of a complete device including hardware and mechanical parts. In contrast, a generalpurpose computer, such as a personal computer, can do many different tasks depending on
programming.
(or)
An embedded system is a single-purpose computer built into a larger system for the purposes of
controlling and monitoring the system. A specialized computer system that is part of a larger
system or machine.
There are many definitions of embedded system but all of these can be combined into a
single concept. An embedded system is a special purpose computer system that is used for
particular task.
Features of Embedded Systems
The versatility of the embedded computer system lends itself to utility in all kinds of enterprises,
from the simplification of deliverable products to a reduction in costs in their development and
manufacture. Complex systems with rich functionality employ special operating systems that

take into account major characteristics of embedded systems. Embedded operating systems have
minimized footprint and may follow real-time operating system specifics.
The special computers system is usually less powerful than general-purpose systems, although
some expectations do exist where embedded systems are very powerful and complicated.
Usually a low power consumption CPU with a limited amount of memory is used in embedded
systems. Many embedded systems use very small operating systems; most of these provide very
limited operating system capabilities.
Since the embedded system is dedicated to specific tasks, design engineers can optimize it,
reducing the size and cost of the product, or increasing the reliability and performance. Some
embedded systems are mass-produced, benefiting from economies of scale.
Some embedded systems have to operate in extreme environment conditions such as very high
temperature & humidity.
For high volume systems such as portable music players or mobile phones, minimizing cost is
usually the primary design consideration. Engineers typically select hardware that is just good
enough to implement the necessary functions.
For low volume or prototype embedded systems, general purpose computers may be adapted by
limiting the programs or by replacing the operating system with a real-time operating system.
Characteristics of Embedded Systems

Embedded computing systems generally exhibit rich functionalitycomplex functionality is


usually the reason for introducing CPUs into the design. However, they also exhibit many nonfunctional requirements that make the task especially challenging:

real-time deadlines that will cause system failure if not met;


multi-rate operation;
in many cases, low power consumption;
low manufacturing cost, which often means limited code size.
Workstation programmers often concentrate on functionality. They may consider the
performance characteristics of a few computational kernels of their software, but rarely analyze
the total application. They almost never consider power consumption and manufacturing cost.
The need to juggle all these requirements makes embedded system programming very
challenging and is the reason why embedded system designers need to understand computer
architecture.
Overview of an Embedded System Architecture
Every Embedded system consists of a custom-built hardware built around a central processing
unit. This hardware also contains memory chips onto which the software is loaded.

Application Software
Operating
System
H/W

The operating system runs above the hardware and the application software runs above the
operating system. The same architecture is applicable to any computer including desktop
computer. However these are significant differences. It is not compulsory to have an operating
system in every embedded system. For small applications such as remote control units, air
conditioners, toys etc.
Applications of Embedded Systems
Some of the most common embedded systems used in everyday life are
Small embedded controllers:

8-bit CPUs dominate, simple or no operating system


(e.g., thermostats)

Control systems:

Often use DSP chip for control computations


(e.g., automotive engine control)

Distributed embedded control: Mixture of large and small nodes on a real-time


Embedded networks
(e.g., cars, elevators, factory automation)
System on chip:

ASIC design tailored to application area


(e.g., consumer electronics, set-top boxes)

Network equipment:

Emphasis on data movement/packet flow


(e.g., network switches; telephone switches)

Critical systems:

Safety and mission critical computing


(e.g., pacemakers, automatic trains)

Signal processing:

Often use DSP chips for vision, audio, or other signal


Processing (e.g., face recognition)

Robotics:

Uses various types of embedded computing (especially

Vision and control) (e.g., autonomous vehicles)


Computer peripherals:

Disk drives, keyboards, laser printers, etc.

Wireless systems:

Wireless network-connected sensor networks and


Motes to gather and report information

Embedded PCs:

Palmtop and small form factor PCs embedded into


Equipment

Command and control:

Often huge military systems and systems of systems


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

Home Appliances, intercom, telephones, security systems, garage door openers, answering
machines, fax machines, home computers, TVs, cable TV tuner, VCR, camcorder, remote
controls, video games, cellular phones, musical instruments, sewing machines, lighting control,
paging, camera, pinball machines, toys, exercise equipment
Office Telephones, computers, security systems, fax machines, microwave, copier, laser printer,
color printer, paging
Auto Trip computer, engine control, air bag, ABS, instrumentation, security system, transmission
control, entertainment, climate control, cellular phone, keyless entry
TYPES OF EMBEDDED SYSTEMS
Based on functionality and performance embedded systems categorized as 4 types
1. Stand alone embedded systems
2. Real time embedded systems
3. Networked information appliances
4. Mobile devices

1. Stand alone embedded systems:As the name implies, stand alone systems work in stand alone mode. They take i/p, process them
and produce the desire o/p. The i/p can be an electrical signal from transducer or temperature
signal or commands from human being. The o/p can be electrical signal to drive another system
an led or lcd display
ex digital camera, microwave oven, CD player, Air conditioner etc

2. Real time embedded systems:In this type of an embedded system a specific work has to be complete in a particular period of
time.
Hard Real time systems:- embedded real time used in missiles
Soft Real time systems:- DVD players
3. Networked information appliances:Embedded systems that are provided with n/w interfaces and accessed by n/w's such as local
area n/w or internet are called Network Information Appliances
Ex A web camera is connected to the internet. Camera can send pictures in real time to any
computers connected to the internet

4. Mobile devices:Actually it is a combination of both VLSI and Embedded System


Mobile devices such as Mobile phone, Personal digital assistants, smart phones etc are special
category of embedded systems

2.2 Introduction to Microcontroller

Based on the Processor side Embedded Systems is mainly divided into 3 types
1. Micro Processor : - are for general purpose eg: our personal computer
2. Micro Controller:- are for specific applications, because of cheaper cost we will go for these
3. DSP ( Digital Signal Processor ):- are for high and sensitive application purpose

MICROCONTROLLER VERSUS MICROPROCESSOR


A system designer using a general-purpose microprocessor such as the Pentium or the 68040
must add RAM, ROM, I/O ports, and timers externally to make them functional. Although the
addition of external RAM, ROM, and I/O ports makes these systems bulkier and much more
expensive, they have the advantage of versatility such that the designer can decide on the amount
of RAM, ROM and I/O ports needed to fit the task at hand.
A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM,
ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the RAM, ROM,
I/O ports and the timer are all embedded together on one chip; therefore, the designer cannot add
any external memory, I/O ports, or timer to it. The fixed amount of on-chip ROM, RAM, and
number of I/O ports in Microcontrollers makes them ideal for many applications in which cost
and space are critical.

CPU platform:
Embedded processors can be broken into two distinct categories: microprocessors (P) and
microcontrollers (C). Microcontrollers have built-in peripherals on the chip, reducing size of
the system.
There are many different CPU architectures used in embedded designs such as ARM, MIPS,
Coldfire/68k, PowerPC, x86, PIC, 8051, Atmel AVR, Renesas H8, SH, V850, FR-V, M32R,
Z80, Z8, etc. This in contrast to the desktop computer market, which is currently limited to just a
few competing architectures.
PC/104 and PC/104+ are a typical base for small, low-volume embedded and ruggedized system
design. These often use DOS, Linux, NetBSD, or an embedded real-time operating system such
as QNX or VxWorks.
A common configuration for very-high-volume embedded systems is the system on a chip (SoC),
an application-specific integrated circuit (ASIC), for which the CPU core was purchased and
added as part of the chip design. A related scheme is to use a field-programmable gate array
(FPGA), and program it with all the logic, including the CPU.

Embedded systems are based on the concept of the microcontroller, a single integrated circuit
that contains all the technology required to run an application. Microcontrollers make integrated
systems possible by combining several features together into what is effectively a complete
computer on a chip, including:
* Central Processing Unit
* Input/Output interfaces (such as serial ports)
* Peripherals (such as timers)
* ROM, EEPROM or Flash memory for program storage
* RAM for data storage
* Clock generator
By integrating all of these features into a single chip it is possible to greatly reduce the number of
chips and wiring necessary to control an electronic device, dramatically reducing its complexity,
size and cost.
* Size & Weight: Microcontrollers are designed to deliver maximum performance for minimum
size and weight. A centralized on-board computer system would greatly outweigh a collection of
microcontrollers.
* Efficiency: Microcontrollers are designed to perform repeated functions for long periods of
time without failing or requiring service.
MICRO CONTROLLER: is a chip through which we can connect many other devices and
also those are controlled by the program the program which burn into that chip

INTRODUCTION TO 8051
Intel Corporation introduced an 8 bit micro controller called the 8051 in 1981. While the time of
introduction, Intel was given some specific features and particular name as

MCS-51

Features:ROM ---- 4 K bytes of Memory


RAM ----- 128 bytes
Timers------2
4 ports --- 32 I/O ports ( each 8 bit wide )
Interrupts-----6
serial port-----1
all on a single chip
Many semiconductor manufacturers started either manufacturing the 8051 devices as such (Intel
was liberal in giving away license to whoever asked) or developing a new kind of
microcontrollers based on 8051 core architecture. Manufacturers modified the basic 8051
architecture and added many new peripheral functions to make them attractive to the designers.
After that so many industries are come into picture to introduce 8051 again wit some extra
features. This has led to many versions of the 8051 with different speeds and amounts of on-chip
ROM marketed by more manufactures those are
Dallas ------ DS4700
Zilog---------Z
Motrolla
Freescale
Atmel ------- AT89C51/52, AT89S51/52
Phillips ----- P89C51RD2Fn
Before these industries came into picture 8051 chips are made with CMOs technology. ATmel
was introduced with ISP (In System Programming)

IN SYSTEM PROGRAMMING (ISP):In-System Programming (ISP) is the ability of some programmable logic devices,
microcontrollers, and other programmable electronic chips to be programmed while installed in a
complete system, rather than requiring the chip to be programmed prior to installing it into the
system. (or) In-system programming is a valuable feature that allows system firmware to be
upgraded without disassembling the embedded system to physically replace memory. Most
Maxim 8051-based microcontrollers can be reprogrammed from a PC or laptop via an
inexpensive RS-232 serial interface and a few logic gates
The primary advantage of this feature is that it allows manufacturers of electronic devices to
integrate programming and testing into a single production phase, rather than requiring a separate
programming stage prior to assembling the system. This may allow manufacturers to program
the chips in their own system's production line instead of buying preprogrammed chips from a
manufacturer or distributor, making it feasible to apply code or design changes in the middle of a
production run.

2.3 AT89S52 MICROCONTROLLER


The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of
in-system programmable Flash memory. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction
set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or
by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with insystem 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.

8051 PIN DIAGRAM

AT89S52 Architecture consists of these specific features:


8 bit CPU with registers A (Accumulator) and B
16 bit Program Counter(PC) and Data Pointer (DPTR)
8 bit Program Status Word (PSW)
8 bit Stack Pointer (SP)
Internal ROM of 8k
Internal RAM of 128 bytes

Four Register banks each containing eight registers

Sixteen bytes, which may be addressed at the bit level

Eighty bytes of general purpose data memory

32 I/O pins arranged as four 8-bit ports: P0,P1,P2,P3


Two 16-bit Timers/Counters: T0 and T1
Full duplex serial data Receiver/Transmitter : SBUF
Control Registers: TCON, TMOD, SCON, SMOD, PCON, IP and IE.
Two external and three internal interrupt sources.
Oscillator and Clock circuits.
Pin Description
Pin ( 32 39 ) Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open drain output
port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that
state will function as high impedance inputs. Port 0 is also the multiplexed low-order address and
data bus during accesses to external memory. In this application it uses strong internal pull ups
when emitting 1s. Port 0 emits code bytes during program verification. In this application,
external pull ups are required.
Pin ( 1- 8 ) Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull ups. Port 1 pins that
have 1s written to them are pulled high by the internal pull ups, and in that state can be used as
inputs. As inputs, port 1 pins that are externally being pulled low will source current because of
the internal pull ups.
Alternate Functions of Port 1 used for In system Programmable
P.5

MOSI --------- Instruction Input

P.6

MISO ---------- Data Output

P.7

SCK ----------- Clk in

Pin ( 21 28 ) Port 2:

Port 2 is an 8-bit bidirectional I/O port with internal pull ups. Port 2

emits the high-order address byte during accesses to external memory that use 16-bit addresses.
In this application, it uses the strong internal pull ups when emitting 1s.
Pin (10 17) Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull ups. It also serves
the functions of various special features of the 80C51 Family as follows:
Port Pin Alternate Function
P3.0- RxD (serial input port)
P3.1 -TxD (serial output port)
P3.2 -INT0 (external interrupt 0)
P3.3- INT1 (external interrupt 1)
P3.4 -T0 (timer 0 external input)
P3.5 -T1 (timer 1 external input)
P3.6 -WR (external data memory write strobe)
P3.7 -RD (external data memory read strobe)
Pin 40 VCC: -Supply voltage
Pin 20 VSS: -Circuit ground potential
Pin 29 PSEN: Program Store Enable is the read strobe to external Program Memory. When the
device is executing out of external Program Memory, PSEN is activated twice each machine
cycle (except that two PSEN activations are skipped during accesses to external Data Memory).
PSEN is not activated when the device is executing out of internal Program Memory.

Pin 30 ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator
frequency, for external timing or clocking purposes, even when there are no accesses to external
memory. (However, one ALE pulse is skipped during each access to external Data Memory.)
This pin is also the program pulse input (PROG) during EPROM programming.
Pin 31 EA/VPP: When EA is held high the CPU executes out of internal Program Memory.
Holding EA low forces the CPU to execute out of external memory regardless of the Program
Counter value. In the 80C31, EA must be externally wired low. In the EPROM devices, this pin
also receives the programming supply voltage (VPP) during EPROM programming.
Pin 18 XTAL1: Input to the inverting oscillator amplifier.
Pin 19 XTAL2: Output from the inverting oscillator amplifier.
REGISTERS
8051 is a collection of 8 and 16 bit registers and 8 bit memory locations. These registers and
memory locations can be made to operate using the software instructions. The program
instructions control the registers and digital data paths that are contained inside the 8051, as well
as memory locations that are located outside the 8051.
Register are used to store information temporarily, while the information could be a byte of data
to be processed, or an address pointing to the data to be fetched. The vast majority of 8051
register are 8-bit registers.
Generally there are two types of registers. They are General purpose Registers (GPRs) and
Special Function Registers (SFRs)
General Purpose Register

The 8 bits of a register are shown from MSB D7 to the LSB D0. With an 8-bit data type, any data
larger than 8 bits must be broken into 8-bit chunks before it is processed.

The most widely used registers


A (Accumulator)
For all arithmetic and logic instructions
B, R0, R1, R2, R3, R4, R5, R6, R7
DPTR (data pointer), and PC (program counter)

16 bit General Purpose Register are Data Pointer (DPTR) and Program Counter (PC)
The program counter points to the address of the next instruction to be executed. DPTR. As the
name suggests, is used to point the data. It is used by a number of commands which allows the
microcontroller to access external memory. When the microcontroller access external memory it
will access at the address indicated by DPTR.

There are 128 bytes of RAM in the 8051


The 128 bytes are divided into three different groups as follows:
1) A total of 32 bytes from locations 00 to 1F hex are set aside for register banks and the stack
2) A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable read/write
memory
3) A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called
scratch pad

Special Function Registers


The program status word (PSW)
PSW register, also referred to as the flag register, is an 8 bit register Only 6 bits are used These
four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow)
They are called conditional flags, meaning that they indicate some conditions that resulted after
an instruction was executed. The PSW3 and PSW4 are designed as RS0 and RS1, and are used to
change the bank. The two unused bits are user-definable

2.4 Timer/Counters

The Atmel 80C51 Microcontrollers implement two general purpose, 16-bit timers/ counters.
They can be used either as timers to generate a time delay or as a counter to count events
happening outside the microcontroller. The microcontroller has two 16-bit wide timers. They are
identified as Timer 0 and Timer 1, and can be independently configured to operate in a variety of
modes as a timer or as an event counter. When operating as a timer, the timer/counter runs for a
programmed length of time, then issues an interrupt request. When operating as a counter, the
timer/counter counts negative transitions on an external pin. After a preset number of counts, the
counter issues an interrupt request. Register pairs (TH0, TL0), (TH1, TL1), and (TH2, TL2) are
the 16-bit counting registers for Timer/Counters 0, 1, and 2, respectively.
Timer 0 Register
The 16-bit register of Timer 0 is accessed as low byte and high byte. The low byte register is
called TL0 (Timer 0 low byte) and high byte register is referred to as TH0 (Timer 0 high byte).
These registers can be accessed like any other register, such as A,B,R0,R1,R2,etc.
Timer 1 Register
Timer 1 is also 16-bits, and its 16-bit register is split into two bytes, referred to as TL1 ( Timer 1
low byte ) and TH1 ( Timer 1 high byte ). These registers are accessible in the same way as the
registers of timer 0.
TMOD Register (timer mode)
TMOD: Timer/Counter Mode Control Register.
Not Bit Addressable.

Timer 1
GATE

Timer 0
When TRx (in TCON) is set and GATE=1, Timer/CounterX will run only
while INTx pin is high (hardware control). When GATE=0, Timer/Counter
will run only while TRx=1 (software control).

C/T

Timer or Counter selector. Cleared for Timer operation (input from


internal system clock). Set for Counter operation

(input from TX input

pin).
M1

Mode selector bit.

M0

Mode selector bit.

M1

M0

Mode

Operating Mode

13-bit Timer (8048 compatible) (TH1)

16-bit Timer/Counter

8-bit Auto-Reload Timer/Counter (TL1).


Reloaded from TH1 at overflow.

timer 1 halted. Retains count.

(Timer 1) Timer/Counter 1 stopped.

TCON: Timer/Counter Control Register


Bit Addressable.

The upper four

The lower 4 bits

bits are used to

are set aside for

store the TF and

controlling the

TR bits of both

TF1

Timer1 overflow flag. Set by hardware when the Timer/Counter 1 overflows.


Cleared by hardware as processor vectors to the interrupt service routine.

TR1

Timer 1 run control bit. Set/cleared by software to turn Timer/Counter 1


ON/OFF.

TF0

Timer0 overflow flag. Set by hardware when the Timer/Counter 0

overflows.

Cleared by hardware as processor vectors to the service routine.


TR0

Timer 0 run control bit. Set/cleared by software to turn Timer/Counter 0


ON/OFF.

IE1

External Interrupt 1 edge flag. Set by hardware when External terrupt edge is
detected. Cleared by hardware when interrupt is processed.

IT1

Interrupt 1 type control bit. Set/cleared by software to specify falling edge/low


level triggered External Interrupt.

IE0

External Interrupt 0 edge flag. Set by hardware when External Interrupt edge
is detected. Cleared by hardware when interrupt is processed.

IT0

Interrupt 0-type control bit. Set/cleared by software to specify falling edge/low


level triggered External Interrupt.

2.5 SERIAL COMMUNICATION

The 8051 serial port is full duplex. In other words, it can transmit and receive data at the same
time. Unlike any other register in the 8051, SBUF is in fact two distinct registers - the write-only
register and the read-only register. Transmitted data is sent out from the write-only register while
received data is stored in the read-only register. There are two separate data lines, one for
transmission (TXD) and one for reception (RXD). Therefore, the serial port can be transmitting data
down the TXD line while it is at the same time receiving data on the RXD line. The TXD line is pin
11 of the microcontroller (P3.1) while the RXD line is on pin 10 (P3.0)

Serial data communication uses two methods, asynchronous and synchronous. The synchronous
method transfers a block of data (characters) at a time, while the asynchronous method transfers a
single byte at a time. It is possible to write software to use either of these methods, but the programs
can be tedious and long. For this reason, there are special IC chips made by many manufacturers for
serial data communications. These chips can be commonly referred to as UART (Universal
Asynchronous Receiver-transmitter) and USART

( Universal Synchronous

Asynchronous Receiver-Transmitter). The 8051 chip has a built-in UART.

Asynchronous Serial Communication and Data Framing


Start Bits and Stop Bits
In the asynchronous method is character is placed between start and stop bits, this is called data
framing. In asynchronous communication, at least two extra bits are transmitted with the data word;
a start bit and a stop bit. Therefore, if the transmitter is using an 8-bit system, the actual number of
bits transmitted per word is ten. In most protocols the start bit is a logic 0 while the stop bit is logic
1. Therefore, when no data is being sent the data line is continuously HIGH. The receiver waits for
a 1 to 0 transition. In other words, it awaits a transition from the stop bit (no data) to the start bit
(logic 0). Once this transition occurs the receiver knows a data byte will follow. Since it knows the
data rate (because it is defined in the protocol) it uses the same clock as frequency as that used by the
transmitter and reads the correct number of bits and stores them in a register. For example, if the
protocol determines the word size as eight bits, once the receiver sees a start bit it reads the next
eight bits and places them in a buffer. Once the data word has been read the receiver checks to see if
the next bit is a stop bit, signifying the end of the data. If the next bit is not a logic 1 then something
went wrong with the transmission and the receiver dumps the data. If the stop bit was received the
receiver waits for the next data word, ie; it waits for a 1 to 0 transition.

Goes out first

Baud Rates in the 8051

11.0592
MHz

XTAL
oscillat
or

Machine
cycle
12 frequency
921.6
kHz

28800
Hz
Timer 1
By UART To timer 1
To set the
Baud rate

32

XTAL = 11.0592 MHz:


The frequency of system clock = 11.0592 MHz / 12 = 921.6 kHz
The frequency sent to timer 1 = 921.6 kHz/ 32 = 28,800 Hz
(a) 28,800 / 3 = 9600

where -3 = FD (hex) is loaded into TH1

(b) 28,800 / 12 = 2400 where -12 = F4 (hex) is loaded into TH1


(c) 28,800 / 24 = 1200 where -24 = E8 (hex) is loaded into TH1

SBUF
SBUF is an 8-bit register used solely for serial communication in the 8051. For a byte of data to
be transferred via the TxD line, it must be placed in the SBUF register. Similarly, SBUF holds
the byte of data when it is received by the 8051s RxD line. SBUF can be accessed like any other
register in the 8051.
The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred
serially via the TxD pin. Similarly, when the bits are received serially via RxD, the 8051
deframes it by eliminating the stop and start bits, making a byte out of the data received, and then
placing it in the SBUF.

DATA TRANSMISSION: Transmission of serial data bits begins anytime data is written to sbuf. " TI " (SCON) set
to 1 when data has been transmitted and signifies that " SBUF " is empty and that another data
byte can be sent.
DATA RECEPTION: Reception of serial data will begin if the receive enable bit (REN) in SCON is set to ' 1 '
for all modes. For mode ' 0 ' only RI must be cleared to 0. Receiver interrupt flag ' RI ' (in
SCON) is set after data has been received in all modes. Setting of ' REN ' bit is a direct program
control that limits the reception of unexpected data.

SCON ( Serial Control ) Register

SM0

SM1

SM2

REN

TB8

RB8

TI

RI

Mode 0: Serial data enters and exits through RxD. TxD outputs the shift clock. 8 bits are
transmitted/received (LSB first). The baud rate is fixed at 1/12 the oscillator frequency.
Mode 1: 10 bits are transmitted (through TxD) or received (through RxD): a start bit (0), 8 data
bits (LSB first), and a stop bit (1). On receive, the stop bit goes into RB8 in Special Function
Register SCON. The baud rate is variable.
Mode 2: 11 bits are transmitted (through TxD) or received (through RxD): start bit (0), 8 data
bits (LSB first), a programmable 9th data bit, and a stop bit (1). On Transmit, the 9th data bit
(TB8 in SCON) can be assigned the value of 0 or 1. Or, for example, the parity bit (P, in the
PSW) could be moved into TB8. On receive, the 9th data bit goes into RB8 in Special Function
Register SCON, while the stop bit is ignored. The baud rate is programmable to either 1/32 or
1/64 the oscillator frequency.

Mode 3: 11 bits are transmitted (through TxD) or received (through RxD): a start bit (0), 8 data
bits (LSB first), a programmable 9th data bit, and a stop bit (1). In fact, Mode 3 is the same as
Mode 2 in all respects except baud rate. The baud rate in Mode 3 is variable. In all four modes,
transmission is initiated by any instruction that uses SBUF as a destination register. Reception is
initiated in Mode 0 by the condition RI = 0 and REN = 1. Reception is initiated in the other
modes by the incoming start bit if REN = 1.
SM2 Enables the multiprocessor communication feature in Modes 2 and 3. In Mode 2 or 3, if
SM2 is set to 1, then Rl will not be activated if the received 9th data bit (RB8) is 0. In Mode 1, if
SM2=1 then RI will not be activated if a valid stop bit was not received. In Mode 0, SM2 should
be 0.

REN Enables serial reception. Set by software to enable reception. Clear by software to disable
reception.
TB8 The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by software as
desired.
RB8 In Modes 2 and 3, is the 9th data bit that was received. In Mode 1, it SM2=0, RB8 is the
stop bit that was received. In Mode 0, RB8 is not used.
TI (Transmit Interrupt)
This is an extremely important flag bit in the SCON register. When the 8051 finishes the transfer
of the 8-bit character it raises the TI flag to indicate that it is ready to transfer another byte. The
TI bit is raised at the beginning of the stop bit.

RI ( Receive Interrupt)
This is an extremely important flag bit in the SCON register. When the 8051 receives data
serially via RxD, it gets rid of the start and stop bits and places the byte in the SBUF register.

Then it raises the RI flag bit to indicate that a byte has been received and chould be picked up
before it is lost.

INTERRUPTS
An interrupt is a special feature which allows the 8051 to provide the illusion of "multi-tasking,"
although in reality the 8051 is only doing one thing at a time. The word "interrupt" can often be
substituted with the word "event."
An interrupt is triggered whenever a corresponding event occurs. When the event occurs, the
8051 temporarily puts "on hold" the normal execution of the program and executes a special
section of code referred to as an interrupt handler. The interrupt handler performs whatever
special functions are required to handle the event and then returns control to the 8051 at which
point program execution continues as if it had never been interrupted.
Interrupt Service Routine
For every interrupt, there must be an interrupt service routine (ISR). Or interrupt handler. When
an interrupt is invoked, the microcontroller runs the interrupt service routine. For every interrupt,
there is a fixed location in memory that holds the address of its ISR. The group of memory
locations set aside to hold the addresses of the ISRs is called interrupt vector table.

Six Interrupts in 8051


1. Reset : When the reset pin is activated, the 8051 jumps to address location 0000
2. Two interrupts are set aside for the timers: one for the Timer 0 and one for Timer1.
3. Two interrupts are set aside for hardware external interrupts : one for INT0 and one for
INT1
4. Serial communication has a single interrupt that belongs to both receive and transmit.
Enabling Interrupt (IE) Register
All interrupt are disabled after reset

We can enable and disable them bye IE


EA

--

EA

ET2

IE.7

ES

ET1

EX1

ET0

EX0

If EA=0, disables all interrupts, no interrupt is acknowledged


If EA=1, each interrupt source is individually enabled or disabled by
setting or clearing its enable bit.

--

IE.6

Not implemented, reserved for future use.

ET2

IE.5

Enables or disables Timer2 overflow or capture interrupt


(8052 only)

ES

IE.4

Enables or disables the serial port interrupt.

ET1

IE.3

Enables or disables Timer 1 overflow interrupt.

EX1

IE.2

Enables or disables external interrupt 1.

ET0

IE.1

Enables or disables Timer 0 overflow interrupt.

EX0

IE.0

Enables or disables external interrupt 0.

Interrupt Priority (IP) Register


0= lower priority, 1= higher priority, reset IP=00H
Lower priority ISR can be interrupted by a high priority interrupt.
A high priority ISR can not be interrupted.
Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt.

--

--

PT2

PS

PT1

PX1

PT0

PX0

--

IP.7

Reserved

--

IP.6

Reserved

PT2

IP.5

Timer2 interrupt priority bit (8052 only)

PS

IP.4

serial port interrupt priority bit.

PT1

IP.3

Timer 1 interrupt priority bit.

PX1

IP.2

external interrupt 1 priority bit.

PT0

IP.1

Timer 0 interrupt priority bit.

PX0

IP.0

external interrupt 0 priority bit.

CRYSTAL OSCILLATOR
The 8051 uses the crystal for precisely that: to synchronize its operation. Effectively, the 8051
operates using what are called "machine cycles." A single machine cycle is the minimum amount
of time in which a single 8051 instruction can be executed. although many instructions take
multiple cycles. 8051 has an on-chip oscillator. It needs an external crystal that decides the
operating frequency of the 8051. The crystal is connected to pins 18 and 19 with stabilizing
capacitors. 12 MHz (11.059MHz) crystal is often used and the capacitance ranges from 20pF to
40pF.
A cycle is, in reality, 12 pulses of the crystal. That is to say, if an instruction takes one machine
cycle to execute, it will take 12 pulses of the crystal to execute. Since we know the we can
calculate how many instruction cycles the 8051 can execute per second:
11,059,000 / 12 = 921,583
11.0592 MHz crystals are often used because it can be divided to give you exact clock rates for
most of the common baud rates for the UART, especially for the higher speeds (9600, 19200).

RESET
RESET is an active High input When RESET is set to High, 8051 goes back to the power on
state.The 8051 is reset by holding the RST high for at least two machine cycles and then
returning it low. Initially charging of capacitor makes RST High, When capacitor charges fully it
blocks DC.

SIP RESISTOR
SIP Resistor is a single in pack Resistor (i.e.,) 8 resistors connected in series. Basically SIP
resistor is a 9 pin connector first pin is for power supply to the entire 8 resistors in SIP.
Generally SIP Resistor is used to close the open drain connections of Port 0.

BASIC REQUIRMENT
The following are the basic five requirements of microcontroller
1. Power Supply
2. Crystal Oscillator
3. Reset
4. SIP Resistor
5. Resistor for EA Pin
1. REGULATED POWER SUPPLY

In mains-supplied electronic systems the AC input voltage must be converted into a DC voltage
with the right value and degree of stabilization. The common DC voltages that are required to
power up the devices are generally in the range of 3 VDC to 30 VDC. Typically the fixed types
of DC voltages are 5V, 9V, 12V, 15V and 18V DC.
POWER SUPPLY MODULES:

STEP DOWN TRANSFORMER

BRIDGE RECTIFIER WITH FILTER

VOLTAGE REGULATORS

BLOCK DIAGRAM OF REGULATED POWER SUPPLY

TRANSFORMER
Transformers convert AC electricity from one voltage to another with little loss of power.
Transformers work only with AC and this is one of the reasons why mains electricity is AC.
Step-up transformers increase voltage, step-down transformers reduce voltage.
A step down power transformer is used to step down the AC voltage from the line voltage
of 110 VAC or 220 VAC i.e, it converts higher voltage at the input side to a lower voltage at the
output.

RECTIFIER
There are several ways of connecting diodes to make a rectifier to convert AC to DC. The
bridge rectifier is the most important and it produces full-wave varying DC

Bridge rectifier
Alternate pairs of diodes conduct, changing over

Output: full-wave varying DC


(using all the AC wave)

the connections so the alternating directions of


AC are converted to the one direction of DC.
FILTER
Filtering is performed by a large value electrolytic capacitor connected across the DC supply to
act as a reservoir, supplying current to the output when the varying DC voltage from the
rectifier is falling. The diagram shows the unfiltered varying DC (dotted line) and the
filtered DC (solid line). The capacitor charges quickly near the peak of the varying DC,
and then discharges as it supplies current to the output.
Typically 1000 f capacitor is used

REGULATOR
This is a simple DC regulated supply project using 7805 voltage regulator to obtain a variable
DC voltage range from 5V to 15V

Pin out of the 7805 regulator IC.


1. Unregulated voltage in
2. Ground
3. Regulated voltage out

If you need other voltages than +5V, you can modify the circuit by replacing the 7805 chips with
another regulator with different output voltage from regulator 78xx chip family. The last numbers
in the the chip code tells the output voltage. Remember that the input voltage must be at least 3V
greater than regulator output voltage ot otherwise the regulator does not work well.
POWER SUPPLY INTERFACE WITH MICROCONTROLLER

The power supply consists of a 9-0-9 step down transformer. A bridge rectifier is used to rectify
and convert AC to DC. A 1000uF capacitor is used to filter the ripples and the output is
connected to 7805 voltage regulator. This comprises the power supply for the entire circuit. Vcc
is connected to Pin 40 the power supply of microcontroller.

CHAPTER 3
HARDWARE IMPLEMENTATION
MEMS
Microelectromechanical systems (mems) is the technology of the very small, and merges
at the nano-scale into nano- electromechanical systems (nems) and nanotechnology. Mems are
also referred to as micro-machines or micro systems technology - mst. Mems are made up of
components between 1 to 100 micro-meters in size and mems devices generally range in size
from 20 micrometers to a millimeter. They usually consist of a central unit that processes data,

the microprocessor and several components that interact with the outside such as micro sensors.
Due to mems large surface area to volume ratio, surface effects such as electrostatics and wetting
dominate volume effects such as inertia or thermal mass.
This property is used to detect any motion or change in acceleration due to gravity or
simply called g force. The courier transport system needs to be secured and at the same time,
should be cargo protective such that they dont get damaged during freight due to physical
shocks. The present project deals with designing an activation system for the protection of such
cargo by checking the change in g force. If motion or change is detected the protection system is
activated.
The system uses a compact circuitry build around flash version of at89s52
microcontroller with a non volatile memory
Programs are developed using embedded c, compiled using ride tool. Isp is used to dump
the code into microcontroller.

Micro machined Accelerometer (MEMS)

Features

Selectable Sensitivity (1.5g/2g/4g/6g)

Low Current Consumption: 500 A

Sleep Mode: 3 A

Low Voltage Operation: 2.2 V 3.6 V

6mm x 6mm x 1.45mm QFN

High Sensitivity (800 mV/g @ 1.5g)

Fast Turn On Time

Integral Signal Conditioning with Low Pass Filter

Robust Design, High Shocks Survivability

Pb-Free Terminations

Environmentally Preferred Package

Low Cost

INTRODUCTION TO MEMS
Micro electromechanical systems (MEMS) is the technology of the very small and
miniature systems and merges at the nano-scale into nano electromechanical systems (NEMS)
and nanotechnology. MEMS are made up of components between 1 to 100 micrometers in size
(i.e. 0.001 to 0.1 mm) and MEMS devices generally range in size from 20 micrometers (20
millionths of a meter) to a millimeter. They usually consist of a central unit that processes data,
the microprocessor and several components that interact with the outside such as micro sensors.
At these size scales, the standard constructs of classical physics are not always useful. Due to

MEMS' large surface area to volume ratio, surface effects such as electrostatics and wetting
dominate volume effects such as inertia or thermal mass.
Micro-Electro-Mechanical Systems (MEMS) is the integration of mechanical elements,
sensors, actuators, and electronics on a common silicon substrate through micro fabrication
technology. While the electronics are fabricated using integrated circuit (IC) process sequences
(e.g., CMOS, Bipolar, or BICMOS processes), the micromechanical components are fabricated
using compatible "micromachining" processes that selectively etch away parts of the silicon
wafer or add new structural layers to form the mechanical and electromechanical devices.
MEMS promises to revolutionize nearly every product category by bringing together
silicon-based microelectronics with micromachining technology, making possible the realization
of complete systems-on-a-chip. MEMS is an enabling technology allowing the development of
smart products, augmenting the computational ability of microelectronics with the perception
and control capabilities of micro sensors and micro actuators and expanding the space of possible
designs and applications.
Microelectronic integrated circuits can be thought of as the "brains" of a system and
MEMS augments this decision-making capability with "eyes" and "arms", to allow
Microsystems to sense and control the environment. Sensors gather information from the
environment through measuring mechanical, thermal, biological, chemical, optical, and magnetic
phenomena. The electronics then process the information derived from the sensors and through
some decision making capability direct the actuators to respond by moving, positioning,
regulating, pumping, and filtering, thereby controlling the environment for some desired
outcome or purpose. Because MEMS devices are manufactured using batch fabrication
techniques similar to those used for integrated circuits, unprecedented levels of functionality,
reliability, and sophistication can be placed on a small silicon chip at a relatively low cost.
APPLICATIONS
There are numerous possible applications for MEMS and Nanotechnology. As a
breakthrough technology, allowing unparalleled synergy between previously unrelated fields
such as biology and microelectronics, many new MEMS and Nanotechnology applications will

emerge, expanding beyond that which is currently identified or known. Here are a few
applications of current interest:
Biotechnology
MEMS and Nanotechnology is enabling new discoveries in science and engineering such
as the Polymerase Chain Reaction (PCR) Microsystems for DNA amplification and
identification, micro machined Scanning Tunneling Microscopes (STMs), biochips for detection
of hazardous chemical and biological agents, and Microsystems for high-throughput drug
screening and selection.
Communications
High frequency circuits will benefit considerably from the advent of the RF-MEMS technology.
Electrical components such as inductors and tunable capacitors can be improved
significantly compared to their integrated counterparts if they are made using MEMS and
Nanotechnology. With the integration of such components, the performance of
communication circuits will improve, while the total circuit area, power consumption and
cost will be reduced. In addition, the mechanical switch, as developed by several research
groups, is a key component with huge potential in various microwave circuits. The
demonstrated samples of mechanical switches have quality factors much higher than
anything previously available.
Reliability and packaging of RF-MEMS components seem to be the two critical issues
that need to be solved before they receive wider acceptance by the market.
Accelerometers
MEMS accelerometers are quickly replacing conventional accelerometers for crash airbag deployment systems in automobiles. The conventional approach uses several bulky
accelerometers made of discrete components mounted in the front of the car with separate
electronics near the air-bag. MEMS and Nanotechnology has made it possible to integrate the
accelerometer and electronics onto a single silicon chip at a 5-10 times lower cost. These MEMS
accelerometers are much smaller, more functional, lighter, more reliable, and are produced for a
fraction of the cost of the conventional macro scale accelerometer elements.

A/D CONVERTER
An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device which converts
continuous signals to discrete digital numbers. The reverse operation is performed by a digitalto-analog converter (DAC).Typically, an ADC is an electronic device that converts an input
analog voltage (or current) to a digital number proportional to the magnitude of the voltage or
current. However, some non-electronic or only partially electronic devices, such as rotary
encoders, can also be considered ADCs.
RESOLUTION
The resolution of the converter indicates the number of discrete values it can produce over the
range of analog values. The values are usually stored electronically in binary form, so the
resolution is usually expressed in bits. In consequence, the number of discrete values available,
or "levels", is usually a power of two. For example, an ADC with a resolution of 8 bits can
encode an analog input to one in 256 different levels, since 28 = 256. The values can represent
the ranges from 0 to 255 (i.e. unsigned integer) or from -128 to 127 (i.e. signed integer),
depending on the application.

ACCURACY
An ADC has several sources of errors. Quantization error and (assuming the ADC is intended to
be linear) non-linearity is intrinsic to any analog-to-digital conversion. There is also a so-called
aperture error which is due to a clock jitter and is revealed when digitizing a time-variant signal
(not a constant value).
These errors are measured in a unit called the LSB, which is an abbreviation for least significant
bit. In the above example of an eight-bit ADC, an error of one LSB is 1/256 of the full signal
range, or about 0.4%.

QUANTIZATION ERROR
Quantization error is due to the finite resolution of the ADC, and is an unavoidable imperfection
in all types of ADC. The magnitude of the quantization error at the sampling instant is between
zero and half of one LSB.
In the general case, the original signal is much larger than one LSB. When this happens, the
quantization error is not correlated with the signal, and has a uniform distribution. Its RMS value
is the standard deviation of this distribution, given by

. In the eight-bit

ADC example, this represents 0.113% of the full signal range.


At lower levels the quantizing error becomes dependent of the input signal, resulting in
distortion. This distortion is created after the anti-aliasing filter, and if these distortions are above
1/2 the sample rate they will alias back into the audio band. In order to make the quantizing error
independent of the input signal, noise with an amplitude of 1 quantization step is added to the
signal. This slightly reduces signal to noise ratio, but completely eliminates the distortion. It is
known as dither.

SAMPLING RATE
The analog signal is continuous in time and it is necessary to convert this to a flow of digital
values. It is therefore required to define the rate at which new digital values are sampled from the
analog signal. The rate of new values is called the sampling rate or sampling frequency of the
converter.
A continuously varying band limited signal can be sampled (that is, the signal values at intervals
of time T, the sampling time, are measured and stored) and then the original signal can be exactly
reproduced from the discrete-time values by an interpolation formula. The accuracy is limited by
quantization error. However, this faithful reproduction is only possible if the sampling rate is

higher than twice the highest frequency of the signal. This is essentially what is embodied in the
Shannon- Nyquist sampling theorem.
Since a practical ADC cannot make an instantaneous conversion, the input value must
necessarily be held constant during the time that the converter performs a conversion (called the
conversion time). An input circuit called a sample and hold performs this taskin most cases by
using a capacitor to store the analog voltage at the input, and using an electronic switch or gate to
disconnect the capacitor from the input. Many ADC integrated circuits include the sample and
hold subsystem internally.
MMA7260 (MEMS Sensor)
The device consists of two surface micro
machined capacitive sensing cells (g-cell) and a
signal conditioning ASIC contained in a single
integrated

circuit

package.

The

sensing

elements are sealed hermetically at the wafer


level using a bulk micro machined cap wafer.
The g-cell is a mechanical structure formed
from semiconductor materials (poly silicon)
using semiconductor processes (masking and
etching). It can be modeled as a set of beams attached to a movable central mass that move
between fixed beams. The movable beams can be deflected from their rest position by subjecting
the system to acceleration.
As the beams attached to the central mass move, the distance from them to the fixed beams on
one side will increase by the same amount that the distance to the fixed beams on the other side
decreases. The change in distance is a measure of acceleration. The g-cell beams form two backto-back capacitors. As the center beam moves with acceleration, the distance between the beams
changes and each capacitor's value will change, (C = A/D). Where A is the area of the beam, is
the dielectric constant, and D is the distance between the beams. The ASIC uses switched
capacitor techniques to measure the g-cell capacitors and extract the acceleration data from the
difference between the two capacitors. The ASIC also signal conditions and filters (switched

capacitor) the signal, providing a high level output voltage that is ratio metric and proportional to
acceleration.

MCP3202 (ADC)
Description
The Microchip Technology Inc. MCP3204/3202 devices are successive approximation 12-bit
Analog to Digital (A/D) Converters with on-board sample and hold circuitry. The MCP3204 is
programmable to provide two pseudo-differential input pairs or four single ended inputs. The
MCP3202 is programmable to provide four pseudo-differential input pairs or eight single ended
inputs. Differential Nonlinearity (DNL) is specified at 1 LSB, while Integral Nonlinearity (INL)
is offered in 1 LSB (MCP3204/3202-B) and 2 LSB (MCP3204/3202-C) versions.

Communication with the devices is accomplished using a simple serial interface compatible with
the SPI protocol. The devices are capable of conversion rates of up to 100 ksps. The
MCP3204/3202 devices operate over a broad voltage range (2.7V - 5.5V). Low current design
permits operation with typical standby and active currents of only 500 nA and 320 A,
respectively.

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

Relays are usuallly SPDT or DPDT but they can have many more sets of switch contacts, for
example relays with 4 sets of changeover contacts are readily available. For further information
about switch contacts and the terms used to describe them please see the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to the pins
providing you take care to avoid melting the plastic case of the relay.
The supplier's catalogue should show you the relay's connections. The coil will be obvious and it
may be connected either way round. Relay coils produce brief high voltage 'spikes' when they
are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you
must connect a protection diode across the relay coil.
The animated picture shows a working relay with its coil and switch contacts. You can see a
lever on the left being attracted by magnetism when the coil is switched on. This lever moves the
switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them,
making the relay DPDT.

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

COM = Common, always connect to this, it is the moving part of the switch.
NC = Normally Closed, COM is connected to this when the relay coil is off.

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

Connect to COM and NO if you want the switched circuit to be on when the relay coil is
on.

Connect to COM and NC if you want the switched circuit to be on when the relay coil is
off.

LIQUID CRYSTAL DISPLAY

INTRODUCTION:
An LCD or a liquid crystal display consists of liquid crystals between electrodes. The
arrangement consists of polarization filters which are aligned perpendicular to each other. This
arrangement doesnt allow any visible light if there was no liquid crystal between the filters.
This arrangement is aligned in between transparent conductors.
When sufficient voltage is applied to a certain pixel, the crystal at that pixel aligns such
that no light passes through it. Therefore that particular pixel appears dark. If such an electric
field is applied for a longer period, the alignment of the crystal change, and the quality of lcd
degrades. In a bigger lcd display, to provide voltage sources to each pixel, the rows and column
lines are multiplexed.

PIN DESCRIPTION OF THE LCD:

TABLE: PIN DESCRIPTION OF LCD

LCD INTERFACE WITH MICROCONTROLLER

Microcontroller
P
O
R
T
P
I
N
S

INTERFACING LCD TO MICROCONTROLLER


The LCD is generally interfaced in 8-bit mode or 4-bit mode. In this project LCD is
connected in 4-bit mode the interface connections of LCD with microcontroller are as follows
RS of LCD is connected to p2.0 of microcontroller
EN of LCD is connected to p2.1 of microcontroller
D4 of LCD is connected to p2.4 of microcontroller
D5 of LCD is connected to p2.5 of microcontroller
D6 of LCD is connected to p2.6 of microcontroller
D7 of LCD is connected to p2.7 of microcontroller
In 8-bit mode, the complete ASCII code is sent at once along with the control signals. But
in 4-bit mode, the data is divided into two parts, i.e. MSB & LSB, and are called upper nibble &
lower nibble.

The control signals are RS, R/W & EN. RS is used to select the internal registers i.e. Data
register & command register. R/W is used to set the mode of LCD to read mode or write mode.
EN is used as chip select and is used to push the data internally to the corresponding registers.
To transfer the data/command in 8-bit mode, the data is written to the 8-bit data bus after
selecting the required register and setting the mode to write mode. The e signal pin is then given
a high to low signal to transfer the data.
To transfer the data/command in 4-bit mode, the higher nibble is first written to the MSB
of the data port and the e is given a high to low signal. After a little delay or when the LCD is not
busy, the lower nibble is transferred in the same procedure.

LCD COMMANDS

CHAPTER 4
SOFTWARE IMPLEMENTATION
4.1 KEIL COMPILER:
Keil compiler is a software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which is to be
dumped into the microcontroller for further processing. Keil compiler also supports C language
code.

4.2 ISP 3.0


Introduction
This ISP Programmer can be used either for in-system programming or as a stand-alone
spi programmer for Atmel
ISP programmable devices. The programming interface is compatibe
to STK200 ISP programmer hardware so the users of STK200 can also use the software which
can program both the 8051 and AVR series devices.
Hardware
The power to the interface is provided by the target system. The 74HCT541 IC isolates
and buffers the parallel port signals. It is necessary to use the HCT type IC in order to make sure
the programmer should also work with 3V type parallel port.

The printer port buffer

interface

is

same as

shown

in

figure

1.For

the

u-

controllera40pinZIFsocketcanbe used. This programmer circuit can be use to program the 89S
series devices and the AVR series device switches are pin compatible to 8051, like 90S8515.
For other AVR series devices the user can make an adapter board for 20, 28 and 40 pin devices.
The pin numbers shown in brackets correspond to PC parallel port connector.
Software
The ISP-30a.zip file contains the main program and the i/o port driver. Place all files in
the same folder. The main screen view of the program is shown in figure 3.
Also

make

sure

do

not

program

the

RSTDISBL

fuse

in

ATmega8,

ATtiny26 and ATtiny2313 otherwise further spi programming is disable and you will
need

parallel

programmer

to

enable

the

spi programming. For the fuses setting consult the datasheet of the respective device.
For the auto hardware detection it is necessary to short pin 2 and 12 of DB25connector,
otherwise the software uses the default parallel port i.e. LPT1.
Following are the main features of this software,

Read and write the Intel Hex file.

Read signature, lock and fuse bits.

Clear and Fill memory buffer.

Verify with memory buffer.

Reload current Hex file.

Display buffer checksum.

Program selected lock bits & fuses.

Auto detection of hardware.

Note: The memory

buffer

contains

for the devices which

have

eeprom

both

the code

memory.

data

The

and the

eeprom

eeprom

memory

data

address

in buffer is started after he code memory, so it is necessary the hex file should contains the
eeprom start address after the end of code memory last address i.e. for 90S2313 the start address
for eeprom memory is 0x800.
The software

does

not

provide

the

erase

command

because

th

s function is performed automatically during device programming. If you are required to


erase

the

controller, first use the clear

buffer command then program the controller, this will erase the controller and also set the AVR
device fuses to default setting.

Fig Main screen of the program ISP-Pgm Ver 3.0a


4.3 EMBEDDED C
Ex: Hitec c, Keil c

HI-TECH Software makes industrial-strength software development tools and C


compilers that help software developers write compact, efficient embedded processor code.
For over two decades HI-TECH Software has delivered the industry's most reliable
embedded software development tools and compilers for writing efficient and compact code to
run on the most popular embedded processors. Used by tens of thousands of customers including
General Motors, Whirlpool, Qualcomm, John Deere and many others, HI-TECH's reliable
development tools and C compilers, combined with world-class support have helped serious
embedded software programmers to create hundreds of breakthrough new solutions.
Whichever embedded processor family you are targeting with your software, whether it is
the ARM, PICC or 8051 series, HI-TECH tools and C compilers can help you write better code
and bring it to market faster.
HI-TECH PICC is a high-performance C compiler for the Microchip PIC micro
10/12/14/16/17 series of microcontrollers. HI-TECH PICC is an industrial-strength ANSI C
compiler - not a subset implementation like some other PIC compilers. The PICC compiler
implements full ISO/ANSI C, with the exception of recursion. All data types are supported
including 24 and 32 bit IEEE standard floating point. HI-TECH PICC makes full use of specific
PIC features and using an intelligent optimizer, can generate high-quality code easily rivaling
hand-written assembler. Automatic handling of page and bank selection frees the programmer
from the trivial details of assembler code.
Embedded C Compiler
ANSI C - full featured and portable.
Reliable - mature, field-proven technology.
Multiple C optimization levels.
An optimizing assembler.
Full linker, with overlaying of local variables to minimize RAM usage.
Comprehensive C library with all source code provided.

Includes support for 24-bit and 32-bit IEEE floating point and 32-bit long data types.
Mixed C and assembler programming.
Unlimited number of source files.
Listings showing generated assembler.
Compatible - integrates into the MPLAB

IDE, MPLAB ICD and most 3rd-party

development tools.
Runs on multiple platforms: Windows, Linux, UNIX, Mac OS X, and Solaris.
Embedded Development Environment.
PICC can be run entirely from the. This environment allows you to manage all of your PIC
projects. You can compile, assemble and link your embedded application with a single step.
Optionally, the compiler may be run directly from the command line, allowing you to
compile, assemble and link using one command. This enables the compiler to be integrated into
third party development environments, such as Microchip's MPLAB IDE.

CHAPTER
APPENDIX

#include<reg52.h>
#define lcd_data P2
unsigned int read_i,read_i1;

sbit lcd_rs = P2^0;


sbit lcd_en = P2^1;

sbit r1=P3^0;
sbit r2=P3^1;

sbit cs=P1^0;
sbit din=P1^1;
sbit dout=P1^2;
sbit clk=P1^3;

void delay(unsigned int v)


{
unsigned int i,j;
for(i=0;i<=v;i++)
for(j=0;j<=100;j++);
}
void tx(unsigned char *tx)
{
for(;*tx != '\0';tx++)
{
SBUF=*tx;
while(TI == 0);
TI=0;

}
}

void tx1(unsigned char tx)


{

SBUF=tx;
while(TI == 0);
TI=0;
}

unsigned char receive()


{
unsigned char rx;
while(RI == 0);
rx=SBUF;
RI=0;
return rx;
}

void lcdcmd(unsigned char value)

// LCD COMMAND

lcd_data=value&(0xf0); //send msb 4 bits


lcd_rs=0;

//select command register

lcd_en=1; //enable the lcd to execute command


delay(3);
lcd_en=0;
lcd_data=((value<<4)&(0xf0));

//send lsb 4 bits

lcd_rs=0; //select command register


lcd_en=1; //enable the lcd to execute command
delay(3);
lcd_en=0;

}
void lcddata(unsigned char value)

lcd_data=value&(0xf0); //send msb 4 bits


lcd_rs=1;

//select data register

lcd_en=1; //enable the lcd to execute data


delay(3);
lcd_en=0;
lcd_data=((value<<4)&(0xf0));
lcd_rs=1;

//send lsb 4 bits

//select data register

lcd_en=1; //enable the lcd to execute data


delay(3);
lcd_en=0;

delay(3);
}

unsigned convert(unsigned int value)


{
unsigned char a,b,c,d;

a=value/100;
b=value%100;
c=b/10;
d=b%10;
a=a|0x30;
c=c|0x30;
d=d|0x30;

lcdcmd(0x80);
lcddata(a);
lcddata(c);
lcddata(d);

//sertx(a);sertx(c);sertx(d);
return 1;
}
unsigned convert1(unsigned int value)
{

unsigned char a,b,c,d;

a=value/100;
b=value%100;
c=b/10;
d=b%10;
a=a|0x30;
c=c|0x30;
d=d|0x30;

lcdcmd(0xc0);
lcddata(a);
lcddata(c);
lcddata(d);

//sertx(a);sertx(c);sertx(d);
return 1;
}

void clock()
{
clk=0;
delay(1);
clk=1;
delay(1);
}

void powerup(unsigned char sel)


{
din=0;
clock();clock();clock();clock();clock();

din=1;
clock();//start bit
din=1;
clock();//mode select bit

if(sel==1)din=1;
else{din=0;}
clock();//D2

clock();//D0
clock();//sampling time
}

unsigned int read_1()


{
unsigned char ii=0;

clk=0;
delay(1);
clk=1;//for null charecter
read_i=0;
delay(1);
for(ii=0;ii<12;ii++)
{

clk=0;
delay(1);
if(dout==1){read_i++;}
read_i=read_i<<1;
clk=1;
delay(1);
}
read_i=read_i/40;
//convert(read_i);
return read_i;
}

unsigned int read_2()


{
unsigned char ii=0;

clk=0;
delay(1);
clk=1;//for null charecter

read_i1=0;
delay(1);
for(ii=0;ii<12;ii++)
{
clk=0;
delay(1);
if(dout==1){read_i1++;}
read_i1=read_i1<<1;
clk=1;
delay(1);
}
read_i1=read_i1/40;
//convert1(read_i1);
return read_i1;
}

void lcd_init(void)

{
lcdcmd(0x02);
lcdcmd(0x02);
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/

lcdcmd(0x0e);

//cursor blinking

lcdcmd(0x06);

//move the cursor to right side

lcdcmd(0x01);

//clear the lcd

void msgdisplay(unsigned char b[]) // send string to lcd


{
unsigned char s,count=0;
for(s=0;b[s]!='\0';s++)
{

count++;
if(s==16)
lcdcmd(0xc0);
if(s==32)
{
lcdcmd(1);
count=0;
}
lcddata(b[s]);
}
}

void conv(unsigned long int ch)


{
unsigned long int temp=0,temp2=0;
temp2=ch;
temp=temp2/10000;
// lcdcmd(temp+0x30);
temp2=temp2%10000;

temp=temp2/1000;
lcddata(temp+0x30);

temp2=temp2%1000;
temp=temp2/100;
lcddata(temp+0x30);

temp2=temp2%100;
temp=temp2/10;
lcddata(temp+0x30);

temp2=temp2%10;
lcddata(temp2+0x30);

void main(void)
{

r1=r2=0;
clk=0;
din=0;
dout=0;
cs=0;

lcd_init();
lcdcmd(0x80);
msgdisplay(" HAND GESTURE ");
lcdcmd(0xc0);
msgdisplay("BASED DEVC CNTRL");
delay(200);
lcdcmd(0x01);

lcdcmd(0x80);
msgdisplay("LOAD1:");
lcdcmd(0xc0);
msgdisplay("LOAD2:");

while(1)
{

cs=1;
delay(10);
cs=0;
delay(10);
powerup(0);
read_1();

delay(50);

cs=1;
delay(10);
cs=0;
delay(10);
powerup(1);
read_2();

if((read_i > 110 && read_i < 155) && (read_i1 > 110 && read_i1 < 168))
{
//

if((read_i > 150 && read_i < 170) && (read_i1 < 130 ))
{
r1=0;
lcdcmd(0x87);
msgdisplay("OFF");
}

if((read_i > 160 && read_i < 170) && (read_i1 > 190))
{
r1=1;
lcdcmd(0x87);
msgdisplay("ON ");

if((read_i > 120 && read_i < 130) && (read_i1 > 150))

{
r2=1;
lcdcmd(0xC7);
msgdisplay("ON ");

if((read_i >190 && read_i <200) && (read_i1 > 150))


{
r2=0;
lcdcmd(0xC7);
msgdisplay("OFF");

}
}

You might also like