PowerPoint Presentation by 4hMhFe

VIEWS: 0 PAGES: 24

									Microcontroller and Systems
          Part-5

                  Anil JB
             Assistant Professor
   Faculty of Engineering and Technology,
  Mody Institute of Technology and science,
            Lakshmangarh-332311
                  Sikar(Raj.)
Interfacing Keyboard and Display Devices

   Topics Covered:
   Interface switches and keyboard to the
    8051
   Interface LED displays to the 8051
   Overcome Keybounce and multiple key
    press problems
   Design a microcontroller based system
    with keyboard and display devices
   Interface and program the LCD controller
   Interfacing Switches
                 VCC


          R
                           ON
   P1.0
   P1.1
   P1.2
   P1.3
   P1.4
   P1.5
   P1.6
   P1.7

8051
                        DIP
                       SWITCH
       What is a Keyboard ?
 Collection of keys interfaced to the
  microcontroller
 Arranged in the form of two
  dimensional matrix
 Matrix arrangement used for
  minimizing the number of port lines
 Junction of each row and column
  forms the key
 Interfacing a Keyboard
                            +5V




 P1.0
 P1.1
 P1.2
 P1.3
 P1.4
 P1.5
 P1.6
 P1.7

8051

        One key per port line
          Interfacing a Keyboard


                  3          2           1           0
                                                                        PULL-UP
   P1.0                                                                REGISTERS
          X1
                  7          6           5           4          10K
   P1.1
          X2
                  B          A           9           8
   P1.2
          X3
                  F          E           D           C
   P1.3
          X4            Y4          Y3          Y2          Y1

           8051       P2.3       P2.2        P2.1        P2.0



Keys are organized in two-dimensional matrix to
minimize the number of ports required for interfacing
       Interfacing a Keyboard

                                    10K      10K             10K      10K

                         3           2            1           0            10K

           D     X1
                         7           6            5           4            10K
P1.0       E                                                                      Pull-up
           C                                                                     registers
                 X2
           O             B          A             9           8
                                                                           10K
           D
P1.1       E     X3
           R             F          E             D           C            10K

                 X4            Y4            Y3          Y2           Y1

                  8051       P2.3         P2.2        P2.1         P2.0



Use of decoder further reduces the number of port
 lines required
             Key Issues
 Key bounce can be overcome using
  Software/Hardware approach
 Keyboard Scanning
 Multiple Key Closure
   2-key lockout

   2-key rollover

 Minimize Hardware Requirement:
     Use of Keyboard Encoder
 Minimize   Software Overhead
                                  Key bounce

                         VC

                                       P   1
              C1     0.1F             O
S                                      R
         1    R1
                                       T
                     2             3
             220 K                         2
    R2                                 L
              4.7K
                                       I
                         74HC14            3
                                       N
                                       E
                                       S


Hardware approach to overcome key-bounce
                         Keyboard Scanning
                                          1                       2
             START


                                  READ ALL PORT2 LINES   SET PORT VALUES TO
      INITIALIZE PORT2 AS                                     SCAN ROW
     INPUT AND PORT1 AS
            OUTPUT

                                                                              NO
                             NO                               ANY KEY              SET PORT VALUES TO
                                       ANY KEY
        SET ALL PORT1                                         CLOSED?                SCAN NEXT ROW
                                       CLOSED?
          LINES LOW

                                                                      YES
                                              YES
       READ ALL PORT2                                    GET KEYCODE FROM
                                  DELAY FOR DEBOUNCE
           LINES                                               TABLE
        2


NO          ALL KEYS          READ ALL PORT2 LINES
             OPEN?                                            RETURN



                   YES       NO
                                       ANY KEY
                                       CLOSED?
               1


                                              YES
                                          2




      Software approach for keyboard scanning
          Hardware Approach
   Use of an Encoder
   Automatically translates key press code into
    4-bit number
   Built-in scanning circuit
   Overcomes key bounce using a single
    capacitor (1 µF for debounce time of 10 msec)
   Keyclosure indicated by an output (DA) line
   Last key pressed is stored in a latch
   Examples of Encoder
      20 key encoder – 74C923

      16 key encoder - 74C922
             Scanning by Hardware
                             D         P1.0
                             C         P1.1
  4X4        X1              B         P1.2
             X2              A         P1.3
KEYBOARD
 BOARD       X3
             X4
                            OE
             Y1
             Y2                          Port line /
             Y3             D            Interrupt     X1
             Y4             A              input
                                                       X2
             OSC            KBM              8051
                                                       X3
     0.1F
                   74C922         1 .0  F             X4


                                                            SWITCH
                                                                       DATA OUTPUT
                                                            CLOSED
                                                                       D C B A

Minimizes software overhead                                  Y1 X1
                                                              Y1 X2
                                                                        0 0 0 0
                                                                        0 0 0 1


at the expense of extra hardware                              Y1 X3
                                                              Y1 X4
                                                                        0 0 1 0
                                                                        0 0 1 1
                                                              Y2 Y1     0 1 0 0
                                                              Y2 Y2     0 1 0 1
                                                               Y2 Y3    0 1 1 0
                                                               Y2 Y4    0 1 1 1

                                                                          
                                                               Y4 X4    1 1 1 1
                 Display Devices
   Most popular display device: LED
            Very tiny in size
            Available in many colors
            Very reliable and rugged
            Long life
            Operates at low voltage
            Small power consumption
            Visible in darkness
       Single LED
       Bicolor LED
       Seven Segment Displays
          Common Cathode Form (ICM 7218D)
          Common Anode Form (ICM 7218C)
       Consumes large amount of current
        Interfacing a single LED
                              Vcc
                              R
                                        IF

                               LED

Driver circuit to            SWITCH
interface a single LED
                                                    Vt   VF

                                  Vcc
                         R2
          R1    Port                                     R1
                line

                                  R1
 Port                                        Port
 line                                        line
                    Seven Segment LEDs
            a
    f           b   a   b   c   d   e   f   g   dp   a                   b   c               d           e           f       g           dp
        g c
e

        d       d
                p
                                                                                                             Common anode
                                    Common Cathode

                                                                 a                                       a                   a


                                                     e                   b               b                       b                   b




        Two types: Common
                                                                                                         g                   g
                                                     e                   c               c       e                                   c


                                                                 d                                       d                   d

                                                                                 a                       a                   a


        cathode and common                               f


                                                                 g
                                                                         b   f


                                                                                     g
                                                                                                 f


                                                                                                         g
                                                                                                                                     b




        anode type                                                       c


                                                                                     d
                                                                                             c   e


                                                                                                         d
                                                                                                                 c                   c




                                                                 a               a                       a




        Seven-segment LEDs                              f               b   f               b   f               b       f


                                                                 g                   g                   g                   g
                                                                                             c                           e           a
                                                         e               c                       e               c



        can be conveniently used                                     d

                                                                     a                                   a                   a
                                                                                                                                 d




        to display HEX characters                            f
                                                                                 g
                                                                                             b       f



                                                                                                     e
                                                                                                             g
                                                                                                                         f


                                                                                                                                 g
                                                         e                   e               c                           e


                                                                     d                                       d
                                                                                 d
     Interfacing multiple 7-Segment LEDs
                                             +5V
        3.9 K                               150
                        11
         1          75491
A0                                3
A1       7                 5
A2       8                10
A3       14               12
           2 4        6 9 13



             2 4      6    9 13
B0       1                    3                                              d                             d
                                                   a   b c   d   e   f   g       a   b c   d   e   f   g
B1       7                    5                                              p                             p
B2       8                      10
B3       14                     12
                     75491
                          11
        3.9 K                               150
                                             +5V
                                      +5V
             3.9 K
                               11
                          75492
S0              3                      2
S1              5                      6
S2              8                      7
S3            10                       9
S4            12                      13
S5              14         4          1
           Multidigit Driver
 Features of Multidigit Driver
    8-segment driver output lines

    8-digit driver lines

    20 mA peak current

    LEDs can withstand high peak current

 Sequencing operation:
    Select data using digit address lines DA0-2

    Write data using ID0-3 and ID7 lines

 Three modes of operation:
    HIGH: HEX, LOW: OFF, OPEN: CODED-

     HELP
          Interfacing using Multidigit Driver

                               d
       P1.0   ID0              g
                               p
              ID1              f
              ID2              e
              ID3              d
                               c
              ID7              b
              DA0              a
              DA1                  a   b   c   d   e   f   g   dp
       P1.7   DA2


8051   P3.0
              WRITE
                                   1   2   3   4   5   6   7   8
                         DIGIT1
              MODE
                         DIGIT2
              V+
                         DIGIT3
              GND        DIGIT4
                         DIGIT5
                         DIGIT6
                         DIGIT7
                         DIGIT8

                    ICM7218D
       Liquid Crystal Displays

   Key features:
     Low Power Consumption

     Voltage Controlled

     Easy to read in bright light

     Declining Cost

     Ability to display Characters/Graphics

     Intelligent controller and LCD display

      panels readily available
       Liquid Crystal Displays
P1.0               B0           a
P1.1               B1 DATA IN
P1.2               B2              DIGIT 1
P1.3               B3           g


P1.4               D0           a
P1.5               D1 DIGIT
                   D2
                                   DIGIT 2
P1.6                  SELECT    g
P1.7               D3

                                a
                                    DIGIT 3
       OSC                      
       VCC                      g                DISPLAY MODULE


                                a
             GND                   DIGIT 4
                                g
                                         BACK
                                         PLANE
            LCD Display Module
   LCD modules:
      An LCD panel and small circuit board

       containing the controller chip
      14 – pin connections to microcontroller

      HITACHI’S HD44780 controller can control

       up to 80 characters
      Easy to program

      2 rows, 20/40 character in each row

      Each character can be 5X8 or 5X11 matrix
          LCD Display Module
CG ROM stores                      +5V       GND
segment pattern of 192
char.
CG RAM stores                       2    3   1
                             P1.0   D0
segment patterns of 16       P1.1   D1
user-designed char.          P1.2   D2
                             P1.3   D3
An 8-bit instruction    8
                             P1.4   D4
reg.                     0   P1.5   D5
                         5   P1.6   D6
An 8-bit data reg.      1   P1.7   D7
                             P3.0   RS
DD RAM stores up to         P3.1   R/W
80 8-bit char. Codes         P3.2   E
11 instructions clear               LCD Modules
display, return home

								
To top