Link here

Chapter 10 - The Keypad and LCD Display Interfaces

The QED Board includes built-in hardware and software interfaces for a keypad and liquid crystal display (LCD). These devices connect to the QED Board via a simple "straight-through" ribbon cable interface. Pre-coded routines in the QED-Forth kernel scan the keypad and write to the LCD display.

The onboard keypad/display interface connector is the 34 pin dual-row header located next to the QED-Forth Kernel PROM socket. A 34 pin female ribbon connector plugs into this header. Two female single row connectors terminate the ribbon cable: one for the keypad, and one for the display.

This chapter describes the hardware aspects of the keypad and display interfaces, including how to connect the devices and how to adjust the LCD display contrast. The software device drivers are described in the QED Software Manual in the chapter titled "The User Interface: LCD Display, Keypad, and Serial Ports".


The LCD Display

The QED Board (Rev 1) can accommodate liquid crystal display modules up to 4 lines by 20 characters in size. The processor sends control commands and ascii data to the display via a 14 pin data and control bus.


Connecting the QED Board to the Display

Mosaic Industries provides a ribbon cable that connects both a 4 by 5 keypad and an LCD display module to the QED Board. The onboard keypad/display interface connector is a 34 pin dual-row header labeled "Keypad/Display" on the board's silkscreened legend. A 34 pin female ribbon connector plugs into this header, and two female single row connectors link the cable to the keypad and LCD display. Figure 10.1 diagrams the connector pin-out.

A 14 pin single-row female connector on the ribbon cable connects directly to the display pins at the top rear of the display. The ribbon cable is attached such that the red stripe on the cable (denoting pin 1) is above pin 1 (the pin nearest the corner) on the display. In the "standard orientation", the display connector is at the top of the display, and the display has 4 lines and 20 characters per line.

The display connector taps the 14 even numbered wires #2, 4, 6, ... 28 on the keypad/display ribbon cable and connects them to the LCD display. An additional three wires (#30, 32, and 34) bring out +5V, Vcontrast, and DGND, respectively. As explained below, you can connect a panel-mounted potentiometer to these three signals if your application requires external control of the display's contrast and/or viewing angle.

Keypad/Display Connector
PPB4/KPR4- 1 2 -GND
PPB3/KPR3- 3 4 -+5V
PPC3/KPC3- 5 6 -Vcontrast
PPC0/KPC0- 7 8 -PPB5/Display.RS
PPB2/KPR2- 9 10 -GND
PPC1/KPC1- 11 12 -PPB6/Display.E
PPC2/KPC2- 13 14 -GND
PPB1/KPR1- 15 16 -GND
PPB0/KPR0- 17 18 -GND
N/C- 19 20 -GND
N/C- 21 22 -PPB0/Display.D4
N/C- 23 24 -PPB1/Display.D5
N/C- 25 26 -PPB2/Display.D6
N/C- 27 28 -PPB3/Display.D7
N/C- 29 30 -+5V for remote potentiometer
N/C- 31 32 -Vcontrast for remote potentiometer
N/C- 33 34 -GND for remote potentiometer

Figure 10.1. Pin assignments for the keypad/display connector.

Note that the keypad connections are aligned along one (the odd-numbered) side and the display connections are aligned along the other (even-numbered) side. The keypad connections are tapped by a 9 pin single-row female connector, and the display connections are tapped by a 14 pin single-row female connector. To facilitate panel mounting of a remote contrast/viewing angle adjustment potentiometer, the additional three even-numbered pins (#30, 32, and 34) bring out the connections to the onboard potentiometer.


LCD Control Signals

The LCD module communicates with the processor via a 14 pin bus diagrammed in Figure 10.2. Signals D0 through D7 implement an 8 bit data bus. To conserve I/O pins, the QED Board operates the display in its optional 4 bit mode. Only D4-D7 carry information, and D0-D3 are not used (they are tied low).

Three signals named E, R/W, and RS control the flow of data to the display. The E signal is an active high device select signal; data is latched into the display on its falling edge. R/W is a read/write signal that is tied low to force one-way write-only data transfer; the QED Board's display interface is set up so that it is never necessary to read from the display's internal memory. When the RS signal is high, it indicates that data is being written to the display; when it is low, it indicates that a command is being sent.

The display is powered by the +5V supply connected to the Vdd pin of the display. The Vcontrast signal controls the contrast and optimal viewing angle of the display. It is connected to the center tap of an onboard potentiometer located next to the keypad/display connector. The end points of the potentiometer are connected to +5V and DGND (digital ground). Changing the setting of the potentiometer varies the Vcontrast voltage between 0 and 5 Volts.

LCD Display Pin Assignments
1Vss (GND)
2Vdd (+5V)
3Vee (Vcontrast)

Figure 10.2 Pin assignments at the LCD display. Only data bits D4-D7 are used; D0-D3 are not needed and are tied low. The R/W signal is also tied low to implement a write-only display interface.


Contrast and Viewing Angle Adjustment

The QED Product Design Kit is shipped with a high-contrast "supertwist" LCD display that has a wide viewing angle. In most applications the contrast/viewing angle potentiometer can be left in its default setting (as shipped from the factory) with no adjustments required. If you wish to change the contrast setting, simply twist the potentiometer using a small screwdriver.

If your application requires a remote contrast adjustment, you may connect a panel-mounted or other off-board potentiometer to the top three even-numbered wires on the ribbon cable (wires #30, 32, and 34). Simply connect the end points of the potentiometer between DGND and +5V. DGND is brought out at wire 34, the wire at the edge of the ribbon cable opposite the red stripe, and +5V is brought out at wire #30. Connect the center tap (the wiper) of the potentiometer to wire #32 on the ribbon cable. This effectively places your remote potentiometer in parallel with the onboard potentiometer. Consequently it is important that the onboard potentiometer be adjusted to its midpoint (as opposed to an extreme). Then changes in the remote potentiometer will change the effective voltage applied to the Vcontrast pin of the display.

The most elegant connection scheme for a remote potentiometer is to replace the 14 pin single-row female connector on the ribbon cable with a 17 pin single-row female connector. The three "extra" holes in the connector bring out wires #30, 32, and 34 which can be connected to the remote potentiometer as described above.


The Keypad

The keypad offers a simple yet effective means for an operator to control a computer-based instrument. By pushing a keypad button, the user shorts a "row" circuit to a "column" circuit. The QED hardware is configured to allow the processor to detect such a short circuit. It does this by connecting the 4 rows to digital inputs, and holding them in a default "high" state with pull-up resistors. Each of the 5 columns is connected to a digital output. The processor scans the keypad by each of the column outputs low in turn and reading each of the row inputs to see if it has been pulled low. If it has, the processor deduces that a user is holding down the key at the intersection of that row and column.

By scanning the rows and columns, the processor can identify which key was pressed. Routines built into the QED-Forth kernel (namely, ?KEYPAD, ?KEYPRESS, and KEYPAD) scan the keypad and report which (if any) key is being depressed.


Connecting the Keypad

As shown in Figure 10.1, the keypad connector uses the nine odd numbered pins/wires #1, 3, 5 ... 17 which are terminated in a 9 or 10 pin single-row female connector (the 10th pin, if present, is not used). Pin 1 of this single-row header is connected to the pin marked "F" on the Grayhill 20-key keypad (Part No. 86JB2).

In the "standard orientation", the keypad connector is at the "bottom" of the keypad. The keypad has 4 rows and 5 columns in the standard orientation. In the QED Product Design Kit the front panel keypad is in the standard orientation.

The QED-Forth software assigns key#0 to the lower right key, key#1 directly above key#0. The key directly to the left of key#0 is key#4. In other words, key numbers increase as we progress upward and to the left. The highest key number is key#19 in the upper left corner of the keypad. Thus in the standard orientation the keys are numbered as shown in Figure 10.3.

19 15 11 7 3
18 14 10 6 2
17 13 9 5 1
16 12 8 4 0

Figure 10.3. Key numbers with the keypad in the standard orientation.

For example, if the user presses the key in the upper right corner while the KEYPAD routine is running, the number 3 will be placed on the data stack. Consult the QED Glossary and the chapter titled "The User Interface: LCD Display, Keypad, and Serial Ports" in the QED Software Manual for a detailed explanation of the pre-coded keypad scanning routines.

This page is about: Microcontroller Keypad and LCD Interface 68HC11 MC68HC11F1 – The QED Board includes built in hardware and software interfaces for keypad and liquid crystal display (LCD). These devices connect to QED Board via simple straight through ribbon cable interface. Pre coded routines in QED Forth kernel scan keypad and …