Keypad Module Design

Overview

Again, in designing the keypad module, we broke up the problem into managable parts.


See Keypad Module Top Level VHDL Code
See Keypad External Circuity Schematic

Keypad Module Controller

This is the state machine the controls the components of the keypad module. Its general functions are:

Available documentation:
  • State machine diagram
  • VHDL Code

    Keypad Debounce Counter

    This is basically a counter to implement a debouncing delay. The counter has a preset value of 100 with preset being held high normally. When a keypress is detected, the keypad controller drops the preset signal. The counter then counts down to zero and signals the keypad controller when finished.

    For a clock speed of 3.579MHz (out system clock), this translates to a delay of 0.0279ms. This delay length turned out to be insufficient for consistent keypad debouncing. Due to the frequency requirements of our sensor unit, we could not lower the clock frequency. Also, due to space limitations, we could not expand the size of the counter to give us the required delay. For instance, with the same clock speed, a delay of approximately 3ms would require an inital counter value of 10000, or a 14-bit wide counter.

    Available documentation:
  • VHDL Code

    Keypad Row Scanner

    This is a 4-bit counter/register that is used to scan the keypad. It asserts all 1's except for a single 0 bit that cycles through (i.e. 0111, 1011, 1101, 1110: this is similar to one-hot encoding, except with a 0). This pattern is used to scan the rows of the keypad. The '0' enables one row at a time to allow key presses to be detected on the columns. The '1's disable the other rows. The scanner also has an enable signal which allows the keypad controller to hold the scanner value in order to determine to coordinates of the keypress.

    Available documentation:
  • VHDL Code

    Keypad Coordinate Conversion (Look Up Tables)

    We used two look up tables (LUT) in order to convert the keypad coordinate bit pattern to a BCD value and a decimal ten's digit binary value. The BCD value is used to display output on 7-segment LED's (using external 7447 BCD to 7-segment drivers). The binary value is used by the compare module for comparison with the sensor input.

    Available documentation:
  • VHDL Code for Keypad Coordinates to BCD LUT
  • VHDL Code for Keypad Coordinates to Binary LUT

    Adder Unit

    An adder was required to add the most significant digit (MSD) value and the least significant digit (LSD) value to calculate the binary value of the incoming number.

    Available documentation:
  • VHDL Code

    Registers

    Different sized registers were required in our design. They have reset and enable capabilities.

    Available documentation:
  • VHDL Code for 4-bit Register
  • VHDL Code for 7-bit Register

    Flip Flops

    We required flip flops in order to prevent glitches on some of the keypad controller outputs. Specifically, the keypad controller outputs that are hooked up to level-sensitive inputs (i.e. an active high reset) cannot have glitches. Otherwise the operation of the device would be unpredictable.

    Available documentation:
  • VHDL Code for D-Flip Flop with reset

    Internal Signals

  • int_scan_enable - active high enable signal that controls row scan counter
  • add_load - loads the output of the adder into a register
  • int_LoadMSD - loads the LUT outputs into the MSD register and toadder register
  • int_LoadLSD - loads the LUT outputs into the LSD register
  • int_debounce_done - signal from debounce counter to indicate debounce cycle done
  • debounce_resetD - debounce reset output from state machine (goes to a D-FF to prevent glitches)

    External Signals

  • new_data - signals main state machine that new data is ready
  • new_data_ack - signal from main state machine to indicate ready for data
  • data_enable - control signal to latch data in compare module
  • keypad_MSD, keypad_LSD - BCD digits that go to external BCD to 7-segment drivers
  • keypad_row - asserts row values to scan keypad
  • keypad_column - reads column values to detect key press
  • num - value of entry, goes to compare module
    Back to Design Index.
    Back to project home page.