beautypg.com

C interface – Matrix Orbital PK162-12 User Manual

Page 21

background image

for each position. If the connector has fewer than 7 pins it should be centered on the display connector,

starting with Row 3 and Column 1 and going out. Any matrix style keypad will work with the display, as

well as momentary switches.

The diagram shows the logical layout (row 1, column 1 in upper left). The connector for the keypad is a

10 pin 0.1" spacing male header. Pins 1 through 5 are columns and pins 6 through 10 are rows. The keypad

is scanned whenever a key is pressed: there is no continuous key scan. This means that key presses are dealt

with immediately without any appreciable latency. This also prevents electrical noise which is often caused

by continuous key scans.

NOTE The keypads may be laid out in a different pattern. If this is the case, the user will

need to interpret the key codes differently.

Table 6: Keypad Layout

Columns

Rows

1

2

3

4

1

’A’ 41 Hex

’F’ 46 Hex

’K’ 4A Hex

’P’ 50 Hex

2

’B’ 42 Hex

’G’ 47 Hex

’L’ 4B Hex

’Q’ 51 Hex

3

’C’ 43 Hex

’H’ 48 Hex

’M’ 4C Hex

’R’ 52 Hex

NOTE The keypad connector must be wired with columns on one side and rows on the

other side of the center of the connector. In situations where the keypad isn’t wired this

way an adapter will need to be made, or the user should rewire the connector to meet this

requirement.

4.3 I

2

C Interface

The keypad is read by I

2

C master read. In short, this means that a read of the module will always return

the first unread key press. A read is initiated by writing to the module with its base address plus 1, then

clocking the module’s return byte after the module releases the SDA line. Much more detail on this basic

I

2

C function can be found in the I

2

C specification by Phillips. A good reference is also available at;

 ¢¡£¡¥¤§¦©¨£¨£§¤¢ !¢"¢¨¢#$¤¢£%£&£')(0¨12¢34¢5761¨12¢3¢$£8¢"79@A ¢¡B

The module contains a ten key press buffer so that it can be polled for key presses at an infrequent rate

(every 500 to 1000 mS is typical). All returned key presses indicate the presence or absence of additional

logged key presses by the most significant bit (MSB - bit 7). If the user has pressed two keys since the last

poll of the keypad interface, the first read will return the key code with bit 7 set and the second read will

return the key code with bit 7 clear. The application must take into account this bit to keep up with user key

presses. If there are no keypresses detected, the module will return zero (0x00).

Matrix Orbital

PK162-12

17