Вы находитесь на странице: 1из 60

Project Report

ON
ANDROID CONTROLLED
HOME APPLIANCES
INTRODUCTION:
Nowadays the life is totally based on technology, and human beings
(Engineers) are creating new technical devices and projects on daily
basis just to make our life easy and vast. We are also here to present a
device which will work on android application and Bluetooth. This
project is based on the Bluetooth module and the working of the project
is on the android software. In this project, the devices are operated with
the help of the Bluetooth. This is a sort of wireless device operation.
The Home Automation concept has existed for many years. The terms
Smart Home, Intelligent Home followed and has been used to
introduce the concept of networking appliances and devices in the house.
Home automation Systems (HASs) represents a great research
opportunity in creating new fields in engineering, architecture and
computing. HASs becoming popular nowadays and enter quickly in this
emerging market. However, end users, especially the disabled and
elderly due to their complexity and cost, do not always accept these
systems. Due to the advancement of wireless technology, there are
several different of connections are introduced such as GSM, WIFI,
ZIGBEE, and Bluetooth. Each of the connection has their own unique
specifications and applications. Among the four popular wireless
connections that often implemented in HAS project, Bluetooth is being
chosen with its suitable capability. Bluetooth with globally available
frequencies of 2400Hz is able to provide connectivity up to 100 meters
at speed of up to 3Mbps depending on the Bluetooth device class. In
addition, a Bluetooth master device is able to connect up to 7 devices.
The capabilities of Bluetooth are more than enough to be implemented
in the design. Also, most of the current laptop/notebook or cell phones
are come with built-in Bluetooth adapter. It will indirectly reduce the
cost of this system. Based on the study of HAS project done by
researchers and developers, implemented Microcontroller in wireless
HAS.

BLOCK DIAGRAM:
WORKING:
This project works on the Bluetooth module. In this project we will use
89S52 controller. In this Bluetooth module is used. The Bluetooth serial
module is connected to the 89S52 serially. The devices in the room can
be operated wirelessly. In this relay card are used to operate the
extensions. We can operate the devices in the extension plugs. The
Bluetooth module is operated by an android phone containing the
applications. With the help of the phone with the android applications
we can operate the devices.
HARDWARE DESIGN:
This section mainly discuss about the hardware construction of main
control board. Microcontroller, 89S52is chosen due to its capability to
perform the both serial and USB features to establish the Bluetooth and
USB connection to the GUIs. For the sensor, HSM-20G Sensor Module
is chosen because it is the low cost 2- in-1 combination of humidity and
temperature modules. For the Bluetooth module, low cost Cytron
Bluebee Bluetooth module is chosen to establish the Bluetooth
connection between main control board and the GUIs. The electrical
current is directly connect to the main control board whereby it separates
the regulator and relay circuit. The voltage regulator is constructed by
common reliable regulator circuit which consists of transformer, rectifier
and regulator. 5V and 3.3V DC output is regulated in order to fulfill the
voltage needs of the specific components in the main control board.
Moreover, the low voltage activating switches will replace the existing
switches The ease of installation is taken into account for this system.
The system is designed to directly install beside the electrical switches
on the wall. The installation of this system eliminates the complex
wiring reinstallation and overhead wiring on the wall. The existing
switch connection is connected and controlled by the relay circuit inside
main control board. Furthermore, multiple control boards can be
installed in home. With these simple and low cost components, the main
control board is constructed in pretty small size but still performs the
strong functions and features of the system.
TOOLS/SOFTWARES /COMPONENTS REQUIRED
KEIL Vision2 Software for programming of Microcontroller.

I.C Programmer and Software for the burning of the


Microcontroller..

Components for designing of the embedded part.

Soldering kit.

Measuring Instruments (Multi-meter), etc.

Serial Bluetooth Module

Android Application

COMPONENTS
SERIAL BLUETOOTH MODULE 1NO
MCU (AT89S52) 1NO
LCD WITH CONNETOR 1NO
TRANSFORMER230/12V 1NO
DIODES (1N4007) 2NO
CAPACITORS 4NO
RESISTORS 10NO
PCB 1NO
CRYSTAL OSCILLATOR12MHZ 1NO
LAMP HOLDERS 3NO
CONNECTING WIRES
RELAYS 12V 4NO
EXTENTION BOARD
TRANSISTORS 6NO
WORKING OF CIRCUIT:
Supply Section of this circuit consists of a 12 volts adaptor, and a
IC 7805 IC. The output of the second regulator(IC 7805) is +5 volts,
which is used for all other digital applications.

The display section uses the port 1 of microcontroller. This port is


in open drain configuration and as a result, pull up resistors should be
provided for its normal operation. The contrast of this LCD display is
adjusted by changing the value of a resistor which is grounded at the
other end.

HARDWARE DESCRIPTION
3.1:MICROCONTROLLER- AT89C52:

The 8952 microcontroller is upgraded version of 8051 family of


microcontrollers. The 8051 microcontroller was introduced by Intel
Corporation in the year 1981. It is an 8-bit microcontroller with Harvard
Architecture manufactured by advanced CMOS processes. It has 128
bytes of on chip RAM, 4k bytes of on chip ROM, two 16-bit
timers/counters, four 8-bit ports of which one is a serial port, etc. There
are 6 interrupt sources also.
Since this is an 8-bit micro controller, the CPU can work on only 8
bits of data at a time. Data larger than 8 bits has to be broken down to 8
bit pieces. Though it has an addressing capability of 64 Kbytes, only 4k
bytes have been provided on chip.

8051 is available in different memory types, such as UV-EPROM,


FLASH, and NV-RAM. The UV-EPROM version of 8051 is the 8751.
This chip has only 4K bytes of on chip UV-EPROM. To use this chip for
development requires access to a PROM burner, as well as a UV-
EPROM eraser to erase all the contents of UV-EPROM inside the 8751
chip before you can program it again. It takes about 20 minutes to erase
the 8751 before it can be programmed again. This led to introduce
FLASH and NV-RAM versions of 8051.

Another popular version of 8051 is DS5000 chip from Dallas


Semiconductor. The on chip ROM is in the form of NV-RAM. The
read/write capability of NV-RAM allows the program to be loaded into
the on chip ROM while in the system. This can be done via a serial port
of a PC. Another advantage of NV-RAM is the ability to change the
ROM contents one byte at a time. The entire ROM must be erased
before programmed again in the case of UV-EPROM and flash memory.

There are also OTP (One Time Programmable) versions of the


8051 available from different sources. Flash and NV-RAM versions are
typically used for product development. When a product is designed and
finalized, the OTP version of the 8051 is used for mass production since
it is much cheaper in terms of price per unit.
There are two other members in the 8051 family of
microcontrollers. They are the 8052 and the 8031.The 8052 has all the
standard features of the 8051 in addition to an extra 128 bytes of RAM,
an extra timer, extra 4K bytes of on chip ROM, and two more interrupt
sources. Therefore all programs written for 8051 will run on 8052, but
the reverse is not true.

8031 is often referred to as ROM-less 8051 since it has 0K bytes of


on chip ROM. To use this chip we must add external ROM to it. The
ROM containing the program attached to the 8031 can be as large as
64K bytes. For adding external ROM two ports are needed out of 4
ports, leaving only 2 ports for I/O operations. To solve this, external I/O
ports like 8255 can be added to 8031. Atmel Corporations AT89C52is a
low-power, high-performance CMOS 8-bit microcomputer with 8K
bytes of Flash programmable and erasable read only memory (PEROM).
The device is manufactured using Atmels high-density nonvolatile
memory technology and is compatible with the industry-standard MCS-
51 instruction set and pin out. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional on volatile
memory programmer. By combining a versatile 8-bit CPU with Flash on
a monolithic chip, the Atmel AT89C52 is a powerful microcomputer
that provides a highly flexible and cost-effective solution to many
embedded control applications.
Flash memory can be erased in seconds compared to 20 minutes
needed for 8751. For this reason 89C52 is used in place of 8751 to
eliminate the waiting time needed to erase the chip and thereby speed up
the development time. The development system requires a ROM burner
that supports flash memory. The entire contents of ROM should be
erased in order to program it again; the PROM burner itself does this.
The 89C52 Flash reliably stores memory contents even after 10,000
erase and program cycles. AT89C52 is a popular chip of this category
from Atmel Corporation.

The micro-controller generic part number actually includes a whole


family of microcontrollers that have numbers ranging from 8031 to
8751 and are available in N-channel Metal Oxide Silicon (NMOS)
and CMOS construction. 89c52 is an 8-bit micro-controller having
40 pins arranged as DIP packages. The features unique to micro-
controllers include:
INTERNAL RAM AND ROM
I/O PORTS WITH PROGRAMMABLE PINS
TIMERS AND COUNTERS
SERIAL DATA COMMUNICATION

The 89C52 architecture consists of these specific features:

Eight-bit CPU with registers A and B


16-bit program counter and data pointer
8-bit stack pointer
Internal ROM of 8k
Internal RAM of 128 bytes
Four register banks each containing eight registers
16 bytes addressable at the bit level
80 bytes of general purpose data memory
32 input/output pins arranged as four 8 bit ports
Three 16-bit timer/counter
Full duplex serial data receiver/transmitter
Control registers: TCON, TMOD, SCON, PCON, IP and IE
Two external and three internal interrupt sources
Oscillator and clock circuits
3.1.1: The internal layout of an 89C52:
89C52 Oscillator and Clock

The heart of 89C51 is the circuitry that generates the clock pulses
by which all internal operations are synchronized. Pins XTAL1 and
XTAL2 are provided for connecting a resonant network to form an
oscillator. The crystal frequency is the basic internal clock frequency of
the micro controller.

Program Counter and Data Pointer

The 89C52 contains two 16 bit registers, the program counter and
the data counter. Each is used to hold the address of byte in memory.
Program instruction byte is fetched from location in memory that is
addressed by the PC. The PC is automatically incremented after every
instruction bytes fetched and may also be altered by certain instructions.

The DPTR register is made up of two 8-bit registers named DPH


and DPL, which are used to furnish memory addresses for internal and
external code access and external access. The DPTR is under the control
of program instructions.

A & B CPU registers:

The A and B register holds results of many operations, particularly


math and logical operations. The A register is also used for all data
transfers between the 89C51 and any external memory.
Flags & Program Status Word:

Flags are 1 bit registers provided to store the result of certain


program instructions. The flags are groups inside the program status
word and the power control (PCON) registers. The 89C52 have four
math flags that respond automatically to the result of math operation and
three general-purpose user flags that can be set to 1 or cleared to 0 by the
programmer as desired. The math flag include carry (C), Auxiliary Carry
(AC), Overflow (OV) and Parity (P). User flags are named F0, GF0 and
GF1; they are general purpose flags hat may be used by the programmer
to record some event in the program.

The program status word contains the math flag, user program flag
F0, and the register select bits identify which of the four general purpose
register banks is currently in use by the program.

Internal Memory:

The 89C52 have internal RAM for program code bytes and for
variable data that can be altered as the program runs. Additional memory
can be added externally using suitable circuits. Unlike micro-controller
with a Von Neumann architecture, which can use a single memory
address for either program code or data, but not for both, the 89C52 have
Harvard architecture, which uses the same address, in different
memories, for code and data. Internal security accesses the correct
memory based on the nature of operation in progress.
Internal RAM:

It had 128 internal RAM, which is organized, into distinct areas. 32


bytes from address 00H to 1FH that make up thirty two working
registers organized as four bands of eight registers each. A bit
addressable area of sixteen bytes occupies ram byte addresses 20H to
2FH. A general purpose RAM area above the bit area from 30H to 7FH
addressable as bytes.

Stack and Stack Pointer:

The stack refers to an area of internal ram that is used in


conjunction with certain op codes to store and retrieve data quickly. The
eight-bit stack pointer register is used to hold an internal ram address
called the top of the stack. The address held in the SP register is the
location in the internal ram where the last byte of data was stored by a
stack operation.

When data is to be placed on the stack the SP increments before


storing data on the stack up grows, as data is stored. As data is retrieved
from the stack, the byte is read from the stack, and then the SP
decrements to point to the next available byte of stored data. The SP is
set to 07H when the 89C52 is reset and can be changed to any internal
ram addressed by the programmer.
Special Function Registers:

The 89C52 operations that do not use the internal ram address
from 00H to 7FH are done by a group of specific internal registers each
called special function registers, which may be addressed much like
internal ram, using addresses from 8011 to FFH. Some SFRs are also
bit addressable. This feature allows the programmer to change only what
needs to be altered, leaving the remaining bits in that SFR unchanged.

Input/ Output pins, Ports and Circuits:

One major feature of a micro-controller is the versatility built into


the IO circuits that connect the 89C52 to external world. Four ports are
provided in 89C52 to connect to the outside world. Different functions
are associated with a single port. The function of a port is decided by a
hardware circuit connected and software commands used to program it
under the complete control of a program designer.

Each port has a D type output latch for each pin. The SFR of each
port are made up of these eight latches, which can be addressed at the
SFR address for that port. The port latch should not be confused with the
port pins. The data on the latch does not have to be the same as that on
the pins. The status of each latch may be read from a latch buffer; while
an input buffer is connected directly to each pin status may be read
independently of the latch state. Different op codes accesses the latch or
pin states as appropriate. Port operation is determined by manner in
which microcontroller is connected to the external circuitry.

The two data paths are shown in figure while circuits that read the
latch or pin data using two entirely separate buffers. The output buffer is
enabled when the latch data is read and the lower buffer when the pin
state is read.

Programmable port pins have completely different alternate


functions. The configuration of the control circuitry between the output
latch and the port pins determines the nature of any particular port pin
function. Only one port cannot have alternate function. Port 0, 2, 3 can
be programmed.

Port0: serves as input/output or bidirectional lower order address and


data bus for external memory.

Port1: have no dual functions. It can be used as input/output.

Port2: serves as input/output or bidirectional higher order address and


data bus for external memory.

Port3: can be used as input/output, for serial communication and various


other alternative uses. The port3 alternate uses are given below
Pin Alternate Use SFR

P3.0 RXD Serial data input SBUF

P3.1 TXD Serial data output SBUF

P3.2 INT0 External interrupt 0 TCON.1

P3.3 INT1 External interrupt 1 TCON.3

P3.4 T0 External timer 0 input TMOD

P3.5 T1 External timer 1 input TMOD

P3.6 WR External memory write


pulse

P3.7 RD External memory read


pulse

3.1.2:Counters and Timers:

Many microcontroller applications require the counting of external


events such as frequency of pulse train, or the generation of precise
internal time delays between computer actions. Three sixteen bit
counters named T0,T1and T2 are provided for general use of the
programmer. Each counter may be programmed to count internal clock
pulses acting as a timer or program to count external pulses as a counter.
The counters are divided into eight bit registers called the timer
low (TL0, TL1) and high (TH0, TH1) bytes. All counter actions is
controlled by bit status in the timer mode control registers TMOD, the
timer/counter control register TCON, and certain program instructions.

TMOD is dedicated entirely to the timer and can be considered to


be two duplicate 4 bit registers, each of which controls the action of one
of the timer. TCON has the control bits and flags for the timer in the
upper nibble, control bits and flags for external interrupts in the lower
nibble.

Timer Counter Interrupts:

The timers have been included on the chip to relieve the processor
of timing and counting chores. When the program wished to count a
certain number of internal pulses or external events, a number is placed
in one of the counters. The number represents the maximum count less
the decide count, plus 1.The counter increments from the initial number
to the maximum and then roles over to 0 on the final pulse and also set a
timer flag. The flag condition may be tested by an instruction to tell the
program that the count has been accomplished, or the flag may be used
to interrupt the program.

Timing:

If a counter is programmed to be a timer, it will count the internal


clock frequency of the oscillator divided by 12d. The resultant timer
clock is gated to the timer. The bit TRX in the TCON register must be
set to one (timer run), and the gate counter is configured as a timer, then
the timer pulses are gated to the counter by the bit and gate bit or the
external input bits INT.

Timer Modes of Operation:

The timers may be operated in one of the four modes that are
determined by the mode bits. M1 and M0 in the TMOD register.

Timer mode 0:

Setting timer X mode bits to 00B in the TMOD register results in


using the THX register as an eight bit counter and TLX as a five bit
counter; pulse input is divided by 32d in TL so that the TH counts the
original oscillator reduced by a total 384d.

Timer mode 1:

Mode 1 is similar to mode 0 except TLX is configures as a full 8


bit counter, When the mode bits are set to 01B in the TMOD. The timer
flag would be set in 1311 seconds using a 6MHz crystal.

Timer mode 2:

Setting the mode bits to 10b in the TMOD configures the timer to
use only the TLX counter as an eight bit counter. THX is used to hold a
value that is loaded into TLX every time TLX overflows from FFh to
00h. The timer flag is also set when TLX overflows. This mode exhibits
and auto reloaded feature: TLX will count up from the number in THX,
overflow, and be initialized again with the contents of THX.

Timer mode 3:

Timer 0 and 1 may be programmed to be in mode 0.1,2


independently of a similar mode for the other timer. This is not true for
mode3; the timer does not operate independently if mode 3 is chosen for
timer0. Placing timer 1 in mode3 causes it to stop counting; the control
bit TRI and the timer flag TF1 are then used by timer 0. Timer 0 in mode
3 becomes two completely separate eight bit counters. TL0 is controlled
by the gate arrangement and sets the timer flag TF0 whenever it
overflows from FFh to 00h. TH0 receives the timer clock (the oscillator
divided by 12) under the control of TRI only and set the TF1 flag when
it overflows.

Timer 1 may be still used in modes 0,1 or 2 while timer 0 is on


mode 3 with one important exception: the timer 1 will generate no
interrupts while timer 0 is using the TF1 overflow flags. Switching timer
1 to mode 3 will stop it and hold whatever count is in timer1.

Counting:

The only difference between counting and timing in the source of


the clock pulses when used as a timer, the clock pulses are sourced from
the oscillator through the divide by 12d circuit: when use as counter pint
T0 supplies pulses to counter 0 and pin T1 to counter1. Each high and
low states of the input pulse must be held constant for at least one
machine cycle to ensure reliable counting.

Interrupts:

Interrupts are hardware signals that force a program to call a


subroutine. Interrupts take up the processor time only when the action by
the program is needed. Interrupts are often the only way in which real
time programming can be done successfully.

Interrupts may be generated by internal chip operation or by


external sources. Any interrupt can cause the microcontroller to perform
a hardware call to an interrupt handling subroutine that is located at a pre
determined absolute address in the program memory. Five interrupts are
provided in the 8051. Three of these are generated automatically by
interrupt (R1 or T1). Two interrupts are triggered by external signals
provided by circuitry that is connected to pins INT0 and INT1.

All interrupts are under the control of the program. The


programmer is able to alter the control bits in the Interrupt Enable
register (IE), the Interrupt Priority register (IP) and the Timer Control
register (TCON). The program can block all or any of the combinations
of the interrupt from acting on the program by suitable setting or
clearing of these registers. After the interrupts has been handled by the
interrupt subroutine, which is placed by the programmer in the interrupt
location in the program memory, the interrupt program must resume
operation at the instruction where the interrupt take place. Program
resumption is done by storing the interrupted PC address on the stack in
ram before changing the PC to the interrupt address in ROM. The PC
address will be stored from the stack after an RETI instruction is
executed at the end of the interrupt subroutine.

Timer Flag Interrupt:

When a counter/timer slashes overflow, the corresponding timer


flag TF0 or TF1 is set to one. The flag is cleared to 0 when the resulting
interrupt generates a program call to the appropriate timer subroutine in
the memory.

External Interrupts:

Pins INT0 and INT1 are used by external circuitry. Inputs on these
pins can set the interrupt flags IE0 and IE1 in the TCON register to 1 by
two different methods. The IEX flag may be set when the INTX pin
reached a low level or the flags may be set when a high to low transition
takes place on the INTX pin. Bits INT0 and INT1 in TCON program the
INTX pins for low level interrupt when set to 0 and program the INTX
pins for transition interrupt when set to 1. Flags IEX will be reset when
the processor accepts the transition generated interrupt and the interrupt
subroutine is accessed. The external circuits must remove the low level
before an RETI is executed.
Reset:

This can be considered as the ultimate interrupt as the program


cannot block the action of the voltage at the RST pin. This type of
interrupt is often called non maskable interrupt (NMI). Unlike other
interrupts, the PC is not stored for later program resumption.

Interrupt Control:

The IE register holds the programmable bits that can enable or


disable all the interrupts as a group, or if the group is enabled, each
individual interrupt source can be enabled or disabled. The IP register
bits, may be set by the program to assign priorities among the various
interrupts sources so that more important interrupts can be serviced first.

Pin Description
VCC

Supply voltage.

GND

Ground.

Port 1
Port 1 is an 8-bit bidirectional I/O port. Port pins P1.2 to P1.7
provide internal pullups. P1.0 and P1.1 require external pullups. P1.0
and P1.1 also serve as the positive input (AIN0) and the negative input
(AIN1), respectively, of the on-chip precision analog comparator. The
Port 1 output buffers can sink 20 mA and can drive LED displays
directly.

When 1s are written to Port 1 pins, they can be used as inputs.


When pins P1.2 to P1.7 are used as inputs and are externally pulled low,
they will source current (IIL) because of the internal pullups.

Port 1 also receives code data during Flash programming and


program verification.

Port 3
Port 3 pins P3.0 to P3.5, P3.7 are seven bidirectional I/O pins with
internal pullups. P3.6 is hard-wired as an input to the output of the on-
chip comparator and is not accessible as a general purpose I/O pin. The
Port 3 output buffers can sink 20 mA. 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


AT89C2051 as listed below:

Port Pin Alternate Functions


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)


Port 3 also receives some control signals for Flash programming
and programming verification.

RST
Reset input. All I/O pins are reset to 1s as soon as RST goes high.
Holding the RST pin high for two machine cycles while the oscillator is
running resets the device. Each machine cycle takes 12 oscillator or
clock cycles.

XTAL1
Input to the inverting oscillator amplifier and input to the internal
clock operating circuit.

XTAL2
Output from the inverting oscillator amplifier.

Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an
inverting amplifier which can be configured for use as an on-chip
oscillator, as shown in Fig. Either a quartz crystal or ceramic resonator
may be used. To drive the device from an external clock source, XTAL2
should be left unconnected while XTAL1 is driven as shown in Figure 2.
There are no requirements on the duty cycle of the external clock signal,
since the input to the internal clocking circuitry is through a divide-by-
two flip-flop, but minimum and maximum voltage high and low time
specifications must be observed.
PIN FUNCTION OF IC 89C52.
1 Supply pin of this ic is pin no 40. Normally we apply a 5 volt
regulated dc power supply to this pin. For this purpose either we
use step down transformer power supply or we use 9 volt
battery with 7805 regulator.
2 Ground pin of this ic is pin no 20. Pin no 20 is normally
connected to the ground pin ( normally negative point of the
power supply.
3 XTAL is connected to the pin no 18 and pin no 19 of this ic.
The quartz crystal oscillator connected to XTAL1 and XTAL2
PIN. These pins also needs two capacitors of 30 pf value. One
side of each capacitor is connected to crystal and other pis is
connected to the ground point. Normally we connect a 12 MHz
or 11.0592 MHz crystal with this ic.. But we use crystal upto 20
MHz to this pins
4 RESET PIN.. Pin no 9 is the reset pin of this ic.. It is an active
high pin. On applying a high pulse to this pin, the micro
controller will reset and terminate all activities. This is often
referred to as a power on reset. The high pulse must
be high for a minimum of 2 machine cycles before it is allowed
to go low.

5. PORT0 Port 0 occupies a total of 8 pins. Pin no 32 to pin no


39. It can be used for input or output. We connect all the pins of
the port 0 with the pullup resistor (10 k ohm) externally. This is
due to fact that port 0 is an open drain mode. It is just like a
open collector transistor.

6. PORT1. ALL the ports in micrcontroller is 8 bit wide pin no 1


to pin no 8 because it is a 8 bit controller. All the main register
and sfr all is mainly 8 bit wide. Port 1 is also occupies an 8 pins.
But there is no need of pull up resistor in this port. Upon reset
port 1 acts as an input port. Upon reset all the ports act as an
input port
7. PORT2. Port 2 also have a 8 pins. It can be used as a input or
output. There is no need of any pull up resistor to this pin.
PORT 3. Port3 occupies a total 8 pins from pin no 10 to pin no
17. It can be used as input or output. Port 3 does not require
any pull up resistor. The same as port 1 and port2. Port 3 is
configured as an output port on reset. Port 3 has the additional
function of providing some important signals such as
interrupts. Port 3 also use for serial communication.
SPECIAL FUNCTION REGISTER ( SFR) ADDRESSES.
ACC ACCUMULATOR 0E0H

B B REGISTER 0F0H

PSW PROGRAM STATUS WORD 0D0H

SP STACK POINTER 81H

DPTR DATA POINTER 2 BYTES

DPL LOW BYTE OF DPTR 82H


DPH HIGH BYTE OF DPTR 83H

P0 PORT0 80H

P1 PORT1 90H

P2 PORT2 0A0H

P3 PORT3 0B0H

TMOD TIMER/COUNTER MODE CONTROL 89H


TCON TIMER COUNTER CONTROL 88H
TH0 TIMER 0 HIGH BYTE 8CH
TLO TIMER 0 LOW BYTE 8AH
TH1 TIMER 1 HIGH BYTE 8DH
TL1 TIMER 1 LOW BYTE 8BH

SCON SERIAL CONTROL 98H

SBUF SERIAL DATA BUFFER 99H


PCON POWER CONTROL 87H

INSTRUCTIONS

SINGLE BIT INSTRUCTIONS.

SETB BIT SET THE BIT =1

CLR BIT CLEAR THE BIT =0

CPL BIT COMPLIMENT THE BIT 0 =1, 1=0

JB BIT,TARGET JUMP TO TARGET IF BIT =1

JNB BIT, TARGET JUMP TO TARGET IF BIT =0

JBC BIT,TARGET JUMP TO TARGET IF BIT =1 &THEN


CLEAR THE BIT
MOV INSTRUCTIONS

MOV instruction simply copy the data from one location to another
location

MOV D,S

Copy the data from(S) source to D(destination)

MOV R0,A ; Copy contents of A into Register R0

MOV R1,A ; Copy contents of A into register R1

MOV A,R3 ; copy contents of Register R3 into Accnmulator.

DIRECT LOADING THROUGH MOV

MOV A,#23H ; Direct load the value of 23h in A

MOV R0,#12h ; direct load the value of 12h in R0


MOV R5,#0F9H ; Load the F9 value in the Register R5

ADD INSTRUCTIONS.

ADD instructions adds the source byte to the accumulator ( A) and place
the result in the Accumulator.

MOV A, #25H

ADD A,#42H ; BY this instructions we add the value 42h in


Accumulator ( 42H+ 25H)

ADDA,R3 ;By this instructions we move the data from register r3


to accumulator and then add the contents of the register
into accumulator .

SUBROUTINE CALL FUNCTION.

ACALL,TARGET ADDRESS

By this instructions we call subroutines with a target address within 2k


bytes from the current program counter.
LCALL, TARGET ADDRESS.

ACALL is a limit for the 2 k byte program counter, but for upto 64k
byte we use LCALL instructions.. Note that LCALL is
a 3 byte instruction. ACALL is a two byte instruction.
Restrictions on Certain Instructions
The AT89C2052 and is an economical and cost-effective member
of Atmels growing family of microcontrollers. It contains 2 Kbytes of
flash program memory. It is fully compatible with the MCS-51
architecture, and can be programmed using the MCS-51 instruction set.
However, there are a few considerations one must keep in mind when
utilizing certain instructions to program this device.

All the instructions related to jumping or branching should be


restricted such that the destination address falls within the physical
program memory space of the device, which is 2K for the AT89C2051.
This should be the responsibility of the software programmer. For
example, LJMP 7E0H would be a valid instruction for the AT89C2051
(with 2K of memory), whereas LJMP 900H would not.

1. Branching instructions:
LCALL, LJMP, ACALL, AJMP, SJMP, JMP @A+DPTR

These unconditional branching instructions will execute


correctly as long as the programmer keeps in mind that the
destination branching address must fall within the physical
boundaries of the program memory size (locations 00H to 7FFH
for the 89C2051). Violating the physical space limits may cause
unknown program behavior.

CJNE [...], DJNZ [...], JB, JNB, JC, JNC, JBC, JZ, JNZ

With these conditional branching instructions the same rule


above applies. Again, violating the memory boundaries may cause
erratic execution.

For applications involving interrupts the normal interrupt


service routine address locations of the 80C52 family architecture
have been preserved.
P1.0 and P1.1 should be set to 0 if no external pullups are used,
or set to 1 if external pullups are used. It should be noted that when
idle is terminated by a hardware reset, the device normally resumes
program execution, from where it left off, up to two machine cycles
before the internal reset algorithm takes control. On-chip hardware
inhibits access to internal RAM in this event, but access to the port pins
is not inhibited. To eliminate the possibility of an unexpected write to a
port pin when Idle is terminated by reset, the instruction following the
one that invokes Idle should not be one that writes to a port pin or to
external memory.

Power Down Mode


In the power down mode the oscillator is stopped, and the
instruction that invokes power down is the last instruction executed. The
on-chip RAM and Special Function Registers retain their values until the
power down mode is terminated. The only exit from power down is a
hardware reset. Reset redefines the SFRs but does not change the onchip
RAM. The reset should not be activated before VCC is restored to its
normal operating level and must be held active long enough to allow the
oscillator to restart and stabilize. P1.0 and P1.1 should be set to 0 if no
external pullups are used, if pullups are used.

Programming Algorithm:
To program the AT89C2052, the following sequence is
recommended.

1. Power-up sequence:
Apply power between VCC and GND pins Set RST and XTAL1 to
GND. With all other pins floating, wait for greater than 10
milliseconds

2. Set pin RST to H

Set pin P3.2 to H

3. Apply the appropriate combination of H or L logic levels to


pins P3.3, P3.4, P3.5, P3.7 to select one of the programming
operations shown in the PEROM Programming Modes table.

To Program and Verify the Array:

4. Apply data for Code byte at location 000H to P1.0 to P1.7.

5. Raise RST to 12V to enable programming.

6. Pulse P3.2 once to program a byte in the PEROM array or the lock
bits. The byte-write cycle is self-timed and typically takes 1.2 ms.

7. To verify the programmed data, lower RST from 12V to logic H


level and set pins P3.3 to P3.7 to the appropriate levels. Output
data can be read at the port P1 pins.
8. To program a byte at the next address location, pulse XTAL1 pin
once to advance the internal address counter. Apply new data to
the port P1 pins.
9. Repeat steps 5 through 8, changing data and advancing the address
counter for the entire 2 Kbytes array or until the end of the object
file is reached.

10. Power-off sequence: set XTAL1 to L, set RST to L, Float all


other I/O pins, Turn Vcc power off

Flash Programming Modes


Fig. Programming the Flash Memory Fig. Verifying the
Flash Memory

Flash Programming and Verification Characteristics

Flash Programming and Verification Waveforms


Absolute Maximum Ratings
Operating Temperature = -55C to +125C

Storage Temperature = -65C to +150C

Voltage on any pin with respect to Ground = -1.0V to +7.0V

Maximum Operating Voltage = 6.6 V

DC output current = 25.0 mA

External Clock Drive Waveforms

COMPONENT DESCRIPTION

RESISTANCE

Resistance is the electronic component used to control the current


passing through the circuit. They are calibrated in ohms. In the other
words resistance are circuit elements having the function introducing
electrical resistance into the circuit. There are three basic types :
1. Fixed Resistance
2. Rheostat
3. Potentiometer
A fixed Resistance is a two terminal resistance whose electrical
resistance is constant. A rheostat is a resistance that can be changed in
resistance value without opening the circuit to make adjustment.
potentiometer is an adjustable resistance with three terminals one each
end of the resistance element and third movable along its length.

CAPACITOR
A capacitor is a device capable of storing an electric charge (static
electricity). It consists of two metal plates separated by dielectric
material. Capacitors are available in values ranging from less than one
picofarad to thousands of microfarad. While using a capacitor its ratings
must be carefully observed to make certain that the potential to be
applied across the capacitor is not greater than the rated value.

TYPES OF CAPACITORS :

Depends upon the basis of dielectric used:


Air insulated & vaccum capacitors
Paper insulated capacitors
Mica capacitors
Plastic film capacitors
Ceramic capacitors
Electrolytic & tantalum capacitors

CERAMIC CAPACITOR :

In this project, 0.01 microfarad capacitor is a ceramic capacitor.


The basis of the ceramic material is mainly barium titanate or a similar
material, but other ceramic substance including hydrous silicate of
magnesia or talc are also used. The electrodes are applied in the form of
silver which is either spread or plated on to the opposite faces of a thin
tube, wafer or disc made from the ceramic material. Connecting wires
are then soldered to this deposit and the whole capacitor dipped in for a
suitable coating.

Fig. Tabular and disc type ceramic capacitors

ELECTROLYTIC CAPACITOR :
In this project, 10f capacitor is an electrolytic capacitor. In this
type of capacitors, the dielectric consists of an extremely thin film of
aluminum oxide formed on one of its aluminum foil plates. Intimate
contact with the other plate is achieved by impregnating the paper
between the foils with an electrolyte in the form of viscous substance,
such as ammonium borate. The sandwich is then rolled into a cylindrical
element and housed in either metallic cardboard, plastic or ceramic
protective tube.

Fig. Electrolytic and Tantalum capacitor

SOLDERING

Soldering is the process of joining two metallic conductors the


joint where two metal conductors are to be joined or fused is heated with
a device called soldering iron and then as allow of tin and lead called
solder is applied which melts and converse the joint. The solder cools
and solidifies quickly to ensure is good and durable connection between
the jointed metal converting the joint solder also present oxidation.
SOLDERING & DESOLDERING TECHNIQUES :

There are basically two soldering techniques:

I. Manual soldering with iron.


II. Mass soldering.
The iron consist of an insulated handle connected via a metal

shank to the bit the function of bit is to

1. Stare host & convey it to the component


2. To store and deliver molten solder 7 flux.
3. To remove surplus solder from joints.
Soldering bit are made of copper because it has good heat capacity
& thermal conductivity. It may erode after long term use to avoid it
coating of nickel or tin is used.

SOLDERING WITH IRON :

The surface to be soldered must be cleaned & fluxed. The


soldering iron switched on & bellowed to attain soldering temperature.
The solder in form of wire is allied hear the component to be soldered
&b heated with iron. The surface to be soldered is filled, iron is removed
& the joint is cold without disturbing.

Solder joint are supposed to


1. Provide permanent low resistance path
2. Make a robust mechanical link between PCB & leads of
components.
3. Allow heat flow between component, joining elements & PCB.
4. Retain adequate strength with temperature variation.
The following precaution should be taken while soldering.

1. Use always an iron plated copper core tip for soldering iron.
2. Slightly fore the tip with a cut file when it is cold.
3. Use a wet sponge to wipe out dirt from the tip before soldering
instead of asking the iron.
4. Tighten the tip screw if necessary before iron is connected to
power supply.
5. Clean component lead & copper pad before soldering.
6. Use proper tool for component handling instead of direct handling.
7. Apply solder between component leads, PCB pattern & tip of
soldering iron.
8. Iron should be kept in contact with the joint s for 2-3 second s only
instead of keeping for very long or very small time.
9. Use optimum quantity of solder.
10. Use multistoried wire instead of single strands solvent like
isopropyl alcohol.
11. Every time soldering is over, put a little clean solder on the tip.
IC 7805 :

Three Terminal Positive Fixed Voltage Regulators

These voltage regulators are monolithic integrated circuits


designed as fixed voltage. These regulators employ internal current
limiting, thermal shutdown, and safe-area compensation. With
adequate heat sinking they can deliver output currents in excess of
1.0A. Although designed primarily as a fixed voltage regulator,
these devices can be used with external components to obtain
adjustable voltages and currents.
Output Current in Excess of 1.0A
No external components required
Internal thermal overload protection
Internal short circuit current limiting
Output transistor safe area compensation
Output voltage offered in 2% and 4% tolerance
Available in surface mount D2pAK and standard 3-lead
transistor packages
Previous commercial temperature range has been extended to
a junction temperature range of 40C to +125C

DESCRIPTION
The 7805 series of three terminal positive regulators are available
in the TO-220/D-PAK package and with several fixed output voltages,
making them useful in a wide range of applications. Each type employs
internal current limiting, thermal shut down and safe operating area
protection, making it essentially indestructible. If adequate heat sinking
is provided, they can deliver over 1A output current. Although designed
primarily as fixed voltage regulators, these devices can be used with
external components to obtain adjustable voltages and currents.
TRANSFORMER
Transformer works on the principle of mutual inductance. We know that
if two coils or windings are placed on the core of iron, and if we pass
alternating current in one winding, back emf or induced voltage is
produced in the second winding. We know that alternating current
always changes with the time. So if we apply AC voltage across one
winding, a voltage will be induced in the other winding. Transformer
works on this same principle. It is made of two windings wound around
the same core of iron. The winding to which AC voltage is applied is
called primary winding. The other winding is called as secondary
winding.

Voltage and current relationship:

Let V1 volts be input alternating voltage applied to primary winding. I 1


Amp is input alternating current through primary winding. V2 volt is
output alternating voltage produced in the secondary. I2 amp be the
current flowing through the secondary.

Then relationship between input and output voltages is given by

V1/V2 = N1/N2

Relationship between input and output currents is

I1/I2 = N2/N1
(Where N1 is no. of turns of coil in primary and N2 is number of turns in
secondary ).

We know that Power = Current X Voltage. It is to be noted that input


power is equal to output power. Power is not changed. If V2 is greater
than V1, then I2 will be less than I1. This type of transformer is called as
step up transformer. If V1 is greater than V2, then I1 will be less than I2.
This type of transformer is called as step down transformer.
For step up transformer, N2>N1, i.e., number of turns of secondary
winding is more than those in primary.
For step down transformer, N1>N2, i.e., numbers of turns of primary
winding is more than those in secondary
RESISTORS
The flow of charge (or current) through any material, encounters an
opposing force similar in many respect to mechanical friction. This
opposing force is called resistance of the material. It is measured in
ohms. In some electric circuits resistance is deliberately introduced in
the form of the resistor.
Resistors are of following types:
1. Wire wound resistors.
2. Carbon resistors.
3. Metal film resistors.
Wire Wound Resistors:
Wire wound resistors are made from a long (usually Ni-Chromium)
wound on a ceramic core. Longer the length of the wire, higher is the
resistance. So depending on the value of resistor required in a circuit, the
wire is cut and wound on a ceramic core. This entire assembly is coated
with a ceramic metal. Such resistors are generally available in power of
2 watts to several hundred watts and resistance values from 1ohm to
100k ohms. Thus wire wound resistors are used for high currents.

Carbon Resistors:
Carbon resistors are divided into three types:
a. Carbon composition resistors are made by mixing carbon grains
with binding material (glue) and moduled in the form of rods. Wire
leads are inserted at the two ends. After this an insulating material
seals the resistor. Resistors are available in power ratings of 1/10,
1/8, 1/4 , 1/2 , 1.2 watts and values from 1 ohm to 20 ohms.
b. Carbon film resistors are made by deposition carbon film on a
ceramic rod. They are cheaper than carbon composition resistors.
c. Cement film resistors are made of thin carbon coating fired onto a
solid ceramic substrate. The main purpose is to have more precise
resistance values and greater stability with heat. They are made in
a small square with leads.
Metal Film Resistors:
They are also called thin film resistors. They are made of a thin metal
coating deposited on a cylindrical insulating support. The high resistance
values are not precise in value; however, such resistors are free of
inductance effect that is common in wire wound resistors at high
frequency.
Variable Resistors:
Potentiometer is a resistor where values can be set depending on the
requirement. Potentiometer is widely used in electronics systems.
Examples are volume control, tons control, brightness and contrast
control of radio or T.V. sets.
Fusible Resistors:
These resistors are wire wound type and are used in T.V. circuits for
protection. They have resistance of less than 15 ohms. Their function is
similar to a fuse made to blow off whenever current in the circuit
exceeds the limit.
Resistance of a wire is directly proportional to its length and inversely
proportional to its thickness.
R L
R 1/A
RESISTOR COLOR CODE
Example: 1k or 1000 ohms
1st 2nd 3rd 4th

Band1

Band 2

Band 3

Band 4

COLOUR CODES

COLOUR NUMB MULTIPL COLOU TOLERAN


ER IER R CE
Black 0 100 Gold 5%
Brown 1 101 Silver 10%
Red 2 102 No 20%
Orange 3 103 colour
Yellow 4 104
Green 5 105
Blue 6 106
Violet 7 107
Grey 8 108
White 9 109
Gold 10-1
Silver 10-2

CAPACITORS
A capacitor can store charge, and its capacity to store charge is called
capacitance. Capacitors consist of two conducting plates, separated by
an insulating material (known as dielectric). The two plates are joined
with two leads. The dielectric could be air, mica, paper, ceramic,
polyester, polystyrene, etc. This dielectric gives name to the capacitor.
Like paper capacitor, mica capacitor etc.
Types of capacitors:

Capacitor

Fixed capacitor Variable capacitor

Electrolytic Non-Electrolytic Gang Trimme


condenser r

Paper
Mica Ceramic

Capacitors can be broadly classified in two categories, i.e., Electrolytic


capacitors and Non-Electrolytic capacitors as shown if the figure above.
Electrolytic Capacitor:
Electrolytic capacitors have an electrolyte as a dielectric. When such an
electrolyte is charged, chemical changes takes place in the electrolyte. If
its one plate is charged positively, same plate must be charged positively
in future. We call such capacitors as polarized. Normally we see
electrolytic capacitor as polarized capacitors and the leads are marked
with positive or negative on the can. Non-electrolyte capacitors have
dielectric material such as paper, mica or ceramic. Therefore, depending
upon the dielectric, these capacitors are classified.
Mica Capacitor:
It is sandwich of several thin metal plates separated by thin sheets of
mica. Alternate plates are connected together and leads attached for
outside connections. The total assembly is encased in a plastic capsule or
Bakelite case. Such capacitors have small capacitance value (50 to
500pf) and high working voltage (500V and above). The mica capacitors
have excellent characteristics under stress of temperature variation and
high voltage application. These capacitors are now replaced by ceramic
capacitors.

Ceramic Capacitor:
Such capacitors have disc or hollow tabular shaped dielectric made of
ceramic material such as titanium dioxide and barium titanate. Thin
coating of silver compounds is deposited on both sides of dielectric disc,
which acts as capacitor plates. Leads are attached to each sides of the
dielectric disc and whole unit is encapsulated in a moisture proof
coating. Disc type capacitors have very high value up to 0.001uf. Their
working voltages range from 3V to 60000V. These capacitors have very
low leakage current. Breakdown voltage is very high.

Paper Capacitor:
It consists of thin foils, which are separated by thin paper or waxed
paper. The sandwich of foil and paper is then rolled into a cylindrical
shape and enclosed in a paper tube or encased in a plastic capsules. The
lead at each end of the capacitor is internally attached to the metal foil.
Paper capacitors have capacitance ranging from 0.0001uf to 2.0uf and
working voltage rating as high as 2000V.
THE DIODE
Diodes are polarized, which means that they must be inserted into the
PCB the correct way round. This is because an electric current will only
flow through them in one direction (like air will only flow one way
trough a tyre valve). Diodes have two connections, an anode and a
cathode. The cathode is always identified by a dot, ring or some other
mark.

+
The PCB is often marked with a +sign for the cathode end. Diodes come
in all shapes and sizes. They are often marked with a type number.
Detailed characteristics of a diode can be found by looking up the type
number in a data book. If you know how to measure resistance with a
meter then test some diodes. A good one has low resistance in one
direction and high in other. They are specialized types of diode available
such as the zener and light emitting diode (LED).

SYMBOLS OF DIFFERENT DIODES


anode cathode
simple diode zener diode

Power Supply

For TTL circuits, the power supply pin is labeled Vcc and its nominal
value.

For CMOS ICs, the power supply pin is labeled as VDD & its nominal
value range from T3 to 18V.

Unconnected Inputs

An unconnected input is called floating input. The floating TTL input


acts as logic 1. High level is applied to it. This characteristic is often
used when testing a TTL circuit. A floating TTL input will measure a
DC level between 1.4V to 1.8V when checked with VOM as
oscilloscope. If a CMOS input is left floating, it may have disastrous
results. The IC may become overheated and eventually destroy itself.
For this reason, all inputs to CMOS circuit must be connected to a LOW
or HIGH level or to the output of another IC.

Signals from switches

When a switch is used to provide an input to a circuit, pressing the


switch usually generates a voltage signal. It is the voltage signal which
triggers the circuit into action. What do you need to get the switch to
generate a voltage signal? . . . You need a voltage divider. The circuit
can be built in either of two ways:

The pull down resistor in the first circuit forces Vout to become LOW
except when the push button switch is operated. This circuit delivers a
HIGH voltage when the switch is pressed. A resistor value of 10 is
often used.

In the second circuit, the pull up resistor forces Vout to become HIGH
except when the switch is operated. Pressing the switch connects Vout
directly to 0 V. In other words, this circuit delivers a LOW voltage when
the switch is pressed.

In circuits which process logic signals, a LOW voltage is called 'logic 0'
or just '0', while a HIGH voltage is called 'logic1' or '1'. These voltage
divider circuits are perfect for providing input signals for logic systems.

What kinds of switches could you use. One variety of push button switch
is called a miniature tactile switch. These are small switches which
work well with prototype board:

As you can see, the switch has four pins which are linked in pairs by
internal metal strips. Pressing the button bridges the contacts and closes
the switch. The extra pins are useful in designing printed circuit boards
for keyboard input and also stop the switch from being moved about or
bent once soldered into position.
There are lots of other switches which you might want to use in a
voltage divider configuration. These include magnetically-operated reed
switches, tilt switches and pressure pads, all with burglar alarm
applications

Result
- we are giving advanced idea which can be implemented on large level.

ADVANTAGES

Low cost

Reliable

Portable

Flexible due to microcntroller

Easy to use- system is very easy to understand


BIBILOGRAPHY
Reference websites:

www.jammuprojects.com

www.suprema.com

www.8052.com

www.keil.com

Reference books:

1. The 8051 Microcontroller and Embedded Systems, by Ali


Mazidi & Gillispie Mazidi.

2. Embedded Microprocessor Systems: Real World Design by


Stuart R. Ball

3. Interfacing with C, Second Edition by Howard Hutchings and


Mike James

Вам также может понравиться