'Best DEBOUNCE - DEBOUNCE - DEBOUNCE _|-|_|-|_|___'
Ultra Control Sdn. Bhd.
Anyone for the old Debouce challege:
I hooked a push to make switch at RA1 of a PIC16F84.
The other end to the ground. And connected to the +VDD is a 15KOhm
What is the fool proof way to read the key? I used the code below with
inconsistent result although is does work. Or any recommendation of a
configuration. WWW site welcome.
SCAN MOVLW 0XFF ;Init Port A as input
TRIS PORTA ;
KEY_LO BTFSC PORTA, 1 ;Key Press down = 0
GOTO KEY_LO ;Keep scan till LO detected
CALL DELAY ;Debouce, dont scan for
CALL DELAY ;
CALL DELAY ;
CALL DELAY ;
KEY_RLS BTFSS PORTA, 1 ;Key Release
You may want to use 20 or 30 ms. 500 ms may be a bit too long. Depending on
the app you may want to go on the app then check the key again. I've found
little reason to wait on the key in most cases, but again that depends on your
application. I personally think key debouce is over rated. Unless the key is
processed within 5 or 6 ms, forget about it. I'll probably have a lot of
critics on this opinion, but it works for me. Good luck. Matt.
|Ultra Control Sdn. Bhd. wrote:
> Anyone for the old Debouce challege:
> What is the fool proof way to read the key? I used the code below with
> inconsistent result although is does work.
Code reduces to:
Wait for key_down
Wait for key_up
I substituted 50ms since, as others have noted, it«s more like a
useful debounce period. First problem I see is that if your operation
executes and loops back very fast, the "release" bounce will trip the
wait for key_down immediately. You may therefore wish to put a second
delay in the loop somewhere.
The only other matter I notice is that I very rarely think of waiting
for one keypress as the only function of the system ("Busy wait"). This
is significant as the "other" jobs you may want to do whilst waiting
often provide a very useful debounce delay.
The Stamp code "BUTTON" uses this beautifully. Look at
http://www.dontronics.com/see.html#button for ideas.
> Or any recommendation of a cheap hardware configuration.
Cheap? Ha! Cheapest is (usually) software!
>> Or any recommendation of a cheap hardware configuration.
Two cross-coupled gates (really a SR flip-flop) or a single non-inverting
buffer with out tied to in are "classic" hardware debouncers (for SPDT
switches), and cost only the price of coupla logic gates: a few cents.
But software may be cheaper, depending on the cost of your time :-)
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- New search...