Report on Project Based on 8051 Micro Controller

83
A B.Tech. PROJECT REPORT ON METRO TRAIN PROTOTYPE BASED ON 8051 MICROCONTROLLER By Brijendra Mohan Gupta ELECTRONICS & COMMUNICATION ENGINEERING [0]

description

report on project based on 8051 microcontroller .......

Transcript of Report on Project Based on 8051 Micro Controller

Page 1: Report on Project Based on 8051 Micro Controller

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]

Page 2: Report on Project Based on 8051 Micro Controller

APROJECT 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 TECHNOLOGYIN

ELECTRONICS & COMMUNICATION ENGINEERINGU.P. Technical University, Lucknow

SUBMITTED BY:Brijendra Mohan Gupta

GUIDED BY:Mr. V.K.Aggarwal (Sr. Lec)

IMS ENGINEERING COLLEGE, GHAZIABAD

[1]

Page 3: Report on Project Based on 8051 Micro Controller

CERTIFICATE

This is to certify thatBrijendra 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)

ofU.P. Technical University, Lucknow

Session 2008-2009

The matter in this Project report is a record of the students own work carriedout 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]

Page 4: Report on Project Based on 8051 Micro Controller

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]

Page 5: Report on Project Based on 8051 Micro Controller

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 102.2 Definition of a Microcontroller 112.3 Microcontrollers vs Microprocessors 122.4 Memory Unit 132.5 Central Processing Unit 142.6 Bus 142.7 Input Output Unit 152.8 Serial Communication 152.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 283.3 BF - Busy Flag 293.4 Instruction Register (IR) and Data Register (DR) 293.5 Commands and Instruction set 293.6 Sending Commands to LCD 293.7 Interfacing of LCD with 8051 30

4. DC Motor Interfacing 31-334.1 Introduction 314.2 DC Motor Interfacing 32

5.Other Components 34-445.1 Crystal Oscillator 345.2 Zero PCB 355.3 Buzzer 355.4 Voltage Regulator IC(78XX) 375.5 Resistors 395.6 Capacitors 41

5.7 Batteries And Connectors 44

[4]

Page 6: Report on Project Based on 8051 Micro Controller

6. Description of Project 45-496.1 Introduction 456.2 Circuit Diagram of the Project 476.3 Project Methodology 48

6.3(a) Components 48 6.3(b) Software Used 48

6.3(c) Equipments Used 486.4 Procedure of building the Prototype of Metro Train 486.5 General Working 49

7. Future Scope 50

8. References and Bibliography 51

Appendix-I 52-55

Appendix-II 56-62

[5]

Page 7: Report on Project Based on 8051 Micro Controller

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]

Page 8: Report on Project Based on 8051 Micro Controller

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]

Page 9: Report on Project Based on 8051 Micro Controller

1.INTRODUCTION

METRO TRAIN PROTOTYPE PROJECT

1.1 Objective

1. To construct a model of a metro train controlled by 80512. 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]

Page 10: Report on Project Based on 8051 Micro Controller

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 motors4. Buzzer(5 volt)5. Other components like resistors(1k,10k),capacitors(33 pF) etc.

[9]

Page 11: Report on Project Based on 8051 Micro Controller

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

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.

[10]

Page 12: Report on Project Based on 8051 Micro Controller

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.

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

[11]

Page 13: Report on Project Based on 8051 Micro Controller

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 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.

[12]

Page 14: Report on Project Based on 8051 Micro Controller

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.

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

[13]

Page 15: Report on Project Based on 8051 Micro Controller

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 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.

[14]

Page 16: Report on Project Based on 8051 Micro Controller

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 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

[15]

Page 17: Report on Project Based on 8051 Micro Controller

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.

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,

[16]

Page 18: Report on Project Based on 8051 Micro Controller

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

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.

[17]

Page 19: Report on Project Based on 8051 Micro Controller

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]

Page 20: Report on Project Based on 8051 Micro Controller

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]

Page 21: Report on Project Based on 8051 Micro Controller

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]

Page 22: Report on Project Based on 8051 Micro Controller

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]

Page 23: Report on Project Based on 8051 Micro Controller

• No external pull up resistors required

We have 4 ports in 8051 micro controller. They are port0, port1, port2, port3 which canbe 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 locationsfrom external memory.

PSEN: Program store enable which is used for storing programmingcode into the external memory.

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

[22]

Page 24: Report on Project Based on 8051 Micro Controller

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]

Page 25: Report on Project Based on 8051 Micro Controller

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]

Page 26: Report on Project Based on 8051 Micro Controller

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, #20hDirect Addressing MOV A, #30hIndirect Addressing MOV A, @R0External Direct MOVX A, @DPTRCode Indirect MOVC A, @A+DPTREach 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]

Page 27: Report on Project Based on 8051 Micro Controller

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]

Page 28: Report on Project Based on 8051 Micro Controller

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]

Page 29: Report on Project Based on 8051 Micro Controller

3.2 PIN DESCRIPTION OF LCD:

Fig 3.3 Pin diagram of LCD

[28]

Page 30: Report on Project Based on 8051 Micro Controller

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]

Page 31: Report on Project Based on 8051 Micro Controller

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 – EnableUsed to latch the data present on the data pins.The EN line must be raised/lowered before/after each instruction sent to theLCD 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]

Page 32: Report on Project Based on 8051 Micro Controller

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]

Page 33: Report on Project Based on 8051 Micro Controller

4.2 DC MOTOR INTERFACING

In this project the d.c motor interfacing consists of two motors .One motor is used toopen & close the car door and the other is used to move the car forward. This interfacing isshown 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]

Page 34: Report on Project Based on 8051 Micro Controller

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]

Page 35: Report on Project Based on 8051 Micro Controller

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 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]

Fig 5.1 Crystal oscillator

Page 36: Report on Project Based on 8051 Micro Controller

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]

Page 37: Report on Project Based on 8051 Micro Controller

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]

Page 38: Report on Project Based on 8051 Micro Controller

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]

Page 39: Report on Project Based on 8051 Micro Controller

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]

Page 40: Report on Project Based on 8051 Micro Controller

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).

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]

Fig 5.5 Resistors

Page 41: Report on Project Based on 8051 Micro Controller

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]

Page 42: Report on Project Based on 8051 Micro Controller

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 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]

Fig 5.8 Capacitor

Page 43: Report on Project Based on 8051 Micro Controller

• 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]

Capacitors

Fixed capacitor

Electrolytic Non-electrolytic

Mica Paper

Ceramic

Variablecapacitor

Gang condenser Trimmer

Page 44: Report on Project Based on 8051 Micro Controller

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]

Page 45: Report on Project Based on 8051 Micro Controller

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]

Page 46: Report on Project Based on 8051 Micro Controller

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]

Page 47: Report on Project Based on 8051 Micro Controller

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]

Page 48: Report on Project Based on 8051 Micro Controller

6.2 Circuit Diagram of the project

Following figure shows the complete Metro Train Prototype.

Fig 6.1 Circuit Diagram of Project

[47]

Page 49: Report on Project Based on 8051 Micro Controller

6.3 PROJECT METHODOLOGY

6.3(a) Components:

Component Name Quantity1. Power Supply Section 9 volt battery 1K Resistor 12. 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 13. Buzzer 14. LCD (16x2) 15. Load Driver (L293D) with base 16. A Car (toy-driven by a DC motor) 17. General Purpose Card 48. Single Core Connecting Wires9. Reset Switch (Push-on) 110. 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 FigureStep 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 boardswith the help of soldering ion, solder and flux according to the hardware schematic shown inthe Figure.Step 4: Code/program of the proposed system is developed using assembly language with thehelp of software platform (Keil µ vision3).The coding could be seen in section.

[48]

Page 50: Report on Project Based on 8051 Micro Controller

Step 5: The hex code of the program being created by the software platform is burnt into theflash 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

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]

Page 51: Report on Project Based on 8051 Micro Controller

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]

Page 52: Report on Project Based on 8051 Micro Controller

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.net2. www.atmel.com3. www.electronicsforyou.com4. www.encyclopedia.com5. www.wikipedia.com

[51]

Page 53: Report on Project Based on 8051 Micro Controller

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);lcd_data("Current Station:0");lcd_code(0xC0);

[52]

Page 54: Report on Project Based on 8051 Micro Controller

lcd_data(stations[index1]);delay1(200);buzz = 0;delay1(200);buzz = 1;//------------------------------Door Opendoor1 = 0;delay1(500);door1 = 1;//------------------------------Door Opendelay1(3500);//------------------------------Door Closedoor2 = 0;delay1(1000);door2 = 1;//------------------------------Door Closedelay1(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[]){

int index1;

[53]

Page 55: Report on Project Based on 8051 Micro Controller

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]

Page 56: Report on Project Based on 8051 Micro Controller

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]

Page 57: Report on Project Based on 8051 Micro Controller

APPENDIX-II

Code In Assembly

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

clr mot1 clr mot2setb buzz setb door1setb door2

mov A,#38hlcall cmwrtmov A,#0chlcall cmwrtmov A,#01hlcall cmwrtmov A,#06hlcall cmwrt

mov A,#01hlcall cmwrtmov dptr,#disp1clr Amovc A,@A+dptr lcall dwrt

mov A,#01hlcall cmwrtmov A,#80hclr Amov dptr,#disp2movc A,@A+dptr

[56]

Page 58: Report on Project Based on 8051 Micro Controller

lcall dwrtmov A,#0c0hlcall cmwrtmov dptr,#disp4clr Amovc A,@A+dptrlcall delay1clr buzzlcall delay2setb buzzclr door1lcall delay2setb door1lcall delay2clr buzzlcall delay2setb buzzclr door2lcall delay2setb door2……………………….door closed

lcall delay2setb mot1clr mot2lcall delay1mov A,#01hlcall cmwrtmov A,#80hlcall cmwrtclr Amov dptr,#disp3movc A,@A+dptrmov A,#0c0hclr Amov dptr,#disp5movc A,@A+dptrlcall delay1clr mot1clr mot2

………………………………………………………………….mov A,#01hlcall cmwrtmov A,#80hclr Amov dptr,#disp2

[57]

Page 59: Report on Project Based on 8051 Micro Controller

movc A,@A+dptrlcall dwrtmov A,#0c0hlcall cmwrtmov dptr,#disp5clr Amovc A,@A+dptrlcall delay1clr buzzlcall delay2setb buzzclr door1lcall delay2setb door1lcall delay2clr buzzlcall delay2setb buzzclr door2lcall delay2setb door2……………………….door closed

lcall delay2setb mot1clr mot2lcall delay1mov A,#01hlcall cmwrtmov A,#80hlcall cmwrtclr Amov dptr,#disp3movc A,@A+dptrmov A,#0c0hclr Amov dptr,#disp6movc A,@A+dptrlcall delay1clr mot1clr mot2

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

mov A,#01hlcall cmwrtmov A,#80h

[58]

Page 60: Report on Project Based on 8051 Micro Controller

clr Amov dptr,#disp2movc A,@A+dptrlcall dwrtmov A,#0c0hlcall cmwrtmov dptr,#disp6clr Amovc A,@A+dptrlcall delay1clr buzzlcall delay2setb buzzclr door1lcall delay2setb door1lcall delay2clr buzzlcall delay2setb buzzclr door2lcall delay2setb door2……………………….door closed

lcall delay2setb mot1clr mot2lcall delay1mov A,#01hlcall cmwrtmov A,#80hlcall cmwrtclr Amov dptr,#disp3movc A,@A+dptrmov A,#0c0hclr Amov dptr,#disp7movc A,@A+dptrlcall delay1clr mot1clr mot2

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

mov A,#01h

[59]

Page 61: Report on Project Based on 8051 Micro Controller

lcall cmwrtmov A,#80hclr Amov dptr,#disp2movc A,@A+dptrlcall dwrtmov A,#0c0hlcall cmwrtmov dptr,#disp7clr Amovc A,@A+dptrlcall delay1clr buzzlcall delay2setb buzzclr door1lcall delay2setb door1lcall delay2clr buzzlcall delay2setb buzzclr door2lcall delay2setb door2……………………….door closed

lcall delay2setb mot1clr mot2lcall delay1mov A,#01hlcall cmwrtmov A,#80hlcall cmwrtclr Amov dptr,#disp3movc A,@A+dptrmov A,#0c0hclr Amov dptr,#disp8movc A,@A+dptrlcall delay1clr mot1clr mot2

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

[60]

Page 62: Report on Project Based on 8051 Micro Controller

mov A,#01hlcall cmwrtmov A,#80hclr Amov dptr,#disp2movc A,@A+dptrlcall dwrtmov A,#0c0hlcall cmwrtmov dptr,#disp8clr Amovc A,@A+dptrlcall delay1clr buzzlcall delay2setb buzzclr door1lcall delay2setb door1lcall delay2clr buzzlcall delay2setb buzzclr door2lcall delay2setb door2……………………….door closedmov A,#01hlcall cmwrt clrAmov dptr,#FINISHmovc A,@A+dptrlcall dwrtsjmp $

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

cmwrt: lcall check mov P1,A

clr rs clr rw setb en lcall delay clr en ret

[61]

Page 63: Report on Project Based on 8051 Micro Controller

dwrt: lcall check

mov P1,Asetb rsclr rwsetb enlcall delay1clr enret

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

djnz r2,here2djnz r1,here1ret

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

djnz r2,here2djnz r1,here1ret

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

[62]