Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/26/06 06:01
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#121054 - In minute detail
Responding to: ???'s previous message
Richard Erlacher said:
You have 16 switches in the cited example, organized as four rows and four columns.

Here's the picture again:



Note that the rows are connected to the high nibble (most-significant 4 bits) of P1, and the columns to the low nibble.

Note also that each column has a pull-up resistor.

... writing all '1's (0FF in hexadecimal) to, in this case, P1.


Remember that a standard 8051 port pin has an open-drain driver, so wiriting 1 to a port pin turns the driver off; and writing 0xFF to the whole port turns all the drivers off.

... you write a '0' to one, and only one, of the rows,

wiriting 0 to a port pin turns the driver on, which pulls the line down to 0V

in sequence, e.g. 0EFh, followed by 0DFh, followed by 0BFh, followed by 07Fh

It may be easier to see if we write those numbers in binary:
0EFh = 1110 1111
0DFh = 1101 1111
0BFh = 1011 1111
07Fh = 0111 1111
See how the zero "scans" across the top nibble?

... read the value on P1 after the next timeout, you'll only see the value you've written, unless a switch is closed

When a switch is closed, it connects a row to a column:
  • if the row has a '1', nothing happens;
  • if the row has a '0', it will pull the column down to '0'

    As Steve said initially, because only one row is ever at zero at any given time, you know which row it is!
    And you know which column it is.

    Only one switch exists at the intersection of each row & column - so knowing the row & column identifies which individual switch is pressed!

    If it appears in more than one row, then you've probably struck more than one key.




  • List of 41 messages in thread
    TopicAuthorDate
    connecting a keypad . HOW?            01/01/70 00:00      
       Because...            01/01/70 00:00      
          How many times will this come up?            01/01/70 00:00      
             To be fair            01/01/70 00:00      
             Help him!            01/01/70 00:00      
                OK ... but just this once!            01/01/70 00:00      
       it's quite simple ... therein lies the beauty.            01/01/70 00:00      
          In minute detail            01/01/70 00:00      
             Credit goes to original author Michael Karas            01/01/70 00:00      
                Yes - Credit to Michael Karas            01/01/70 00:00      
          Diodes prevent \"ghosting\"            01/01/70 00:00      
             indeed, but rarely needed            01/01/70 00:00      
                Think of a piano, where each key counts...            01/01/70 00:00      
                   How often do you intend to use multiple keys?            01/01/70 00:00      
                      There is the case of...            01/01/70 00:00      
                         True, but how often?            01/01/70 00:00      
                            Agreed            01/01/70 00:00      
                            general input            01/01/70 00:00      
                      I agree, but...            01/01/70 00:00      
          a small catch            01/01/70 00:00      
             In this case, the pullups were external            01/01/70 00:00      
                HUH????            01/01/70 00:00      
                   Sorry, I should have said you must not ...            01/01/70 00:00      
                      just visualize            01/01/70 00:00      
                         It happens all the time ...            01/01/70 00:00      
                            current limits            01/01/70 00:00      
                               transistors open won't conduct            01/01/70 00:00      
                                  Totally unsuited with push/pulls, unless...            01/01/70 00:00      
                                     This is true, which is why one should READ first            01/01/70 00:00      
                                        there is no reason, but 'linear thinking' (outputs            01/01/70 00:00      
                                           Some encoders "see" pretty high impedances            01/01/70 00:00      
                                              cruel and unusual            01/01/70 00:00      
                                           No!            01/01/70 00:00      
                                              OK, rephrase            01/01/70 00:00      
                                                 Ah, sorry!            01/01/70 00:00      
                                        Benefit of additional pull-ups            01/01/70 00:00      
       Disappearing Original Post!            01/01/70 00:00      
          that is not all that is missing!            01/01/70 00:00      
             Bug            01/01/70 00:00      
                Bugs            01/01/70 00:00      
                   OOps            01/01/70 00:00      

    Back to Subject List