Micro Controller Trainer Manual

download Micro Controller Trainer Manual

of 30

Transcript of Micro Controller Trainer Manual

  • 8/3/2019 Micro Controller Trainer Manual

    1/30

    1

    IPCEDUCATIONAL TRAINERS

    8051 BASED MICROCONTROLLER TRAINER & PROGRAMMERModel: - IPC-8605-MC

    Teacher / Student User Manual

    Note:-we reserve the right to change the shape & design of the trainer without prior notice.Ijaz Parvez &Co, 3 Hall Road Lahore Ph # 042-5424363, 7352790 Email: - [email protected]

    mailto:[email protected]:[email protected]
  • 8/3/2019 Micro Controller Trainer Manual

    2/30

    2

    TABEL OF CONTENTS: -

    History 1

    8051 Microcontroller 3

    Single Bit Port Programming 4

    Byte Writing 7

    Bit Rotation 9

    Arithmetic Instruction 10

    Logic Instruction 13

    LCD Interface 16

    Serial Communication 18

    Seven Segment Drive 21

    Key Pad Interface 23

    Traffic Light Signal 26

  • 8/3/2019 Micro Controller Trainer Manual

    3/30

    3

    History

    It was year 1969, and a team of Japanese engineers from the BUSICOMCompany arrived to United States with a request that a few integratedcircuits for calculators be made using their projects. The proposition was setto INTEL, and Marcian Hoff was responsible for the project. Since he was theone who has had experience in working with a computer (PC) PDP8, itoccured to him to suggest a fundamentally different solution instead of the

    suggested construction. This solution presumed that the function of theintegrated circuit is determined by a program stored in it. That meant thatconfiguration would be more simple, but that it would require far morememory than the project that was proposed by Japanese engineers wouldrequire. After a while, though Japanese engineers tried finding an easiersolution, Marcian's idea won, and the first microprocessor was born. Intransforming an idea into a ready made product, Frederico Faggin was amajor help to INTEL. He transferred to INTEL, and in only 9 months hadsucceeded in making a product from its first conception. INTEL obtained therights to sell this integral block in 1971. First, they bought the license fromthe BUSICOM Company who had no idea what treasure they had. During thatyear, there appeared on the market a microprocessor called 4004. That wasthe first 4-bit microprocessor with the speed of 6 000 operations per second.Not long after that, American company CTC requested from INTEL and TexasInstruments to make an 8-bit microprocessor for use in terminals. Eventhough CTC gave up this idea in the end, Intel and Texas Instruments keptworking on the microprocessor and in April of 1972, first 8-bit microprocessor

    appeared on the market under a name 8008. It was able to address 16Kb ofmemory, and it had 45 instructions and the speed of 300 000 operations per

    second. That microprocessor was the predecessor of all today'smicroprocessors. Intel kept their developments up in April of 1974, and theyput on the market the 8-bit processor under a name 8080 which was able toaddress 64Kb of memory, and which had 75 instructions, and the price beganat $360.

    In another American company Motorola, they realized quickly what washappening, so they put out on the market an 8-bit microprocessor 6800.Chief constructor was Chuck Peddle, and along with the processor itself,Motorola was the first company to make other peripherals such as 6820 and6850. At that time many companies recognized greater importance ofmicroprocessors and began their own developments. Chuck Peddle leavedMotorola to join MOS Technology and kept working intensively on developingmicroprocessors.

    At the WESCON exhibit in United States in 1975, a critical event took place inthe history of microprocessors. The MOS Technology announced it wasmarketing microprocessors 6501 and 6502 at $25 each, which buyers couldpurchase immediately. This was so sensational that many thought it was

  • 8/3/2019 Micro Controller Trainer Manual

    4/30

    4

    some kind of a scam, considering that competitors were selling 8080 and6800 at $179 each. As an answer to its competitor, both Intel and Motorolalowered their prices on the first day of the exhibit down to $69.95 permicroprocessor. Motorola quickly brought suit against MOS Technology andChuck Peddle for copying the protected 6800. MOS Technology stoppedmaking 6501, but kept producing 6502. The 6502 was a 8-bit microprocessorwith 56 instructions and a capability of directly addressing 64Kb of memory.Due to low cost , 6502 becomes very popular, so it was installed intocomputers such as: KIM-1, Apple I, Apple II, Atari, Comodore, Acorn, Oric,Galeb, Orao, Ultra, and many others. Soon appeared several makers of 6502(Rockwell, Sznertek, GTE, NCR, Ricoh, and Comodore takes over MOSTechnology) which was at the time of its prosperity sold at a rate of 15million processors a year!

    Others were not giving up though. Frederico Faggin leaves Intel, and startshis own Zilog Inc.In 1976 Zilog announced the Z80. During the making of this microprocessor,

    Faggin made a pivotal decision. Knowing that a great deal of programs havebeen already developed for 8080, Faggin realized that many would stayfaithful to that microprocessor because of great expenditure which redoing ofall of the programs would result in. Thus he decided that a new processorhad to be compatible with 8080, or that it had to be capable of performing allof the programs which had already been written for 8080. Beside thesecharacteristics, many new ones have been added, so that Z80 was a verypowerful microprocessor in its time. It was able to address directly 64 Kb ofmemory, it had 176 instructions, a large number of registers, a built inoption for refreshing the dynamic RAM memory, single-supply, greater speedof work etc. Z80 was a great success and everybody converted from 8080 to

    Z80. It could be said that Z80 was without a doubt commercially mostsuccessful 8-bit microprocessor of that time. Besides Zilog, other newmanufacturers like Mostek, NEC, SHARP, and SGS also appeared. Z80 wasthe heart of many computers like Spectrum, Partner, TRS703, Z-3.

    In 1976, Intel came up with an improved version of 8-bit microprocessornamed 8085. However, Z80 was so much better that Intel soon lost thebattle. Altough a few more processors appeared on the market (6809, 2650,SC/MP etc.), everything was actually already decided. There weren't anymore great improvements to make manufacturers convert to something new,so 6502 and Z80 along with 6800 remained as main representatives of the 8-bit microprocessors of that time.

    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 sendingdata must be added to it. In short that means that microprocessor is the veryheart of the computer. On the other hand, microcontroller is designed to beall of that in one. No other external components are needed for its

  • 8/3/2019 Micro Controller Trainer Manual

    5/30

    5

    application because all necessary peripherals are already built into it. Thus,

    we save the time and space needed to construct devices.

    8051 MICROCONTROLLERA large variety of microcontrollers are available in market. Most common are 8051 andpic microcontroller family. In 8051 family there are many chips having different partnumber, & brands. Intel Philips, Dallas, seimens, Atmel etc. but in Pakistan there is onlyatmel brand is most commonly used.There are some microcontrollers numberof 8051 family, AT89C51/52/55 &AT89S51/52/53. We will use in all labsAT89S51.

    Features Compatible with MCS-51Products 4K Bytes of In-System Programmable (ISP)Flash Memory

    Endurance: 1000 Write/Erase Cycles

    4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 128 x 8-bit Internal RAM 32 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and PageMode)

    DescriptionThe AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4Kbytes of in-system programmable Flash memory. The device is manufactured usingAtmels high-density nonvolatile memory technology and is compatible with the industry-

    standard 80C51 instruction set and pinout. The on-chip Flash allows the programmemory to be reprogrammed in-system or by a conventional nonvolatile memoryprogrammer.By combining a versatile 8-bit CPU with in-system programmable Flash on amonolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides ahighly-flexible and cost-effective solution to many embedded control applications.The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes ofRAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a fivevectortwo-level interrupt architecture, a full duplex serial port, on-chip oscillator, andclock circuitry. In addition, the AT89S51 is designed with static logic for operation

  • 8/3/2019 Micro Controller Trainer Manual

    6/30

    6

    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, andinterrupt system to continue functioning. The Power-down mode saves the RAMcontentsbut freezes the oscillator, disabling all other chip functions until the next externalinterrupt or hardware reset.

    LAB # 1SINGLE BIT PORT PROGRAMMING

    OBJECTIVE: HOW TO PROGRAME SINGLE BIT OF POTRDESCRIPTION:

    There are some examples of single bit instruction. You just type these examples inPinnacle52 software and name the file with extension asm (test.asm).This file is calledassembly source file. Now you will need an executable file to run this program intomicrocontroller, so press ctrl+f2 keys for making an executable file.

    Now this file should copied into microcontroller by using IPC MC- 8605 andverify the performance.Now you can see your program output on LEDs connecting with port 2.

    Apparatus / Component.Microcontroller AT89S51, IPC MC- 8605.

    Example #1. Single LED blinking.;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    LOOP:SETB P2.0 ; Set bit zero of port 2.ACALL DELAY ; delay (140ms)CLR P2.0 ; low bit zero of port 2.ACALL DELAY ; delay (140ms)SJMP LOOP ; jump to function LOOP

    DELAY:MOV R1,#0FFH ;write value on register R1.

    AG:MOV R2,#0FFH ;write value on register R2.DJNZ R2,$ ; stay here till R2=0DJNZ R1,AG ; jump on label (AG) if R2 not equal to zero.RET ; returnEND

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  • 8/3/2019 Micro Controller Trainer Manual

    7/30

    7

    Example #2. Two LED blinking.;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    SETB P2.0 ; Set bit zero of port 2.

    SETB P2.1 ; Set bit one of port 2.

    ACALL DELAY ; delay (140ms)CLR P2.0 ; low bit zero of port 2.

    CLR P2.1 ; low bit one of port 2.

    ACALL DELAYSJMP LOOP ; Jump to label (LOOP).

    DELAY:MOV R1,#0FFH ;write value on register R1.

    AG:MOV R2,#0FFH ;write value on register R2.DJNZ R2,$ ; stay here till R2=0DJNZ R1,AG ; jump on label (AG) if R2 not equal to zero.RET ; retunEND

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  • 8/3/2019 Micro Controller Trainer Manual

    8/30

    8

    Example #3. Running lights

    ;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    LOOP:SETB P2.7 ; Set bit seven of port 2.ACALL DELAY ; delay (140ms)CLR P2.7 ; low bit seven of port 2.ACALL DELAY ;delay (140ms)SETB P2.7 ; Set bit seven of port 2.

    CLR P2.6 ; low bit six of port 2.

    ACALL DELAY ;delay (140ms)SETB P2.6 ; Set bit six of port 2.CLR P2.5 ; low bit five of port 2.ACALL DELAYSETB P2.5 ; Set bit five of port 2.CLR P2.4 ; low bit four of port 2.ACALL DELAYSETB P2.4 ; Set bit four of port 2.CLR P2.3 ; low bit three of port 2.ACALL DELAYSETB P2.3 ; Set bit three of port 2.CLR P2.2 ; low bit two of port 2.ACALL DELAYSETB P2.2 ; Set bit two of port 2.CLR P2.1 ; low bit one of port 2.ACALL DELAYSETB P2.1 ; Set bit one of port 2.CLR P2.0 ; low bit zero of port 2.ACALL DELAYSETB P2.1 ; Set bit one of port 2.SJMP LOOP ; Jump to label (LOOP).

  • 8/3/2019 Micro Controller Trainer Manual

    9/30

    9

    DELAY:MOV R1,#0FFH ;write value on register R1.

    AG: MOV R2,#0FFH ;write value on register R2.DJNZ R2,$ ; stay here till R2=0DJNZ R1,AG ; jump on label (AG) if R2 not equal to zero.

    RET ; returnEND :End of program

  • 8/3/2019 Micro Controller Trainer Manual

    10/30

    10

    LAB # 2BYTE WRITING

    OBJECTIVE: HOW TO WRITE DATA ON PORTS/REGISTER/MEMORYADDRESS.

    DESCRIPTION:There are some examples of byte writing instruction. You just type these

    examples in Pinnacle52 software and name the file with extension asm (first.asm).Thisfile is called assembly source file. Now you will need an executable file to run thisprogram into microcontroller, so press ctrl+f2 keys for making an executable file.

    Now this file should copied into microcontroller by using IPC MC- 8605Now you can see your program output on LEDs connecting with port 2.

    Apparatus / Component.Microcontroller AT89S51, IPC MC- 8605 .

    Example #1. Write byte on ports & registers.;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{LOOP:

    MOV P2,#0 ;Send value on port 2.ACALL DELAY ;Delay (2100ms)MOV P2,#0FFH ;Send value on port 2.ACALL DELAY ;Delay (2100ms)MOV R4,#3 ;Send value in register R4.MOV P2,R4 ;Copy data of R4 into port 2.ACALL DELAYMOV R7,#100ACALL DELAYMOV P2,R7 ;Copy data of R7 into port 2.ACALL DELAYSJMP LOOP ;Delay (2100ms)

    DELAY:MOV R0,#0FH ;write value on register R0

    REE:MOV R1,#0FFH ;write value on register R1.

    AG:MOV R2,#0FFH ;write value on register R2.DJNZ R2,$ ; stay here till R2=0DJNZ R1,AG ; jump on label (AG) if R2 not equal to zero.DJNZ R0,REE ; jump on label (REE) if R0 not equal to zero.RETEND

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  • 8/3/2019 Micro Controller Trainer Manual

    11/30

    11

    Example #2. Write byte to register, copy byte to register, copy byte to Accumulator

    ;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{LOOP:MOV R4,#11 ; write data in R4MOV R5,R4 ; Copy R4 data into R5MOV P2,R5 ; Copy R5 data into P2ACALL DELAYMOV A,#51 ; ; write data in AMOV P2,AACALL DELAYMOV R4,P2MOV A,#200

    MOV P2,AACALL DELAYMOV P2,R4ACALL DELAYSJMP LOOP

    DELAY:MOV R0,#0FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND :End of program

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  • 8/3/2019 Micro Controller Trainer Manual

    12/30

    12

    LAB #3BIT ROTATION

    OBJECTIVE:How To Rotate Bits Of Any Ports/Register/Memory address

    DESCRIPTION:There are some examples of bit rotating instructions. You just type these

    examples in Pinnacle52 software and name the file with extension asm (rotate.asm). Thisfile is called assembly source file. Now you will need an executable file to run thisprogram into microcontroller so press ctrl+f2 keys for making an executable file.

    Now this file should copied into microcontroller by using programmer device.The programmed microcontroller should be place on microcontroller to verify theperformance.Now you can see your program output on LEDs connecting with port 2

    Apparatus / Component.Microcontroller AT89C51, IPC MC- 8605 .

    Example #1 Rotate accumulator bits left and copy accumulator data on port2.;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    MOV A,#11111110B ; A=254LOOP:

    MOV P2,A ; write value of register A on port2ACALL DELAYRL A ; Rotate left bits of register ASJMP LOOP

    DELAY:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGRETEND :End of program

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}Example #2. Rotate accumulator bits right and copy accumulator data on port2.;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    MOV A,#01111111B ; A=127LOOP: MOV P2,A

    ACALL DELAYRR ASJMP LOOP

    DELAY:MOV R1,#0FFH

    AG: MOV R2,#0FFHDJNZ R2,$DJNZ R1,AG

  • 8/3/2019 Micro Controller Trainer Manual

    13/30

    13

    RETEND :End of program

    LAB #4ARITHMETIC INSTRUCTIONS

    OBJECTIVE:HOW TO PLUS, MINUS, MULTIPLY, AND DIVIDE NUMBERS IN 8051.

    DESCRIPTION:There are some examples of arithmetic instructions. You just type these examples

    in Pinnacle52 software and name the file with extension asm(abc.asm). This file is calledassembly source file. Now you will need an executable file to run this program intomicrocontroller, so press ctrl+f2 keys for making an executable file.

    Now this file should copied into microcontroller by using programmer device.The programmed microcontroller should be place on microcontroller trainer to verifythe performance.Now you can see your program output on LEDs connecting with port 2

    Apparatus / Component.Microcontroller AT89C51, IPC MC- 8605 .

    Example #1. THIS IS ADDITION EXAMPLE;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    ORG 30HLOOP:

    MOV A,#10 ; A=10MOV R7,#51 ; R7=51ADD A,R7 ;A+R7=61, Now A= 61MOV P2,A ; P2=A . (P2=61)ACALL DELAY ; 140ms delayADD A,#33 ; A=33MOV P2,A ; A=P2. (P2=33)ACALL DELAYSJMP LOOP ; GOTO LOOP

    DELAY:MOV R0,#01FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND :End of program

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  • 8/3/2019 Micro Controller Trainer Manual

    14/30

    14

    Example #2. SUBTRACTION

    ;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    ORG 30HLOOP:

    MOV A,#10 ;A=10MOV R3,#1 ; R3=1SUBB A,R3 ; A-R3=9, NOW A=9MOV P2,A ; P2=9ACALL DELAYMOV A,#101 ; A=101SUBB A,#99 ; A-99=2

    MOV P2,A ; P2=2ACALL DELAYSJMP LOOP

    DELAY:MOV R0,#1FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

    ;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    Example #3. MULTILPLICATION

    LOOP:MOV A,#10MOV B,#11MUL ABMOV P2,AACALL DELAYMOV P2,BACALL DELMUL ABMOV P2,AACALL DELAYMOV P2,BACALL DELAY

  • 8/3/2019 Micro Controller Trainer Manual

    15/30

    15

    SJMP LOOPDELAY:

    MOV R0,#1FHREE:

    MOV R1,#0FFH

    AG: MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

    ;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    Example #4. DIVISION

    MOV A,#99MOV B,#9DIV ABMOV P2,AACALL DELAYMOV P2,BACALL DELAYMOV A,#205MOV B,#11DIV ABMOV P2,AACALL DELAYMOV P2,BACALL DELAYSJMP LOOP

    DELAY:MOV R0,#1FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

  • 8/3/2019 Micro Controller Trainer Manual

    16/30

    16

  • 8/3/2019 Micro Controller Trainer Manual

    17/30

    17

    LAB #5LOGIC INSTRUCTION

    OBJECTIVE:How to use logic instructions (Anding, Oring, Xoring, compliment).

    DESCRIPTION:There are some examples of logic control instructions. You just type these

    examples in Pinnacle52 software and name the file with extension asm (abc.asm) Thisfile is called assembly source file. Now you will need an executable file to run thisprogram into microcontroller, so press ctrl+f2 keys for making an executable file. Nowthis file should copied into microcontroller by using programmer device. Afterprogrammed microcontroller you should be place this on microcontroller trainer to verifythe performance.Now you can see your program output on LEDs connecting with port 2

    Apparatus / Component.Microcontroller AT89C51, IPC MC- 8605 .

    Example of logic And.ORG 30HMOV A,#10101010BANL A,#11111111BMOV P2,AACALL DELAYMOV A,#01111000BANL A,#11001001B ;andingMOV P2,AACALL DELAYSJMP LOOP

    DELAY:MOV R0,#1FH

    REE: MOV R1,#0FFHAG:

    MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

  • 8/3/2019 Micro Controller Trainer Manual

    18/30

    18

    Example of logic Or gate

    ORG 30HLOOP:

    MOV A,#00001111BORL A,#11110001BMOV P2,AACALL DELAYMOV P2,AACALL DELAYSJMP LOOP

    DELAY:MOV R0,#1FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]

    example of Xor gate.

    ORG 30HLOOP:

    MOV A,#00110110BXRL A,#00100001BMOV P2,AACALL DELAYXRL A,#00000000B

    MOV P2,AACALL DELAYSJMP LOOP

    DELAY:MOV R0,#1FH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFH

  • 8/3/2019 Micro Controller Trainer Manual

    19/30

    19

    DJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

    Example of Compliment bits (Not gate).

    ORG 30HLOOP:

    MOV A,#00001111BMOV P2,AACALL DELAYCPL AMOV P2,AACALL DELAY

    SJMP LOOP

    DELAY:MOV R0,#0AH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND

  • 8/3/2019 Micro Controller Trainer Manual

    20/30

    20

    LAB #6LCD interface

    Objective:

    How to interface alphanumeric LCD to 8051.

    DESCRIPTION:There is an examples of interfacing a matrix LCD to 8051 microcontroller. You

    just type this example in Pinnacle52 software and name the file with extensionasm(lcd.asm). This file is called assembly source file. Now you will need executable fileto run this program into microcontroller so press ctrl+f2 keys for making executable file.this file should copied into microcontroller by using programmer device. Afterprogrammed microcontroller you should be place on microcontroller trainer to verifythe performance.Now you can see your program output on LCD connecting with microcontroller.

    Apparatus / Component.Microcontroller AT89C51, IPC MC- 8605.

    LCD code example.ORG 30HMOV A,#38H ; 2 Line LCDACALL COMNWRTACALL DELAYMOV A,#38HACALL COMNWRTACALL DELAY

    MOV A,#0EH ;ACALL COMNWRTACALL DELAYMOV A,#01H ; Clear LCDACALL COMNWRTACALL DELAYMOV A,#06HACALL COMNWRTACALL DELAYMOV A,#80H ; cursor positionACALL COMNWRTMOV A,#A ; print character A on lcdACALL DATAWRTACALL DELAYMOV A,#L ; ; print character L on lcdACALL DATAWRTACALL DELAYMOV A,#LACALL DATAWRTACALL DELAY

  • 8/3/2019 Micro Controller Trainer Manual

    21/30

    21

    MOV A,#AACALL DATAWRTACALL DELAYMOV A,#HACALL DATAWRT

    ACALL DELAYSJMP $

    COMNWRT:MOV P1,ACLR P3.2 ;RSNOPCLR P3.3 ;READ/WRITESETB P3.4 ; ENABLENOPCLR P3.4

    NOPRETDATAWRT:

    MOV P1,ASETB P3.2 ;RSNOP

    CLR P3.3 ;READ,WRITESETB P3.4 ; ENABLENOPCLR P3.4NOPRET

  • 8/3/2019 Micro Controller Trainer Manual

    22/30

    22

    LAB # 7Serial Communication

    Objective:How to send data using UART (serial communication).

    DESCRIPTION:There is an examples of serial communication to computer. This is full duplex

    serial communication. Microcontroller send data to computer and display this data onmonitor via hyper terminal software, when computer send data to microcontroller itdisplay this data on LCD which is connected to microcontroller . You just type thisexample in Pinnacle52 software and name the file with extension asm. This file is calledassembly source file. Now you will to need executable file to run this program into

    microcontroller, so press ctrl+f2 keys for making executable file. Now this file shouldburned to microcontroller by using programmer device. After programmedmicrocontroller you should be place on microcontroller trainer to verify the performance.

    Now you can see your program output on LCD connecting with microcontroller &HyperTerminal.

    Apparatus / Component.Microcontroller AT89S51, IPC MC- 8605.

    ; Receive & Transmit data to & from Pc Comm. port

    ; SEND THIS DATA ON LCD AND P2

    ORG 00MOV R7,#07 ;Pointer addressACALL DELAYMOV A,#38H ; 2 line matrix LCD

    ACALL COMNWRTACALL DELAYMOV A,#0EHACALL COMNWRT

    ACALL DELAYMOV A,#01H ; Clear LCDACALL COMNWRTACALL DELAYMOV A,#06HACALL COMNWRTACALL DELAYMOV A,#80HACALL COMNWRT

  • 8/3/2019 Micro Controller Trainer Manual

    23/30

    23

    AGAIN:AJMP MAIN1

    COMNWRT:

    MOV P1,ACLR P3.2 ;RSNOPCLR P3.3 ;READ/WRITESETB P3.4 ; ENABLENOPCLR P3.4NOPRET

    DATAWRT:MOV P1,A

    SETB P3.2 ;RSNOPCLR P3.3 ;READ,WRITESETB P3.4 ; ENABLENOPCLR P3.4NOP

    DJNZ R7,GORETMOV R7,#07MOV A,#80HACALL COMNWRT

    GORET:RET

    DELAY:MOV R3,#0FH

    HERE2: MOV R4,#0FHHERE: DJNZ R4,HERE

    DJNZ R3,HERE2RET

    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    MAIN1:MOV P2,#0FFHMOV TMOD,#20H ; Timer 1 mode 2MOV TH1,#0FAH ; 4800 BAUDRATEMOV SCON,#50H ; Receive & Transmit both enable.SETB TR1 ; start timer1ACALL TXSJMP MAIN

    ;***************************************

  • 8/3/2019 Micro Controller Trainer Manual

    24/30

    24

    TX:MOV A,#AMOV SBUF,A

    HER: JNB TI,HERCLR TIMOV A,#LMOV SBUF,A

    HER1: JNB TI,HER1CLR TIRET

    ;***************************************

    ;+++++++++++++++++++++++++++++++++++MAIN: JNB RI,MAIN

    MOV A,SBUFMOV P2,A

    ACALL DATAWRTCLR RIACALL TXSJMP MAIN

    ;+++++++++++++++++++++++++++++++++++END

  • 8/3/2019 Micro Controller Trainer Manual

    25/30

    25

    LAB #87 SEGMENT DRIVE

    Objective:How to drive multiplexed 7 segment display with microcontroller

    DESCRIPTION:There is an examples of multiplexed 7 segment display interfacing. In this

    experiment there is four common anode 7 segment display connecting to port zero andtheir common points are connected to P2.0 , P2.1 ,P2.2 ,P2.3. You just type thisexample in Pinnacle52 software and name the file with extension asm (7seg.asm). Thisfile is called assembly source file. Now you will to need executable file to run thisprogram into microcontroller so press ctrl+f2 keys for making executable file. Now thisfile should burned to microcontroller by using programmer device. After programmedmicrocontroller you should be place microcontroller on microcontroller trainer to verifythe performance.

    Now you can see your program output on 7segment display connected withmicrocontroller Trainer board.

    Apparatus / Component.Microcontroller AT89C51, IPC MC- 8605 .

    ;multiplexed seven segment driveSCAN:

    ACALL DIGIT1 ; digit 1 subroutineACALL DIGIT2 ; digit 2 subroutineACALL DIGIT3 ; digit 3 subroutine

    ACALL DIGIT4 ; digit 4 subroutineSJMP SCAN

    DIGIT1:MOV P0,#F9H ; Display 1 on digit oneCLR P2.0ACALL ONSETB P2.0NOPNOPNOP

    RETDIGIT2:

    MOV P0,#A4H ; Display 2 on digit twoCLR P2.1ACALL ONSETB P2.1NOPNOPNOP

  • 8/3/2019 Micro Controller Trainer Manual

    26/30

    26

    RETDIGIT3:

    MOV P0, #B0H; Display 3 on digit threeCLR P2.2ACALL ON

    SETB P2.2NOPNOPRET

    DIGIT4:MOV P0,#99H ; Display 4 on digit fourCLR P2.3ACALL ON

    SETB P2.3NOPNOPNOPRET

    ON:MOV R1,#0FH

    AGA:MOV R2,#050H

    DJNZ R2,$DJNZ R1,AGARET

  • 8/3/2019 Micro Controller Trainer Manual

    27/30

    27

    LAB #9KEYPAD INTERFACE

    Objective:How to interface matrix Keypad

    DESCRIPTION:There is an example of interfacing a matrix key pad to 8051 microcontroller. You

    just type this example in Pinnacle52 software and name the file with extension asm(keypad.asm)... This file is called assembly source file. Now you will need executable fileto run this program, so press ctrl+f2 keys for making executable file. Now this file shouldcopied into microcontroller by using programmer device. After programmedmicrocontroller you should be place this on microcontroller trainer to verify theperformance.Now you can see your program output on 7 segment connecting with microcontroller.

    Apparatus / Component.Microcontroller AT89C51 , IPC MC- 8605

    ; c1=4wire c2=5 c3=2 r1=3 R2=6WIRE R3=8

    ; R4=11

    ;**********************************************************************

    ; C1=P1.0 C2=P1.1 C3=P1.2****** R1=P1.3*** R2=P1.4 ** R3=P1.5 *

    ; R4=P1.6 *

    ;**********************************************************************

    ;**********************************************

    ; ROUTINE FOR KEY IDENTIFICATION |*; |*

    ;**********************************************

    ORG 30H

    MOV P2,#00H

    KEYSCAN:

    CLR P1.0

    JNB P1.3,ONE ; 1

    J4: JNB P1.4,FOUR ; 4

    J7: JNB P1.5,SEVEN; 7

    J*: JNB P1.6,JSTAR ; "*"

    SETB P1.0

    ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

    CLR P1.1

    JNB P1.3,TWO ; 2

    J5: JNB P1.4,FIVE ; 5

    J8: JNB P1.5,EIGHT; 8

    J0: JNB P1.6,ZERO ; 0

    SETB P1.1

    ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

    CLR P1.2

  • 8/3/2019 Micro Controller Trainer Manual

    28/30

    28

    JNB P1.3,THREE; 3

    J6: JNB P1.4,SIX ; 6

    J9: JNB P1.5,NINE; 9

    J#: JNB P1.6,HASH ; #

    SETB P1.2

    AJMP KEYSCAN

    JSTAR: SJMP STAR

    ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

    |||

    ONE: MOV P0,#F9H

    ACALL DEL

    JNB P1.3,$

    AJMP J4

    ;?????????????????????????????????????????????????????????????????????

    TWO: MOV P0,#A4H

    ACALL DEL

    JNB P1.3,$

    AJMP J5?????????????????????????????????????????????????????????????????????

    ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    THREE: MOV P0,#B0H

    ACALL DEL

    JNB P1.3,$

    AJMP J6

    ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    ;{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

    FOUR: MOV P0,#99H

    ACALL DEL

    JNB P1.4,$

    AJMP J7

    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    FIVE: MOV P0,#92H

    ACALL DEL

    JNB P1.4,$

    AJMP J8

    ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    SIX: MOV P0,#82H

    ACALL DEL

    JNB P1.4,$

    AJMP J9

    ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    ;))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

    SEVEN: MOV P0,#F8H

    ACALL DEL

    JNB P1.5,$

    AJMP J*

    ;`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    EIGHT: MOV P0,#80H

  • 8/3/2019 Micro Controller Trainer Manual

    29/30

    29

    ACALL DEL

    JNB P1.5,$

    AJMP J0

    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    NINE: MOV P0,#98H

    ACALL DEL

    JNB P1.5,$

    AJMP J#

    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ZERO: MOV P0,#C0H

    ACALL DEL

    JNB P1.6,$

    AJMP KEYSCAN

    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    STAR: MOV P0,#89H

    ACALL DEL

    JNB P1.6,$ AJMP KEYSCAN

    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ;======================================================================

    HASH:

    MOV P0,#8CH

    ACALL DEL

    JNB P1.6,$

    AJMP KEYSCAN

    ;===========================================================

    DEL:

    MOV R1,#FFH

    LOOP: MOV R2,#FFH

    DJNZ R2,$

    DJNZ R1,LOOP

    RET

    END

  • 8/3/2019 Micro Controller Trainer Manual

    30/30

    LAB 10TRAFFIC LIGHT SIGNAL

    Design a traffic light signal system using AT89C51 microcontroller.

    REQUIRMENT:

    Program a microcontroller such that it can control traffic light in thefollowing sequence.

    Red light should be on for 8 seconds Red & Yellow light should be on for 2 seconds

    Green light should be on for 8 seconds

    Yellow light should be on for 2 seconds

    The loop should continue

    Apparatus / Component.Microcontroller AT89C51,Microcontroller

    programmer and microcontroller trainer.

    MOV P2,#0FFH ; All bits of p2 are high

    CLR P2.0 ; red LED is onACALL DELAY ; delay for 2 SecondACALL DELAY ; delay for 2 SecondACALL DELAY ; delay for 2 SecondCLR P2.1 ; Yellow LED is onACALL DELAY ; delay for 2 SecondSETB P2.0 ;Red LED is offSETB P2.1 ; yellow LED is offCLR P2.2 ;Green LED is onACALL DELAY ; delay for 2 SecondACALL DELAY ; delay for 2 SecondACALL DELAY ; delay for 2 SecondACALL DELAY ; delay for 2 SecondSETB P2.2 ;Green LED is off

    CLR P2.1 ;Yellow LED is onACALL DELAY ; delay for 2 SecondSETB P2.1 ; yellow LED is offSJMP LOOP ;repeat same sequence again

    DELAY: ; 2 Second delay routineMOV R0,#0EH

    REE:MOV R1,#0FFH

    AG:MOV R2,#0FFHDJNZ R2,$DJNZ R1,AGDJNZ R0,REERETEND