Professional Documents
Culture Documents
Anjali Rai
Submitted By :EC4873
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
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
Advanced Software Products and Solutions to its clients. Achieving the needs
of our costumer and converting their ideas to real models is our motto.
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.
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.
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
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
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
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
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
4. Cheaper in comparison.
5. Occupies less space.
VARIOUS MICROCONTROLLERS
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)
ATMEL 89C51
It
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
PIN DIAGRAM
PIN DESCRIPTION
Vcc
PSEN
This is an output pin. PSEN stands for program store enable. It
is the read strobe to external program memory
ALE
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
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
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
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-
#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
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
The electromagnetic relay consists of a multi-turn coil,
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
STEPPER MOTOR
A stepper motor is an electromechanical device which converts
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
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 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);
}
}
}
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.
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
PB1
I/O
DB2
I/O
10
DB3
I/O
11
DB4
I/O
12
DB5
I/O
13
DB6
I/O
14
DB7
I/O
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_puts(unsigned char *str)
// function to display string to lcd
{
while(*str!='\0')
{
lcd_data(*str);
str++;
}
}
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
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
Future Development: