Professional Documents
Culture Documents
PROTOTYPE
USING 8051
SUBMITTED BY:
CERTIFICATE
To whom it May concern
Certificate is awaited
CERTIFIED BY:
2
A CKNOWLEDGEMENT
3
-SWADESH
PREFACE
"Any sufficiently advanced technology is indistinguishable from
magic,"wrote ARTHUR C. CLARKE. Today, we can drive in a
voice activated car, get our clothes washed and dried in a
washing machine with in minutes, and read the temperature and
air pressure from our wrist watch .A musical greeting card has
more computing power than NASA'S lunar Lander had in 1969.
Thousand of people have embedded processors beneath their
skin, as pacemaker or hearing aids.
4
can go up in flames if spark plugs misfire. Even the Boeing
aircraft may go off course. Fingers are then pointed at the system
developer or software engineer for writing a code that is not
robust. It's imperative for embedded application to be much
more reliable than their desktop counterparts.
5
INDEX
S.No. Title Page
1. Introduction To Semiconductor 6
technologies - Vedant.
2. Introduction to Embedded Systems 8
7. Circuit Diagram 26
8. Program Code 27
10. Bibliography 50
6
S EMICONDUCTOR T ECHNOLOGIES -
VEDANT
AN ISO 9001:2000 C ERTIFIED I NSTITUTION
Semiconductor Technologies has always been in sync with the future. It
has understood and appreciated the needs of India, its people and its ever-
growing industry. Over the last six 20 years tell the saga of VEDANT
contribution in leading the national effort in the vital areas of
microelectronics.
7
would like to bring in your notice that VEDANT is a member of “Indian
Semiconductor Association” as well. Semiconductor Technologies-
VEDANT (Now an ISO 9001: 2000 Certified Institution) is center for the
training crafted in VLSI/ESD education module followed with VLSI Design
software along with the FPGA programming & 8051 Microcontroller kit.
Vedant
VEDANT (VLSI design and training) is one of the prestigious projects
of SCL, a pioneer with vertically integrated facility in the country.
8
Flash Magic (Rom burning)
The real Time Systems can be further divided into two types:
Soft Real-Time System
Compute output response as fast as possible, but no specific
deadlines that must be met.
Hard Real-Time System
9
Output response must be computed by specified deadline or system
fails.
Logical/Dig Computer
Programmin
ital Systems
g
Design Organization
Embedded
Embed Systems
ded
& DSP
Real
Advance
Time
d Control
System VLSI/ASI
Digital System
s C
Design s
&
(Synthesi
SoC
s)
Design
10
Programming Languages Used in New Embedded
Designs
90.0%
80.0%
70.0%
1998-1999
60.0%
1999-2000
50.0%
40.0%
30.0%
20.0%
10.0%
0.0%
Assembly C C++ Java Other
11
Micro Controllers Trend in the Embedded Systems
100.0%
80.0%
60.0%
40.0%
20.0%
0.0%
4-bit 8-bit 16-bit 32-bit 64-bit Special
12
Application of embedded systems in
sphere of life
Consumer electronics
Telecommunication
Automobile
Medical instrumentation
Defense
Communication satellite
Data communication
Internet appliances
13
Introduction to microcontroller
A microcontroller is a computer-on-a-chip, or, if you prefer, a single-
chip computer. Micro suggests that the device is small, and controller
tells you that the device might be used to control objects, processes, or
events. Another term to describe a microcontroller is embedded
controller, because the microcontroller and its support circuits are often
built into, or embedded in, the devices they control.
You can find microcontrollers in all kinds of things these days. Any
device that measures, stores, controls, calculates, or displays information
is a candidate for putting a microcontroller inside. The largest single use
for microcontrollers is in automobiles—just about every car
manufactured today includes at least one microcontroller for engine
control, and often more to control additional systems in the car. In
desktop computers, you can find microcontrollers inside keyboards,
modems, printers, and other peripherals. In test equipment,
microcontrollers make it easy to add features such as the ability to store
measurements, to create and store user routines, and to display messages
and waveforms. Consumer products that use microcontrollers include
cameras, video recorders, compact-disk players, and ovens. And these
are just a few examples.
Microcontroller Basics
14
A microcontroller is similar to the microprocessor inside a personal
computer. Examples of microprocessors include Intel’s 8086, Motorola’s
68000, and Zilog’s Z80. Both microprocessors and microcontrollers
contain a central processing unit, or CPU. The CPU executes
instructions that perform the basic logic, math, and data-moving
functions of a computer. To make a complete computer, a
microprocessor requires memory for storing data and programs, and
input/output (I/O) interfaces for connecting external devices like
keyboards and displays. In contrast, a microcontroller is a single-chip
computer because it contains memory and I/O interfaces in addition to
the CPU. Because the amount of memory and interfaces that can fit on a
single chip is limited, microcontrollers tend to be used in smaller
systems that require little more than the microcontroller and a few
support components. Examples of popular microcontrollers are Intel’s
8052 (including the 8052-BASIC, which is the focus of this book),
Motorola’s 68HC11, and Zilog’s Z8.
Microcontroller History
15
personal computer from scratch, since mass production has drastically
lowered the price of assembled systems. At most, building a personal
computer now involves only installing assembled boards and other major
components in an enclosure. A personal computer like Apple’s
Macintosh or IBM’s PC is a general-purpose machine, since you can use
it for many applications—word processing, spreadsheets, computer-
aided design, and more—just by loading the appropriate software from
disk into memory. Interfaces to personal computers are for the most part
standard ones like those to video displays, keyboards, and printers.
But along with cheap, powerful, and versatile personal computers has
developed a new interest in small, customized computers for specific
uses. Each of these small computers is dedicated to one task, or a set of
closely related tasks. Adding computer power to a device can enable it to
do more, or do it faster, better, or more cheaply. For example,
automobile engine controllers have helped to reduce harmful exhaust
emissions. And microcontrollers inside computer modems have made it
easy to add features and abilities beyond the basic computer-to-phone-
line interface. In addition to their use in mass-produced products like
these, it’s also become feasible to design computer power into one-of-a-
kind projects, such as an environmental controller for a scientific study
or an intelligent test fixture that ensures that a product meets its
specifications before it’s shipped to a customer. At the core of many of
these specialized computers is a microcontroller. The computer’s
program is typically stored permanently in semiconductor memory such
as ROM or EPROM. The interfaces between the microcontroller and the
outside world vary with the application, and may include a small display,
a keypad or switches, sensors, relays, motors, and so on.
These small, special-purpose computers are sometimes called single-
board computers, or SBCs. The term can be misleading, however, since
the computer doesn’t have to be on a single circuit board, and many
types of computer systems, such as laptop and notebook computers, are
now manufactured on a single board.
16
Block diagram of the 80C51
Microcontroller
17
Pin Diagram of the 40 Pin DIP package of the 80C51
18
8051 architecture contains the following:
19
8 bit CPU with registers A and B
20
INTRODUCTION TO THE KEIL SOFTWARE
The Keil Software 8051 development tools are listed below. These are
the programs that will perform the following:
Compile C Code
Assemble the assembly source files.
Link & Locate the object modules & the libraries.
Create the HEX files.
Debug the Target Program.
The LIB51 library manager combines object modules into libraries that
may be used by the linker.
The OH51 Object HEX converter creates Intel Hex files fro0m the
absolute object module.
21
The RTX51 real time operating system simpifies the design of the
complex, time critical software projects.
INTRODUCTION TO THE
PROJECT
This project is designed to demonstrate the technology used in the now a
day’s driver less metro train which is used in most of the developed
countries like Germany, France, and Japan etc. These trains are equipped
with the CPU, which controls the train. The train is programmed for the
specific path. Every station on the path is defined; stoppage timing of the
train and distance between the two stations is predefined.
In this project
In this project we try to give the same prototype for this type of trains.
We are using microcontroller 89c51 as CPU. The motion of the train is
controlled by the stepper motor, for displaying message in the train we
are using intelligent LCD display of two lines. The train is designed for
three stations, named as Bodhgaya, Rajgir, Nalanda .the stoppage time is
of 3 sec and time between two consecutive stations is 6sec.there is a
LCD display for showing various messages in the train for passengers.
There are indicators, which are used to show the train direction i.e. UP
path and DOWN path. Before stopping at station the train blows the
buzzer. It also includes an emergency brake system due to which the
train stops as soon as the brakes are applied and resumes journey when
the emergency situation is over.
22
So this project gives an illustration of actual modern metro train
controlled through embedded electronics control system.
Implementation: This project is implemented using the following kit
6. ADC/DAC interface
8. Switch array
23
Interfacing an LCD to the 8051
LCD Operation:
Our project chose LCD over Seven Segment Displays due to
the following reasons:
1)Ease of program of charcters.
2)Ascii Values could be directly sent to the LCD.
3)In built command words to control Display.
24
PIN DESCRIPTION OF LCD
25
VCC- provides +5 volt
VSS provides gnd
VEE is used to control LCD contrast
RS ( Register Select )
E ( Enable)
D0 – D7
26
The 8 – bit data pins ( d0 – D7) are used to send information
to the LCD or read the content of the LCD internal Register.
To display letters and numbers , we send ASCII codes for
the letter A-Z , a-z & 0-9 to these pins while makin RS = 1.
There are also Instruction Command Codes that can be sent
to the LCD to clear the display or force the cursor to the home
position or blink the cursor.
27
CIRCUIT DIAGRAM
28
Port 0 pins
connected to LCD
data lines
LEDs
8
0
displaying 5
message)
DISPLAY
1
LCD
(For
the
Project Code
29
org 300h
c1:db 'WELCOME TO LKO',0
c2:db 'U R IN:-',0
c3:db 'NEXT STATION:-',0
c4: db 'MORADABAD',0
c6:db 'BAREILY',0
c5:db 'MEERUT',0
c7:db'MADE BY SHOBHIT',0
c8:db'TAUFIQUE',0
org 0h
mov a,#38h
acall cmnwrt
acall delay
mov a,#01h
acall cmnwrt
acall delay
mov a,#0eh
acall cmnwrt
acall Delay
mov a,#80h
acall cmnwrt
acall delay
mov dptr,#c1
a1:mov a,#0h
movc a,@a+dptr
acall datawrt
30
acall delay
acall delay
jz loop
inc dptr
sjmp a1
loop:
mov a,#01h
acall cmnwrt
acall delay
acall delay
acall delay
mov a,#081h
acall cmnwrt
mov dptr,#c2
a2: clr a
movc a,@a+dptr
acall datawrt
acall delay1
acall delay1
acall delay1
jz pl
inc dptr
sjmp a2
pl:
mov a,#089h
acall cmnwrt
mov dptr,#c4
a3: clr a
31
movc a,@a+dptr
acall datawrt
acall delay
jz ul
inc dptr
sjmp a3
ul:mov a,#01h
acall cmnwrt
acall delay
acall delay
acall delay
mov a,#81h
acall cmnwrt
mov dptr,#c6
a4: clr a
movc a,@a+dptr
acall datawrt
acall delay1
acall delay1
acall delay1
jz df
inc dptr
sjmp a4
df:
mov a,#01h
acall cmnwrt
acall delay
mov a,#80h
32
acall cmnwrt
mov dptr,#c3
a5:clr a
movc a,@a+dptr
acall datawrt
acall delay1
acall delay1
acall delay1
jz ty
inc dptr
sjmp a5
ty:
mov a,#0c9h
acall cmnwrt
mov dptr,#c5
a6:clr a
movc a,@a+dptr
acall datawrt
acall delay
acall delay
acall delay
jz rv
inc dptr
sjmp a6
rv:mov a,#01h
acall cmnwrt
acall delay
mov a,#80h
33
mov dptr,#c7
a7:clr a
movc a,@a+dptr
acall datawrt
acall delay1
acall delay1
acall delay1
jz gh
inc dptr
sjmp a7
gh:mov a,#0c0h
acall cmnwrt
acall delay
mov dptr,#c8
a8:clr a
movc a,@a+dptr
acall datawrt
acall delay
acall delay
inc dptr
sjmp a8
again:sjmp again
cmnwrt:
mov p0,a
clr p2.0
clr p2.1
setb p2.2
acall delay
34
clr p2.2
ret
datawrt:
mov p0,a
setb p2.1
clr p2.0
setb p2.2
acall delay
clr p2.2
ret
delay:mov r3,#70
here2:mov r4,#250
here:djnz r4,here
djnz r3,here2
delay1:mov r1,#240
def:mov r2,#250
jkl:djnz r2,jkl
djnz r1,def
ret
end
35
A51 MACRO ASSEMBLER METRO2
07/04/2009 16:09:48 PAGE 1
36
0000 7438 11 mov a,#38h
0002 11DD 12 acall cmnwrt
0004 11F7 13 acall delay
0006 7401 14 mov a,#01h
0008 11DD 15 acall cmnwrt
000A 11F7 16 acall delay
000C 740E 17 mov a,#0eh
000E 11DD 18 acall cmnwrt
0010 11F7 19 acall Delay
0012 7480 20 mov a,#80h
0014 11DD 21 acall cmnwrt
0016 11F7 22 acall delay
0018 900300 23 mov dptr,#c1
001B 7400 24 a1:mov a,#0h
001D 93 25 movc a,@a+dptr
001E 11EA 26 acall datawrt
0020 11F7 27 acall delay
0022 11F7 28 acall delay
0024 6003 29 jz loop
0026 A3 30 inc dptr
0027 80F2 31 sjmp a1
0029 32 loop:
0029 7401 33 mov a,#01h
002B 11DD 34 acall cmnwrt
002D 11F7 35 acall delay
002F 11F7 36 acall delay
0031 11F7 37 acall delay
0033 7481 38 mov a,#081h
0035 11DD 39 acall cmnwrt
37
A51 MACRO ASSEMBLER METRO2
07/04/2009 16:09:48 PAGE 2
38
007B 7401 79 mov a,#01h
007D 11DD 80 acall cmnwrt
007F 11F7 81 acall delay
0081 7480 82 mov a,#80h
0083 11DD 83 acall cmnwrt
0085 900318 84 mov dptr,#c3
0088 E4 85 a5:clr a
0089 93 86 movc a,@a+dptr
008A 11EA 87 acall datawrt
008C 11FF 88 acall delay1
008E 11FF 89 acall delay1
0090 11FF 90 acall delay1
0092 6003 91 jz ty
0094 A3 92 inc dptr
0095 80F1 93 sjmp a5
0097 94 ty:
0097 74C9 95 mov a,#0c9h
0099 11DD 96 acall cmnwrt
009B 900339 97 mov dptr,#c5
009E E4 98 a6:clr a
009F 93 99 movc a,@a+dptr
00A0 11EA 100 acall datawrt
00A2 11F7 101 acall delay
00A4 11F7 102 acall delay
00A6 11F7 103 acall delay
00A8 6003 104 jz rv
00AA A3 105 inc dptr
39
A51 MACRO ASSEMBLER METRO2
07/04/2009 16:09:48 PAGE 3
40
00F0 D2A2 145 setb p2.2
00F2 11F7 146 acall delay
00F4 C2A2 147 clr p2.2
00F6 22 148 ret
00F7 7B46 149 delay:mov r3,#70
00F9 7CFA 150 here2:mov r4,#250
00FB DCFE 151 here:djnz r4,here
00FD DBFA 152 djnz r3,here2
00FF 79F0 153 delay1:mov r1,#240
0101 7AFA 154 def:mov r2,#250
0103 DAFE 155 jkl:djnz r2,jkl
0105 D9FA 156 djnz r1,def
0107 22 157 ret
158 end
41
A51 MACRO ASSEMBLER METRO2
07/04/2009 16:09:48 PAGE 4
A1 . . . . . . . . C ADDR 001BH A
A2 . . . . . . . . C ADDR 003AH A
A3 . . . . . . . . C ADDR 0050H A
A4 . . . . . . . . C ADDR 006CH A
A5 . . . . . . . . C ADDR 0088H A
A6 . . . . . . . . C ADDR 009EH A
A7 . . . . . . . . C ADDR 00B8H A
A8 . . . . . . . . C ADDR 00D0H A
AGAIN. . . . . . . C ADDR 00DBH A
C1 . . . . . . . . C ADDR 0300H A
C2 . . . . . . . . C ADDR 030FH A
C3 . . . . . . . . C ADDR 0318H A
C4 . . . . . . . . C ADDR 0327H A
C5 . . . . . . . . C ADDR 0339H A
C6 . . . . . . . . C ADDR 032DH A
C7 . . . . . . . . C ADDR 0340H A
C8 . . . . . . . . C ADDR 034FH A
CMNWRT . . . . . . C ADDR 00DDH A
DATAWRT. . . . . . C ADDR 00EAH A
DEF. . . . . . . . C ADDR 0101H A
DELAY. . . . . . . C ADDR 00F7H A
DELAY1 . . . . . . C ADDR 00FFH A
DF . . . . . . . . C ADDR 007BH A
GH . . . . . . . . C ADDR 00C7H A
HERE . . . . . . . C ADDR 00FBH A
HERE2. . . . . . . C ADDR 00F9H A
JKL. . . . . . . . C ADDR 0103H A
LOOP . . . . . . . C ADDR 0029H A
P0 . . . . . . . . D ADDR 0080H A
P2 . . . . . . . . D ADDR 00A0H A
PL . . . . . . . . C ADDR 0049H A
RV . . . . . . . . C ADDR 00ADH A
TY . . . . . . . . C ADDR 0097H A
42
UL . . . . . . . . C ADDR 005BH A
43
A51 MACRO ASSEMBLER METRO2
07/03/2009 15:42:10 PAGE 4
44
A51 MACRO ASSEMBLER METRO2
07/03/2009 15:42:10 PAGE 5
N A M E T Y P E V A L U E ATTRIBUTES
A1 . . . . . . . . C ADDR 001DH A
A2 . . . . . . . . C ADDR 003EH A
A3 . . . . . . . . C ADDR 0054H A
A4 . . . . . . . . C ADDR 0072H A
A5 . . . . . . . . C ADDR 0090H A
A6 . . . . . . . . C ADDR 00A6H A
AGAIN. . . . . . . C ADDR 00B3H A
C1 . . . . . . . . C ADDR 0300H A
C2 . . . . . . . . C ADDR 030FH A
C3 . . . . . . . . C ADDR 0318H A
C4 . . . . . . . . C ADDR 0327H A
C5 . . . . . . . . C ADDR 0339H A
C6 . . . . . . . . C ADDR 032DH A
CMNWRT . . . . . . C ADDR 00B5H A
D1 . . . . . . . . C ADDR 00D1H A
D11. . . . . . . . C ADDR 00FDH A
D2 . . . . . . . . C ADDR 00DDH A
D3 . . . . . . . . C ADDR 00EBH A
DATAWRT. . . . . . C ADDR 00C2H A
DD2. . . . . . . . C ADDR 0109H A
DD3. . . . . . . . C ADDR 0117H A
DEF. . . . . . . . C ADDR 0130H A
DELAY. . . . . . . C ADDR 0126H A
DELAY1 . . . . . . C ADDR 012EH A
DF . . . . . . . . C ADDR 0081H A
HERE . . . . . . . C ADDR 012AH A
HERE2. . . . . . . C ADDR 0128H A
JKL. . . . . . . . C ADDR 0132H A
LOOP . . . . . . . C ADDR 002BH A
P0 . . . . . . . . D ADDR 0080H A
P1 . . . . . . . . D ADDR 0090H A
P2 . . . . . . . . D ADDR 00A0H A
P3 . . . . . . . . D ADDR 00B0H A
PL . . . . . . . . C ADDR 004DH A
RIBHU. . . . . . . C ADDR 00CFH A
RIBHU1 . . . . . . C ADDR 00FBH A
TY . . . . . . . . C ADDR 009FH A
UL . . . . . . . . C ADDR 005FH A
45
SYMBOL TABLE LISTING
------ ----- -------
NAME T Y P E V A L U E ATTRIBUTES
A1 . . . . . . . . C ADDR 002EH A
AGAIN. . . . . . . C ADDR 01F8H A
AGAIN1 . . . . . . C ADDR 0210H A
AGAIN10. . . . . . C ADDR 02D5H A
AGAIN11. . . . . . C ADDR 02E3H A
AGAIN12. . . . . . C ADDR 02FBH A
AGAIN13. . . . . . C ADDR 0315H A
AGAIN14. . . . . . C ADDR 0323H A
AGAIN15. . . . . . C ADDR 033BH A
AGAIN16. . . . . . C ADDR 0355H A
AGAIN17. . . . . . C ADDR 0363H A
AGAIN2 . . . . . . C ADDR 021EH A
AGAIN3 . . . . . . C ADDR 0236H A
AGAIN4 . . . . . . C ADDR 0250H A
AGAIN5 . . . . . . C ADDR 025EH A
AGAIN6 . . . . . . C ADDR 0276H A
AGAIN7 . . . . . . C ADDR 0290H A
AGAIN8 . . . . . . C ADDR 029EH A
AGAIN9 . . . . . . C ADDR 02BDH A
AGAINA . . . . . . C ADDR 0030H A
ALLAHABAD. . . . . C ADDR 0045H A
BACK1. . . . . . . C ADDR 0196H A
BACK3. . . . . . . C ADDR 01B5H A
BACKA. . . . . . . C ADDR 01BAH A
BACKB. . . . . . . C ADDR 019BH A
BACKC. . . . . . . C ADDR 01D4H A
BACKD. . . . . . . C ADDR 01CCH A
BACKE. . . . . . . C ADDR 018EH A
BACKF. . . . . . . C ADDR 01ADH A
BHADOHI. . . . . . C ADDR 0035H A
CS . . . . . . . . C ADDR 00B5H A
D. . . . . . . . . C ADDR 02A5H A
DELAY. . . . . . . C ADDR 01C7H A
DELAY1 . . . . . . C ADDR 0189H A
DELAY3 . . . . . . C ADDR 01A8H A
DELAYA . . . . . . C ADDR 002CH A
46
DOWNJOURNEY. . . . C ADDR 0081H A
LCD_CMD. . . . . . C ADDR 0002H A
LCD_WRITE. . . . . C ADDR 000FH A
LED1 . . . . . . . C ADDR 012DH A
LED3 . . . . . . . C ADDR 015BH A
MAIN . . . . . . . C ADDR 036AH A
OUT. . . . . . . . C ADDR 01BEH A
OUT1 . . . . . . . C ADDR 019FH A
P0 . . . . . . . . D ADDR 0080H A
P1 . . . . . . . . D ADDR 0090H A
P2 . . . . . . . . D ADDR 00A0H A
P3 . . . . . . . . D ADDR 00B0H A
PN . . . . . . . . C ADDR 00F5H A
TF0. . . . . . . . B ADDR 0088H.5 A
TH0. . . . . . . . D ADDR 008CH A
TL0. . . . . . . . D ADDR 008AH A
TMOD . . . . . . . D ADDR 0089H A
TR0. . . . . . . . B ADDR 0088H.4 A
U. . . . . . . . . C ADDR 01E0H A
UPJOURNEY. . . . . C ADDR 0055H A
VARANASI . . . . . C ADDR 001CH A
47
BIBLIOGYRAPHY
Books:
• Title: The 8051 Microcontroller and Embedded System.
Author: Muhammad Ali Mazidi & Janice Gillispie
Mazidi.
Publication: Pearson Education.
Magazines:
Websites:
• SOFTWARE: www.keil.com
• Down loader: www.easacademy.com
• Reference: www.efymag.com
48
• Datasheets: www.datasheetarchive.com
49