Using the Keypad Capabilities

updated May 19, 2000

TRM has a keypad input that is compatible with matrix keypads up to 4x4 (16 keys). This page describes:


Configuration Options

You can configure TRM-425 to

Which mode the TRM uses depends on the Key Strobe Time configuration setting. If the Key Strobe Time is set to 0, keypresses are sent immediately. This is the factory default, and the mode you should use with a PC or any system that supports full-duplex serial and buffering of incoming serial data.

A non-zero setting for Key Strobe Time tells TRM-425 to signal a keypress and wait for permission before sending the key code out the serial port. Key Strobe Time tells TRM-425 how long to signal and wait for permission to send before giving up and discarding the keypress. This mode is appropriate for simple controllers (such as the BASIC Stamp® series) that cannot receive and buffer incoming serial data.

Key Strobe Handshaking

The key strobe pin (pin 6 of J1) is normally in a logic-high state (~+5V). It is pulled logic-low (~0V) when a key is pressed, and remains low for the duration set by Key Strobe Time (in units of 512us). For example, if Key Strobe Time is set to 100, a keypress will be signalled by a 51-ms low on on the key-strobe pin.

At the end of the strobe time, TRM-425 changes the key strobe pin to input and checks its state. If it is logic-high (its normal state when not connected), TRM will discard the keypress and not send any serial data. If it is low (meaning that your computer/controller has pulled it low), TRM will send the key code via its serial output.

Here is a general outline for programs that use key strobe handshaking. It assumes that the controller/computer being used can configure a pin as input or output under program control, and that the pin connected to key_strobe is initialized as an input.

Main_Loop
  ' do other processing
  ' check key_strobe
  IF key_strobe=0 THEN GOSUB getKeyCode
GOTO Main_Loop

getKeyCode
  ' make key_strobe pin output-low
  LOW key_strobe
  ' Wait for serial data from TRM
  getSerialInput
  ' make key_strobe input
  INPUT key_strobe
  ' process the key data
RETURN

For a more specific example, see the BASIC Stamp II demo programs.

Selecting the Key Strobe Time Value

In order for key-strobe handshaking to work reliably, your program must be able to respond to a low on the key-strobe pin before the key strobe time elapses. In the outline above, if (for example) the Main_Loop always executes in 30ms or less, Key Strobe Time should be set somewhat longer--say 50ms (about 100 units of .512ms).


Hookup Information for Common Keypads

The keypad input (J2) on the TRM-425 allows you to connect just about any 4x4 or smaller keypad. This page provides hookup information for several popular keypads.

General Note on Wiring Harnesses:
In many of the descriptions below we suggest ready-made flex cables made by AMP and sold through Digi-Key. These are the most convenient hookups for keypads whose layouts match the TRM's keypad input. To make custom solderless wiring harnesses, you may want to use discrete wires and crimp sockets. For a general description of this process, see our app note.


Generic Keypad

Matrix Keypad Layout

Description: A 4x4 matrix keypad consists of 16 switches wired across 4 row and 4 column connections as shown here:

Generic matrix keypad.

This arrangement allows just 8 circuit connections to read the states of 16 switches. Row and column numbers are arbitrary and vary from one keypad manufacturer to another. In connecting this type of keypad to the TRM-425 the most important thing is not to mix row and column connections, since this will make some keys unreadable.

Fewer than 16 keys: 12-key (4x3) keypads are wired identically to 16-key units, except that they omit one column. They are therefore completely compatible with the TRM.


Grayhill Keypads

Series 96 Keypads

Description: Economical, conductive-rubber keypads in black ABS housing. Available in front-panel and rear-panel mounts, 12- and 16-key styles. Indoor use, 3-million operation lifetime. Numeric keys are phone-style layout.

Availability: Digi-Key part number series GH50**-ND where ** is a number from 01 to 11 specifying type. See catalog or web page for selection.

Connection: Directly compatible with TRM J2 connector. Pins 1-8 of keypad connect to pins 1-8 of J2, respectively. (On 12-key models, pins 1-7 connect to 1-7.)

Wiring: Ribbon cable with 8-conductor header socket (0.025" sockets on 0.1" spacing) at each end makes fast, solderless connection. Suggest AMP assemblies from Digi-Key, such as A9BBG-0804F-ND (4 inch flex ribbon with 8-cond. sockets both ends).

Layout: Keypad layout matches TRM configuration software.

Series 88 Sealed Keypads

Description: Snap-dome type keypad fully sealed under plastic-sheet cover. Available in 12- and 16-key styles. Indoor or outdoor use, 3-million operation lifetime. Different key layouts available, including blank for user-created legends. Panel-seal gaskets also available.

Availability: Digi-Key part number series GH50**-ND where ** is a number from 12 to 27 specifying type. See catalog or web page for selection.

Connection: Directly compatible with TRM J2 connector. Pins 1-8 of keypad connect to pins 1-8 of J2, respectively. (On 12-key models, pins 1-7 connect to 1-7.)

Wiring: Ribbon cable with 8-conductor header socket (0.025" sockets on 0.1" spacing) at each end makes fast, solderless connection. Suggest AMP assemblies from Digi-Key, such as A9BBG-0804F-ND (4 inch flex ribbon with 8-cond. sockets both ends).

Layout: Keypad layout matches TRM configuration software.


C&K Components, Inc.

Sealed Membrane Keypads

Description: Snap-dome type keypad sealed under plastic-sheet cover. Adhesive backed and fitted with ribbon cable/socket connector. Available in 12- and 16-key styles. Transparent top for user-created legends.

Availability: Digi-Key part number series CKN60**-ND where ** is 10 (12-key) or 11 (16-key). See catalog or web page for selection.

Connection: Directly compatible with TRM J2 connector. Pins 1-8 of keypad connect to pins 1-8 of J2, respectively.

Wiring: Ribbon cable is preinstalled to keypad; no additional wiring required.

Layout: Key layout is reversed top-to-bottom relative to TRM configuration software. This is easily corrected by entering key codes in reverse top-to-bottom order. Example:

To get this...   ...enter this
1 2 3 A   * 0 # D
4 5 6 B   7 8 9 C
7 8 9 C   4 5 6 B
* 0 # D   1 2 3 A

MGR Industries Inc.

Storm 700 Series

Description: Environmentally sealed, rugged, conductive-rubber keypads. Interchangeable keytop tiles for custom legends. Available in 12- or 16-key layouts.

Availability: Digi-Key part number series MGR11**-ND where ** is 02 or 12 (12-key, black or gray), or 03 or 13 (16-key, black or gray). See catalog or web page for selection.

Connection: Pinout must be rearranged to match TRM J2 connector as listed in table below. Pin 1 of the keypad is shown in Storm documentation shipped with pad; it's the rightmost pin when pad is viewed from the back and oriented so that connector is closer to the bottom.

TRM J2 Storm 700
1 1
2 2
3 8
4 7
5 3
6 4
7 5
8 6

Wiring: Discrete wires either soldered or with crimp-on 0.025" sockets at both ends (see app note). For prototyping, consider Seetron Connectamundos (part number CNX-010, two packs needed).

Layout: Keypad layout matches TRM configuration software (when connection listed above is used).


Jameco OEM Surplus

Part Number 169244

Description: OEM surplus, large-button, phone-style pad with 16 keys.

Availability: Jameco part number 169244

Connection: Pinout must be rearranged to match TRM J2 connector as listed in table below. Pin 1 of the keypad is directly below the "0" key as viewed from front of pad.

TRM J2 169244 Pad
1 8
2 1
3 2
4 4
5 3
6 5
7 6
8 7

Wiring: Discrete wires either soldered or with crimp-on 0.025" sockets at both ends (see app note). For prototyping, consider Seetron Connectamundos (part number CNX-010, two packs needed).

Layout: Keypad layout matches TRM configuration software (when connection listed above is used).


Jameco OEM Surplus

Part Number 160071

Description: OEM surplus 2-row by 8-column pad made by ACT. Sealed top, snap-dome switches.

Availability: Jameco part number 160071

Connection: Pins 1-8 match TRM J2 perfectly. Ground keypad pin 9.

Wiring: Ribbon cable with 8-conductor header socket (0.025" sockets on 0.1" spacing) at each end makes fast, solderless connection. Suggest AMP assemblies from Digi-Key, such as A9BBG-0804F-ND (4 inch flex ribbon with 8-cond. sockets both ends).

Layout: Keys are laid out in 2 rows by 8 columns and are labeled with numbers 0-9 and the following function keys: UP, DOWN, 2ND, CLEAR, HELP, ENTER. The key codes match the TRM layout well. To assign codes to the keys, enter them in the TRM configuration software as shown below. (Note that multi-character entries like DOWN refer to the printed legend on the keypad--you can assign only one character code per key.)

1 2 3 UP
4 5 6 DOWN
7 8 9 2ND
CLR 0 HELP ENTER