??? 09/06/04 08:35 Read: times |
#76951 - almost Responding to: ???'s previous message |
Dear abhishek,
Hello, thank you for your reply. as you know, keypad scanning routines are usually called within a timer ISR with intervals of 10-30 ms(some engineers have recommended longer intervals) and usually after reading pins they save the value in a variable and compare next reading and only if the same pin was in signaled state again they report a pressed key. That’s a good practice to make sure that what has been read is not noise transient (EMI). Because most likely noise transients are not going to last for 10-30 ms. That’s a very good practice and I am strongly in favor of it. But when we use a strong pull –up, normal noise sources cannot cause a transient and hence a false signal. So the question remain why still double check validity of an input from matrix keypad. Some users argue that it is because of debouncing of the tact switch and I argued let it bounce because when we read a 0 from pin and we are sure it is not because of noise, it doesn’t matter that the tact switch is in bouncing state or not because in both situations we have received a valid signal from the tact switch and we can deliver it without contemplation to the program. if i'm right this can be done following way 1.read the key if it is down go to step 3. 2. perform debaouncing delay. go to step 1 3. exit Actually it is simpler that that : 1.read the key if it is down report it to the program otherwise exit(until next call) in best case you will save 100 msecs. but this saving is not significant as you must delay again to achieve certain repeat rate of the keystrokes. this may be benificial if you dont want to repeat the keystroke and use it only once. The best that can be saved by this method are: 1- CPU burden is decreased because of not performing debouncing(I admit that this decrease can be very slight) 2- The chance of reporting keys to your program more real time is increased. Unfortunately with not performing debouncing intervals of calling scanning routine can not be increased at all because it is true that in the best conditions mcu might detect a pressed key with the next calling of scanning routine but there is a chance that that mcu miss that opportunity because of bouncing of tact switch and then mcu will detect it in second next call ( like when it performs debouncing). Thank you very much |