You are on page 1of 63

A

B.Tech. PROJECT REPORT


ON

METRO TRAIN PROTOTYPE BASED


ON 8051 MICROCONTROLLER

By

Brijendra Mohan Gupta

ELECTRONICS & COMMUNICATION ENGINEERING


IMS ENGINEERING COLLEGE, GHAZIABAD
(U.P. Technical University, Lucknow (U.P.))

2009-2010

[0]
A
PROJECT REPORT
ON

METRO TRAIN PROTOTYPE BASED


ON 8051 MICROCONTROLLER
2009-2010

Submitted in partial fulfillment of the


requirements for the award of the degree

BACHELOR OF TECHNOLOGY
IN
ELECTRONICS & COMMUNICATION ENGINEERING
U.P. Technical University, Lucknow

SUBMITTED BY:
Brijendra Mohan Gupta

GUIDED BY:
Mr. V.K.Aggarwal (Sr. Lec)
IMS ENGINEERING COLLEGE, GHAZIABAD
[1]
CERTIFICATE

This is to certify that


Brijendra Mohan Gupta

has successfully completed the project work entitled


“Metro Prototype Based On 8051
Microcontroller”
in partial fulfillment of the requirement for the degree of

Bachelor of Technology
(Electronics & Communication)
of
U.P. Technical University, Lucknow
Session 2008-2009

The matter in this Project report is a record of the students own work carried
out under my supervision and guidance. The matter embodied in this report
has not been submitted by anyone for award of any degree/ diploma.
We wish them all the success in future endeavors.

H.O.D Project Guide

[2]
ACKNOWLEDGEMENT

We consider ourself exceptionally fortunate that we had indulgent guides, learned


philosophers and caring friends to successfully steer us through one of the most interesting
period of our academic career. Today when our endeavor has reached its friction, we look back
in mute gratitude to one and all without whose help we are sure this reality would have been a
dream.

This work has been possible through the direct and indirect co-operation of various
people of IMSEC towards whom we wish to express my gratitude.

We are extremely thankful to IMSEC faculties who provided us challenging opportunity


to work on this project.

Our special thanks to Mr. V.K.Aggarwal (Electronics & Communication Department,


IMSEC, Ghaziabad) under whom we completed this project. He provided us with all the possible
help and advice. Without their guidance this project would have not reached its completion in
such a successful manner.

We are also thankful to Dr. Sanjay Gairola (H.O.D., Electronics & Communication
Department, IMSEC, Ghaziabad) and Prof. V.K. Gupta (Electronics & Communication
Department, IMSEC, Ghaziabad) for their valuable suggestions.

ANKIT MITTAL
CHETANYA SHARMA
BRIJENDRA MOHAN GUPTA
B. Tech. (EC Final Year)
IMS Engineering College, Ghaziabad

[3]
List of Contents

1.Introduction 8-9
1.1Objectives 8
1.2Features 8
1.3Overview 8
1.4Schematic Representation of Project 9

2. Microcontroller(AT89C51) 10-25
2.1 Introduction 10
2.2 Definition of a Microcontroller 11
2.3 Microcontrollers vs Microprocessors 12
2.4 Memory Unit 13
2.5 Central Processing Unit 14
2.6 Bus 14
2.7 Input Output Unit 15
2.8 Serial Communication 15
2.9 Timer Unit 16
2.10 Watch Dog 17
2.11 Analog to Digital Converter 17
2.12 Pin Configuration 20
2.13 RAM Architecture 23

3. Introduction to 16X2 LCD Display 26-30


3.1Liquid Crystal Display 26
3.2 Pin description of LCD 28
3.3 BF - Busy Flag 29
3.4 Instruction Register (IR) and Data Register (DR) 29
3.5 Commands and Instruction set 29
3.6 Sending Commands to LCD 29
3.7 Interfacing of LCD with 8051 30

4. DC Motor Interfacing 31-33


4.1 Introduction 31
4.2 DC Motor Interfacing 32

5.Other Components 34-44


5.1 Crystal Oscillator 34
5.2 Zero PCB 35
5.3 Buzzer 35
5.4 Voltage Regulator IC(78XX) 37
5.5 Resistors 39
5.6 Capacitors 41
5.7 Batteries And Connectors 44

[4]
6. Description of Project 45-49
6.1 Introduction 45
6.2 Circuit Diagram of the Project 47
6.3 Project Methodology 48
6.3(a) Components 48
6.3(b) Software Used 48
6.3(c) Equipments Used 48
6.4 Procedure of building the Prototype of Metro Train 48
6.5 General Working 49

7. Future Scope 50

8. References and Bibliography 51

Appendix-I 52-55

Appendix-II 56-62

[5]
LIST OF FIGURES

Fig. No. Topic Page No.


Fig 1.1 Schematic representation of the project 9

Fig 2.1 Showing a typical microcontroller device and its different subunits 11

Fig 2.2 Simplified model of a memory unit 12

Fig 2.3 Simplified central processing unit with three registers 13

Fig 2.4 Showing connection between memory and central unit using buses 14

Fig 2.5 Simplified input-output unit communicating with external world 15

Fig 2.6 Serial unit sending data through three lines only 16

Fig 2.7 Timer unit generating signals in regular time intervals 16

Fig 2.8 Watchdog 17

Fig 2.9 Block for converting an analog input to digital output 18

Fig 2.10 Physical configuration of the interior of a microcontroller 18

Fig 2.11 Microcontroller outline with basic elements and internal connections 19

Fig 2.12 Pin configuration of Microcontroller 20

Fig 2.13 RAM Architecture 23

Fig 3.1 16x2 LCD 26

Fig 3.2 Different layers of LCD 27

Fig 3.3 Pin diagram of LCD 28

Fig 3.4 Interfacing of LCD 30

Fig 4.1 Connections of L293D 32

Fig 5.1 Crystal oscillator 34

Fig 5.2 Buzzer 36

[6]
Fig 5.3 Regulator ICs 37

Fig 5.4 Regulator IC 78XX 38

Fig 5.5 Resistors 39

Fig 5.6 Symbol of Resistance 39

Fig 5.7 Carbon film resistors 40

Fig 5.8 Capacitor 41

Fig 5.9 Symbol of Capacitor 41

Fig 5.10 Capacitor & Battery Connection 42

Fig 5.11 Battery 44

Fig 5.12 Battery Connector 44

Fig 6.1 Circuit diagram of the project 47

[7]
1.INTRODUCTION

METRO TRAIN PROTOTYPE PROJECT

1.1 Objective

1. To construct a model of a metro train controlled by 8051

2. To write a program in assembly language that will help microcontroller to control buzzer,
LCD, stepper motor.

1.2 Features

 Microcontroller AT89C51 to control the whole circuitry of the prototype.

 Stepper motor , to control the motion of the train

 Intelligent LCD , for displaying messages in the train

 Buzzer, as indicator, to inform stoppage of train

1.3 OVERVIEW

In the project, we have tried to give the above mentioned prototype for this train. We are using
microcontroller 89C51 to control the whole circuitry. The motion of the train is controlled by the
stepper motor. For displaying message in the train, we are using intelligent LCD display having
two lines. The train is designed for the five stations named Kishan Ganj, Pratap Nagar,
Shahadara, Indraprashta and Rohini West. The stoppage time of the train is programmed as 3
sec and the time taken by the train between two consecutive station is programmed as 6 sec.
There is a LCD display for showing various messages in the train for passenger’s
convenience.like current station is Indraprastha and next station is Rohini West. Before stopping
at station, the buzzer sounds for 3 seconds.

[8]
1.4 SCHEMATIC REPRESENTATION OF THE PROJECT

Fig1.1 Schematic representation of the project

This is a schematic representation, which shows all the important parts of the project. To
understand the project, one must go through all the parts in detail. The project also consists of an
assembly language program, which controls the operation of the microcontroller. We have used
Microcontroller AT89C51 as CPU to control the overall functionality of the project, Stepper
motor to control the motion of the train, Intelligent LCD for displaying messages in the train and
a buzzer to inform stoppage of the train.

The project consists of following important parts:

1. Microcontroller (AT89C51)

2. LCD display(16 characters x 2)

3. DC motors

[9]
4. Buzzer(5 volt)

5. Other components like resistors(1k,10k),capacitors(33 pF) etc.

2. MICROCONTROLLER(AT89C51)

2.1 Introduction

Circumstances that we find ourselves in today in the field of microcontrollers had their
beginnings in the development of technology of integrated circuits. This development has made
it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for
production of microprocessors, and the first computers were made by adding external peripherals
such as memory, input-output lines, timers and other. Further increasing of the volume of the
package resulted in creation of integrated circuits. These integrated circuits contained both
processor and peripherals. That is how the first chip containing a microcomputer, or what would
later be known as a microcontroller came about.

2.2 Definition of a Microcontroller

Microcontroller, as the name suggests, are small controllers. They are like single chip 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
standalone computers without other supporting circuitry.
 Field Programmability, Flexibility
 Microcontrollers often use EEPROM or EPROM as their storage device to allow field
programmability 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.
 Easy to Use

[10]
Assembly language is often used in microcontrollers and since they usually follow RISC
architecture, the instruction set is small. The development package of microcontrollers
often includes an assembler, a simulator, a programmer to "burn" the chip and a
demonstration board. Some packages include a high level language compiler such as a C
compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:

 A Timer module to allow 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 a PC or another microcontroller.
 An ADC to allow the microcontroller to accept analogue input data for processing.

Figure 2.1: Showing a typical microcontroller device and its different subunits

The heart of the microcontroller is the CPU core.  In the past this has traditionally been based on
an 8-bit microprocessor unit.

[11]
2.3 Microcontrollers versus Microprocessors

Microcontroller differs from a microprocessor in many ways. First and the most important is its
functionality. In order for a microprocessor to be used, other components such as memory, or
components for receiving and sending data must be added to it. In short that means that
microprocessor is the very heart of the computer. On the other hand, microcontroller is designed
to be all of that in one. No other external components are needed for its application because all
necessary peripherals are already built into it. Thus, we save the time and space needed to
construct devices

2.4 Memory unit

Memory is part of the microcontroller whose function is to store data. 


The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose
that we marked the drawers in such a way that they can not be confused, any of their contents
will then be easily accessible. It is enough to know the designation of the drawer and so its
contents will be known to us for sure.

Figure2.2: Simplified model of a memory unit

Memory components are exactly like that. For a certain input we get the contents of a certain
addressed memory location and that's all. Two new concepts are brought to us: addressing and
memory location. Memory consists of all memory locations, and addressing is nothing but
selecting one of them. This means that we need to select the desired memory location on one

[12]
hand, and on the other hand we need to wait for the contents of that location. Besides reading
from a memory location, memory must also provide for writing onto it. This is done by
supplying an additional line called control line. We will designate this line as R/W (read/write).
Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then
writing is done on the memory location. Memory is the first element, and we need a
few operation of our microcontroller.

The amount of memory contained within a microcontroller varies between different


microcontrollers. Some may not even have any integrated memory (e.g. Hitachi 6503, now
discontinued). However, most modern microcontrollers will have integrated memory. The
memory will be divided up into ROM and RAM, with typically more ROM than RAM.

Typically, the amount of ROM type memory will vary between around 512 bytes and 4096
bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as
128 Kbytes of ROM type memory.

ROM type memory, as has already been mentioned, is used to store the program code. ROM
memory can be ROM (as in One Time Programmable memory), EPROM, or EEPROM.

The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes
to 4 Kbytes.

RAM is used for data storage and stack management tasks. It is also used for register stacks (as
in the microchip PIC range of microcontrollers).

2.5 Central Processing Unit


Let add 3 more memory locations to a specific block that will have a built in capability to
multiply, divide, subtract, and move its contents from one memory location onto another. The
part we just added in is called "central processing unit" (CPU). Its memory locations are called
registers.

[13]
Figure2.3: Simplified central processing unit with three registers

Registers are therefore memory locations whose role is to help with performing various
mathematical operations or any other operations with data wherever data can be found. Look at
the current situation. We have two independent entities (memory and CPU) which are
interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for
example, we wish to add the contents of two memory locations and return the result again back
to memory, we would need a connection between memory and CPU. Simply stated, we must
have some "way" through data goes from one block to another.

2.6 Bus

That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires.
There are two types of buses: address and data bus. The first one consists of as many lines as the
amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or
the connection line. First one serves to transmit address from CPU memory, and the second to
connect all blocks inside the microcontroller.

Figure2.4: Showing connection between memory and central unit using buses

As far as functionality, the situation has improved, but a new problem has also appeared: we
have a unit that's capable of working by itself, but which does not have any contact with the
outside world, or with us! In order to remove this deficiency, let's add a block which contains

[14]
several memory locations whose one end is connected to the data bus, and the other has
connection with the output lines on the microcontroller which can be seen as pins on the
electronic component.

2.7 Input-output unit

Those locations we've just added are called "ports". There are several types of ports: input,
output or bidirectional ports. When working with ports, first of all it is necessary to choose which
port we need to work with, and then to send data to, or take it from the port.

Figure2.5: Simplified input-output unit communicating with external world

When working with it the port acts like a memory location. Something is simply being written
into or read from it, and it could be noticed on the pins of the microcontroller.

2.8 Serial communication

Beside stated above we've added to the already existing unit the possibility of communication
with an outside world. However, this way of communicating has its drawbacks. One of the basic
drawbacks is the number of lines which need to be used in order to transfer data. What if it is
being transferred to a distance of several kilometers? The number of lines times’ number of
kilometers doesn't promise the economy of the project. It leaves us having to reduce the number
of lines in such a way that we don't lessen its functionality. Suppose we are working with three
lines only, and that one line is used for sending data, other for receiving, and the third one is used
as a reference line for both the input and the output side. In order for this to work, we need to set
the rules of exchange of data. These rules are called protocol. Protocol is therefore defined in
advance so there wouldn't be any misunderstanding between the sides that are communicating
with each other. For example, if one man is speaking in French, and the other in English, it is
[15]
highly unlikely that they will quickly and effectively understand each other. Let's suppose we
have the following protocol. The logical unit "1" is set up on the transmitting line until transfer
begins. Once the transfer starts, we lower the transmission line to logical "0" for a period of time
(which we will designate as T), so the receiving side will know that it is receiving data, and so it
will activate its mechanism for reception. Let's go back now to the transmission side and start
putting logic zeros and ones onto the transmitter line in the order from a bit of the lowest value to
a bit of the highest value. Let each bit stay on line for a time period which is equal to T, and in
the end, or after the 8th bit, let us bring the logical unit "1" back on the line which will mark the
end of the transmission of one data. The protocol we've just described is called in professional
literature NRZ (Non-Return to Zero).

Figure2.6: Serial unit sending data through three lines only

As we have separate lines for receiving and sending, it is possible to receive and send data (info.)
at the same time. So called full-duplex mode block which enables this way of communication is
called a serial communication block. Unlike the parallel transmission, data moves here bit by bit,
or in a series of bits what defines the term serial communication comes from. After the reception
of data we need to read it from the receiving location and store it in memory as opposed to
sending where the process is reversed. Data goes from memory through the bus to the sending
location, and then to the receiving unit according to the protocol.

2.9 Timer unit

Since we have the serial communication explained, we can receive, send and process data.

[16]
Figure2.7: Timer unit generating signals in regular time intervals

However, in order to utilize it in industry we need a few additionally blocks. One of those is the
timer block which is significant to us because it can give us information about time, duration,
protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose
numeric value increments by one in even intervals, so that by taking its value during periods T1
and T2 and on the basis of their difference we can determine how much time has elapsed. This is
a very important part of the microcontroller whose understanding requires most of our time.

2.10 Watchdog

One more thing is requiring our attention is a flawless functioning of the microcontroller 
during its run-time. Suppose that as a result of some interference (which often does occur in
industry) our microcontroller stops executing the program, or worse, it starts working
incorrectly.

Figure2.8: Watchdog

Of course, when this happens with a computer, we simply reset it and it will keep working.
However, there is no reset button we can push on the microcontroller and thus solve our
problem. To overcome this obstacle, we need to introduce one more block called watchdog. This
block is in fact another free-run counter where our program needs to write a zero in every time it
executes correctly. In case that program gets "stuck", zero will not be written in, and counter
alone will reset the microcontroller upon achieving its maximum value. This will result in
executing the program again, and correctly this time around. That is an important element of
every program to be reliable without man's supervision.

2.11 Analog to Digital Converter

[17]
As the peripheral signals usually are substantially different from the ones that microcontroller
can understand (zero and one), they have to be converted into a pattern which can be
comprehended by a microcontroller. This task is performed by a block for analog to digital
conversion or by an ADC. This block is responsible for converting an information about some
analog value to a binary number and for follow it through to a CPU block so that CPU block can
further process it.

Figure2.9: Block for converting an analog input to digital output

Finally, the microcontroller is now completed, and all we need to do now is to assemble it into an
electronic component where it will access inner blocks through the outside pins. The picture
below shows what a microcontroller looks like inside.

Figure2.10: Physical configuration of the interior of a microcontroller

Thin lines which lead from the center towards the sides of the microcontroller represent wires
connecting inner blocks with the pins on the housing of the microcontroller so called bonding
lines. Chart on the following page represents the center section of a microcontroller.

[18]
Figure2.11: Microcontroller outline with basic elements and internal connections

For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a
program that would be executed, and a few more elements which make up interface logic
towards the elements of regulation (which will be discussed in later chapters).

[19]
2.12 PIN CONFIGURATION

Figure2.12 Pin configuration of Microcontroller

VCC (Pin 40) Provides voltage to the chip . +5V

GND (Pin 20) Ground

XTAL1 (Pin 19) and XTAL2 (Pin 18) Crystal Oscillator connected to pins 18, 19.

RST (Pin 9) RESET pin

External Access: EA 31

• Connected to VCC for on chip ROM

• Connected to Ground for external ROM containing the code Input Pin

Program Store Enable: PSEN 29


Output Pin

[20]
Address Latch Enable: ALE 30
\Output Pin . Active high .

I/O Port Pins and their Functions:


Four ports P0,P1,P2,P3 with 8 pins each, making a total of 32 input/output pins.

PORT 0

• Pins 32-39

• Can be used as both Input or Output

• External pull up resistors of 10K need to be connected

• Dual role: 8051 multiplexes address and data through port 0 to save pins .AD0-AD7

• ALE is used to de multiplex data and address bus

PORT 1

• Pins 1 through 8

• Both input or output

• No dual function

• Internal pull up registers

• On RESET configured as output

PORT 2

• Pins 21 through 28

• No external pull up resistor required

• Both input or output

• Dual Function: Along with Port 0 used to provide the 16-Bit address for external
memory. It provides higher address A8-A16

PORT 3

• Pins 10 through 17

[21]
• No external pull up resistors required

We have 4 ports in 8051 micro controller. They are port0, port1, port2, port3 which can
be accessed as i/o ports. The pins of the micro controller are explained below.

Reset: It resets total 8051 micro controller.

RXD: It receives data in serial communication.

TXD: It transmits data in serial communication.

INT0: External interrupt for timer 0.

INT1: External interrupt for timer1

T0: Timer0.

T1: Timer1.

RD: To read into external memory.

WR: To write into external memory.

XTAL1 & XTAL2: To connect the crystal oscillator.

ALE: Address latch enable which is used to access the address locations
from external memory.

PSEN: Program store enable which is used for storing programming


code into the external memory.

EA: External Access: 64 KB of ROM is the limit for external memory.

[22]
2.13 RAM ARCHITECTURE

Fig 2.13 RAM Architecture

The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the
8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading,
writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is reset this
memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map.
The first 8 bytes (00h - 07h) are "register bank 0". These alternative register banks are located in
internal RAM in addresses 08h through 1Fh.Bit memory actually resides in internal RAM, from
addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from addresses 30h
through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed.
This area is also utilized by the microcontroller as a storage area for the operating stack.

Register Banks

The 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers are
numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7).These registersare generally
used to assist in manipulating values and moving data from one memory location to another. The
concept of register banks adds a great level of flexibility to the 8051.

[23]
Bit Memory

The 8051, being a communication oriented microcontroller, gives the user the ability to access a
number of bit variables. These variables may be either 1 or 0. There are 128 bit variables
available to the user, numbered 00h through 7Fh. The user may make use of these variables with
commands such as SETB and CLR. It is important to note that Bit Memory is really a part of
Internal RAM. In fact, the 128 bit variables occupy the 16 bytes of Internal RAM from 20h
through 2Fh.

Special Function Register (SFR) Memory

Special Function Registers (SFRs) are areas of memory that control specific functionality of the
8051 processor. For example, four SFRs permit access to the 8051’s 32 input/output lines.
Another SFR allows a program to read or write to the 8051’s serial port .SFR is a part of Internal
Memory. This is not the case. When using this method of memory access (it’s called direct
address), any instruction that has an address of 00h through 7Fh refers to an Internal RAM
memory address; any instruction with an address of 80h through FFh refers to an SFR control
register.

Registers

The Accumulator

The Accumulator, as its name suggests, is used as a general register to accumulate the results of
a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile
register

The "R" registers

The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including R7.
These registers are used as auxiliary registers in many operations.

The "B" Register

The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte)
value. The "B" register is only used by two 8051 instructions: MUL AB and DIV AB.

The Data Pointer (DPTR)

The Data Pointer (DPTR) is the 8051’s only user-accessible 16-bit (2-byte) register. The
Accumulator, "R" registers, and "B" register are all 1-byte values. DPTR, as the name suggests,
is used to point to data. It is used by a number of commands which allow the 8051 to access
external memory.

[24]
The Program Counter (PC)

The Program Counter (PC) is a 2-byte address which tells the 8051 where the next instruction to
execute is found in memory. When the 8051 is initialized PC always starts at 0000h and is
incremented each time an instruction is executed.
.

The Stack Pointer (SP)

The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The
Stack Pointer is used to indicate where the next value to be removed from the stack.

Addressing Modes

An "addressing mode" refers to how you are addressing a given memory location. The
addressing modes are as follows,
With an example of each:
Immediate Addressing MOV A, #20h
Direct Addressing MOV A, #30h
Indirect Addressing MOV A, @R0
External Direct MOVX A, @DPTR
Code Indirect MOVC A, @A+DPTR
Each of these addressing modes provides important flexibility.

Interrupts

An interrupt is a special feature which allows the 8051 to provide the illusion of "multitasking,"
although in reality the 8051 is only doing one thing at a time.
.
Timers

Timers are one of the categories of hardware time delays. Time delays are used to keep a system
into halting System or sleepy mode. We have two timers-timer0, timer1.Hardware time delays
are used to generate exact time delays.

[25]
3. LCD INTERFACING

3.1 LIQUID CRYSTAL DISPLAY (LCD):

Basic diagram of LCD is as shown in figure, and description of its layers as follows:

1. Polarizing filter film with a vertical axis to polarize light as it enters.


2. Glass substrate with ITO electrodes. The shapes of these electrodes will determine the
shapes that will appear when the LCD is turned ON. Vertical ridges etched on the surface
are smooth.
3. Twisted liquid crystal.
4. Glass substrate with common electrode film (ITO) with horizontal ridges to line up with
the horizontal filter.
5. Polarizing filter film with a horizontal axis to block/pass light.
6. Reflective surface to send light back to viewer. (In a backlit LCD, this layer is replaced
with a light source.)

Fig 3.1 16x2 LCD

[26]
Fig 3.2 Different layers of LCD

A Liquid Crystal Display (LCD) is a thin, flat panel used for electronically displaying
information such as text, images, and moving pictures. Its uses include monitors for computers,
televisions, instrument panels. Among its major features are its lightweight construction, its
portability, and its ability to be produced in much larger screen sizes than are practical for the
construction of cathode ray tube (CRT) display technology. Its low electrical power consumption
enables it to be used in battery-powered electronic equipment. It is an electronically-modulated
optical device made up of any number of pixels filled with liquid crystals and arrayed in front of
a light source(backlight or reflector) to produce images in color or monochrome.

[27]
3.2 PIN DESCRIPTION OF LCD:

Fig 3.3 Pin diagram of LCD

[28]
3.3 BF - Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for
processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this
flag is cleared (BF = 0). This is helpful in producing and exact amount of delay. For the LCD
processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of
the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept
next command or data and BF = 0 means LCD is ready for the next command or data to process.

3.4 Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers controller Instruction and Data register. Instruction register
corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD
clear, LCD address etc. and Data register is used for storing data which is to be displayed on
LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the
data register and data is then moved automatically to the DDRAM and hence is displayed on the
LCD.

3.5Commands and Instruction set

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by the
MCU. Before starting the internal operation of the LCD, control information is temporarily
stored into these registers to allow interfacing with various MCUs, which operate at different
speeds, or various peripheral control devices. The internal operation of the LCD is determined by
signals sent from the MCU.

3.6 Sending Commands to LCD


To send commands we simply need to select the command register. Everything is same as we
have done in the initialization routine. But we will summarize the common steps and put them in
a single subroutine.

Following are the steps:


 Move data to LCD port
 Select command register
 Select write operation
 Send enable signal
 Wait for LCD to process the command

[29]
3.7 INTERFACING OF LCD WITH 8051:

The standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user
may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data
bus is used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will
require a total of 11 data lines.

Fig 3.4 Interfacing of LCD

The three control lines are EN, RS, and RW.

EN – Enable
Used to latch the data present on the data pins.
The EN line must be raised/lowered before/after each instruction sent to the
LCD regardless of whether that instruction is read or writes text or instruction.
If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

RS – Register Select
RS = 0 ® Command Register
RS = 1 ® Data Register

R/W = 0 ® Write , R/W = 1 ® Read

D0 – D7 Bi-directional data/command pins.

[30]
4.DC MOTOR INTERFACING

4.1 INTRODUCTION

A direct current (DC) motor is a fairly simple electric motor that uses electricity and a magnetic
field to produce torque, which turns the motor. At its most simple, a DC motor requires two
magnets of opposite polarity and an electric coil, which acts as an electromagnet. The repellent
and attractive electromagnetic forces of the magnets provide the torque that causes the DC motor
to turn.

A DC motor requires at least one electromagnet. This electromagnet switches the current flow as
the motor turns, changing its polarity to keep the motor running. The other magnet or magnets
can either be permanent magnets or other electromagnets. Often, the electromagnet is located in
the center of the motor and turns within the permanent magnets, but this arrangement is not
necessary.

To imagine a simple DC motor, think of a wheel divided into two halves between two magnets.
The wheel of the DC motor in this example is the electromagnet. The two outer magnets are
permanent, one positive and one negative. For this example, let us assume that the left magnet is
negatively charged and the right magnet is positively charged.

Electrical current is supplied to the coils of wire on the wheel within the DC motor. This
electrical current causes a magnetic force. To make the DC motor turn, the wheel must have be
negatively charged on the side with the negative permanent magnet and positively charged on the
side with the permanent positive magnet. Because like charges repel and opposite charges attract,
the wheel will turn so that its negative side rolls around to the right, where the positive
permanent magnet is, and the wheel's positive side will roll to the left, where the negative
permanent magnet is. The magnetic force causes the wheel to turn, and this motion can be used
to do work.

When the sides of the wheel reach the place of strongest attraction, the electric current is
switched, making the wheel change polarity. The side that was positive becomes negative, and
the side that was negative becomes positive. The magnetic forces are out of alignment again, and
the wheel keeps rotating. As the DC motor spins, it continually changes the flow of electricity to
the inner wheel, so the magnetic forces continue to cause the wheel to rotate.

DC motors are used for a variety of purposes, including electric razors, electric car windows, and
remote control cars. The simple design and reliability of a DC motor makes it a good choice for
many different uses, as well as a fascinating way to study the effects of magnetic fields.

[31]
4.2 DC MOTOR INTERFACING

In this project the d.c motor interfacing consists of two motors .One motor is used to
open & close the car door and the other is used to move the car forward. This interfacing is
shown in fig. This uses L293D IC interfacing.

Push-Pull Four Channel Driver

Description

Output currents to 1A or 600mA per channel respectively. Each channel is controlled by a TTL-
compatible logic input and each pair of drivers (a The L293 and L293D are quad pushpull
drivers capable of delivering full bridge) is equipped with an inhibit input which turns off all four
transistors. A separate supply input is provided for the logic so that it may be run off a lower
voltage to reduce dissipation. Additionally the L293D includes the output clamping diodes
within the IC for complete interfacing with inductive loads. Both devices is available in 16-pin
Batwing DIP packages. They are also available in Power S0IC and Hermetic DIL packages.

Block Diagram

Fig 4.1 Connections of L293D

[32]
FEATURES:

 Output Current 1A Per Channel (600mA for L293D)


 Peak Output Current 2A Per Channel (1.2A for L293D)
 Inhibit Facility
 High Noise Immunity
 Separate Logic Supply
 Over-Temperature Protection

[33]
5.OTHER COMPONENTS

5.1 CRYSTAL OSCILLATOR:

It is often required to produce a signal whose frequency or


pulse rate is very stable and exactly known. This is important
in any application where anything to do with time or exact
measurement is crucial. It is relatively simple to make an
oscillator that produces some sort of a signal, but another
matter to produce one of relatively precise frequency and
stability. An ordinary quartz watch must have an oscillator
accurate to better than a few parts per million. One part per
million will result in an error of slightly less than one half
second a day, which would be about 3 minutes a year. This
might not sound like much, but an error of 10
Fig 5.1 Crystal oscillator parts per million would result in an error of about a half an
hour per year. A clock such as this would need resetting
about once a month, and more often if you are the punctual
type.

A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating
crystal of piezoelectric material to create an electrical signal with a very precise frequency. This
frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable
clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and
receivers. The most common type of piezoelectric resonator used is the quartz crystal, so
oscillator circuits designed around them were called "crystal oscillators".

Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens of
megahertz. More than two billion (2×109) crystals are manufactured annually. Most are small
devices for consumer devices such as wristwatches, clocks, radios, computers, and cellphones.
Quartz crystals are also found inside test and measurement equipment, such as counters, signal
generators, and oscilloscopes.

OPERATION:

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly
ordered, repeating pattern extending in all three spatial dimensions.

[34]
Almost any object made of an elastic material could be used like a crystal, with appropriate
transducers, since all objects have natural resonant frequencies of vibration. For example, steel is
very elastic and has a high speed of sound. It was often used in mechanical filters before quartz.
The resonant frequency depends on size, shape, elasticity, and the speed of sound in the material.
High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-
frequency crystals, such as those used in digital watches, are typically cut in the shape of a
tuning fork. For applications not needing very precise timing, a low-cost ceramic resonator is
often used in place of a quartz crystal.

When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field
by applying a voltage to an electrode near or on the crystal. This property is known as
piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns
to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves
like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency.
(See RLC circuit.)

Quartz has the further advantage that its elastic constants and its size change in such a way that
the frequency dependence on temperature can be very low. The specific characteristics will
depend on the mode of vibration and the angle at which the quartz is cut (relative to its
crystallographic axes).[7] Therefore, the resonant frequency of the plate, which depends on its
size, will not change much, either. This means that a quartz clock, filter or oscillator will remain
accurate. For critical applications the quartz oscillator is mounted in a temperature-controlled
container, called a crystal oven, and can also be mounted on shock absorbers to prevent
perturbation by external mechanical vibrations.

5.2 ZERO PCB PLATE

PCB is a platform where many of the embedded systems to be made. PCB (Printed
Circuit Board) is used for the assembly of various components on a single plate. The connections
on the PCB should be identical to the circuit diagram, but while the circuit diagram is arranged to
be readable, the PCB layout is arranged to be functional, so there is rarely any visible correlation
between the circuit diagram and the layout.

PCB layout can be performed manually (using CAD) or in combination with an


Autorouter. The best results are usually still achieved using atleast some manual routing

Sometimes abbreviated PCB, a thin plate on which chips and other electronic
components are placed. Computers consist of one or more boards, often called cards or adapters

5.3 BUZZER

Buzzer is a device used for beep signal. This will help us to make understand information or
message. A buzzer is usually electronic device used in automobiles, household applications etc.

[35]
Fig 5.2 Buzzer

It mostly consists of switches or sensors connected to a control unit that determines if and which
button was pushed or a preset time has lapsed, and usually illuminates a light on appropriate
button or control panel, and sounds a warning in the form of a continuous or intermittent buzzing
or beeping sound. Initially this device was based on an electromechanical system which was
identical to an electrical bell without the metal gong. Often these units were anchored to a wall or
ceiling and used the ceiling or wall as a sounding board. Another implementation with some AC-
connected devices was to implement a circuit to make the AC current into a noise loud enough to
derive a loudspeaker and hook this circuit to a cheap 8-ohm speaker. These buzzers do not make
a sound or turn on a light, they stop a nearby digital clock, briefly fire two smoke cannons on
each side of the stage exit and open the exit. However, at the end of the Heartbreaker in Viking,
the buzzer is replaced with a sword that, when removed, causes two contacts to touch, closing
the circuit and causing the latter two actions above to occur.

Buzzer may be mechanical, electromechanical or electronic.

Mechanical

A joy buzzer is an example of a purely mechanical buzzer.

Electromechanical

Early devices were based on an electromechanical system identical to an electric bell without the
metal gong. Similarly, a relay may be connected to interrupt its own actuating current, causing
the contacts to buzz. Often these units were anchored to a wall or ceiling to use it as a sounding
board. The word "buzzer" comes from the rasping noise that electromechanical buzzers made.

Electronic

A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal
source. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a
beep.

[36]
5.3 VOLTAGE REULATOR IC(78XX):

A voltage regulator is an electrical regulator designed to automatically maintain a


constant voltage level. It may use an electromechanical mechanism, or passive or active
electronic components. Depending on the design, it may be used to regulate one or more AC or
DC voltages.

With the exception of passive shunt regulators, all modern electronic voltage regulators
operate by comparing the actual output voltage to some internal fixed reference voltage. Any
difference is amplified and used to control the regulation element in such a way as to reduce the
voltage error. This forms a negative feedback control loop; increasing the open-loop gain tends
to increase regulation accuracy but reduc``e stability (avoidance of oscillation, or ringing during
step changes). There will also be a trade-off between stability and the speed of the response to
changes. If the output voltage is too low (perhaps due to input voltage reducing or load current
increasing), the regulation element is commanded, up to a point, to produce a higher output
voltage - by dropping less of the input voltage (for linear series regulators and buck switching
regulators), or to draw input current for longer periods (boost-type switching regulators); if the
output voltage is too high, the regulation element will normally be commanded to produce a
lower voltage.

Fig 5.3 Regulator ICs

The 78xx (also sometimes known as LM78xx) series of devices is a family of self-
contained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular
choice for many electronic circuits which require a regulated power supply, due to their ease of
use and relative cheapness. When specifying individual ICs within this family, the xx is replaced
with a two-digit number, which indicates the output voltage the particular device is designed to
provide (for example, the 7805 has a 5 volt output, while the 7809 produces 9 volts). The 78xx
line are positive voltage regulators, meaning that they are designed to produce a voltage that is
positive relative to a common ground. There is a related line of 79xx devices which are
complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to
provide both positive and negative supply voltages in the same circuit, if necessary.

[37]
Fig
5.4 Regulator IC 78XX

FEATURES

• Output current in Excess of 1.0 A

• No external component required

• Internal thermal overload protection

• Internal short circuit current limiting

• Output transistor safe-area compensation

• Output voltage offered in 2% and 4% tolerance

• Available I n surface mount D2PAK and standard 3-lead transistor packages

• Previous commercial temperature range has been extended to a junction temperature range of -40
degree C to +125 degree C.

[38]
5.4 RESISTORS

A resistor is a two-terminal electronic component


that produces a voltage across its terminals that is
proportional to the electric current passing through it in
accordance with Ohm's law:

V = IR

Resistors are elements of electrical networks and


electronic circuits and are ubiquitous in most electronic
equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire
made of a high-resistivity alloy, such as nickel/chrome).

Fig 5.5 Resistors


The primary characteristics of a resistor are the
resistance, the tolerance, maximum working voltage and the power rating. Other characteristics
include temperature coefficient, noise, and inductance. Less well-known is critical resistance, the
value below which power dissipation limits the maximum permitted current flow, and above
which the limit is applied voltage. Critical resistance depends upon the materials constituting the
resistor as well as its physical dimensions; it's determined by design.

Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits. Size,
and position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.

Fig 5.6 Symbol of Resistance

FUNCTION
Resistor restrict the flow of electric current, for example a resistor is placed in series with a light-
emitting diode(LED) to limit the current passing through the LED.

[39]
TYPES OF RESISTORS

FIXED VALUE RESISTORS


It includes two types of resistors as carbon film and metal film .These two types are explained under

1. CARBON FILM RESISTORS: During manufacture, at in film of carbon is deposited


onto a small ceramic rod. The resistive coating is spiraled away in an automatic machine
until the resistance between there two ends of the rods is as close as possible to the
correct value. Metal leads and end caps are added, the resistors is covered with an
insulating coating and finally painted with colored bands to indicate the resistor value

Fig 5.7 Carbon film resistors

Fig 5.7 Carbon Film Resistors Another example for a Carbon 22000 Ohms or 22 Kilo-
Ohms also known as 22K at 5% tolerance: Band 1 = Red, 1st digit Band 2 = Red, 2nd
digit Band 3 = Orange, 3rd digit, multiply with zeros, in this case 3 zero's Band 4 = Gold,
Tolerance, 5%

2. METAL FILM RESISTORS: Metal film and metal oxides resistors are made in a similar
way, but can be made more accurately to within ±2% or ±1% of their nominal vale there are
some difference in performance between these resistor types, but none which affects their use
in simple circuit.

3. WIRE WOUND RESISTOR: A wire wound resistor is made of metal resistance wire, and
because of this, they can be manufactured to precise values. Also, high wattage resistors can
be made by using a thick wire material. Wire wound resistors cannot be used for high
frequency circuits. Coils are used in high frequency circuit. Wire wound resistors in a
ceramic case, strengthened with special cement. They have very high power rating, from 1 or
2 watts to dozens of watts. These resistors can become extremely hot when used for high
power application, and this must be taken into account when designing the circuit.

[40]
5.5 CAPACITORS:

A capacitor or condenser is a passive electronic component


consisting of a pair of conductors separated by a dielectric
(insulator). When a potential difference (voltage) exists across the
conductors, an electric field is present in the dielectric. This field
stores energy and produces a mechanical force between the
conductors. The effect is greatest when there is a narrow separation
between large areas of conductor, hence capacitor conductors are
often called plates.

An ideal capacitor is characterized by a single constant value,


capacitance, which is measured in farads. This is the ratio of the
electric charge on each conductor to the potential difference Fig 5.8 Capacitor
between them. In practice, the dielectric between the plates passes
a small amount of leakage current. The conductors and leads introduce an equivalent series
resistance and the dielectric has an electric field strength limit resulting in a breakdown voltage.

Capacitors are widely used in electronic circuits to block the flow of direct current while
allowing alternating current to pass, to filter out interference, to smooth the output of power
supplies, and for many other purposes. They are used in resonant circuits in radio frequency
equipment to select particular frequencies from a signal with many frequencies.

BASIC

Like a battery, a capacitor has two terminals. Inside the capacitor, the terminals connect to two metal
plates separated by a dielectric. The dielectric can be air, paper, plastic or anything else that does not
conduct electricity and keeps the plates from touching each other. You can easily make a capacitor
from two pieces of aluminum foil and a piece of paper. It won't be a particularly good capacitor in
terms of its storage capacity, but it will work. In an electronic circuit, a capacitor is shown like this:

Fig 5.9 Symbol of Capacitor

When you connect a capacitor to a battery, here’s what happens:

[41]
• The plate on the capacitor that attaches to the negative terminal of the battery accepts electrons that
the battery is producing.

• The plate on the capacitor that attaches to the positive terminal of the battery loses electrons to the
battery.

Fig 5.10 Capacitor & Battery Connection

TYPES OF CAPACITORS:

ELECTROLYTIC CAPACITOR

[42]
An electrolytic capacitor is a type of capacitor that uses an ionic conducting liquid as one of its
plates with a larger capacitance per unit volume than other types. They are often referred to in
electronics usage simply as "electrolytics". They are valuable in relatively high-current and low-
frequency electrical circuits. This is especially the case in power-supply filters, where they store
charge needed to moderate output voltage and current fluctuations in rectifier output. They are
also widely used as coupling capacitors in circuits where AC should be conducted but DC should
not.Electrolytic capacitors can have a very high capacitance, allowing filters made with them to
have very low corner frequencies.

MICA CAPACITOR

Mica capacitors are high precision high stability high reliability capacitors. They are available in
small values, and are mostly used at high frequencies.

PAPER CAPACITOR

Common in antique radio equipment, paper dielectric and aluminum foil layers rolled into a
cylinder and sealed with wax. Low values up to a few μF, working voltage up to several hundred
volts, oil-impregnated bathtub types to 5 kV used for motor starting and high-voltage power
supplies, and up to 25 kV for large oil-impregnated energy discharge types.

CERAMIC CAPACITOR

The main differences between ceramic dielectric types are the temperature coefficient of
capacitance, and the dielectric loss. C0G and NP0 (negative-positive-zero, i.e. ±0) dielectrics
have the lowest losses, and are used in filters, as timing elements, and for balancing crystal
oscillators. Ceramic capacitors tend to have low inductance because of their small size. NP0
refers to the shape of the capacitor's temperature coefficient graph (how much the capacitance
changes with temperature). NP0 means that the graph is flat and the device is not affected by
temperature changes.

TRIMMER CAPACITOR

These capacitors have a rotating plate (which can be rotated to change the capacitance) separated
from a fixed plate by a dielectric medium. Typically values range from 5 pF to 60 pF.

5.6 BATTERIES AND CONNECTORS:

[43]
A nine-volt battery, sometimes referred to by its original designation as a PP3 battery is
used here, the battery has both the positive and negative terminals on one end. The negative
terminal is fashioned into a snap fitting which mechanically and electrically connects to a mating
terminal on the power connector. The power connector has a similar snap fitting on its positive
terminal which mates to the battery. This makes battery polarization obvious since mechanical
connection is only possible in one configuration. The clips on the 9-volt battery can be used to
connect several 9-volt batteries in series. Inside a PP3 there are six cells, either cylindrical
alkaline or flat carbon-zinc type, connected in series. Some brands use welded tabs internally to
attach to the cells, others press foil strips against the ends of the cells. Finally we will connect
this assembly with a 9 volts PP3 dry battery, we find it experimentally that RTC will work with
low voltage supplies. As mentions in the circuit diagram we connect it to the appropriate space.

Fig 5.11 Battery

Fig 5.12 Battery Connector

6.Description of Project
[44]
6.1 Introduction

The Need

Delhi, the National Capital with a population of about 12 million is, perhaps, the only city of its
size in the world, which depends almost entirely on buses on it sole mode of mass transport.bus
services are inadequate and heavily over-crowded.. The result of extreme congestion on the road,
ever slowing speeds, increasing accident rate, fuel wastage and environmental pollution. Delhi
has now become the fourth most city in the world, with automobiles contributing more than two
thirds of the total atmospheric pollution. Pollution related health problems are reaching
disconcerting levels. Immediate steps are, therefore, needed to improve both the quality and
availability of mass transport service. This is possible only if a rail-based mass transit system,
which is non-polluting, is introduced in the city without further delay.

[45]
Delhi MRTS Project

With a view to reducing the problems of Delhi’s commuter, the launching of an Integrated Multi
Mode Mass Rapid Transport System for Delhi had long been under consideration. The first
concrete step in this direction was, however, taken when a feasibility study for developing such a
multi-modal MRTS system was commissioned by GNCTD (with support from GOI) in 1989 and
completed by RITES in 1991.

My Prototype of metro train

I have made the prototype of Metro train using Microcontroller 89C51.The basic function of this
project is given later. I have used a toy car to implementing it which has two DC motors. One is
used for opening and closing the door and other is used for moving the car forward. The
complete description of project is given below.

[46]
6.2 Circuit Diagram of the project

Following figure shows the complete Metro Train Prototype.

Fig 6.1 Circuit Diagram of Project

[47]
6.3 PROJECT METHODOLOGY

6.3(a) Components:

Component Name Quantity


1. Power Supply Section
9 volt battery
1K Resistor 1
2. Microcontroller Section
Microcontroller IC (AT89C51) with base 1
Crystal Oscillator (11.0592 MHz) 1
Capacitor (30pF) 2
Capacitor (10μF) 1
Resistor (8.2K) 1
LCD Connector 1
3. Buzzer 1
4. LCD (16x2) 1
5. Load Driver (L293D) with base 1
6. A Car (toy-driven by a DC motor) 1
7. General Purpose Card 4
8. Single Core Connecting Wires
9. Reset Switch (Push-on) 1
10. Old and Rough CD drive for making Door System 1
(We are to use only motor and Pulley system for door)

6.3(b) Software used:


1. Keil μVision3.
2. Top-View Simulator

6.3(c) Equipments used:


1. Soldering iron, solder, flux.
2. Hex Blade

6.4 Procedure of building the Prototype of Metro Train

Step 1: Circuit diagram of the proposed system is designed and finalized.(Refer to Figure
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 boards
with the help of soldering ion, 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 µ vision3).The coding could be seen in section.

[48]
Step 5: The hex code of the program being created by the software platform is burnt into the
flash code memory of our microcontroller IC 89C51.
Step 6: Testing is done at various levels to finalize the appropriate program for the most
proper working of the system

6.5 General Working

When the power is turned on a message (“welcome to metro”) is displayed on LCD. Then a
message “Current station is Kishan Ganj” is displayed and door is opened also. A buzzer is also
turned on when door opens. After some delay the door is closed and car is started to move
forward. A message “current station is Kishan Ganj” is displayed also on LCD. After some delay
a message “next station is Pratap nagar” is displayed. After some time the train stops and a
message “ current station is Pratap nagar” is displayed. This process is continued for five
stations. In the end a message “End of line” is displayed on LCD. This whole process is repeated
until we turned off the power supply.

[49]
7. FUTURE SCOPE

The new cars would feature the following:

 Stainless steel exteriors instead of an aluminium car body.


 Thinner, stronger stainless steel seats that offer more leg room. Each car would have 64
cloth-padded, taller seats with seat-back grab handles.
 A total end to carpeting. Floors would be rubberized.
 Interactive maps on LCD screens that would also likely display advertisements
 Automated station announcements. So no more "Judishuwary Square".
 Security cameras on all rail cars.

The 7000 series won't be ready for service for at least five years. The latest models are in the
6000 series, which were introduced last year.

[50]
8.REFRENCES AND BIBLOGRAPHY

 “THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM” by Muhammad


Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay.
 “The 8051 MICROCONTROLLER” by K. J. Ayala.
 "Advanced Microprocessors and Microcontrollers" by B.P. Singh & Renu Singh.
 "Let Us C" by Yashwant Kanitkar.
 "Data Structure through C" by Yashwant Kanitkar.
 Digital design by Morris Mano.

NET LINKS:

1. www.8051projects.net
2. www.atmel.com
3. www.electronicsforyou.com
4. www.encyclopedia.com
5. www.wikipedia.com

[51]
APPENDIX-I

C Language Code

#include<reg51.h>
void lcd_data(char[]);
void lcd_ok(bit);
void delay(unsigned int);
void delay1(unsigned int);
void lcd_code(char);
void check();
void lcd_init();
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P1^7;
sbit mot1 = P2^3;
sbit mot2 = P2^4;
sbit door1 = P2^5;
sbit door2 = P2^6;
sbit buzz = P2^7;
#define lcd_port P1

main()
{
char index1;
code char stations[][16] = {{"Kishan Ganj0"}, {"Pratap Nagar0"}, {"Shahadara0"},
{"Indraprashta0"}, {"Rohini West0"}};
mot1 = 0;
mot2 = 0;
buzz = 1;
door1 = 1;
door2 = 1;

lcd_init();
lcd_code(0x01);
lcd_data("Welcome To Metro0");
delay1(1000);
lcd_code(0x80);
for(index1 = 0; index1 != 5; index1++)
{
lcd_code(0x01);
lcd_code(0x80);

[52]
lcd_data("Current Station:0");
lcd_code(0xC0);
lcd_data(stations[index1]);
delay1(200);
buzz = 0;
delay1(200);
buzz = 1;
//------------------------------Door Open
door1 = 0;
delay1(500);
door1 = 1;
//------------------------------Door Open
delay1(3500);
//------------------------------Door Close
door2 = 0;
delay1(1000);
door2 = 1;
//------------------------------Door Close
delay1(300);
mot1 = 1;
mot2 = 0;
if(index1 < 4)
{
delay1(2000);
lcd_code(0x01);
lcd_code(0x80);
lcd_data("Next Station:0");
lcd_code(0xC0);
lcd_data(stations[index1+1]);
delay1(2000);
mot1 = 0;
mot2 = 0;
lcd_code(0x01);
}
else
{
lcd_code(0x01);
lcd_data("End Of Line0");
delay1(1000);
}
}

void lcd_data(char ch[])

[53]
{
int index1;
for(index1 = 0; ch[index1] != '0'; index1++)
{
check();
lcd_port = ch[index1];
lcd_ok(1);
}
return;
}

void lcd_ok(bit mybit)


{
if(mybit)
{
rs = 1;
}
else
{
rs = 0;
}
rw = 0;
en = 1;
delay(1);
en = 0;
return;
}

void delay1(unsigned int itime)


{
unsigned int i,j;
for(i = 0; i < itime; i++)
for(j = 0; j < 500; j++);
return;

void delay(unsigned int time)


{
int i = 0;
for(; time > 0; time--)
for(; i < 353; i++);
return;

[54]
}

void lcd_init()
{
lcd_code(0x38);
lcd_code(0x0C);
lcd_code(0x01);
lcd_code(0x06);
return;
}

void lcd_code(char ch)


{
check();
lcd_port = ch;
lcd_ok(0);
return;
}

void check()
{
rs = 0;
rw = 1;
while(busy == 1)
{
en = 0;
delay(1);
en = 1;
}
return;
}

[55]
APPENDIX-II

Code In Assembly

org 000h
buzz bit P2.7
rs bit P2.0
rw bit P2.1
en bit P2.2
mot1 bit P2.3
mot2 bit P2.4
door1 bit P2.5
door2 bit P2.6
busy bit P1.7

clr mot1
clr mot2
setb buzz
setb door1
setb door2

mov A,#38h
lcall cmwrt
mov A,#0ch
lcall cmwrt
mov A,#01h
lcall cmwrt
mov A,#06h
lcall cmwrt

mov A,#01h
lcall cmwrt
mov dptr,#disp1
clr A
movc A,@A+dptr
lcall dwrt

mov A,#01h
lcall cmwrt
mov A,#80h
clr A

[56]
mov dptr,#disp2
movc A,@A+dptr
lcall dwrt
mov A,#0c0h
lcall cmwrt
mov dptr,#disp4
clr A
movc A,@A+dptr
lcall delay1
clr buzz
lcall delay2
setb buzz
clr door1
lcall delay2
setb door1
lcall delay2
clr buzz
lcall delay2
setb buzz
clr door2
lcall delay2
setb door2……………………….door closed

lcall delay2
setb mot1
clr mot2
lcall delay1
mov A,#01h
lcall cmwrt
mov A,#80h
lcall cmwrt
clr A
mov dptr,#disp3
movc A,@A+dptr
mov A,#0c0h
clr A
mov dptr,#disp5
movc A,@A+dptr
lcall delay1
clr mot1
clr mot2

………………………………………………………………….
mov A,#01h
lcall cmwrt
mov A,#80h

[57]
clr A
mov dptr,#disp2
movc A,@A+dptr
lcall dwrt
mov A,#0c0h
lcall cmwrt
mov dptr,#disp5
clr A
movc A,@A+dptr
lcall delay1
clr buzz
lcall delay2
setb buzz
clr door1
lcall delay2
setb door1
lcall delay2
clr buzz
lcall delay2
setb buzz
clr door2
lcall delay2
setb door2……………………….door closed

lcall delay2
setb mot1
clr mot2
lcall delay1
mov A,#01h
lcall cmwrt
mov A,#80h
lcall cmwrt
clr A
mov dptr,#disp3
movc A,@A+dptr
mov A,#0c0h
clr A
mov dptr,#disp6
movc A,@A+dptr
lcall delay1
clr mot1
clr mot2

…………………………………………………………………………………………..

mov A,#01h

[58]
lcall cmwrt
mov A,#80h
clr A
mov dptr,#disp2
movc A,@A+dptr
lcall dwrt
mov A,#0c0h
lcall cmwrt
mov dptr,#disp6
clr A
movc A,@A+dptr
lcall delay1
clr buzz
lcall delay2
setb buzz
clr door1
lcall delay2
setb door1
lcall delay2
clr buzz
lcall delay2
setb buzz
clr door2
lcall delay2
setb door2……………………….door closed

lcall delay2
setb mot1
clr mot2
lcall delay1
mov A,#01h
lcall cmwrt
mov A,#80h
lcall cmwrt
clr A
mov dptr,#disp3
movc A,@A+dptr
mov A,#0c0h
clr A
mov dptr,#disp7
movc A,@A+dptr
lcall delay1
clr mot1
clr mot2

………………………………………………………………………………………

[59]
mov A,#01h
lcall cmwrt
mov A,#80h
clr A
mov dptr,#disp2
movc A,@A+dptr
lcall dwrt
mov A,#0c0h
lcall cmwrt
mov dptr,#disp7
clr A
movc A,@A+dptr
lcall delay1
clr buzz
lcall delay2
setb buzz
clr door1
lcall delay2
setb door1
lcall delay2
clr buzz
lcall delay2
setb buzz
clr door2
lcall delay2
setb door2……………………….door closed

lcall delay2
setb mot1
clr mot2
lcall delay1
mov A,#01h
lcall cmwrt
mov A,#80h
lcall cmwrt
clr A
mov dptr,#disp3
movc A,@A+dptr
mov A,#0c0h
clr A
mov dptr,#disp8
movc A,@A+dptr
lcall delay1
clr mot1
clr mot2

[60]
……………………………………………………………………………..

mov A,#01h
lcall cmwrt
mov A,#80h
clr A
mov dptr,#disp2
movc A,@A+dptr
lcall dwrt
mov A,#0c0h
lcall cmwrt
mov dptr,#disp8
clr A
movc A,@A+dptr
lcall delay1
clr buzz
lcall delay2
setb buzz
clr door1
lcall delay2
setb door1
lcall delay2
clr buzz
lcall delay2
setb buzz
clr door2
lcall delay2
setb door2……………………….door closed
mov A,#01h
lcall cmwrt
clrA
mov dptr,#FINISH
movc A,@A+dptr
lcall dwrt
sjmp $

…………………………………………………………………………………………………….
……………………………………………………………………………………………………..

cmwrt: lcall check


mov P1,A
clr rs
clr rw
setb en
lcall delay

[61]
clr en
ret

dwrt: lcall check


mov P1,A
setb rs
clr rw
setb en
lcall delay1
clr en
ret

delay1: mov r1,#10


here1: mov r2,#255
here2: mov r3,#255
here3: djnz r3,here3
djnz r2,here2
djnz r1,here1
ret

delay2: mov r1,#250


here1: mov r2,#255
here2: mov r3,#255
here3: djnz r3,here3
djnz r2,here2
djnz r1,here1
ret

org 800h
disp1: db “Welcome to Metro”,0
disp2: db ”Current Station”,0
disp3: db ”Next Station”,0
disp4: db ”Kishan Ganj”,0
disp5: db ”Pratap Nagar”,0
disp6: db ”Shahadra”,0
disp7: db “Indraprastha”,0
disp8: db ”Rohini West”,0
finish: db ”End of Line”,0

[62]

You might also like