DIY: Programmable Keypad

Handy Circuit Building Electronics Project

Designer: RESTHOR
Description: Programmable Keypad
Skill Level: Intermediate
Assembly Time: 1-2 hours

Programmable Keypad Ever worked on building a circuit, had to scrounge around for a switch to wire it to the breadboard at the same time holding on to it with one hand while and pushing the switch with the other hand and making sure the switch doesn't come loose while testing the circuit? An extra hand would be handy right now.

The Programmable Keypad uses a standard telephone style keypad and provides eight either momentary contact or push on/push off, or both, switches that are de-bounced. It has eight open collector outputs, and eight LEDs corresponding to each output showing the state of each output (on or off). The outputs are accessed via terminal blocks for easy hookup.

Tools you will need:

Soldering iron and solder
Small screwdriver
Wire cutters
1/8 inch drill bit and drill
Voltmeter
Extra resistor (1kΩ ±500Ω)
5 volt power supply

Kit Includes:

Qty.
Description Mfr. P/N
1
Shift Register CD4094
1
Darlington Array ULN2803
1
20 Pin IC Socket 6100-20
1
Tapered Square Rubber Feet (4) SJ5023BLK4
1
8 Pin Right Angle Header 7000-1X8RG-B
1
Phenolic Prototype Board 22-516
1
16 Pin IC Socket 6100-16-R
1
18 Pin IC Socket 6100-18-R
4
Standoffs, 4/40, 1/2 inch 2104-440-AL-7
10
1/4 Watt, 10kΩ Resistors, 5% CF1/4W103JRC
10
3mm Green LEDs LTL-4232N
10
Screws, 4-40, 1/4 inch 4-40X1/4PPN
4
2 Position Connector Terminal Blocks OSTTA020161
1
3 Position Connector Terminal Blocks OSTTA030161
1
8 Bit CMOS Microcontroller PIC16F690-I/P
1
Keypad COM62229M
1
PCB --

Order the programmable keypad kit.

The keypad is supplied with 5 volts DC and ground from the user's circuit and has an additional voltage terminal called "Vload" for outputs in case a different voltage for the output load is required. The outputs are supplied by a ULN2803 open collector Darlington transistor array which can sink up to a 500mA of current and can withstand up to 50 volts in the off state.

The outputs can be connected to anything that an open collector transistor output can be connected to. There is an LED corresponding to each of the outputs which shows the state of the output at all times. A lighted LED indicates that output is on, i.e., that output transistor is on, which pulls the output low (to ground) assuming a pull-up resistor is also connected to the output.

Keys 1-8 determine the state of the corresponding output, so for example if key 1 is briefly pressed, output one goes on then off, and so on for the other keys. If a key is programmed to push on/push off, then pressing a key and releasing it will turn an output on (or off) and the output will stay on (or off). Pushing the same key again will toggle the output to the opposite state.

Key 9 immediately complements all outputs (i.e., if an output is on, it will go off and vice versa).

Key 0 immediately turns all outputs off and clears any program flags. The "*" key (the star key) takes the Keypad into programming mode, described below. The "#" key exits the program mode with all switches then acting according to their program. Each key can be individually programmed as either momentary or push on, push off. If a key is held down, the output pulses on/off as long as the key is held down. The program is retained if power is removed and restored when power returns.

Program Modes:

Mode Mode Description
1
Default mode - All switches are momentary action
2
All switches are push on/push off
3
Individual keys can be programmed for push on/push off
4
Individual keys can be programmed for momentary action

Here are the steps to program the keys:
  1. Momentarily press the star ("*") key. All the LEDs flash to indicate the keypad has entered programming mode.
  2. Momentarily press one of the keys 1, 2, 3 or 4 to activate the corresponding mode. The LED corresponding to the pressed key flashes.
  3. Press "#" to exit program mode. All LEDs go out.
Program modes 3 and 4 are special cases. If "*" then "3" is pressed, the Keypad waits for one other key to be pressed indicating that the second key pressed (any one of the 1 throughout 8 keys) is to be programmed as a push on/push off key. When the second key is pressed, the LED for that programmed key flashes. Then press "#" to exit, and the corresponding key/output will be push on/push off.

Program mode 4 works the same way, but the key that is programmed will be a momentary action key. Mode 4 would be used if, for example, program mode 2 had previously been activated making all keys push on/push off, but one or more of the keys then needed to be programmed as a momentary action key. As stated above to cancel a program, push the "0" key, and all keys return to the default mode and the program flags are cleared. Any combination of momentary action or push on/push off can be programmed.

The picture (above) shows the prototype which was assembled on a strip board. The kit is supplied with a two layer printed circuit board, rubber feet for the board and a preprogrammed PIC16F690 micro controller. Assembly involves soldering the keypad connector, IC sockets and terminal blocks to the board, attaching the keypad to the 8 pin connector and to the board with standoffs and screws supplied with the kit.

This Programmable Keypad is a useful general purpose tool for development purposes, is easy to use and program, and can be used as the input device for any number of circuits that require a keypad of a collection of momentary and/or push on/push off type switches or any kind of one-of-eight input to output signals.

Step 1 - Check Parts

Examine each part received with the kit and compare it with the parts list to make sure all the parts have been received. Then examine the printed circuit board, and make sure you understand where the various parts will go by matching the silkscreen labels on the board with the parts. The parts are not installed yet.

Step 2 - IC Sockets

Locate the three IC sockets (one has 20 pins, one has 18 pins and one has 16 pins). Locate the 20 pin socket and insert it into the board location labelled "U1". Make sure the socket is inserted from the labelled side of the board and that the small notch on one end of the socket is inserted at the same where one of the socket holes has a square outline (indicating pin one). Turn the board over while holding the socket in place, and solder the socket pins to the board. Make sure there are no solder bridges between pins. In the same way, install the 18 pin socket at location U2 and the 16 pin socket at location U3.

Step 3 - Keypad Connector

Locate the 8 position header pin connector. It will have short pins on one side and long pins bent at a 90 degree angle on the other side. Insert the short pins into the 8 holes on the board labelled "Keypad" making sure to have the long bent pins facing toward the outer edge of the board. Turn the board over and solder the pins in place.

Step 4 - Terminal Blocks

Locate the four two position terminal blocks and install them in the holes labelled "Outputs" on the board. Make sure the wire openings face the edge of the board. Solder the terminal blocks in place. Locate the 3 position terminal block and insert it into the board at the location with "+5, Gnd and Vl" labels. Make sure the wire holes face the edge of the board.

Step 5 - LEDs

Locate eight (4) LEDs. Note that one of the two wires on each LED is longer than the other. The longer wire is the anode side of the LED, and the short wire is the cathode side. Note on the board that there is a line of holes labelled D1 through D8, and that D1 through D4 are oriented differently than D5 through D8. Insert a LED into the D1 location with the short wire inserted into the hole with the flat side of the label.

THIS IS CRITICAL - IF THE LEDS ARE INSTALLED BACKWARDS THEY WILL NOT WORK.

Turn the board over and slightly bend the wires out to hold the LED in place. In the same way, insert LEDs into the D2, D3 and D4 locations. Turn the board over and solder the LEDs in place and clip the excess wires off.

Locate the remaining 4 LEDs. Note that on the board, the labels for D5 through D8 are reversed from D1 through D4 (the flat side on the label is reversed, and the labels are upside down). Insert an LED into location D5 so that the short wire goes through the hole with the flat side on the label. Turn the board over, slightly bend the wires out to hold the LED in place and solder the wires and clip off the excess wire. Repeat for the remaining 3 LEDs, making sure the cathode (short) wire is inserted into the hole with the flat side label.

Step 6 – Integrated Circuits

Locate the three integrated circuits (IC). Note that on each IC, one pin has a small dimple next to it or one end of the IC is notched. In each case the IC will be inserted into its socket with the small dimple or notch near the hold on the board that has a square outline (pin 1). Carefully place the PIC16F690 into the 20 pin socket (U1) in the correct orientation, and press it into the socket. Insert the ULN2803A into the 18 pin socket (U2), and insert the CD4094 into the 16 pin socket.

Step 7 - Prepare Keypad Mounting Board

Locate the keypad, the phenolic board, 4 screws and 4 standoffs. Using a hacksaw, cut the phenolic board to 3 x 3 inches. Now, place the phenolic board against the printed circuit board and mark the location on the phenolic board of the 4 1/8 inch holes in the printed circuit board. Drill a 1/8 inch hole in the phenolic board at each of the marked locations. Now attach 4 standoffs to the phenolic board with 4 screws. Attach the phenolic board to the printed circuit board with 4 screws, making sure the phenolic board is mounted on the component side of the printed circuit board.

Step 8 – Keypad Install

Remove the protective paper from the bottom of the keypad to expose the sticky material on the bottom of the keypad. Carefully align the keypad on the phenolic board so that the top and bottom edges of the keypad line up with the top and bottom edges of the phenolic board and so that the keypad sits inside of the 4 screws on the phenolic board. The lower edge of the keypad (where the ribbon cable is attached) should be above the pin header on the Printed Circuit Board. Using a wire cutter, cut pin number 8 off the pin header, so that the only pins remaining are pins 1 through 7. Now loop the ribbon cable from the keypad down to the header and insert the ribbon cable connector into the header so that pin 1 of the header inserts into socket 1 of the keypad connector.

Test... Test... Test

Connect a 5 volt supply to the +5 and ground screw terminal block. With 5 volts applied to the Programmable Keypad, briefly push each of the buttons 1 through 8. Each of the LEDs 1 through 8 should briefly light. Briefly push button 9. All LEDs should briefly light. Briefly push the star key. All LEDs should be flashing. Then briefly push the 2 key. The number 2 LED should flash. Push the # key and the LEDs should stop flashing. Then push any key 1 through 8 and the corresponding LEDs should light and stay on.

Pushing the same key should extinguish the LED. Push each of the keys 1 through 8 and note that all of the LEDs should be on and stay on. Push key 0, and all the LEDs will go off. Connect a pull-up resistor to any one of the output terminals and to 5 volts, and verify with a voltmeter that the outputs are low when the corresponding LEDs are on, and the outputs are high when the corresponding LEDs are off. Alternately, connect an LED to the Terminals, through a 1K resistor to 5 volts, and note that the output LEDs match the state of the Keypad LEDs. Following a similar process, test the programming features as described in the overview.

Troubleshooting

If the keypad did not function as described above, it could be that a component was installed incorrectly, or a solder joint was improperly made. First verify that all components are installed in the proper locations and in the proper orientation. This will require removing the keypad from the board.

Check that all soldered connections are good (all have a shiny smooth appearance), there are no solder bridges (inadvertent connections between solder pads) and that there are no cold solder joints (solder appears dull or cracked). If all parts are installed and soldered correctly, verify that the supply voltage is not less than 4.5 volts and not more than 5.5 volts. Re-attach the keypad and test again, making sure that button presses are brief (a small fraction of a second). Holding a button down will cause the LEDs to flash and the outputs to pulse, which is ok if that is intended, otherwise the keypad functions may not behave as expected, especially when programming a key in program mode. If all else fails, contact Jameco.