You are on page 1of 15

A B.Tech.

PROJECT REPORT ON

METRO TRAIN PROTOTYPE BASED ON 8051 MICROCONTROLLER

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

List of Contents
1.Introduction 1.1Objectives 1.2Features 1.3Overview 1.4Schematic Representation of Project 2. Microcontroller(AT89C51) 2.1 Introduction 2.2 Definition of a Microcontroller 2.3 Microcontrollers vs Microprocessors 2.4 Memory Unit 2.5 Central Processing Unit 2.6 Bus 2.7 Input Output Unit 2.8 Serial Communication 2.9 Timer Unit 2.10 Watch Dog 2.11 Analog to Digital Converter 2.12 Pin Configuration 2.13 RAM Architecture 3. Introduction to 16X2 LCD Display 3.1Liquid Crystal Display 3.2 Pin description of LCD 3.3 BF - Busy Flag 3.4 Instruction Register (IR) and Data Register (DR) 3.5 Commands and Instruction set 3.6 Sending Commands to LCD 3.7 Interfacing of LCD with 8051 4. DC Motor Interfacing 4.1 Introduction 4.2 DC Motor Interfacing 5.Other Components 5.1 Crystal Oscillator 5.2 Zero PCB 5.3 Buzzer 5.4 Voltage Regulator IC(78XX) 5.5 Resistors 5.6 Capacitors 5.7 Batteries And Connectors

6. Description of Project 6.1 Introduction 6.2 Circuit Diagram of the Project 6.3 Project Methodology 6.3(a) Components 6.3(b) Software Used 6.3(c) Equipments Used 6.4 Procedure of building the Prototype of Metro Train 6.5 General Working 7. Future Scope 8. References and Bibliography Appendix-I Appendix-II

LIST OF FIGURES
Fig. No.
Fig 1.1 Fig 2.1 Fig 2.2 Fig 2.3 Fig 2.4 Fig 2.5 Fig 2.6 Fig 2.7 Fig 2.8 Fig 2.9 Fig 2.10 Fig 2.11 Fig 2.12 Fig 2.13 Fig 3.1 Fig 3.2 Fig 3.3 Fig 3.4 Fig 4.1 Fig 5.1 Fig 5.2 Fig 5.3 Fig 5.4 Fig 5.5 Fig 5.6 Fig 5.7

Topic
Schematic representation of the project Showing a typical microcontroller device and its different subunits Simplified model of a memory unit Simplified central processing unit with three registers Showing connection between memory and central unit using buses Simplified input-output unit communicating with external world Serial unit sending data through three lines only Timer unit generating signals in regular time intervals Watchdog Block for converting an analog input to digital output Physical configuration of the interior of a microcontroller Microcontroller outline with basic elements and internal connections Pin configuration of Microcontroller RAM Architecture 16x2 LCD Different layers of LCD Pin diagram of LCD Interfacing of LCD Connections of L293D Crystal oscillator Buzzer Regulator ICs Regulator IC 78XX Resistors Symbol of Resistance Carbon film resistors

Fig 5.8 Fig 5.9 Fig 5.10 Fig 5.11 Fig 5.12 Fig 6.1

Capacitor
Symbol of Capacitor Capacitor & Battery Connection

Battery Battery Connector Circuit diagram of the project

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 passengers convenience.like current station is Indraprastha and next station is Rohini West. Before stopping at station, the buzzer sounds for 3 seconds.

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

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

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

You might also like