ELEC3050 HCS12 Lab5 F11

ELEC3050 HCS12 Lab5 F11 - ELEC3040 3050 Lab Manual Lab 5...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ELEC3040/ 3050 Lab Manual Lab 5 Revised 2/09/11 4-1 LAB 5: MATRIX KEYPAD INTERFACE USING PARALLEL I/O THE VELLEMAN 16-KEY MATRIX KEYPAD The purpose of this lab is to use the MC9S12C32 (HCS12) microcontroller to control a peripheral device, interfaced through parallel I/O ports and accessed using either program-controlled or interrupt-driven I/O. The peripheral device for this lab is a matrix keypad, as used on a variety of products (phones, keyless entry systems, appliances, etc.) The keypad is pictured in Figure 1. Note that there are 8 pins on the bottom of the keypad, with pin spacing (“pitch”) that will allow the pins to be inserted into a standard breadboard. This keypad closely resembles the simulated keypad in CodeWarrior that was used in ELEC 2200 projects. Refer to the keypad scanning example in Chapter 18 of the Cady text book and homework projects from ELEC 2220. Figure 1. Velleman 16-Key Matrix Keypad Figure 2. Matrix Keypad Circuit Diagram Pins: 1-2-3-
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lab 5 Revised 2/09/11 4-2 The keypad’s electrical circuit, shown in Figure 2, contains no “active” electrical components. It is simply a matrix of wires and switch contacts, arranged in rows and columns, with a key and a pair of contacts at each row-column intersection. Springs normally hold the keys away from the contacts, resulting in open circuits between the row and column wires. When a key is pressed, the contact closure connects the corresponding row and column wires, creating a short circuit between them. When the key is released, its spring pulls it away from the contacts, restoring the open circuit. Detection of a pressed key thus requires detection of a short circuit between a row wire and a column wire, with the key number determined from the row and column numbers. INTERFACING THE MATRIX KEYPAD TO THE MICROCONTROLLER To detect a pressed key and identify the key number, the computer must “scan” the keypad to look for a short circuit condition between a row and a column wire. If a short is detected, the computer must determine which row and column wires have been shorted together to identify the pressed key. The most common way to scan a matrix keypad is to set all row and column wires at the same voltage, V1, and then drive one of the column wires Ci to a different voltage, V2. This is illustrated in Figure 3, in which columns 1, 3 and 4 are driven high, with column 2 driven low; the four row lines are normally held at logic 1 with pull-up resistors. If switch 5 is pressed, column 2 is shorted to row 2, resulting in the 0 on column 2 forcing row 2 low. If no switch is pressed, all rows remain pulled up to logic 1. (The roles of the row and column wires can be reversed if desired.) Figure 3. Keypad scanning example
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

ELEC3050 HCS12 Lab5 F11 - ELEC3040 3050 Lab Manual Lab 5...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online