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