report on 8051 based home security system

18
CHAPTER 1 1.1 Introduction An Embedded product uses the microprocessor(or microcontroller) to do a specific task only. A printer is an example of Embedded system since the processor inside it performs one task only namely getting the data and printing it.In contrast to this Pentium based PC can be used for any no. of applications such as word processor, print server, bank teller terminal, video game player, network server or internet terminal. Software for variety of applications can be loaded and run. Of course the reason a PC can perform multiple task is that it has RAM memory and an operating system that loads the application software into RAM & lets the CPU run it. In an Embedded system there is only one application software that is typically burned into ROM. An x86PC contains or is connected to various Embedded Products such as keyboard, printer, modem, Disc controller, Sound card, CD-Rom Driver, Mouse & so on. Each one of these

Upload: jishnu-gupta

Post on 27-Oct-2014

110 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Report on 8051 based home security system

CHAPTER 1

1.1 Introduction

An Embedded product uses the microprocessor(or microcontroller) to do a specific task only.

A printer is an example of Embedded system since the processor inside it performs one task

only namely getting the data and printing it.In contrast to this Pentium based PC can be used

for any no. of applications such as word processor, print server, bank teller terminal, video

game player, network server or internet terminal. Software for variety of applications can be

loaded and run. Of course the reason a PC can perform multiple task is that it has RAM

memory and an operating system that loads the application software into RAM & lets the

CPU run it. In an Embedded system there is only one application software that is typically

burned into ROM. An x86PC contains or is connected to various Embedded Products such as

keyboard, printer, modem, Disc controller, Sound card, CD-Rom Driver, Mouse & so on.

Each one of these peripherals has a microcontroller inside it that performs only one task. For

example inside every mouse there is microcontroller to perform the task of finding the mouse

position and sending it to PC.

Although microcontroller are preferred choice for many Embedded systems, There are times

that a microcontroller is inadequate for the task. For this reason in recent years many

manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD & Cyrix

have targeted their microprocessors for the high end of Embedded market. While INTEL,

AMD, Cyrix push their x86 processors for both the embedded and desktop pc market,

Page 2: Report on 8051 based home security system

Motorolla is determined to keep the 68000 families alive by targeting it mainly for high end

of embedded system.

One of the most critical needs of the embedded system is to decrease power consumptions and

space. This can be achieved by integrating more functions into the CPU chips. All the

embedded processors based on the x86 and 680x0 have low power consumptions in additions

to some forms of I/O, Com port & ROM all on a single chip. In higher performance

Embedded system the trend is to integrate more & more function on the CPU chip & let the

designer decide which feature he/she wants to use.

1.2 EXAMPLES OF EMBEDDED SYSTEM

Automated teller machines (ATMS).

Cellular telephones and telephonic switches.

Computer printers, Copiers,Disk drives (floppy disk drive and hard disk drive)

Home automation products like thermostat, air conditioners and security monitoring

system, House hold appliances including microwave ovens, washing machines, TV sets DVD

players/recorders.

Measurement equipment such as digital storage oscilloscopes, logic analyzers and

spectrum analyzers.

Personal digital assistants (PDA’s), i.e., small hand held computer with P1M5 and

other applications.

Wearable computers.

Page 3: Report on 8051 based home security system

CHAPTER 2Microcontrollers/Microprocessors

Page 4: Report on 8051 based home security system

A microcontroller can be considered a self-contained system with a processor, memory and peripherals and can be used as an embedded system.

The majority of microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. These are called embedded systems. While some embedded systems are very sophisticated, many have minimal requirements for memory and program length, with no operating system, and low software complexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. 

2.1 MICROPROCESSOR (MPU) A microprocessor is a general-purpose digital computer central processing unit

(CPU). CPU is stand-alone, RAM, ROM, I/O, timer are separate.The block diagram of a

microprocessor CPU is shown

Fig. 3

BLOCK DIAGRAM OF A MICROPROCESSOR

CPUGeneral-Purpose Micro-processor

RAM ROM I/O Port

TimerSerial COM Port

Data Bus

Page 5: Report on 8051 based home security system

2.2 MICROCONTROLLERS (MCU)

A microcontroller is a true computer on a chip. The design incorporates all of the

features found in micro-processor CPU: ALU, PC, SP, and registers. The CPU, RAM,

ROM, I/O ports, clock circuit and timers are all on a single chip.

2.3 COMPARISON B/W MICROPROCESSORS & MICROCONTROLLERS

Microprocessor Microcontroller

1.Designer can decide on the amount of ROM,

RAM and I/O ports.

2.Expensive and versatile

3.Multipurpose

4. Concerned with rapid movement of the code

& data from the external addresses to the chip.

1.Fixed amount of on-chip ROM, RAM, I/O

ports

2.For applications in which cost, power and

space are critical

3.Specific purpose

4.Concerned with the rapid movement of the bits

within the chip.

Table:-1

Page 6: Report on 8051 based home security system

2.4 The 8051 Microcontroller

The Intel 8051 microcontroller is one of the most popular general purpose microcontrollers in use today. The success of the Intel 8051 spawned a number of clones which are collectively referred to as the MCS-51 family of microcontrollers, which includes chips from vendors such as Atmel, Philips, Infineon, and Texas Instruments.

The Intel 8051 is an 8-bit microcontroller which means that most available operations are

limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard, and Extended. The

Short and Standard chips are often available in DIP (dual in-line package) form, but the

Extended 8051 models often have a different form factor, and are not "drop-in compatible".

All these things are called 8051 because they can all be programmed using 8051 assembly

language, and they all share certain features (although the different models all have their own

special features).

Some of the features that have made the 8051 popular are:

64 KB on chip program memory.

128 bytes on chip data memory(RAM).

4 reg banks.

128 user defined software flags.

8-bit data bus

16-bit address bus

32 general purpose registers each of 8 bits

16 bit timers (usually 2, but may have more, or less).

3 internal and 2 external interrupts.

Bit as well as byte addressable RAM area of 16 bytes.

Four 8-bit ports, (short models have two 8-bit ports).

16-bit program counter and data pointer.

1 Microsecond instruction cycle with 12 MHz Crystal.

8051 models may also have a number of special, model-specific features, such as UARTs,

ADC, OpAmps, etc...

Page 7: Report on 8051 based home security system

2.6 8051 Microcontroller’s Basic Pin Description

PIN 9: PIN 9 is the reset pin which is used

reset the microcontroller’s internal

registers and ports upon starting up.

(Pin should be held high for 2

machine cycles.)

PINS 18 & 19: The 8051 has a built-in oscillator

amplifier hence we need to only

connect a crystal at these pins to

provide clock pulses to the circuit.

PIN 40 and 20: Pins 40 and 20 are VCC and ground

respectively. The 8051 chip needs

+5V 500mA to function properly,

although there are lower powered versions like the Atmel 2051 which is a scaled down

version of the 8051 which runs on +3V.

PINS 29, 30 & 31:

As described in the features of the 8051, this chip contains a built-in flash memory. In

order to program this we need to supply a voltage of +12V at pin 31. If external

Figure 6 Basic Pin Diag. of 8051 µC

Page 8: Report on 8051 based home security system

memory is connected then PIN 31, also called EA/VPP, should be connected to

ground to indicate the presence of external memory.

PIN 30 is called ALE (address latch enable), which is used when multiple memory

chips are connected to the controller and only one of them needs to be selected.

PIN 29 is called PSEN. This is "program store enable". In order to use the external

memory it is required to provide the low voltage (0) on both PSEN and EA pins.

CHAPTER 3Internal Design of 8051 Microcontroller

3.1 Architectural features & Description3.1.1 The Central Processing Unit

The central processing unit (CPU) does all the computing: it fetches, decodes and executes

program instructions and directs the flow of data to and from memory. The CPU performs the

calculations required by program instructions and places the results of these calculations, if

required, into memory space. Most CPUs are synchronous. This means that they depend on

the cycles of a processor clock. A clock generates a high-frequency square wave usually

driven by a crystal, a RC (resistor capacitor) or an external source. The clock is sometimes

referred to as an oscillator. The clock speed, or oscillation rate, is measured in megahertz

Page 9: Report on 8051 based home security system

(MHz), which represents one million cycles/second. For example, if the clock speed is 3 MHz

then there are 3,000,000-clock cycles/second. Clock configurations are micro controller

dependent.

Fig. 8 Block Diag. of Internal Architecture of CPU of 8051 µC

These include:

1. THE STACK POINTER:

The stack pointer contains the address of the next location on the stack. The address in the

stack pointer is decremented when data is pushed on the stack and incremented when data is

popped from the stack.

2. THE INDEX REGISTER:

The index register is used to specify an address when certain addressing modes are used. It is

also known as the pointer register. The Microchip devices use the name FSR (file select

register).

3. THE PROGRAM COUNTER:

Page 10: Report on 8051 based home security system

The PC holds the address of the next instruction in program memory space. It contains the

address of the next instruction the CPU will process. As each instruction is fetched and

processed by the ALU, the CPU increments the PC and thereby steps through the program

stored in the program memory space.

4. THE ACCUMULATOR:

The accumulator is a register that can hold operands or results of operations as necessary. The

Microchip devices use the name W (working) register. Other registers may reflect results

from the instruction just executed, control the options available on the device, and enable

access to certain areas of memory.

3.1.2 The Internal Architecture of 8051

Data and Program Memory

The 8051 Microcontroller can be programmed in PL/M, 8051 Assembly, C and a number of

other high-level languages. Many compilers even have support for compiling C++ for an

8051.

Program memory in the 8051 is read-only, while the data memory is considered to be

read/write accessible. When stored on EEPROM or Flash, the program memory can be

rewritten when the microcontroller is in the special programmer circuit.

Program Start Address

The 8051 starts executing program instructions

from address 0000 in the program memory. Direct Memory

The 8051 has 256 bytes of internal addressable RAM, although only the first 128 bytes are

available for general use by the programmer. The first 128 bytes of RAM (from 0x00 to 0x7F)

are called the Direct Memory, and can be used to store data.

Page 11: Report on 8051 based home security system

Special Function Register

The Special Function Register (SFR) is the upper area of addressable memory, from address

0x80 to 0xFF. A, B, PSW, DPTR are called SFR.This area of memory cannot be used for data

or program storage, but is instead a series of memory-mapped ports and registers. All port

input and output can therefore be performed by memory mov operations on specified

addresses in the SFR. Also, different status registers are mapped into the SFR, for use in

checking the status of the 8051, and changing some operational parameters of the 8051.

General Purpose Registers

The 8051 has 4 selectable banks of 8 addressable 8-bit registers, R0 to R7. This means that

there are essentially 32 available general purpose registers, although only 8 (one bank) can be

directly accessed at a time. To access the other banks, we need to change the current bank

number in the flag status register.

A and B Registers The A register is located in the SFR memory location 0xE0. The A register works in a similar fashion to the AX register of x86 processors. The A register is called the accumulator, and by default it receives the result of all arithmetic operations. The B register is used in a similar manner, except that it can receive the extended answers from the multiply and divide operations. When not being used for multiplication and Division, the B register is available as an extra general-purpose register.

Page 12: Report on 8051 based home security system

CHAPTER 4Interfacing of Various Devices with Microcontroller

4.1 Interfacing of Power Supply

Page 13: Report on 8051 based home security system

Fig. 11 Power Supply Circuit

Above is shown the circuitry of regulated power supply using a bridge rectifier. The power supply incorporates shunt capacitor circuit along with 7805 and 7812 voltage regulator IC. For the interfacing of various components Vcc of 5 Volts has been supplied. Also the various sensors incorporated in the project have been provided the Vcc in parallel with the supply.

4.2 Interfacing of LED

The 8051 microcontrollers can provide only low input current and since their pins are

configured as outputs when voltage level on them is equal to 0, direct connecting to LEDs is

carried out as it is shown in figure. The resistor here is current limiting resistor.

4.3 Interfacing of Seven Segmented Display

The most commonly used are so called 7-segment displays. They are composed of 8 LEDs, 7

segments are arranged as a rectangle for symbol displaying and there is additional segment for

Fig. 12 LED Interfacing with 8051 µC

Fig.14 Seven Segmented Display

Page 14: Report on 8051 based home security system

decimal point displaying. In order to simplify connecting, anodes and cathodes of all diodes

are connected to the common pin so that there are common cathode displays and common

anode displays. Segments are marked with the letters a to g as shown in the figure.