Keyboard scanner provides system supervision

Jan. 26, 1998
The circuit shown scans a numeric keypad while also generating 16-ms timing interrupts, low-line resets, and power-fail warnings for a larger system (see the figure). The core of the circuit is a versatile...

The circuit shown scans a numeric keypad while also generating 16-ms timing interrupts, low-line resets, and power-fail warnings for a larger system (see the figure). The core of the circuit is a versatile PIC16C54 microcontroller augmented by a microprocessor supervisor (IC3).

In place of the microcontroller shown in the figure, most systems typically employ dedicated logic—a keyboard-interface IC such as the 74C922, a time-base generator such as the 74C4060, a 32-kHz crystal, and a microprocessor supervisor. The small and inexpensive PIC, however, offers design flexibility in exchange for some simple code development (see the listing part a and part b).

The microprocessor supervisor generates activehigh and active-low resets in response to a low VCC voltage. It comes in 5-V and 3.3-V versions; the one shown is a 5-V type with a trip threshold of 4.4 V. It also monitors the battery via the power-fail input (PFI), with a trip threshold of 6.4 V set by R1 and R2. Battery status is read by the PIC at IC3’s !PFO output, and encoded as the MSB (RB7) of an 8-bit data word returned to the main processor every 16 ms.

Other data bits in this byte pertain to the keypad—a 4-by-4 matrix-type such as the Grayhill 84S-BC series. The PIC scans the keypad for contact closures by issuing consecutive “1”s on the low nibble of the bidirectional RB port (RB0-RB3) and watching for a tell-tale “1” on the high nibble. It then converts this row-column information to a 4-bit code, issues it on RB1-RB4 (along with the rest of the byte), enables the latch (IC1), and issues an interrupt. If no key was pressed, the key code is all “0”s on RB0-RB4 (otherwise RB0 is a “1”).

The duration of each contact also is measured by the PIC. A minimum 32-ms interval (two scans or ticks) verifies a valid closure and debounces the contacts. Closure duration is encoded as 0 to 1 tick, 2 to 10 ticks (<0.16 seconds), 10 to 20 ticks (0.16 to 0.32 seconds), or >20 ticks (>0.32 seconds), and returned to the system as data bits RB5 and RB6. This data enables the main processor to provide an autorepeat function for the keypad.

Finally, the crystal-accurate 16-ms interrupts provide a time base for the processor that eliminates the need for a separate time-base generator and crystal. Other advantages (over the discrete CMOS MSI approach) include: flexibility—the software allows for easy changes in the keyboard code, auto-repeat time, debounce delay, interrupt rate, etc.. Board space⇓the PIC is available in a surface-mount package and IC3 comes in a tiny shrink SO-8 “µMax” package. Cost and reliability—the PIC uses a standard AT crystal instead of the fragile 32-kHz-type otherwise required.

Sponsored Recommendations

The Importance of PCB Design in Consumer Products

April 25, 2024
Explore the importance of PCB design and how Fusion 360 can help your team react to evolving consumer demands.

PCB Design Mastery for Assembly & Fabrication

April 25, 2024
This guide explores PCB circuit board design, focusing on both Design For Assembly (DFA) and Design For Fabrication (DFab) perspectives.

What is Design Rule Checking in PCBs?

April 25, 2024
Explore the importance of Design Rule Checking (DRC) in manufacturing and how Autodesk Fusion 360 enhances the process.

Unlocking the Power of IoT Integration for Elevated PCB Designs

April 25, 2024
What does it take to add IoT into your product? What advantages does IoT have in PCB related projects? Read to find answers to your IoT design questions.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!