De-bounce with R-C

manie

Senior Member
BB: you mention in your 'x2' thread here:
http://www.picaxeforum.co.uk/showthread.php?t=12505

that adding the R-C helped to de-bounce the switches. Can you post a text-schematic as how the components were placed please ?

EDIT: Can this be done on an analogue voltage single pin keypad input to the Picaxe ?
EDIT-2: Would this be like a "low-pass" filter circuit ?
 
Last edited:

hippy

Ex-Staff (retired)
It doesn't seem likely an analogue keypad can be debounced with an R-C as what the voltage is indcates what the key pressed was. The way to do this is to have a key read routine which returns 'none' or an ID of the key pressed. Debouncing would best be done in software; multiple reads until two or more same ID are seen in sequence.
 

manie

Senior Member
Hippy: Thanks, thats how I do it now, also 3-read average seems to work OK to see if key-press is in the "range".
 

ylp88

Senior Member
The RC circuit does act as a low pass filter, with the effect of ignoring the bounces (which are short, and thus are primarily high frequency components).

For digital switches in my circuits, I usually use a 10k pullup with a 0.1uF in parallel with the switch to ground.

ylp88
 

BeanieBots

Moderator
For straight forward 'debounce' you can't get simpler than a pause within your code. The X2 example you quoted REQUIRED external debounce because it involved the dedicated interrupt pins AND used edge triggering. The X2 is so fast that the 'bounce' could be seen as multiple pushes of the switch.

As Hippy states, for an analogue version, it is the actual voltage which dtermines the pin push, hence, the software has no other option than to wait until it has settled for reliable readings. Adding an RC filter could actually make things worse.

This really is a question of 'horses for courses'.
To answer the question for yourself, consider what is actually happening.
How will your circuit/code behave if a the button is:-
Pressed for a few mS, released for a few mS then pressed again. Maybe several times. In most cases, you can simply add a short pause to get around the issue.
 

manie

Senior Member
The code I currently use is below:

Code:
ReadKey:			'do keypad analog read

temw2=0
cntb1=0
	do until cntb1 = 3
		pause 10
		readadc10 0, temw1			'get key anal value
		if temw1>490 then
			temw2=temw2+temw1
			inc cntb1
		end if
	loop
	temw1=temw2/3
	high 6
	pause 400				'time to release key,flash Kbd-Led
	low 6
return
If it can be improved, then kindly make suggestions...
 
Top