|A keypad is used for data entry. It needs to be used with a PIC.
How does it operate?
The keys on a keypad form a matrix of push-to-make switches. This data sheet gives details of the Rapid 78-0305 keypad.
There are 12 push switches, arranged on a matrix of four rows and three columns. These are connected to seven pads at the bottom of the keypad.
If no key is pressed there is no electrical contact between the rows and the columns.
When a key is pressed it makes an electrical connection between the row and the column that it is on.
So, for example, if the key labelled ‘6’ is pressed, this makes electrical contact between row 2 (connected to pad 7) and column 3 (connected to pad 5).
So, if key ‘6’ is pressed this creates an electrical connection between pad 7 and pad 5.
The connections are:
||is connected to|
Keypad and PIC connections
Keypads are designed for use with PICs.
The four rows of the keypad are connected to four of the output signals from the PIC. The three columns of the keypad are connected to three of the input signals to the PIC.
The circuit diagram on the left shows the kinds of connections that might be used but the actual pins used on the PIC depend on the PIC and software used.
The PIC detects which key is pressed by ‘scanning’ the keypad. The principle involved is shown in the section of subroutine.
First the PIC sets the signal going to Row 1 high (a digital ‘1’). All the other Rows are made low (a digital ‘0’).
Then it tests the input signals coming from each Column in turn. If any of the Column signals is high, this means that the corresponding key in Row 1 has been pressed.
If a key has been pressed the software sets a variable (‘A’ in the example) to the value of the key pressed and then returns from the subroutine.
After testing the three Columns, the PIC then sets the signal going to Row 2 high and again tests the three columns.
In the case of the ‘*’ and the ‘#’ keys, the variable can be given other values (such as 10 and 11).
The variable should also be set to another value (such as 13) if none of the keys are being pressed.
The main program can then check the value of the variable to find the key that has been pressed.
Because a PIC works so quickly the entire scanning process can be completed in a very short time (about a hundredth of a second).
- Entering data into a PIC-based system
The keypad can be mounted on the case, with wires connecting it to the PCB, or it can be mounted directly on the PCB (which gives a more reliable connection).
If it is PCB-mounted, double sided terminal pins can be used to make connections between the PCB and the pads on the keypad (the holes in the keypad pads need to be slightly enlarged to allow the terminal pins to fit).
Use a multimeter on the resistance setting to check that the columns and rows are connected in the way that you expect when the keys are pressed.
After connecting the keypad, the PIC and an output device, write a test program to test just one switch. Then write a set of programs each of which test a different row.
If there is a fault, check:
- the row and column connections are as expected;
- the connections to the PIC signals and the software correspond;
- the tracks and solder joints.
Return to list of datasheets