Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/31/05 01:51
Read: times


 
#94128 - Debounce
Responding to: ???'s previous message
Hi Vignesh,

I just read through the thread and did not find any reference to debouncing the keys ( or if I missed it I am sorry ).

When you are handling key presses without debounce, code like this will produce completely unpredictable results :
while(P0^7==1);
     TR1=1;
     while(P0^7==0);
     TR1=0;


Due to contact bounce, both conditions will be satisfied in rapid succession and even though your code would have been executed, it is of no use to you. The bouncing contact would have simulated many press and release conditions.

Some suggestions to overcome this :

> Instead of querying key presses directly, query the stored image of the key presses. You can run a basic 5ms interrupt based timer and within that ISR update the input key status - and establish a routine to AND the previous image with the current image. The main will then read only the result of this ANDing when it requires to check status of any pin. You will have thus effectively debounced the key presses by 10ms. This is a generic guideline - the timings, methodology etc have to be worked out to suit your specific need.

> Use a hardware debounce chip. Check MAXIM site for options and application notes on this debounce issue.

Raghu

List of 22 messages in thread
TopicAuthorDate
Keil: getting input            01/01/70 00:00      
   If it works in ASM it Works in C            01/01/70 00:00      
      Why C?!            01/01/70 00:00      
         Irrelevant            01/01/70 00:00      
         Of Course            01/01/70 00:00      
   key scan            01/01/70 00:00      
      Delay..            01/01/70 00:00      
         Delay            01/01/70 00:00      
         Software Delay Loops            01/01/70 00:00      
            Software Delay Loops            01/01/70 00:00      
   Learning 'C'            01/01/70 00:00      
   to be precise..            01/01/70 00:00      
      Debounce            01/01/70 00:00      
         completely missed it..            01/01/70 00:00      
      to be precise...            01/01/70 00:00      
         Sorry Leo !            01/01/70 00:00      
         Inferences            01/01/70 00:00      
            Right answer, wrong reason            01/01/70 00:00      
               and therefore            01/01/70 00:00      
            Congratulations            01/01/70 00:00      
               to: Raghu Sir            01/01/70 00:00      
      BIts!            01/01/70 00:00      

Back to Subject List