Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Button debounce tips?

Status
Not open for further replies.

ltg

Member level 4
Joined
Feb 24, 2002
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
533
button debounce

Hi,

Can anybody give me a smart button debounce algorithm without using time delays? Thanks!

Best regards,
ltg
 

debounce button

For which MCU and which language, C or assembler?
 
  • Like
Reactions: keeloq

    keeloq

    Points: 2
    Helpful Answer Positive Rating
pic debounce

Hi,

Sorry for unclear information. It for 8-bit and 16-bit MCU and in language C.

Best Regards,
ltg
 

debounce in c

I use it by detecting DTMF tones. kt3170.. and 16f84..

It is not important long press or short presss for any time:

for example:

loop:
....
....

if button=0 then loop

if button=1
pause 50ms
if button=0 then loop

loop2:
if button=1 ?
goto loop2

..
..
..

end
 

button debouncing

If you are using interrupts simply read your button(s) periodically (for example 50 times per second).

All you have to do is take the last button state, compare it to the current button state and if anything has changed report it to your main program and keep the current button state as last button state.

hope this helps
 

debounce c

If you want something different, take a look at a smart routine here:

hxxp://www.dattalo.com/technical/software/pic/debounce.html
 

debounce algorithm

I agree with C-Man. In most applications, the simplest solution is to sample the button at a steady rate. Use a D-flop and clock, or a software timer interrupt. I usually set the sampling period to be at least twice the worst-case bounce duration. If the button bounces 10 ms, I'll set the clock to 50 Hz.
 

how to debounce a button

Hello,

I'm using RTOS and never had such problems. The task that scans the keyboard, wakes up every 10-20ms and read the key status. If there is toggle 1-0 I report key pressed. Using RTOS is very easy to build "long press" buttons, where you can change the functionality of the same key - fast press - INC/DEC, long press - ENTER.
Trust me, for keys and buttons scan RTOS is one excellent solution.

While the task is waiting (10-20ms) other tasks continue working. The whole project becomes very reliable, with smooth operation.

Best regards
Luben
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top