MP _ MC2011 Lab Manual by nuhman10

VIEWS: 28 PAGES: 50

									                               SIX SEMESTERS

           MICROPROCESSOR & MICROCONTROLLER

                             CONTROL SYSTEM LAB

               DEPARTMENT OF ELECTRICAL ENGINEERING




Prepared By:                    Checked By:                       Approved By:




Engr. Zubair Khalid             Engr. M.Nasim Khan                Dr.Noman Jafri


Lecturer (Lab) Electrical,      Senior Lab Engineer Electrical,   Dean,

FUUAST-Islamabad                FUUAST-Islamabad                  FUUAST-Islamabad
Lab: 1
INTRODUCTION TO 8086 BASED MICROPROCESSOR TRAINER
                                        (IPC-8603)
SYSTEM INTRODUCTION

      IPC-8603 is a single board MICROPROCESSOR TRAINING/DEVELOPMENT KIT
       configured around the INTEL’s 16 bit Microprocessor 8086. The system can operate at
       either 4.9 MHz or 2.45 MHz .

MEMORY
      IPC-8603 provides 16K Bytes of EPROM loaded with monitor and 16K bytes of
      CMOS RAM.
      EPROM : 32K
      RAM : 32K
      Total Memory = 64K
INPUT/OUTPUT
      Parallel : 72 I/O lines using 3 nos. of 8255
      Serial : RS-232-C (Main).
      TIMER/COUNTER : Three 16 bit Timer/Counter through 8253.
      Keyboard & Display : 25 keys and 8 Seven Segment display.
      BUS : All address, data and control signals (TTL Compatible)
      Interrupt : 8259A , 8 user Interrupt.
      Physical Size : 299mm x 180mm.
   
      Operating Temp. : 0 to 50°

IC 8279
8279 is a general purpose programmable keyboard and display I/O interface
device designed for use with the 8086 microprocessor. It provides a scanned
interface to 28 contact key matrix provided in IPC-8603 and scanned displays.

8255
8255 is a programmable peripheral interface (PPI) designed to use with 8086
Microprocessor. This basically acts as a general purpose I/O component to
interface peripheral equipments to the system bus.

8253
This chip is a programmable interval timer/counter and can be used for the
generation of accurate time delays under software control. Various other functions
that can be implemented with this chip are programmable rate generator.
Event Counter, Binary rate multiplier, real time clock etc. This chip has got three
independent 16 bit counters each having a count rate of up to 2 MHz.

8251

This chip is a programmable communication interface and is used as a peripheral
device. This device accepts data characters from the CPU in parallel form
and then converts them into a continuous serial data stream for transmission.
Simultaneously it can receive serial data stream and converts them into parallel
data characters for the CPU. This chip will signal the CPU whenever it can
accept a new character for transmission or whenever it has received a character
for the CPU. The CPU can read the complete status of it at any time. 8251 has
been utilized in IPC-8603 for Main/Aux. RS-232-C interface and 20mA current
loop.

INTERFACES

    KEYBOARD DESCRIPTION
              The IPC-8603 has 25 keys and eight seven segment displays to communicate
              with outside world. As the power is turned on and Reset key is pressed, a
              message -UP 86 is displayed on the display and all the keys are in command
              mode. The keyboard is shown below.




    HEXADECIMAL DISPLAY CHARACTERS
Lab: 2
 COMMAND DESCRIPTION OF EXAMINE BYTE, EXAMINE
          WORD, EXAMINE REGISTER.

         HEXADECIMAL KEYPAD LEGEND INTERPRETATION
FUNCTION KEY OPERATION
COMMAND DESCRIPTION
The various commands that can be executed by the monitor are listed below
    EXAMINE BYTE
    EXAMINE WORD
    EXAMINE REGISTER
    INPUT BYTE
    INPUT WORD
    OUTPUT BYTE
    OUTPUT WORD
    GO
    MOVE
    STEP
    INSERT
    DELETE
    FILL
    BLANK CHECK
    VERIFY
    LIST
    PROGRAM/DUPLICATE

EXAMINE BYTE




EXAMINE WORD




Examine a Series of Memory Byte Locations Relative to the CS Register.
Examining & Modifying Memory Word Location 10H relative to the DS Register.




EXAMINE REGISTER
Lab: 3
EXAMINING AND MODIFYING A REGISTER, EXAMINING A SERIES OF
 REGISTERS, THE GO (GO) COMMAND, TRANSFERRING CONTROL TO
THE SAMPLE PROGRAM, ENTERING AND EXECUTING A BREAKPOINT
                       IN THE PROGRAM.


Examining and Modifying a Register.




Examining a Series of Registers.
GO

Function
The Go (Go) command is used to transfer control of the 8086 from the keypad
monitor program to a user’s program in memory.




Transferring Control to the Sample Program.




Entering and Executing a Breakpoint in the program.
EPROM PROGRAMMER
IPC-8603 provides onboard EPROM PROGRAMMER for the 2764/27128/27256 EPROMS.

BLANK CHECK
Blank check command is used to check the EPROM placed in the ZIF (Zero Insertion Force)
socket for blank.




1) The starting address of the EPROM from where the blank check should start.
2) The End address of the EPROM till where the system should check for blank.
Lab: 4

         Introduction to 89S52 & LED Interfacing

Features


     4.0V to 5.5V Operating Range
     Fully Static Operation: 0 Hz to 33 MHz
     256 x 8-bit Internal RAM
     Three 16-bit Timer/Counters
     Fast Programming Time
     Flexible ISP Programming

Pin Configurations
Block Diagram




LED Code
ORG             000
                START:
                CLR      P0.0
END
LAB 5:

              Blinking LEDs In Different Formations


Objective:



1. Make basic circuitry to run a microcontroller.
2. Interfacing LEDs with 89S51 microcontroller.
3. Microcontroller programming in C.
4. Writing hex code to the microcontroller.
5. Running a simple program to blink set of LEDs.
6. Interfacing Microcontroller trainer.
C code
#include <reg51.h>
#include <stdio.h>
void wait (void)
{ unsigned int x;
for(x=0;x<10000;x++)
{}
}

void main (void)
{
unsigned int i;        /* Delay variable */
unsigned char j;       /* LED variable */
while (1)                         /* Loop forever */
{
for (j=0x01; j< 0x80; j<<=1)
{ /* Blink LEDs 0, 1, 2, 3, 4, 5, 6 */
P2 = j; /* send Output to Port 1 */
P0 = j; /* Output to LED Port */
wait (); /* call wait function */
}

}

}



ASSEMBLY CODE

ORG                      000
                         START:
                         CLR                      P0.0
                         ACALL            DELAY
                         SETB             P0.0
                         ACALL            DELAY
                         CLR                      P0.1
                         ACALL            DELAY
                         SETB             P0.1
                         ACALL            DELAY
                         CLR                      P0.2
                         ACALL            DELAY
                         SETB             P0.2
                         ACALL            DELAY
                         CLR                      P0.3
                         ACALL            DELAY
                         SETB             P0.3
                         ACALL            DELAY
                         CLR                      P0.4
                         ACALL            DELAY
                         SETB             P0.4
                         ACALL            DELAY
                         CLR                      P0.5
                         ACALL            DELAY
                         SETB             P0.5
                         ACALL            DELAY
                         CLR                      P0.6
                         ACALL            DELAY
                         SETB             P0.6
                         ACALL            DELAY
                         CLR                      P0.7
                         ACALL            DELAY
                         SETB             P0.7
                         ACALL            DELAY
                         ACALL            DELAY

                         CLR                      P0.7
                         ACALL            DELAY
            SETB    P0.7
            ACALL   DELAY
            CLR             P0.6
            ACALL   DELAY
            SETB    P0.6
            ACALL   DELAY
            CLR             P0.5
            ACALL   DELAY
            SETB    P0.5
            ACALL   DELAY
            CLR             P0.4
            ACALL   DELAY
            SETB    P0.4
            ACALL   DELAY
            CLR             P0.3
            ACALL   DELAY
            SETB    P0.3
            ACALL   DELAY
            CLR             P0.2
            ACALL   DELAY
            SETB    P0.2
            ACALL   DELAY
            CLR             P0.1
            ACALL   DELAY
            SETB    P0.1
            ACALL   DELAY
            CLR             P0.0
            ACALL   DELAY
            SETB    P0.0
            ACALL   DELAY
            AJMP    START


DELAY:

            MOV           R0,#255
BACK: MOV           R1,#255
            DJNZ    R1,$
            DJNZ    R0,BACK
            RET
LAB 6

7-Segment Interfacing and Programming
            ORG             000

START:

            MOV             P0,#08H                ;CODE OF ZERO IN HEX

            CLR             P2.7             ;PNP TRANSISTER ON

            ACALL DELAY                ;CALL DELAY ROUTINE

            SETB   P2.7                ;PNP TRANSISTER OFF

            MOV             P0,#0EBH         ;CODE OF ONE IN HEX

            CLR             P2.6

            ACALL DELAY

            SETB   P2.6



            MOV             P0,#092H         ;CODE OF TWO IN HEX

            CLR             P2.5

            ACALL DELAY

            SETB   P2.5



            MOV             P0,#0C2H         ;CODE OF THREE IN HEX

            CLR             P2.4

            ACALL DELAY

            SETB   P2.4

            AJMP   START



;DELAY TIME ROUTINE

DELAY:

            MOV    R1,#20

BACK: MOV   R2,#100

  DJNZ   R2,$
   DJNZ   R1,BACK

   RET




Write code of the following
Lab 7

LCD Interfacing and Programming.

Hardware list
 LCD Types Character Locations




Assembly Programming Code


   ORG   00

   MOV   A,#38H                  ;COMMAND FOR LCD

   ACALL COMNWRT                 ;ROUTINE FOR SENDING COMMANDS TO LCD

   ACALL DELAY                   ;DELAY TIME ROUTINE

   MOV   A,#38H

   ACALL COMNWRT

   ACALL DELAY

   MOV   A,#0EH         ;COMMAND FOR DISPLAY ON & CURSOR BLINKING

   ACALL COMNWRT

   ACALL DELAY

   MOV   A,#01H         ;COMMAND FOR CLEAR DISPLAY SCREEN

   ACALL COMNWRT

   ACALL DELAY

   MOV   A,#06H         ;COMMAND FOR SHIFT CURSOR TO RIGHT

   ACALL COMNWRT

   ACALL DELAY

   MOV   A,#83H         ;FORCE CURSOR TO BEGINNING OF IST LINE

   ACALL COMNWRT

   ACALL DELAY

   MOV        A,#'W'                        ;DATA TO WRITE ON LCD
ACALL    DATAWRT   ;ROUTINE FOR WRITING DATA ON LCD

ACALL DELAY

MOV      A,#'E'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'L'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'L'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#' '

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'C'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'O'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'M'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#'E'

ACALL    DATAWRT

ACALL DELAY

MOV      A,#' '

ACALL    DATAWRT

ACALL DELAY
            MOV           A,#'I'

            ACALL         DATAWRT

            ACALL DELAY

            MOV           A,#'.'

            ACALL         DATAWRT

            ACALL DELAY

            MOV           A,#'P'

            ACALL         DATAWRT

            ACALL DELAY

            MOV           A,#'.'

            ACALL         DATAWRT

            ACALL DELAY

            MOV           A,#'C'

            ACALL         DATAWRT

            ACALL DELAY

            SJMP     $



COMNWRT:

   MOV     P1,A

   CLR   P3.7       ;PIN RS=0

   NOP

   CLR   P3.6       ;PIN READ/WRITE=0

   SETB P3.5      ;PIN ENABLE=1

   NOP

   CLR   P3.5       ;PIN ENABLE=0

   NOP

   RET

DATAWRT:

   MOV     P1,A
   SETB P3.7    ;PIN RS=1

   NOP

   CLR   P3.6   ;PIN READ,WRITE=0

   SETB P3.5    ;PIN ENABLE=1

   NOP

   CLR   P3.5   ;PIN ENABLE=0

   NOP

   RET

DELAY:

  MOV           R0,#255

  DJNZ          R0,$

  RET

   END
Lab 8

Input switch with LCD interfacing

Hardware list
 LCD Types Character Locations




Assembly Programming Code


                 ORG             000

                 MOV             A,#38H   ;LCD initialization

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#38H

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#0EH

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#01H

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#06H

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#80H

                 LCALL COMMAND

                 ACALL DELL

                 MOV             A,#'J'
        ACALL DATAR

        ACALL DELL



        ABC:                         ;ABC STARTS



        CLR              P2.7

        JB               P2.1,ONE

        JB               P2.2,TWO

        JB               P2.0,ZERO

        AJMP ABC

ZERO:

        ACALL DELKEY

        MOV              A,#'0'

        ACALL DATAR

        ACALL DELL

        ;JB     P2.0,$



ONE:

        ACALL            DELKEY

        MOV              A,#'1'

        ACALL DATAR

        ACALL DELL

        ;JB     P2.1,$

        AJMP ABC




TWO:

        ACALL DELKEY

        MOV              A,#'2'
                    ACALL DATAR

                    ACALL DELL

                    ;JB          P2.2,$

                    AJMP ABC



DELL:



DFG:         MOV R2,#2

             DJNZ R2,$

             RET    ;ABC RETURNS



COMMAND:

    MOV     P1,A

    CLR     P3.7     ;PIN RS=0

    NOP

    CLR     P3.6     ;PIN READ/WRITE=0

    SETB    P3.5    ;PIN ENABLE=1

   ACALL     DELL

    CLR     P3.5     ;PIN ENABLE=0

    RET

DATAR:

    MOV     P1,A

    SETB    P3.7    ;PIN RS=1

    NOP

    CLR     P3.6    ;PIN READ,WRITE=0

    SETB    P3.5    ;PIN ENABLE=1

    ACALL    DELL

    CLR     P3.5    ;PIN ENABLE=0

    RET
DELKEY:

           MOV         R5,#2

           DJNZ R5,$

           RET

     END
Lab 9

SINGLE PHASE STEPPER MOTOR CONTROL.




A stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has a series of
magnets mounted on it, and the coils surrounding the shaft are alternately given current or not, creating
magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.

This design allows for very precise control of the motor: by proper pulsing, it can be turned in very
accurate steps of set degree increments (for example, two-degree increments, half-degree increments,
etc.). They are used in printers, disk drives, and other devices where precise positioning of the motor is
necessary.
                                   STEPPER MOTOR



                             Assembly Code For single phase


          ORG 000H



START:

          MOVP2,#00010001B

          CALL DELAY

          MOVP2,#10001000B

          CALL DELAY

          MOVP2,#01000100B

          CALL DELAY

          MOVP2,#00100010B

          CALL DELAY

          JMP START

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

; DELAY 20mS

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

DELAY:

          MOVR6,#40

DL1:

          MOVR7,#249

          DJNZ R7,$

          DJNZ R6,DL1

          RET
          END




Lab 10

DOUBLE PHASE STEPPER MOTOR CONTROL.




A stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has
a series of magnets mounted on it, and the coils surrounding the shaft are alternately given
current or not, creating magnetic fields which repulse or attract the magnets on the shaft,
causing the motor to rotate.

This design allows for very precise control of the motor: by proper pulsing, it can be turned in
very accurate steps of set degree increments (for example, two-degree increments, half-degree
increments, etc.). They are used in printers, disk drives, and other devices where precise
positioning of the motor is necessary.
                            Assembly Code For 2- phase
ORG000H

START:

MOV P2,#00110011B

CALL DELAY



MOV P2,#10011001B

CALLDELAY

MOVP2,#11001100B

CALL DELAY



MOV P2,#01100110B

CALL DELAY

JMP START

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

; DELAY 20mS

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

DELAY:

MOV R6,#40

DL1:

MOV R7,#249
DJNZ R7,$

DJNZ R6,DL1

RET

END



              Write a code to Rotate Stepper Motor At 90 Step
Lab 11


PHOTOINTERRUPTER CONTROL.




Photointerrupters are transmission type sensors incorporating an infrared LED and a
photosensor in the same package. Photointerrupters detect an object when it interrupts the
light beam emitted from the LED. Phototransistors, or digital output photo ICs, can be
selected as the photosensor.
                          Assembly Code For Photointerrupter

Stepper motor control through Photointerrupter changes the direction from CCW to CW.



ORG        000H

           MOV       A,#00110011B

TEST:

           JB P3.4,TURNR

           RL        A

           MOV       P2,A

           CALL      DELAY

           JMP       TEST

TURNR:

           RR         A

           MOV       P2,A

           CALL      DELAY

           JMP       TEST

DELAY:

           MOV       R6,#20

DL1:

           MOV       R7,#249

           DJNZ      R7,$

           DJNZ      R6,DL1

           RET

           END
Lab 12


PULSE COUNTER.




A pulse counter could be divided in three parts. The first part is a pulses source. The
second unit is microcontroller which counts, memorizes states and prepares results.
Finally, the third part is a converter of electrical states into states available to our senses
i.e. seven segment display .

Photointerrupters are transmission type sensors incorporating an infrared LED and a
photosensor in the same package. Photointerrupters detect an object when it interrupts the
light beam emitted from the LED. Phototransistors, or digital output photo ICs, can be
selected as the photosensor. And this sensor is widely used as a counter. The control
mechanism is designed to count the number of times the path is broken.
                       Assembly Code For Pulse Counter

        ORG   000H

        MOV   A,#0

        MOV   P2,#0

NEXT:

        JB    P3.4,$



        ADD   A,#1

        DA    A

        MOV   P2,A



        JNB   P3.4,$



        JMP   NEXT



        END
Lab 13

Dot Matrix LED Control.




             DOT MATRIX   DOT MATRIX
Assembly Programming Code


         ORG    000H

         CLR    P1.7

START:

         MOV    R0,#64

         MOV    P2,#FFH

         MOV    A,#10000000B

NEXT_COL:

         MOV    P0,A

         CALL   DELAY

         RR     A

         DJNZ   R0,NEXT_COL



         MOV    R0,#64

         MOV    P0,#FFH

         MOV    A,#10000000B

NEXT_ROW:

         MOV    P2,A

         CALL   DELAY

         RR     A

         DJNZ   R0,NEXT_ROW



         JMP    START



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

; DELAY 0.1S
;==============================

DELAY:

         MOV    R6,#200

DL1:

         MOV    R7,#249

         DJNZ   R7,$

         DJNZ   R6,DL1

         RET

         END



Write Assembly code for A.
Lab 14

SPEAKER CONTROL.




The most common type of speaker is the MOVING COIL speaker, where a coil of wire is
suspended in the magnetic field of a circular magnet. When a speech current is passed through
the coil a varying magnetic field is generated by the coil.
The two magnetic fields interact causing movement of the coil. The movement of the coil causes
a cone, which is attached to the coil, to move back and forth. This compresses and decompresses
the air thereby generating sound waves.
                     Assembly Code For Speaker
     ORG 000H

START:

     MOV R0,#5

NEXT2:

     MOV R1,#100

NEXT1:

     SETB P3.7

     CALL DELAY

     CLR   P3.7

     CALL DELAY

     DJNZ R1,NEXT1

     DJNZ R0,NEXT2

     CALL DL05S

     JMP   START

                             ; DELAY 0.5mS

DELAY:

     MOV R7,#249
       DJNZ R7,$

       RET



                     ; DELAY 0.5S

DL05S:

       MOV R5,#5

DL2:

       MOV R6,#200

DL1:

       MOV R7,#249

       DJNZ R7,$

       DJNZ R6,DL1

       DJNZ R5,DL2

       RET



       END
Lab 15


DIGITAL THERMOMETER




                     Assembly Code For Speaker
ORG      000

         CLK   =     P2.3
         DAT   =     P2.2
         CS    =     P2.0
         MEMDATA     =        40H

         MOV         A,#38H
         ACALL COMMAND
         ACALL DEL
         MOV         A,#38H
         ACALL COMMAND
      ACALL   DEL
      MOV           A,#0CH
      ACALL   COMMAND
      ACALL   DEL
      MOV           A,#01H
      ACALL   COMMAND
      ACALL   DEL
      MOV           A,#06H
      ACALL   COMMAND
      ACALL   DEL
      MOV           A,#80H
      ACALL   COMMAND
      ACALL   DEL
      MOV           A,#'T'
      ACALL   DATAR
      ACALL   DEL
      MOV           A,#'E'
      ACALL   DATAR
      ACALL   DEL
      MOV           A,#'M'
      ACALL   DATAR
      ACALL   DEL
      MOV           A,#' '
      ACALL   DATAR
      ACALL   DEL
      MOV           A,#' '
      ACALL   DATAR
      ACALL   DEL

      ADC_READ:
            MOV              R2,#9
            CLR              A
            CLR              CLK
            CLR              CS

              LOOP:
                      MOV            C,DAT
                      RLC            A
                      SETB   CLK
                      NOP
                      CLR          CLK
                      DJNZ   R2,LOOP
                      MOV          MEMDATA,A
                      SETB   CS
                      MOV          45H,#8
AGAIN1:

                      MOV            A,MEMDATA
                      MOV            B,#10
                      DIV            AB
                      MOV            41H,B
                      MOV            B,#10
                      DIV            AB
                      ORL            A,#30H
                      MOV            42H,A
                      MOV            A,B
                      ORL            A,#30H
                                  MOV           43H,A
                                  MOV           A,41H
                                  ORL           A,#30H
                                  MOV           44H,A

                                  MOV           A,#86H
                                  ACALL   COMMAND
                                  ACALL   DEL
                                  MOV           A,42H
                                  ACALL   DATAR
                                  ACALL   DEL
                                  ACALL   DEL
                                  MOV           A,43H
                                  ACALL   DATAR
                                  ACALL   DEL

                                  MOV           A,44H
                                  ACALL   DATAR
                                  ACALL   DEL
                                  DJNZ    45H,AGAIN1
                                  SJMP    ADC_READ


                 COMMAND:
                 MOV              P1,A


 CLR       P3.7 ;RS
          NOP
          CLR     P3.6 ;READ/WRITE
          SETB    P3.5 ; ENABLE
          NOP
          CLR     P3.5
          NOP
          RET
DATAR:
                 MOV              P1,A
          SETB         P3.7 ;RS
          NOP
          CLR          P3.6 ;READ,WRITE
          SETB         P3.5 ; ENABLE
          NOP
          CLR          P3.5
          NOP
         RET

								
To top