Hardware resource implications
While it does not require on-chip facilities (such as timers etc.), the keypad scanning process imposes both a CPU and memory load.
Reliability and safety issues
Keypad scanning is a software-based technique, closely related to SWITCH INTERF ACE ( SOFTW ARE ) [page 399]. In a hostile environment, use of a keypad may provide a less reliable solution than use of a number of individual switches with a hardware inter- face (see SWITCH INTERF ACE ( HARDW ARE ) [page 410]).
However, particularly where a large keypad – such as a QWERTY keypad with around 30 keys – is required, use of separate switches may be impractical. The safest thing to do in such circumstances may be to use a shared-clock scheduler (see Part F), and have a second microcontroller link to the keypad. This ‘keypad microcontroller’ should then have a separate power supply, and should be opto-isolated from the main system board.
Portability
This code is highly portable and this approach to keypad scanning is very widely used.
Overall strengths and weaknesses
Multiplexed keypads are easy to use and inexpensive.
Because the pattern is software based, minimal protection against ESD and malicious damage (for example) is provided: use of a separate, isolated, keypad processor may be necessary if the reliability of the main processor is essential.
In harsh environments, it may be safer to avoid multiplexed keypads and use individual switches.
Related patterns and alternative solutions
See SWITCH INTERF ACE ( SOFTW ARE ) [page 399] and SWITCH INTERF ACE ( HARDW ARE ) [page 410].