Sei sulla pagina 1di 68

TRAINING REPORT ON

EMBEDDED SYSTEM USING


8051 MICROCONTROLLER
J.N.G.E.C. SUNDERNAGAR

Anjali Rai

Submitted By :EC4873

Archna Dhiman EC4881


Jyoti Thakur
EC 4894
Monika Chauhan EC4904
Neha Verma
EC4907

TABLE OF CONTENT
TOPIC

Acknowledgment
Preface
Company profiles
Embedded system

Introduction
Applications of embedded system
Microcontroller
Introduction
Definition of microcontroller
Block diagram
Microprocessor
Introduction
Definition of microprocessor
Block diagram
Difference between microcontroller and microprocessor

Various microcontrollers

8031
8051
AT89C51
8051 microcontroller architecture
Block diagram
Pin diagram
Pin description
Microcontroller memory organization
Program memory
Data memory
Software used
Various steps to use compiler
How to debug the program

Interfacing with various devices

LED Interfacing
DC Motor
Relay
Stepper Motor
Seven Segment
LCD Interfacing
Project description
Introduction to project
Circuit diagram of Home Security Prototype
Project methodology
Procedure
Description in detail
Application and advantages
Future development
Reference and Bibliography

COMPANY PROFILES

EEAST is a complete R & D organization dedicated to provide electronics and

Advanced Software Products and Solutions to its clients. Achieving the needs
of our costumer and converting their ideas to real models is our motto.

We are working in the field of Embedded systems, Automation and advanced

system design for the last five years with the vision of becoming a center of
Excellence to provide Solutions, Services and Training in various fields of
technologies.

EEAST is an organization providing advanced projects, complete electronics

solutions in development systems like microprocessor, micro-controllers,


wireless communications, optical-fiber communications, real time operating
systems, digital signal processing,

Embedded systems and Micro-sensors including software solution, solution in

C, C++, Java, Net, Visual basic, embedded C and embedded LINUX.

INTRODUCTION TO EMBEDDED SYSTEMS


An Embedded System employs a combination of hardware & software (a

computational engine) to perform a specific function; is part of a larger


system
that may not be a computer works in a reactive and timeconstrained environment. Software is used for providing features and
flexibility. Hardware ={Processors, ASICs, Memory...} is used for
performance (& sometimes security )
An embedded system is a special purpose system in which the computer is

completely encapsulated by the device it controls.


Unlike a general purpose

computer, such as a PC, an embedded system


performs predefined tasks usually with very specific tasks design
engineers can optimize it reducing the size and cost of the product.
Embedded systems are often mass produced, so the cost savings may be
multiplied by millions of items.

The core of any embedded system is

formed
by
one
or
several
microprocessoror
micro
controller
programmed to perform a small number of
tasks. In contrast to a general purpose
computer, which can run any software
application, the userchooses, the software
on an embedded system is semipermanent, so it is often called firmware.

APPLICATIONS OF EMBEDDED SYSTEM


Automated tiller machines (ATMS).
Avionic,suchasinertialguidancesystems,flightcontrolhardware/softwa

re and letter integrated system in aircraft and missile.


Cellular telephones and telephonic switches.
Computer network equipment, including routers timeservers and firewalls
Computer printers, Copiers
.Disk drives (floppy disk drive and hard disk drive)
Engine controllers and antilock brake controllers for automobiles.
Home automation products like thermostat, air conditioners sprinkles and
security monitoring system.
House hold appliances including microwave ovens, washing machines, TV
sets DVD players/recorders.
Medical equipment
Stationary video game controllers.
Wearable computers.
Measurement equipment such as digital storage oscilloscopes, logic
analyzers and spectrum analyzers.
Multimedia appliances: internet radio receivers, TV set top boxes.

MICROPROCESSOR (MPU)
A microprocessor is a general-purpose digital

computercentral
processing
unit(CPU).Although
popularlyknownasacomputeron
achip
isinnosensea
complete
digitalcomputer.The
blockdiagramof
amicroprocessorCPUisshown,
which
contains an arithmetic and logical unit (ALU),
program counter (PC), a stackpointer
(SP),some working registers, a clock timing
circuit, and interrupt circuits.

BLOCK DIAGRAM OF
MICROPROCESSOR

The prime use of microprocessor is to read data, perform

extensive calculations on that data and store them in


the mass storage device or display it. The prime
functions of microcontroller is to read data, perform
limited calculations on it,control its environment based
on these data.
Thus the microprocessor is said to be general-purpose

digital computers whereas the microcontroller are intend


tobe special purposedigital controller.
Microprocessor need many opcodes for moving data

from the external memory to the CPU, microcontroller


may require just one or two, also microprocessor may
have one or two types ofbit handling instructions
whereas microcontrollers have many.

Lastly,

themicroprocessor
design
accomplishes the goal of flexibility in
thehardware configuration by enabling large
amounts of memory and I/O that could be
connected to the address and data pins on the
IC package. The microcontroller design uses
much more limited set of single and double
byte instructions to move code and data from
internal

Microcontroller
Microcontroller,asthenamesuggests,aresm

allcontrollers.
Theyarelike
singlechip
computers that are often embedded into other
systems to function as processing/controlling
unit. For example, the remote control you are
using probably has microcontrollers inside
that do decoding and other controlling
functions. They are also used in automobiles,
washing machines, microwave ovens, toys ...
etc, where automation is needed

The key features of microcontrollers include:


High Integration of Functionality
Microcontrollers sometimes are

called single-chip
computers because they have on-chip memory and
I/O circuitry and other circuitries that enable them to
function as small stand alone computerswithout other
supportingcircuitry.
FieldProgrammability,Flexibility
Microcontrollers often
useEEPROMor EPROMas
theirstoragedevice toallow fieldprogrammability so
they are flexible to use. Once the program is tested to
be correct then large quantities of microcontrollers
can be programmed to be used in embedded systems

A Timer module toallow the microcontroller to

perform tasks for certain time periods.


A serial I/O port to allow data to flow between

the microcontroller and other devices such as


aPC or anothermicrocontroller.
An ADC to allow the microcontroller to accept

analogue input datafor processing

BLOCK DIAGRAMOF A MICROCONTROLLER

Thedesign
incorporatesallofthefeaturesfoundinmicroprocessor
CPU: ALU, PC, SP, and registers. Italso added the other
features needed to make acomplete computer: ROM,
RAM, parallel I/O, serial I/O, counters, and clock circuit

DIFFERENCE BETWEEM MICROPROCESSOR AND


MICROCONTROLLER

MICROPROCESSORS
MICROCONTROLLERS
1.
Microprocessorscontainno
Microcontrollershaveaninternal

1.

2.
Microprocessor dont have any I/O
ports.
Ports.
3.
Advantage of versatility.
consumption.
4.
Expensive.
5.
With the addition of external RAM
And ROM, the system is more bulky.

RAMor ROM.
RAMandaROM
2.Microcontrollers have I/O

3. Advantage of less power

4. Cheaper in comparison.
5. Occupies less space.

VARIOUS MICROCONTROLLERS

First microcontroller is 8031


FEATURES
1. It is Intels product. Neither a microprocessor nor a

microcontroller.
2. It is 8-bit controller.
3. Internally no RAM is provided i.e. code is outside the chip.
.Second microcontroller is 8051
.FEATURES
1. It is first complete 8-bit microcontroller.
2. It is a name of a family. In which the instruction set, pin
configuration, architecture are same, only memory
storage capacity is different.
3. Internally PROM (programmable read only memory) is
provided so it called one time programmable (OTP)

Third microcontroller is AT89C51


FEATURES
1. It is similar to 8051 microcontroller i.e. having same

instruction set, pin configuration, architecture.


2. It is also 8-bit microcontroller. Its cost is only Rs 10

more than 8051.


3. It uses EPROM (erasable programmable read only

memory) or FLASH memory.


4. It is multiple time programmable (MTP) i.e. 1000

times. So it is better than 8051.

ATMEL 89C51

It

is a lower-power, high-performance CMOS 8-bit


microcomputer with 4K 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 nonvolatile
memory programmer.
By combining a versatile 8-bit CPU with Flash on a

monolithic chip, the Atmel AT89C51 is a powerful


microcontroller, which provides a highly flexible and costeffective solution to many embedded control applications.

THE 8051 MICROCONTROLLER


The 8051 provides the following standard features:
4k bytes of ROM, 128 bytes of RAM, 32 I/O lines, two

16-bit timer/counters, and five vector two-level


interrupt architecture, a full duplex serial port, onchip oscillator and clock circuitry
In addition, the 8051 is designed with static logic

for operation down to zero frequency and supports


two software selectable power saving modes.

BLOCK DIAGRAM OF MICROCONTROLLER

EXTERNAL
INTERRUPTS

INTERRUPT
CONTROL

ON-CHIP
ROM for
program
code

ETC.

ON-CHIP
RAM

TIMER 0

CPU

OSC

BUS
CONTROL

4 I/O
PORTS

SERIAL
PORT

TXD RXD

THE 8051 MICROCONTROLLERS ARCHITECTURE


Eight bit CPU with registers A (the accumulator) & B.
Sixteen bit program counter (PC) and data pointer (DPTR).
Eight bit program status word (PSW).
Eight bit stack pointer (SP).
Internal ROM or EPROM.
Internal RAM of 128 bytes

Four register banks, each containing eight registers.


Sixteen bytes, which may be addressed at the bit level.
Eight bytes of general-purpose data memory.
Thirty two I/O pins arranged as four-bit ports P 0-P3.
Two 16-bit timer/counters T 0 and T1.
Full duplex serial data received/transmitter.
Two external and three internal interrupt sources.

PIN DIAGRAM

PIN DESCRIPTION

Vcc

Pin 40 provides supply voltage to the chip. The voltage source is +5 V .


GND

Pin 20 is the ground.


X1 and X2
The 8051 have an on-chip oscillator but requires external clock to run it. Most
often a quartz crystal oscillator is connected to input X1 (pin 19) and X2 (pin 18).
RESET
Pin 9 is the reset pin. It is an input and is active high (normally low).
EA
EA, which stands for external access, is pin number 31 in the
DIP packages. It is input pin and must be connected to either Vcc
or GND. In other words, it cannot be left unconnected.

PSEN
This is an output pin. PSEN stands for program store enable. It
is the read strobe to external program memory
ALE

ALE (Address latch enable) is an output pin and is active


high
I/O port pins

The four ports P0, P1, P2, and P3 each use 8 pins,
making them 8-bit ports. All the ports upon RESET are
configured as output, ready to be used as output ports. To
use any of these as input port, it must be programmed.

Software Used
The

Keil 8051 Development Tools are


designed to solve the complex problems
facing embedded software developers.

When starting a new project, simply select the

microcontroller you use from the Device


Database and the Vision IDE sets all
compiler, assembler, linker, and memory
options for you.

INTERFACING WITH VARIOUS DEVICES:

LED INTERFACING
CIRCUIT DIAGRAM

VCC

D 1
L E D
D 2

3
3
3
3
3
3
3
3

D 3
L E D
D 4

D 5
L E D

1 9
1 8
9

D 6
Y ?

D 7
L E D
D 8
L E D

9
8
7
6
5
4
3
2
1
2
3
4
5
6
7
8

L E D

L E D

40

U ?

L E D

3 1

C R Y S TA L
C ?
C A P N P

P
P
P
P
P
P
P
P

0
0
0
0
0
0
0
0

.0
.1
.2
.3
.4
.5
.6
.7

/A
/A
/A
/A
/A
/A
/A
/A

P
P
P
P
P
P
P
P

1
1
1
1
1
1
1
1

.0 /T 2
.1 /T 2 -E X
.2
.3
.4
.5
.6
.7

XTA L 1
XTA L 2
R S T

0
1
2
3
4
5
6
7

P
P
P
P
P
P

P
P
2
2
2
2
2
2

2 .0 /A
2 .1 /A
.2 /A 1
.3 /A 1
.4 /A 1
.5 /A 1
.6 /A 1
.7 /A 1

8
9
0
1
2
3
4
5

P 3 .0 /R XD
P 3 .1 /T XD
P 3 .2 /IN T O
P 3 .3 /IN T 1
P 3 .4 /T O
P 3 .5 /T 1
P 3 .6 /W R
P 3 .7 /R D
P S E N
A L E /P R O G

E A /V P P

A T8 9 C 5 2
R 1
R

D
D
D
D
D
D
D
D

20

2
2
2
2
2
2
2
2

1
2
3
4
5
6
7
8

1
1
1
1
1
1
1
1

0
1
2
3
4
5
6
7

2 9
3 0

Like a normal diode, an LED consists of a chip of semiconducting

material impregnated, or doped, with impurities to create a p-n junction.


LEDs are usually built on an n-type substrate, with an electrode attached

to the p-type layer deposited on its surface. P-type substrates, while less
common, occur as well.
Many commercial LEDs, especially GaN/InGaN, also use sapphire

substrate. Substrates that are transparent to the emitted wavelength,


and backed by a reflective layer, increase the LED efficiency.
The refractive index of most LED semiconductors is quite high, so in

almost all cases the LED is coupled into a much lower-index medium.
The large index difference makes the reflection quite substantial (per
the Fresnel coefficients), and this is usually one of the dominant causes
of LED inefficiency.
Often more than half of the emitted light is reflected back at the LED-

package and package-air interfaces impurities to create a p-n junction.

There are two methods of LED interfacing:


Common Anode Method
Common Cathode Method
Here we have employed Common Anode
Method

FOUR ON FOUR OFF PATTERN

#include<reg51.h>
// this file contains the Ports and SFR address of 8051
#include<delay.h> // this file is used to produce seconds and milliseconds delay
#define led P1
// 'P1' is given the another name as led, u can use 'led' Or
directly 'P1'
//for programming

Void main () // main program starts from here


{
while (1)
// Repeat forever
{
led=0xf0;
// light on lower 4 leds '0'-> ON (11110000)
secdelay (1);
// 1 secdelay
led=0x0f;
// light on upper 4 leds '1'-> OFF (00001111)
secdelay (1);
}
}

DC MOTOR INTERFACING
Circuit Diagram
VCC
VCC

R1

10 K

S1
S2 1
S3 1
1

2
2
2

33PF C R Y STAL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

C1
Y1
C2

33PF

19
20

VCC
P 1 .0
P 1 .1
P 1 .2
P 1 .3
P 1 .4
P 1 .5
P 1 .6
P 1 .7
RESET
R XD
TXD
IN T 0
IN T 1
T0
T1
WR
RD
X2
X1
VSS

GROUND

P 0 .0
P 0 .1
P 0 .2
P 0 .3
P 0 .4
P 0 .5
P 0 .6
P 0 .7
E A /V P
A L E /P
PSEN

8051

P 2 .7
P 2 .6
P 2 .5
P 2 .4
P 2 .3
P 2 .2
P 2 .1
P 2 .0

40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21

R E S IS T O R S IP 1 0
R2
2
3
4
5
6
7
8
9
10

2
3

1
4
5
6

IN 1

O U T1

IN 2

O U T2

IN 3

O U T3

IN 4

O U T4

IN 5

O U T5

IN 6

O U T6

16
15
1

10 U F

U1

14

MG2

13
12

M OTOR DC

11

SW 1 C3

R ESET S/W

U5

7
C

IN 7

O U T7

GRD

VCC

U L2 0 0 3

10
9
VCC

K1

3
4
1
2

R ELAY S P D T
D E V IC E

Working Principle
The principle upon which the d.c. motor works is very
simple. If a current carrying conductor is placed in a
magnetic field, mechanical force is experienced on the
conductor, the direction of which is given by the
Fleming's left hand rule and hence the conductor moves in
the direction of force. The magnitude of the mechanical
force experienced on the conductor is given by:
F = B Ic Lc newton
where B is the field strength in teslas,
Ic is the current flowing through the conductor in amperes
and Lc is the length of the conductor in metres.


ON -OFF DC MOTOR
#include<reg51.h>
#include<delay.h>
/* define the motor using sbit as dc motor */
sbit dc_motor=P0^5;
#define ON 1
#define OFF 0
void main()
{
while(1)
{
dc motor=ON; // switch on the Dc motor
secdelay(3);
dc_motor=OFF; // switch OFF the Dc motor
secdelay(2);
}

RELAY INTERFACING

ELECTROMAGNETIC solenoid valve


The electromagnetic relay consists of a multi-turn coil,

wound on an iron core, to form an electromagnet.


When the coil is energised, by passing current
through it, the core becomes temporarily magnetised.
The magnetised core attracts the iron armature. The
armature is pivoted which causes it to operate one or
more sets of contacts.
When the coil is de-energised the armature and
contacts are released. The coil can be energised from
a low power source such as a transistor while the
contacts can switch high powers such as the mains
supply.
The relay can also be situated remotely from the
control source. Relays can generate a very high
voltage across the coil when switched off. This can
damage other components in the circuit.
To prevent this a diode is connected across the coil.

As there are always some chances of high


voltage spikes back from the switching
circuit i.e. heater so an up to coupler/isolator
MCT2e is used.
It provides and electrical isolation between the
microcontroller and the heater

CIRCUIT DIAGRAM
VCC

10 U F

U1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

R1

10 K

S1
1
S2
1
S3

2
2

33P F C R Y STAL
C1
Y1
C2

33PF

18
19
20

P 1 .0
P 1 .1
P 1 .2
P 1 .3
P 1 .4
P 1 .5
P 1 .6
P 1 .7
RESET
R XD
TXD
IN T 0
IN T 1
T0
T1
WR
RD
X2
X1
VSS

GROUND

VCC
P 0 .0
P 0 .1
P 0 .2
P 0 .3
P 0 .4
P 0 .5
P 0 .6
P 0 .7
E A /V P
A L E /P
PSEN

8051

P 2 .7
P 2 .6
P 2 .5
P 2 .4
P 2 .3
P 2 .2
P 2 .1
P 2 .0

40
39
38
37
36
35
34
33
32
31
30

R E S IS T O R S IP 1 0
R2
2
3
4
5
6
7
8
9
10

1
2
3

4
5
6

IN 1

O U T1

IN 2

O U T2

IN 3

O U T3

IN 4

O U T4

IN 5

O U T5

IN 6

O U T6

7
C

IN 7

O U T7

GRD

VCC

29
28
27
26
25
24
23
22
21

16
15
14

MG2

13
12
11
2

SW 1 C3

R ESET S/W

U5

VCC

10
9
VCC

U L2 0 0 3

M OTOR DC

K1
3
1
2

5
4

R ELAY S P D T
D E V IC E

SIMPLE RELAY CONTROL


#include<reg51.h>
#include<delay.h>
sbit dev=P0^6;
#define ON 1
#define OFF 0
void main()
{
while(1)
{
dev=ON;
secdelay(5);
dev=OFF;
secdelay(3);
}
}

// define the 220v device using sbit as dev

STEPPER MOTOR
A stepper motor is an electromechanical device which converts

electrical pulses into discrete mechanical movements. Stepper


motor is a form of ac. motor .
The shaft or spindle of a stepper motor rotates in discrete step

increments when electrical command pulses are applied to it in


the proper sequence.
The motors rotation has several direct relationships to these

applied input pulses.


The sequence of the applied pulses is directly related to the

direction of motor shafts rotation.


The speed of the motor shafts rotation is directly related to the

frequency of the input pulses and the length of rotation is


directly related to the number of input pulses applied

For every input pulse, the motor shaft turns

through a specified number of degrees, called


a step.
Its working principle is one step rotation

for one input pulse. The range of step


size may vary from 0.72 degree to 90
degree.

A stepper motor differs from a conventional motor (CM)


as under:
Input to SM is in the form of electric pulses
whereas input to a CM is invariably from a
constant voltage source.
A CM has a free running shaft whereas shaft
of SM moves through angular steps.
In control system applications, no feedback
loop is required when SM is used but a
feedback loop is required when CM is used.
A SM is a digital electromechanical device
whereas a CM is an analog electromechanical
device .

CIRCUIT DIAGRAM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

R1

10 K
2

S1
1
S2
S3 1

2
2

33PF C R Y STAL
C1
C2

33PF

Y1

18
19
20

P 1 .0
P 1 .1
P 1 .2
P 1 .3
P 1 .4
P 1 .5
P 1 .6
P 1 .7
RESET
R XD
TXD
IN T 0
IN T 1
T0
T1
WR
RD
X2
X1
VSS

GROUND

VCC
P 0 .0
P 0 .1
P 0 .2
P 0 .3
P 0 .4
P 0 .5
P 0 .6
P 0 .7
E A /V P
A L E /P
PSEN

40
39
38
37
36
35
34
33
32
31
30
29

U5

R2
2
3
4
5
6
7
8
9
10

2
3
4
5
6

7
8

IN 1

O U T1

IN 2

O U T2

IN 3

O U T3

IN 4

O U T4

IN 5

O U T5

IN 6

O U T6

IN 7

O U T7

GRD

VCC

16

1
2
3

15
14
13
12
11
10
9
VCC

8051

P 2 .7
P 2 .6
P 2 .5
P 2 .4
P 2 .3
P 2 .2
P 2 .1
P 2 .0

28
27
26
25
24
23
22
21

UL2 0 0 3

10 UF

U1

R E S IS T O R S IP 1 0

M O T O R M SG 1T E P P E R

SW 1 C3

R ESET S / W

VCC

VCC

DIRECTION CONTROL
#include<reg51.h>
#include<delay.h>
sbit m1=P0^0;
// define the four windings of stepper motor using sbit m1,m2,m3,m4
sbit m2=P0^1;
sbit m3=P0^2;
sbit m4=P0^3;
void mov_clk()
{
m1=1;m2=0;m3=0;m4=0;
//give high pulse to m1 motor moves one step angle in
// clockwise
ms_delay(200);
m1=0;m2=1;m3=0;m4=0;
//give high pulse to m2 motor moves two step angle in
// clockwise
ms_delay(200);
m1=0;m2=0;m3=1;m4=0; //give high pulse to m3 motor moves three step angle in
// clockwise
ms_delay(200);
m1=0;m2=0;m3=0;m4=1; //give high pulse to m4 motor moves four step angle in
// clockwise
ms_delay(200);
}

void mov_anticlk()
{
m1=0;m2=0;m3=0;m4=1;
moves one step anglein

//give high pulse to m4 motor


//

anti clockwise
ms_delay(200);
m1=0;m2=0;m3=1;m4=0;
ms_delay(200);
m1=0;m2=1;m3=0;m4=0;
ms_delay(200);
m1=1;m2=0;m3=0;m4=0;
ms_delay(200);
}
void motor_stop()
{
m1=0;m2=0;m3=0;m4=0;
}

void main()
{
while(1)
{
mov clk(); // motor moves in clock wise direction
motor stop();
// motor stops
secdelay(2);
mov anticlk();
// motor moves in anticlock
wise direction
motor stop();
// motor stops
secdelay(2);
}
}

SEVEN SEGMENT INTERFACING


The seven-segment LED display has four
individual digits, each with a decimal point.

Each of the seven segments (and the decimal

point) in a given digit contains an individual


LED.
When a suitable voltage is applied to a given

segment LED, current flows through and


illuminates that segment LED. By choosing
which segments to illuminate, any of the nine
digits can be shown

Seven segment displays come in two varieties common anode (CA) and common cathode
(CC).
In a CA display, the anodes for the seven segments
and the decimal point are joined into a single circuit
node.
To illuminate a segment in a CA display, the
voltage on a cathode must be at a suitably lower
voltage (about .7V) than the anode.
In a CC display, the cathodes are joined together,
and the segments are illuminated by bringing the
anode voltage higher than the cathode node
(again, by about .7V).
The Digilab board uses CA displays.

Circuit diagram

R2

4 70 E

LED 1
LED 2

VC C (5 V)

LED 6
LED 7
LED 8

R1

10 K

S1
S2
S3

33P F C R Y STAL
C1
C2

33PF

Y 1

18
19
20

X2
X1
VSS

P 0 .0
P 0 .1
P 0 .2
P 0 .3
P 0 .4
P 0 .5
P 0 .6
P 0 .7
E A /V P
A L E /P
PSEN

40
39
38
37
36
35
34
33
32
31
30
29

g
f
vcc
a
b

10 U F

P 1 .0
P 1 .1
P 1 .2
P 1 .3
P 1 .4
P 1 .5
P 1 .6
P 1 .7
RESET
R XD
TXD
IN T 0
IN T 1
T0
T1
W R
RD

VCC

8051

P
P
P
P
P
P
P
P

2 .7
2 .6
2 .5
2 .4
2 .3
2 .2
2 .1
2 .0

28
27
26
25
24
23
22
21

e
d
vcc
c
h

C3

LED 5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

VCC

6
7
8
9
10

SW 1

R ESET S/W

VCC

LED 4

U1

5
4
3
2
1

LED 3

GROUND

U2

7-s e g m e n t

UP COUNTER
#include<reg51.h>
#include<delay.h>
#define seg_port P2
//define segment port
// array is used to store the value of data to be sent on the port to display
// any digit on seven segment as below
unsigned char seg_array[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void main()
{
unsigned char count;
while(1)
{
for(count=0;count<10;count++)
{
seg_port=seg_array[count];
secdelay(1);
}
}
}

// put array digit value from array to the port

LCD
LCD Display
Liquid crystal displays (LCD) are widely used
in recent years as compares to LEDs. This is
due to the declining prices of LCD, the ability
to display numbers, characters and graphics,
incorporation of a refreshing controller into
the LCD, their by relieving the CPU of the task
of refreshing the LCD and also the ease of
programming for characters and graphics. HD
44780 based LCDs are most commonly used.

LCD pin description


1
1
1
1
1
1
1
9
8
7
6
5
4
3
2
1

6
5
4
3
2
1
0

G
V
D
D
D
D
D
D
D
D
E
R
R
C
V
G

nd
cc
7
6
5
4
3
2
1
0
/
S
o
c
n

6
5
4
3
2
1
0
9
8
7
6
5
4
3
2
1

W
ntrast
c
d

1
1
1
1
1
1
1

LCD pin
description
Pin

Symbol

I/O

Description

VSS

Ground

VCC

+5V power
supply

VEE

Power supply to
control contrast

RS

RS=0 to select
command
register, RS=1
to select data
register.

R/W

R/W=0 for
write, R/W=1
for read

Pin

Symbol

I/O

Description

PB0

I/O

The 8 bit data bus

PB1

I/O

The 8 bit data bus

DB2

I/O

The 8 bit data bus

10

DB3

I/O

The 8 bit data bus

11

DB4

I/O

The 8 bit data bus

12

DB5

I/O

The 8 bit data bus

13

DB6

I/O

The 8 bit data bus

14

DB7

I/O

The 8 bit data bus

Circuit diagram

LCD FUNCTION
#include<reg51.h>
#include<delay.h>
#define DATA P1
// define DATA and Control Pins of LCD
sbit RS=P3^5;
sbit RW=P3^6;
sbit E=P3^7;

void lcd_cmd(unsigned char data x) // function to write command at lcd


port
{
ms_delay(20);
DATA=data x;
RS=0;
//clear RS (i.e. RS=0) to write command
RW=0; // write operation
E=1; // send H-L pulse at E pin
ms_delay(5);
E=0;
}

void lcd_data (unsigned char datax)


// function to write data at lcd port
{
ms_delay(20);
DATA=datax;
RS=1;
// set RS=1 to write DATA
RW=0;
// write operation
E=1;
// send H-L pulse at E pin
ms_delay (5);
E=0;
}
void lcd_init()
// function to initialize the LCD at power on time
{
lcd_cmd(0x38);
// 2x16 display select
ms_delay(3);
lcd_cmd (0x38);
// 2x16 display select
ms_delay(3);
lcd_cmd (0x0c);
// display on cursor off command
ms_delay(3);
lcd_cmd (0x06);
// automatic cursor movement to right
ms_delay(3);
lcd_cmd (0x01);
// lcd clear command
ms_delay(3);
lcd_cmd (0x80);
// first row first column select command
ms_delay(3);
}


void lcd_puts(unsigned char *str)
// function to display string to lcd
{
while(*str!='\0')
{
lcd_data(*str);
str++;
}
}

void displaypval(unsigned int datax)


// function to display 3 digit decimal value to lcd
{
unsigned int temp,temparr[3];
for(temp=3;temp>0;temp--)
{
temparr[temp-1]=datax%10;
datax=datax/10;
}
for(temp=0;temp<3;temp++)
{
lcd_data(temparr[temp]+48);
}
}

void main()
{
lcd_init();
while(1)
{
lcd_cmd(0x80);
lcd_puts("Value");
lcd_cmd(0xc0);
displaypval(123);
}

MINOR
PROJECT
HOME SECURITY
SYSTEM

INTRODUCTION
THE NEED
Our doors serve as entrances to our homes and

offices. They may also provide access to strangers,


criminals and offenders. So how do we secure our
doors and prevent intrusions by these people? This is
the sole of purpose of door locks. They keep us and
our properties safe and protected
The method of lock picking involves opening the door
lock with a locking tool kit. A basic kit contains a
screwdriver or other types of tension wrench and a
lock pin, which is a long and thin piece of metal that
is curved at one end. In cases of emergencies, a
hairpin may substitute for the lock pin.

A professional kit, on the other hand, contains several

types of tension wrenches in varying in sizes and


shapes and lock pins with different dimensions. It may
also contain a pick gun which is an instrument that
vibrates and push several lock pins at the same time.
The main goal of this project is develop an
embedded password security door lock system
using microcontroller. In this project we are going
to use 4x4 keypad to enter the security lock. Here
microcontroller place major role which is nothing
but decision of door opening. Here predefined
password is stored in microcontroller. We have to
write a code such that whenever password is
entered from keypad if that password is matches
door has to open. Otherwise buzzer has to on.

PROJECT METHODOLOGY
Component Name
1.Power supply section
Plug with wire
Step down transformer
1N4007 diodes
LM7805
100F capacitor
ON/OFF switch
1K Resistor
2. Microcontroller section
Microcontroller IC (AT89C51) with base
Crystal oscillator
Capacitor
Resistor
LCD connector
3.Buzzer
4.LCD
5. Stepper motor
6.ON/OFF switch

Quantity
1
1
4
1
1
1
1
1
1
2
1
1
1
1
1
3


Software Used
Keil Version3.
Equipment used
1. Soldering iron
2. Solder
3. Flux
PROCEDURE
Step 1
Circuit diagram of the proposed system is designed and finalized.(Refer to Figure6.1 )
Step 2
All the components and software platform to be used are selected which are also mentioned
above.
Step 3
All the hardware components are soldered on their respective printed circuit board with the
help of soldering iron, solder and flux according to the hardware schematic shown in the
Figure
Step 4
Code/program of the proposed system is developed using assembly language with the help of
software platform (Keil u vision3).The codingcould be seen in section
Step 5
The hex code of the program being created by the software platform is burnt into thef lash
code memory of our microcontroller IC 89C51.
Step 6
Testing is done at various levels to finalize the appropriate program for the mostproper
working of the system.

DESCRIPTION IN DETAIL
It mainly consists of following blocks:
1. Microcontroller: This is the CPU (central processing unit) of our

project. We are going to use a microcontroller of 8051 family. The


various functions of microcontroller are like:
I. Reading the digital input from Keypad
II. Sending this data to LCD so that the person operating this
project should read the password
III. Sensing the password using keypad and to check whether it is
a correct password or a wrong password and rotate the stepper motor
if the password entered is a correct password.
2. LCD: We are going to use 162 alphanumeric Liquid Crystal

Display (LCD) which means it can display alphabets along with


numbers on 2 lines each containing 16 characters.
3. Keypad: User will enter the password using the keypad. Various

keys of keypad are as following,


I. Increment (1 to 9)
II. Decrement
III. Enter

Applications and Advantages:

1. This project can be used in offices, companies


also at home. It will provide keyless entry.
2. This can be used in Banks for safety lock.
3. User dont have to carry keys along with him.

Future Development:

1. We can monitor parameters like fire, overheat


2. We can provide voice feedback system
3. We can interface GSM modem which will send
sms if invalid attempt is made to open the lock.

Potrebbero piacerti anche