??? 09/05/04 10:13 Read: times |
#76906 - debouncing for matrix keypad ? |
Dear friends :
Hello, today I was thinking about necessity of debouncing mechanical keys when reading a matrix keypad. In most routines for scanning a matrix keypad, a part of the routine is dedicated to debouncing but really is it necessary ? First theory : when a mechanical key is pressed it bounces(the output has voltage transients before becoming stable). As in following scheme I connect microswitch output (which due to be read by mcu) via a relatively strong pull up (for example 4.7 K) Ok, let’s assume it bounces like what has been shown by kai klaas earlier. Keypad scanning routines usually read pins with intervals of 15-30 ms. Even if first reading is wrong because of bouncing (i.e. pin is read low instead of high) second reading after say 15ms will be high. And if first reading is high after 15-30 ms output is stable anyway and will remain high. As it comes to detecting how long a key is pressed down( repeats), it is the same story because as long as the key is pressed down there is no bouncing. Please consider because of the strong pull-ups there is no danger of reading a glitch. Now experimental: I was rather surprised when I saw actual bouncing of a micro switch on an oscilloscope because it was much smoother than I was expected here is one of the worst cases I saw in scope please consider most of the pressings and releasings of the micro switch was even smoother than this. ![]() Best regards Reza |