Implementing Debounce logic for Push button

Thread Starter

RaviKumar.N

Joined Nov 24, 2005
4
Hi All,

I am Raviumar.N. I have used push buton in my application.

The push-button is connected to INT0 of the 8051 microcontroller. The moment push-button is presssed, INT0 will be fired and the corresponding work will be done within the ISR.


When the Push-button is pressed once, the interrupt has to fire only one time. But, for a single press of the Push-button, the ISR will be executed will be executed 'n' times.

This 'n' may vary between 20 - 40 times.


Please provide me the solution for this.

Regards,
Ravikumar.N
 

n9352527

Joined Oct 14, 2005
1,198
Disable the corresponding interrupt to prevent re-entrant. Enable it back once the button has been released after down for a preset amount of time (button register time).
 

beenthere

Joined Apr 20, 2004
15,819
Hi,

Just to expand a little - always disable all interrupts as soon as one is detected. Handle the interrupt, and then, at the last step, reenable interrupt handling. To save some other possible headaches, you might also locking out the button input until it has been inactive for some tens of milliseconds. A good design in an interface will pass only one interrupt signal per input, whereas your button can stay down for a long time in computer terms.
 

chesart1

Joined Jan 23, 2006
269
Hi,

You could design a one shot circuit that sends a single pulse to the 8051 each time the push button is depressed. Another words, your one shot will react to a rising or falling edge rather than a level.

One idea would be to design the one shot circuit so that the interrupt occurs when the push button is released. This would solve the problem you described in your message.

One additional suggestion. If both your main program and your interrupt servicing routines are modifying the same RAM location, you could run into some strange problems.

John
 
Originally posted by RaviKumar.N@Feb 15 2006, 07:50 AM
Hi All,

I am Raviumar.N. I have used push buton in my application.

The push-button is connected to INT0 of the 8051 microcontroller. The moment push-button is presssed, INT0 will be fired and the corresponding work will be done within the ISR.
When the Push-button is pressed once, the interrupt has to fire only one time. But, for a single press of the Push-button, the ISR will be executed will be executed 'n' times.

This 'n' may vary between 20 - 40 times.
Please provide me the solution for this.

Regards,
Ravikumar.N
[post=14050]Quoted post[/post]​
 

windoze killa

Joined Feb 23, 2006
605
Originally posted by chesart1@Feb 17 2006, 09:50 AM
Hi,

You could design a one shot circuit that sends a single pulse to the 8051 each time the push button is depressed. Another words, your one shot will react to a rising or falling edge rather than a level.

One idea would be to design the one shot circuit so that the interrupt occurs when the push button is released. This would solve the problem you described in your message.

One additional suggestion. If both your main program and your interrupt servicing routines are modifying the same RAM location, you could run into some strange problems.

John
[post=14089]Quoted post[/post]​
No it won't. If you have bounce in the push button switch you will see that falling edge many times. All the one shot will do is be a buffer to the switch.
 
Top