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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/26/07 03:08
Read: times


 
#144997 - Debouncing
Responding to: ???'s previous message

Most mechanical switches have a problem called bouncing. If you're switching a light bulb it is not a problem as the light bulb and most likely our eyes would not see it, however, a microcontroller is much faster! There is an amazing amount written about this problem on the 'net - search for Ganssle and debounce. Anyway, using an interrupt for a keypress it not really a good idea - you have no control over how many interrupts will happen on the switch inputs - you might get interference from a mobile phone that will inject interference and cause too many interrupts and cripple your processing. Switches are slow, switches operated by humans are even slower. My usual arrangement is to have a timer tick set for 10mS. In this timer tick ISR you can read the switch inputs and debounce them. My usual technique for debounce if if the switch has been activated for 4 consecutive ticks, is is active otherwise it is not. My timer tick also sets a flag that my main code waits for timing purposes.

If you want to use the switch interrupts to wake the processor - this is ok, but disable the switch interrupts once the processor is awake then use the timer tick to process the switches as described.


List of 6 messages in thread
TopicAuthorDate
ISR Keyboard            01/01/70 00:00      
   How to use the 'Insert Code' button            01/01/70 00:00      
      much better view            01/01/70 00:00      
         Debouncing            01/01/70 00:00      
   Debouncing etc is far easier handled            01/01/70 00:00      
   see the FAQ            01/01/70 00:00      

Back to Subject List