mini prjct

Upload: affable-ash

Post on 08-Apr-2018




0 download

Embed Size (px)


  • 8/7/2019 mini prjct


  • 8/7/2019 mini prjct







  • 8/7/2019 mini prjct



    AIM:The main aim of this project is to scroll data on LCDs for display

    Boards (Advertisements).

    DESCRIPTION: In this project we are using the keys for sending the data and

    Display on LCD. This project is used on railway stations or bus stations,

    Bank officers. Here we display the data on a 16x2 LCD display where we

    can display only 16 characters on the single line, but by scrolling we can

    display up to 50 characters on a single line. So that we can display any

    advertisements that consumes space and cost. Then we interface the LCD in

    nibble mode for data transmission. When a key is pressed then the data thatis prefixed in the memory of the controller will be displayed on the LCD


  • 8/7/2019 mini prjct














    Data change


    LCD(16x2) display Board

  • 8/7/2019 mini prjct




  • 8/7/2019 mini prjct



  • 8/7/2019 mini prjct


    It comprises of microcontroller AT89C51, three-to-eight decoder74LS138,

    common anode alphanumeric displays, regulator 7805 and a few discrete


    At the heart of the moving-message display is Atmel AT89C51 microcontroller

    (IC1). It is a low-power, high-performance, 8-bit microcontroller with 4 KB of

    ash programmable and erasable read-only memory (PEROM) used as on-chip program memory, 128 bytes of RAM used as internal data memory, 32

    individually programmable input/output (I/O) lines divided into four 8-bit ports,

    two16-bit programmable timers/counters, a five -vector two-level interrupt

    architecture, on-chip oscillator and clock circuitry.

    Ports P0 and P2 of the microcontroller have been configured to

    act as a common data bus for all the 16alp ha nu me ri c di sp la ys

    wh os e co rresponding data pins have been tied together to make a

    common 16-bitdata bus. Port-2 provides the higher byte of data, while

    Port-0 provides the lower one to light up a character on the display.

    Port pins P1.2-P1.4and P1.5-P1.7 of the microcontroller ha ve be en

    Us ed as ad dr es s in pu ts for decoder IC3 and IC4 (74LS138) to

    enable one of the fourteen alpha numeric displays (DIS3 through

    DIS16) a t a t i m e , r e sp e c t i v e ly . H o w e v e r , displays DIS1 and

    DIS2 are enabled or disabled directly by port pins P1.0and P1.1. Pins 4

    and 5 are grounded and pin 6 is made high to enable decoder 74LS138.


  • 8/7/2019 mini prjct



    A variable regulated power supply, also called a variable bench power supply, isone where you can continuously adjust the output voltage to your requirements.Varying the output of the power supply is the recommended way to test a projectafter having double checked parts placement against circuit drawings and theparts placement guide.

    This type of regulation is ideal for having a simple variable bench power supply.Actually this is quite important because one of the first projects a hobbyist shouldundertake is the construction of a variable regulated power supply. While adedicated supply is quite handy e.g. 5V or 12V, it's much handier to have avariable supply on hand, especially for testing.

    Most digital logic circuits and processors need a 5 volt power supply. To usethese parts we need to build a regulated 5 volt source. Usually you start with anunregulated powersupply ranging from 9 volts to 24 volts DC (A 12 volt powersupply is included with the Beginner Kit and the Microcontroller Beginner Kit.). Tomake a 5 volt power supply, we use a LM7805 voltage regulator IC (IntegratedCircuit). The IC is shown below.

    The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC powersupply (anything from 9VDC to 24VDC) to the Input pin,
  • 8/7/2019 mini prjct


    connect the negative lead to the Common pin and then when you turn on thepower, you get a 5 volt supply from the Output pin.


    Brief description of operation: Gives out well regulated +5V output, output currentcapability of 100 mA

    Circuit protection: Built-in overheating protection shuts down output when regulator ICgets too hot

    Circuit complexity: Very simple and easy to build

    Circuit performance: Very stable +5V output voltage, reliable operation

    Availability of components: Easy to get, uses only very common basic components

    Design testing: Based on datasheet example circuit, I have used this circuit succesfullyas part of many electronics projects

    Applications: Part of electronics devices, small laboratory power supply

    Power supply voltage: Un regluated DC 8-18V power supply Power supply current: Needed output current + 5 mA

    Component costs: Few dollars for the electronics components + the input transformercost


  • 8/7/2019 mini prjct





    The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K 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 80C51 and 80C52 instruction set and pin out. 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 AT89C52 is a powerful microcomputer, which provides a highly flexible and cost effective solution tomany embedded control applications.


    The AT89C52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplexserial port, on-chip oscillator, and clock circuitry. In addition, the AT89C52 is designed with staticlogic for operation down to zero frequency and supports two software selectable power saving

  • 8/7/2019 mini prjct


    modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, andinterrupt system to continue functioning. The Power Down Mode saves the RAM contents butfreezes the oscillator, disabling all other chip functions until the next hardware reset.


    VCC:Supply voltage.GND:Ground.

    Port 0:Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTLinputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0can also be configured to be the multiplexed low-order, address/data bus during accesses toexternal program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives

    the code bytes during Flash programming and outputs the code bytes during programverification. External pull-ups are required during program verification.

    Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers cansink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulledlow will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can beconfigured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 triggerinput (P1.1/T2EX), respectively, as shown in the following table.

    Port Pin Alternate FunctionsP1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction

    control) Port 1 also receives the low-order address bytes during Flash programming and program verification.

    Port 2:Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers cansink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulledlow will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order addressbyte during fetches from external program memory and during accesses to external data memorythat use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX@ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives thehigh-order address bits and some control signals during Flash programming and verification.

    Port 3:Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers cansink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulledlow will source current (IIL) because of the pull-ups. Port 3 also serves the functions of variousspecial features of the AT89C51, as shown in the following table.

  • 8/7/2019 mini prjct


    Port Pin Alternate FunctionsP3.0 RXD (serial input port)P3.1 TXD (serial output port)P3.2 INT0 (external interrupt 0)P3.3 INT1 (external interrupt 1)P3.4 T0 (timer 0 external input)

    P3.5 T1 (timer 1 external input)P3.6 WR (external data memory write strobe)P3.7 RD (external data memory read strobe)Port 3 also receives some control signals for Flash programmingand programming verification.

    RST: Reset input. A high on this pin for two machine cycles while the oscillator is runningresets the device.

    ALE/PROG:Address Latch Enable is an output pulse for latching the low byte of the address during

    accesses to external memory. This pin is also the program pulse input (PROG) duringFlash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the

    oscillator frequency and may be used for external timing or clocking purposes. Note,however, that one ALE pulse is skipped during each access to external data memory. If

    desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit

    set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin isweakly pulled high. Setting the ALE-disable bit has no effect if the microcrontroller is in

    external execution mode.

    PSEN:Program Store Enable is the read strobe to external program memory. When the AT89C52 is

    executing code from external program memory, PSEN is activated twice each machine cycle,except that two PSEN activations are skipped during each access to external data memory.

    EA/VPP:External Access Enable. EA must be strapped to GND in order to enable the device to fetch codefrom external program memory locations starting at 0000H up to FFFFH. Note, however, that iflock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC forinternal program executions. This pin also receives the 12-volt programming enable voltage(VPP) during Flash programming when 12-volt programming is selected.

    XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

    XTAL2:Output from the inverting oscillator amplifier.

  • 8/7/2019 mini prjct




    LCDs can add a lot to your application in terms of providing an useful interface for the

    user, debugging an application or just giving it a "professional" look. The most commontype of LCD controller is the Hitachi 44780, which provides a relatively simple interface

    between a processor and an LCD. Using this interface is often not attempted by

    inexperienced designers and programmers because it is difficult to find good

    documentation on the interface, initializing the interface can be a problem and thedisplays themselves are expensive.


  • 8/7/2019 mini prjct


  • 8/7/2019 mini prjct


    The 2 line x 16 character LCD modules are available from a wide range ofmanufacturers and should all be compatible with the HD44780. The diagram tothe right, shows the pin numbers for these devices. When viewed from the front,the left pin is pin 14 and the right pin is pin 1.

    LCDs can be added quite easily to an application and use as few as three digitaloutput pins for control. As for cost, LCDs can be often pulled out of old devices orfound in surplus stores for less than a dollar. The most common connector usedfor the 44780-based LCDs is 14 pins in a row, with pin centers 0.100" apart

  • 8/7/2019 mini prjct




    An assembler is a software tool designed to simplify the task of writing computer

    programs. It translates symbolic code into executable object code. This objectcode may then be programmed into a microcontroller and executed. Assemblylanguage programs translate directly into CPU instructions which instruct theprocessor what operations to perform. Therefore, to effectively write assemblyprograms, you should be familiar with both the microcomputer architecture andthe assembly language.Assembly language operation codes (mnemonics) are easily remembered. Youcan also symbolically express addresses and values referenced in the operandfield of instructions. Since you assign these names, you can make them asmeaningful as the mnemonics for the instructions. For example, if your programmust manipulate a date as data, you can assign it the symbolic name DATE. If

    your programcontains a set of instructions used as a timing loop (a set of instructions executedrepeatedly until a specific amount of time has passed), you can name theinstruction group TIMER_LOOP.

    An assembly program has three constituent parts:1. Machine instructions2. Assembler directives3. Assembler controls

    A machine instruction is a machine code that can be executed by the machine.

    Detailed discussion of the machine instructions can be found in the hardwaremanuals of the 8051 or derivative microcontroller.Assembler directives are used to define the program structure and symbols,and generate non-executable code (data, messages, etc.).Assembler directivesinstruct the assembler how to process subsequent assembly languageinstructions. Directives also provide a way for you to define program constantsand reserve space for variables.Assembler controls set the assembly modes and direct the assembly flow.Assembler controls direct the operation of the assembler when generating alisting file or object file. Typically, controls do not impact the code that isgenerated by the assembler. Controls can be specified on the command line or

    within an assembler source file.

    7.2 DIRECTIVE CATEGORIESThe Ax51 assembler has several directives that permit you to define symbolvalues, reserve and initialize storage, and control the placement of your code.The directives should not be confused with instructions. They do not produce

  • 8/7/2019 mini prjct


  • 8/7/2019 mini prjct


    PUBLIC 130 PUBLIC symbol[, symbol...] Identify symbols which canbe used outside the current module.RSEG 110 RSEG segSelect a relocatable segment.SEGMENT 106 segSEGMENT class [reloctype][alloctype]Define a relocatable segment.SET 113 SET expression Set symbol value, 116sfr16sbit sfrsymbol= address;sfr16 symbol= address;Sbit symbol= address;Define a special function register(SFR) symbol or a SFR bit symbol.USING 134 USING expressions Set the predefined symbolic registeraddress and reserve space for the specified register bank.

    XDATA 114 symbolXDATA xdata_address assign a symbol name toa specific off-chip data address.XSEG 111 XSEG [AT absolute address] Define an absolute segmentwithin the external data address space.Shaded directives and options are available only in AX51 and A251.4The directives are divided into the following categories:_Segment ControlGeneric Segments: SEGMENT, RSEGAbsolute Segments: CSEG, DSEG, BSEG, ISEG, XSEG

    _Symbol Definition

    Generic Symbols: EQU, SETAddress Symbols: BIT, CODE, DATA, IDATA, XDATASFR Symbols: sfr, sfr16, sbitText Replacement: LIT_Memory InitializationDB, DW, DD_Memory ReservationDBIT, DS, DSB, DSW, DSD_Procedure DeclarationPROC / ENDP, LABEL_Program LinkagePUBLIC, EXTRN / EXTERN, NAME_Address ControlORG, EVEN, USING_OthersEND, _ _ERROR_

  • 8/7/2019 mini prjct



    Several new variants of the 8051 extend the code and/or x data space of the classic 8051with address extension registers. The following table shows the memory classes used for

    programming the extended 8051 devices. These memory classes are available for classic

    8051 devices when you are using memory banking with the LX51 linker/locater. Inaddition to the code banking known from the BL51 linker/locater, the LX51

    linker/locator supports also data banking for Xdata and code areas with standard 8051


    The memory prefixes D: I: X: C: B0: .. B31: cannot be used at Ax51 assemblerlevel. The memory prefix is only listed for better understanding. The Lx51linker/locater and several Debugging tools, for example the Vision2 Debugger,are using memory prefixes to identify the memory class of theaddress. If you are using the Dallas 390 contiguous mode the address space forCODE can be C:0000 - C:0xFFFFFF.

  • 8/7/2019 mini prjct



    Each line of an assembly program can contain only one control, directive, orinstruction statement. Statements must be contained in exactly one line. Multiline statements are not allowed. Statements in x51 assembly programs are not

    column sensitive. Controls, directives, and instructions may start in any column.Indentation used in the programs in this project is done for program clarity and isneither required nor expected by the assembler. The only exception is thatarguments and instruction operands must be separated from controls, directives,and instructions by at least one space.

    All x51 assembly programs must include the END directive. This directivesignals to the assembler that this is the end of the assembly program. Anyinstructions, directives, or controls found after the END directive are ignored. Theshortest valid assembly program contains only an END directive.

  • 8/7/2019 mini prjct



  • 8/7/2019 mini prjct



    ; File Name C750DSP.ASM; Single Message, Moving Message Display

    ; *************** USE METALINKS (( ASM51.EXE )) TO ASSEMBLE*****************;; ************ THIS ASSEMBLER WILL CREATE A ( HEX ) FILE**************

    ; 0B0H = PORT3 DIRECT ADDRESSD_BUS DATA 0B0H ; data bus ( PORT 3 )

    ; 90H = PORT 1 DIRECT ADDRESSA_BUS DATA 90H ; address bus ( PORT 1 ),A0=P1.0,A1=P1.1,A2=P1.2

    ; 80H.0 = PORT 0 BIT 0 ( PORT0 BIT ADDRESS )WR BIT 80H.0; WR signal. to write to display A_BUS,data must bestable,

    ; then WR is brought LOW, data is written on LOW to HIGH; transition of WR. so we then bring WR to HIGH to


    A3 BIT 80H.1; clear for brightness set, then set and leave set.; to set brightness send the following out to the data

    D_BUS.; MSD-LSD 0=100% 1=80% 2=53% 3=40% 4=27% 5=20% 6=13%


    RST BIT 80h.2; Display Reset

    ;***************************************************************************;* FIRMWARE For Control Of The HDSP-2112 Display*;* A MOVING MESSAGE DISPLAY*;* FOR THE PHILLIPS 87C750 MICROCONTROLLER*


    org 0 ; Establish Reset Vector at 0

    ; Routine to Reset Display on Power-Up

    clr D_BUS.7; Enable Displayclr RST ; Reset & Clear Display

  • 8/7/2019 mini prjct


    setb wracall delay2 ; No Read or Write for at least 3 clock cycles

    ; after Reset & Clearsetb RST ; Hold RST High for remainder of program

    ; Set Display Brightness

    bright: clr a3 ; clr A3 to setup for brightness setmov D_BUS,#7; data to blank displayclr wr ; WR=LOWsetb wr ; WR=HIGH, data written to display on LOW to

    HIGHmov D_BUS,#6; 13% brightnessclr wrsetb wrsetb a3 ; transition of WR pin, then we leave A3 set

    for the; remainder of the program, as it is ONLY used


    ; tell the display we want to set BRIGHTNESS.

    count: mov r7,#4 ; Load R7 with the number of times+1 you wantyour

    ; message to be displayed before power down.; a 4 here will play the message 3 times etc...

    count2: djnz r7,load ; Decrement counter, if not=zero goto loadajmp power_down ; else power down.

    load: mov dptr,#message-1 ; load message address -1

    begin: mov r0,#20h; beginning RAM address for storage +manipulation

    mov r5,#8 ; #8=indicator of how many DIGITS the HDSP-2112 has

    mov a,#20h ; ASCII equivalent of a BLANK space on display.

    ramclr: mov @r0,a ; load ASCII BLANKS in display RAMinc r0 ; increment to next RAM addressdjnz r5,ramclr ; if we havent BLANKED out 8 address's keep


    fetch: acall getchr; RAM BLANK done, get first character to bediplayed

    halt: jz count2 ; if return value in ACC = decimal 0 start over

    mov r5,#8 ; number of display DIGITS available on HDSP-2112

    mov r0,#20h; load beginning RAM address

    doit: xch a,@r0 ; SWAP ACC data with display RAM datainc r0 ; increment to next RAM addressdjnz r5,doit; check if END of RAM location, if not keep

    goingmov r0,#20h; again load first RAM addressmov r4,#7 ; address to select first digit

  • 8/7/2019 mini prjct


    ; ( far right ) on displayacall msgout ; send message digit to displayajmp fetch ; return to routine FETCH.

    msgout: clr d_bus.7; re-enable displaymov r5,#8 ; load number of digits our display has for

    use.; notice here with R5 holding the starting

    value; of 8, that this allows the routine MSGOUT1 to; decrement R4 8 times. R4 originally holds the; address for digit #8, or the ( RIGHT MOST ); digit on our display. By decrementing R4; we move the display digit ( ADDRESS ) from; digit to digit.; or from digit 8 to digit 1, from RIGHT TO

    LEFT; as seen facing the display.



    ; DISPLAY ).

    msgout1: mov a,r4 ; load digit address for display digitselection

    mov A_BUS,a ; select digit position on displaydec r4 ; 1st digit=7 ( right side of display )

    decrement formov a,@r0 ; next, then load ACC with data to D_BUS,a ; move data to displayclr wr ; WRITE STROBE for displaysetb wr ; write data to display on LOW to HIGH

    transitioninc r0 ; increment RAM pointer to next data digit for

    displaydjnz r5,msgout1 ; if not=8 total digits keep goingacall delay2 ; delay to prevent JERKY look between digit

    updates.; and to set our display ( SCROLL SPEED ).

    ret ; return to calling routine.

    getchr: inc dptr ; increment DPTR to point to next display digitclr a ; location ( MESSAGE ADDRESS ) in CODE space.movc a,@a+dptr; move CODE ( MESSAGE ) digit pointed to byret ; ACC+DPTR too ACC, and return to calling


    power_down: mov 87h,#2 ; Set bit "PD" of the PCON Special FunctionRegister

    ; This will cause the controller to Power Down.

    ; routine DELAY2 sets the SCROLL SPEED, and will prevent a JERKYAPPEARANCE; between display digit updates. by changing the value first loaded into

  • 8/7/2019 mini prjct


    ; R1 in the first line to a lower number the scroll speed is faster,and by; changing it to a higher number the scroll speed will be slower.

    delay2: mov r1,#2delay3: mov r2,#00hdelay4: mov r3,#00hdelay5: djnz r3,delay5

    djnz r2,delay4djnz r1,delay3retnop

    ; the number 0 will indicate the END of our message.

    message: db ' Merry Christmas..............,'db ' And A Happy New Year..........',0