intel's mcs-51 family of microcontrollers and its ... keyboard interface 3 3.0 installation the...

Download Intel's MCS-51 family of microcontrollers and its ... KEYBOARD INTERFACE 3 3.0 INSTALLATION The interface

Post on 01-Apr-2020

6 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • KEYBOARD INTERFACE

    1

    CONTENTS

    PAGE NO

    1.0 Introduction 2

    2.0 Description of the Circuit 2

    3.0 Installation 3

    4.0 Demonstration Examples 4

    4.1 Demonstration Program for MPS 85-3 Trainer 5

    4.2 Demonstration Program for ESA 85-2 Trainer 6

    4.3 Demonstration Program for ESA-80 Trainer 8

    4.4 Demonstration Program for ESA-65 Trainer 10

    4.5 Demonstration Program for ESA-31 Trainer 12

    4.6 Demonstration Program for ESA-68K Trainer 13

    4.7 Demonstration Program for ESA-196 Trainer 15

    4.8 Demonstration Program for ESA 86/88-2 Trainer 17

    4.9 Demonstration Program for ESA 68K-2 Trainer 19

    4.10 Demonstration Program for ESA-51 Trainer 21

    4.11 Demonstration Program for ESA 86/88-3 Trainer 24

    4.12 Demonstration Program for ESA-51E Trainer 26

    4.13 Demonstration Program for ESA 86/88E Trainer 29

    5.0 Exercises 31

    Appendix A : Component Layout Diagram

    Appendix B : Schematic Diagram

  • KEYBOARD INTERFACE

    2

    CALCULATOR KEYPAD INTERFACE

    1.0 INTRODUCTION

    Electro Systems Associates Private Limited (ESA) manufactures trainers for most of the popular

    microprocessors viz 8085, Z-80, 6502, 8031, 68000 and 8086/8088 . ESA offers a variety of

    modules which can be interfaced to these trainers. These modules can be effectively used for

    teaching/training in the laboratories.

    In many microprocessor based systems, calculator keypad is used as an input device. A calculator

    keypad can be interfaced to a microprocessor using a dedicated peripheral controller like INTEL

    8279A Keyboard/Display controller. In this case, the controller can handle the interface problems

    like key debounce, 2-key lock-out, N-key roll-over etc,. Further, such controllers can directly

    encode the position of the depressed key. In an alternative approach, the calculator keypad interface

    is passive and software is used for encoding the key positions and for handling problems like key

    debounce, roll-over etc.

    The present interface module provides a calculator style calculator keypad consisting of the keys 0

    to 9, + ,-, x, =, %, ., C, CE and two spare keys. These 20 keys are arranged in a 3x8 matrix (the

    third row has only 4 keys). The row lines can be driven through port C (Bits PC2, PC1 and PC0)

    and the status of column lines can be read through port A. This interface allows the user to study

    a number of techniques generally used in calculator keypad interfacing. User can write programs

    for software debouncing of key closures, two-key lock out, keyboard encoding and parsing etc

    to gain a good understanding of keyboard interface. Further, user can become familiar with the

    arithmetic group of processor instructions by implementing the calculator functions like

    Addition, Subtraction, Multiplication, Division, Percentage etc.

    2.0 DESCRIPTION OF THE CIRCUIT

    Please refer to the schematic of this interface presented in Appendix B.

    It can be seen that the 20 keys are arranged in a 3x8 matrix fashion. The row lines are driven by

    PC0, PC1 and PC2. The column lines are read through port A. When no key is pressed, all the

    return lines are low. The rows are driven high one after another in sequence. When a row is

    driven high, pressing a key in that row causes the corresponding return line to be read as high.

    Then it scan for the column for which the key is depressed. The row and column positions can then

    be used to encode the key. As the scanning of the rows occurs at very high speed compared to

    human reaction times, there is no danger of missing a key depression. Further issues like

    debounce etc have to be handled through appropriate software routines.

    The sample program presented in the next section illustrates some of these techniques. User can

    develop the software for other functions (for eg: calculator functions) and test the results.

  • KEYBOARD INTERFACE

    3

    3.0 INSTALLATION

    The interface is housed in a plastic enclosure which has a locking mechanism. To open the cover,

    push the locking mechanism with the finger and lift the cover to open.

    The interface module has a 26-pin connector at one edge of the card. This is used for connecting the

    interface to the trainer with a flat cable connector set. The +5V DC power required by this

    interface is drawn from the trainer via the flat cable connector set.

    Table 3-1 shows the connector on various trainers for which the interface can be connected. Some

    trainers have two connectors and either may be used for connecting the interface to the trainer.

    The demonstration programs presented in this manual assumes that the interface is connected to

    connectors shown in column A. If the connector shown in column B is used, then user has to

    change the port addresses appropriately. User may refer to the component layout diagrams of

    respective ESA trainers to locate the connectors mentioned here.

    TABLE-3.1

    MICROPROCESSOR

    TRAINER

    A B

    MPS85-3 J2 J1

    ESA85-2 J2 J1

    ESA-80 J2 J1

    ESA-65 P4

    ESA-68K P3 P4

    ESA 68K-2 J2 J1

    ESA 68-2 J1 J6

    ESA 196 J1 J2

    ESA-31 J2 J1

    ESA-51 J10 J7

    ESA-51E J5 J3

    ESA-86/88-2 J4 J5

    ESA-86/88-3 J8 J9

    ESA-86/88E J4 J6

  • KEYBOARD INTERFACE

    4

    4.0 DEMONSTRATION EXAMPLES

    A sample program to illustrate the operation of this interface is presented below:

    This program encodes the key position as follows:

    Key code = D7 D6 D5 D4 D3 D2 D1 D0

    where

    D7 = D6 = 0

    D5 D4 D3 = row number (000 or 001 or 010)

    D2 D1 D0 = column number (000 to 111)

    Examples:

    a) Key labeled 7 is in row 0 and column 7

    so D5 D4 D3 = 000 and

    D2 D1 D0 = 111

    Code = 00 000 111 = 07H

    b) Key labeled X is in row 1 and column 5

    so D5 D4 D3 = 001 and

    D2 D1 D0 = 101

    Code = 00 001 101 = 0DH

    c) Key labeled CE is in row2 and column 1

    so D5 D4 D3 = 010 and

    D2 D1 D0 = 001

    code = 00 010 001 = 11H

    The encoding of the other keys can be worked out in a similar way.

    The program is written as an infinite loop. So, user must press the RESET key to allow the

    monitor program to regain control.

  • KEYBOARD INTERFACE

    5

    4.1 DEMONSTRATION PROGRAM FOR MPS 85-3 TRAINER

    ; Assume the interface is connected over J2 of the trainer.

    ; The trainer can be in KEYBOARD MODE or SERIAL MODE.

    UPDDT EQU 044CH

    DISPM EQU 0B5BH

    DISLOC EQU 8FF1H

    NMOUT EQU 0C41H

    ADDRESS OPCODE LABLE MNEMONIC COMMENTS

    8C00 3E 92 MVI A,92H ;Configure 8255 for

    ;mode 0

    8C02 D3 43 OUT 43H ;Port A as I/P,

    ;Port C as O/P.

    8C04 21 5B 8C LXI H,MES ;Display the message

    8C07 CD 5B 0B CALL DISPM ;for the serial mode

    8C0A DB 50 BACK: IN 50H ;Read DIP switch

    8C0C E6 08 ANI 08H

    8C0E CA 1E 8C JZ SRL

    8011 CD 30 8C CALL KESCN ;Wait for key enclose

    8C14 79 MOV A,C

    8C15 32 F1 8F STA DISLOC

    8C18 CD 4C 04 CALL UPDDT ;Display key code

    ;in data field

    8C1B C3 0A 8C JMP BACK ;Repeat the same

    8C1E CD 30 8C SRL: CALL KESCN

    8C21 79 MOV A,C

    8C22 F5 PUSH PSW ;Push the scanned value

    8C23 21 74 8C LXI H,DEL ;Delete old values

    8C26 CD 5B 0B CALL DISPM

    8C29 F1 POP PSW ;Get the scanned value

    8C2A CD 41 0C CALL NMOUT ;Display the scanned

    8C2D C3 0A 8C JMP BACK ;value.

    8C30 16 02 KESCN: MVI D,02H ;3 Scan rows

    8C32 0E 10 MVI C,10H ;keycode

    8C34 06 04 MVI B,04H ;Scan lines high

    8C36 78 NXTGRP: MOV A,B ;Make one of the

    8C37 D3 42 OUT 42H ;Scan lines high

    8C39 0F RRC

    8C3A 47 MOV B,A

View more