Anda di halaman 1dari 23

METRO TRAIN PROTOTYPE USING 8051 MICROCONTROLLER

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

SUBMITTED BY:Siddharth Jain (09102270) Jaspreet Singh (09102290)

Prakash K.Gupta (09102344)

CERTIFICATE
This is to certify that the work titled METRO TRAIN PROTOTYPE USING 8051 MICROCONTROLLER submitted by Siddharth Jain, Jaspreet Singh and Prakash K.Gupta in minor project of degree of Bachelor of Technology of Jaypee Institute of Information Technology, Noida has been carried out under my

supervision. This work has not been submitted partially or wholly to any other University or Institute for the award of this or any other degree or diploma.

Signature Of Supervisor. Name of Supervisor: Mrs. NEETU SINGH Department of Electronics and Communications Engineering Jaypee Institute of Information Technology, Noida

ACKNOWLEDGEMENT
First and foremost, we would like to thank God for blessing us with the strength, intelligence, and patience to complete this project. We would like to express my sincere thanks to Mrs.Neetu Singh who have been helping us by giving their valuable suggestions and guiding us right way throughout the project. We are extremely thankful to the Dean, Prof. S. L. Maskara and the HOD of Electronics and Communication Engineering Department, Prof. R. C. Jain for

providing the infrastructural facilities to work in, without which this work would have not been possible.

Name of Student:students:Siddharth Jain Jaspreet Singh Prakash K.Gupta

Signatures of
. . .

Date: ..

CONTENTS
1. 2. 3. 4. 5. 6. 7. 8. 9. 8051 Microcontroller Architecture Component List Features of LCD Used Features of Stepper Motor and its Driver IC Schematic Diagram PCB Layout Flow Chart Source Code in Assembly Bibliography

8051 Microcontroller Architecture


AT89C51:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

Pin Configurtion

The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.

Programming the Flash


The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-voltage programming mode provides a convenient way to program the AT89C51 inside the users system, while the high-voltage programming mode is compatible with conventional thirdparty Flash or EPROM programmers. The AT89C51 is shipped with either the high-voltage or low-voltage programming mode enabled. The AT89C51 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode. Programming Algorithm: Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table. To program the AT89C51, take the following steps. 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY. Program Verify: If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled. Chip Erase: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip erase operation must be executed before the code memory can be re-programmed. Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates 89C51 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming

Programming The AT89C51

Data Memory
The right half of the internal and external data memory spaces available on Atmels Flash microcontrollers. Hardware configuration for accessing up to 2K bytes of external RAM. In this case, the CPU executes from internal Flash. Port 0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2 are used to page the RAM. The CPU generates RD and WR signals as needed during external RAM accesses. You can assign up to 64K bytes of external data memory. External data memory addresses can be either 1 or 2 bytes wide. One-byte addresses are often used in conjunction with one or more other I/O lines to page the RAM. Twobyte addresses can also be used, in which case the high address byte is emitted at Port 2. Internal data memory addresses are always 1 byte wide, which implies an address space of only 256 bytes. However, the addressing modes for internal RAM can in fact accommodate 384 bytes. Direct addresses higher than 7FH access one memory space, and indirect addresses higher than 7FH access a different memory space. Thus, the Upper 128 and SFR space occupying the same block of addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7. Two bits in the Program Status Word (PSW) select which register bank is in use. This architecture allows more efficient use of code space, since register instructions are shorter than instructions that use direct addressing.

The Instruction Set


All members of the Atmel microcontroller family execute the same instruction set. This instruction set is optimized for 8- bit control applications and it provides a variety of fast addressing modes for accessing the internal RAM to facilitate byte operations on small data structures. The instruction set provides extensive support for 1-bit variables as a separate data type, allowing direct bit manipulation in control and logic systems that require Boolean processing. The following overview of the instruction set gives a brief description of how certain instructions can be used.

Components List for Project


AT89c51 ULN2003 Stepper Motor 2 Line LCD Buzzer LED Resistances 4.7K 470 ohm 33picofarad Ceramic Disk Capacitor Crystal Osci. (12 MHz) Mini Switch 10K Pot (Preset) Diode 1n4007 IC Base (16Pin, 40Pin, 8Pin) Relimate (5 pin and 2 pin) Relimate (16pin) Power chord Capacitor 100Microfarad/ 25v Capacitor 470 Microfarad / 25v Power IC 7805 Transformer (9-0-9) (10K) 1 1 1 1 1 3 5 5 5 2 1 2 1 4 1 each 1 each 2 1 1 1 1 1

FEATURES OF LCD USED


Liquid Crystal Displays (LCDs) are categorized as non emissive display devices, in that respect, they do not produce any form of light like a Cathode Ray Tube (CRT). LCDs either pass or block light that is reflected from an external light source or provided by a back/side lighting system. There are two modes of operation for LCDs during the absence of an electric field (applied Power); a mode describes the transmittance state of the liquid crystal elements. Normal White mode: the display is white or clear and allows light to pass through and Normal Black Mode: the display is dark and all light is diffused. Virtually all displays in production for PC/Workstation use are normal white mode to optimize contrast and speed. A simplified description of how a dot matrix LCD display works is as follows: A twisted nematic (TN) LC display consists of two polarizers, two pieces of glass, some form of switching element or electrode to define pixels, and driver Integrated Circuits (ICs) to address the rows and columns of pixels. To define a pixel (or subpixel element for a color display), a rectangle is constructed out of Indium Tin Oxide -- a semi-transparent metal oxide (ITO) and charge is applied to this area in order to change the orientation of the LC material ( change from a white pixel to a dark pixel). The method utilized to form a pixel in passive and active matrix displays differs and will be described in later sections. Figure 1 illustrates a cross sectional view of a simple TN LC display. Figure 2 depicts a dot matrix display as viewed without its metal module/case exposing the IC drivers.

Looking directly at the display the gate or row drivers are located either on the left or the right side of the display while the data or column drivers are located on the top (and or bottom) of the display. New thin display module technology mounts the ICs on conductive tape that allows them to be folded behind the display further reducing the size of the finished module. An IC will address a number of rows or columns. Figure 1: Cross Section of a Simple LC Display
viewer ///////////////////////////////////// Polarizer _____________________________________ glass ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Liquid Crystal _____________________________________ glass \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Polarizer Backlight

Figure 2: LCD panel and IC driver locations Polarizers are an integral part of a LCD display, possessing the unique property of only passing light if it is oriented in a specific (oriented) direction. To utilize this phenomena in TN LC displays, the bottom polarizer orients incoming light in one direction. The oriented light passes through the LC material and is either unaltered or "bent" 90 degrees. Depending on the orientation of the top polarizer, this light will either pass through or be diffused. If the light is diffused, it will appear as a dark area. Figure 3 is a simple illustration of the sequence of events that occur when light passes through a simple twisted nematic LC display.

Features of Stepper Motor and its Driver IC


Introduction
Stepper motors are commonly used in accurate motion control. They allow to control any motion with high precision by counting the number of steps applied to the motor. Most of systems controlling stepper motors are embedded systems such as printer, scanner or floppy disk drive. This application note describes how to drive a unipolar stepper motor with the Programmable Counter Array of an Atmel C51/C251 microcontroller. There are two major types of stepper motors: Permanent magnet stepper motors (unipolar stepper motors and bipolar stepper motors) and variable reluctance stepper motors (hybrid stepper motors).

Stepper Motor Driver IC ULN2003

Pin Connection:

SCHEMATIC DIAGRAM

PCB Layout:

PROGRAM in Assembly:
$mod51 dat equ p1 busy equ p1.7 rs equ p3.5 rw equ p3.4 en equ p3.3 bzr equ p0.2 ledf equ p0.0 ledb equ p0.1 org 0000h ajmp main org 0003h test: mov c,p3.2 jnc halt setb bzr reti halt: clr bzr ajmp test main: mov ie,#00h setb ea ;setb ex0 here: mov p2,#00h acall ini mov dptr,#show0 acall read clr ledf ;p1.0 acall delay mov a,#01h acall command; Now make memory clear cursor home mov dptr,#show1 acall read setb ex0 ;############# mov a,#0c0h

;till zero blow on the bzr

acall command mov dptr,#show3 acall read acall delay ;Stopage1 time 3 sec rookee acall delay clr bzr acall delay mov a,#01h acall command mov dptr,#show2 acall read mov a,#0c0h acall command mov dptr,#show4 acall read setb bzr acall delay10 acall stepperf mov a,#01h acall command mov dptr,#show1 acall read mov a,#0c0h acall command mov dptr,#show4 acall read acall delay ;Stopage2 time 3 sec shsar acall delay clr bzr acall delay mov a,#01h acall command mov dptr,#show2 ;display ne acall read mov a,#0c0h acall command mov dptr,#show5 acall read setb bzr acall delay10

acall stepperf mov a,#01h acall command mov dptr,#show1 acall read mov a,#0c0h acall command mov dptr,#show5 acall read acall delay ;Stopage2 time 3 sec Meerut acall delay clr bzr acall delay setb ledf ; p1.0 ;off led at p1.0 for forward journey clr ledb ; p1.1 ; 0n Led for back ward journey mov a,#01h acall command mov dptr,#show2 ;display ne acall read mov a,#0c0h acall command mov dptr,#show4 acall read setb bzr acall delay10 acall stepperb

shar

mov a,#01h acall command mov dptr,#show1 acall read mov a,#0c0h acall command mov dptr,#show4 acall read acall delay ;Stopage2 time 3 sec shsar acall delay clr bzr acall delay

mov a,#01h acall command mov dptr,#show2 ;display ne acall read mov a,#0c0h acall command mov dptr,#show3 acall read setb bzr acall delay10 acall stepperb mov a,#01h acall command mov dptr,#show1 acall read mov a,#0c0h acall command mov dptr,#show3 acall read setb ledb ;p1.1 ljmp here ;routine for stepper motor

roor

; Delay Routine ;one sec delay delay: push acc push 00h push 01h push p0 push p1 mov r0,#0eh loopr: mov a,#0ffh loopb: mov b,#0ffh loopa: djnz b,loopa djnz 0e0h,loopb djnz r0,loopr pop p1

pop p0 pop 01h pop 00h pop acc ret ;dlay stepper delays: push acc push 00h push 01h push p0 push p1 mov a,#0ffh loopa1: mov b,#0fh loopb1: djnz b,loopb1 djnz 0e0h,loopa1 pop p1 pop p0 pop 01h pop 00h pop acc ret delay10: mov tmod,#01h mov tcon,#00h mov tl0,#0f0h mov th0,#0f8h setb tr0 no: jnb tf0,no clr tr0 clr tf0 ret ;=============== Routine to read data from prog mem read: nex: clr a

movc a,@a+dptr cjne a,#'0',aga sjmp down aga: acall display inc dptr sjmp nex down: ret ;================ stepper routine stepperf: push acc push p1 mov a,#88h mov r1,#04h loop1: mov r0,#0e0h loop: mov p2,a acall delays rr a djnz r0,loop djnz r1,loop1 pop p1 pop acc ret stepperb: push acc push p1 mov a,#88h mov r1,#04h loop12: mov r0,#0e0h loop0: mov p2,a acall delays rl a djnz r0,loop0 djnz r1,loop12 pop p1 pop acc ret

;******************************************************* ;LCD strobe subroutines ini: mov a,#38h acall command mov a,#38h acall command mov a,#38h acall command mov a,#38h acall command mov a,#0eh acall command mov a,#06h acall command mov a,#01h acall command mov a,#80h acall command ret command: acall ready mov dat,a clr rs clr rw setb en clr en ret display: acall ready mov dat,a setb rs clr rw setb en clr en ret ready: clr en mov dat,#0ffh clr rs

setb rw wait: clr en setb en jb busy,wait clr en ret show0: db 'Welcome To All','0' show1: db 'CURRENT STATION','0' show2: db 'NEXT STATION','0' show3: db 'ROORKEE','0' show4: db 'MEERUT','0' Show5: db 'DELHI','0' end

Bibliography

1.) The 8051 Microcontroller And Embedded Sysytem By- Mazidi And Mazidi 2.) Programming and Customizing The 8051 Microcontroller By- Myke Predko 3.) www.google.com 4.) www.wikipedia.com

Anda mungkin juga menyukai