geekhack

geekhack Projects => Making Stuff Together! => Topic started by: deadall127 on Sat, 12 November 2016, 05:48:26

Title: 0ms Switch Debouncer
Post by: deadall127 on Sat, 12 November 2016, 05:48:26
I was searching some informations about custom keyboards and I found something about chattering, so I've made a circuit to correct that:

(http://i.imgur.com/OSEj32n.png)

the sine signals and the op-amp are just here to simulate a switch bouncing

for a software implementation, the idea is very simple: once the signal state changes, wait (settable amount of time)ms before refresh that key state

to do that, we could start with an array of unsigned integers (char, short, int, long) and obviously a boolean output array
then if the coresponding number of switch in the array == 0 && if a switch state change is detected (hardware signal != output array)
{
   put a number into that array (depending on the frequency of matrix sweep and the time setted) and change the state of the switch in the output array (output_array[that switch] = ~output_array[that switch])
}
else decrease this number (array[that switch]--;)
Title: Re: 0ms Switch Debouncer
Post by: tufty on Sun, 13 November 2016, 07:37:29
http://www.eng.utah.edu/~cs5780/debouncing.pdf
Title: Re: 0ms Switch Debouncer
Post by: bpiphany on Tue, 15 November 2016, 01:22:50
If only there was a double throw keyboard switch. Then we could start talking hardware de-bouncing for real.. Latches should be cheap enough to sprinkle a board with =)

Noise would be a potential party stopper. Software de-bouncing is also effectively a form of de-noisification. Taking away the bounce may potentially make noise apparent instead.
Title: Re: 0ms Switch Debouncer
Post by: dorkvader on Wed, 16 November 2016, 20:56:22
If only there was a double throw keyboard switch. Then we could start talking hardware de-bouncing for real.. Latches should be cheap enough to sprinkle a board with =)

Noise would be a potential party stopper. Software de-bouncing is also effectively a form of de-noisification. Taking away the bounce may potentially make noise apparent instead.

get analog switches like hall effect (as well as some capacitive and inductive designs, etc), and only actuate when the analog signal passes a threshold.
Title: Re: 0ms Switch Debouncer
Post by: deadall127 on Sun, 20 November 2016, 15:22:49
thanks for the comments; I'm studing electronics so I've made an electronic circuit but the main goal of my post was to talk about software implementation and share something that I've never seen (null delay sounds interesting right?) and the idea is simple :3

obviously the chattering is a mechanical-switch-only problem so hall effect and topre switches don't need that :cool:
Title: Re: 0ms Switch Debouncer
Post by: bpiphany on Mon, 21 November 2016, 00:41:09
I think many firmwares are actually implemented just like this. They actuate on anything, and then de-bounces (keyboards are usually negative logic though). This requires that there are no spurious signals.

Isn't deciding whether an analog signal is a digital 1 or 0 inherently a "bouncy" process as well? The transition perhaps is a lot more smooth and tidy, bet there is still a transition phase where anything can happen. Unless of course you have upper and lower thresholds, in a schmitt trigger manner. A dual throw switch with SR-latch de-bouncing uses the mechanical hysteresis of the switch rather than that of the electrical signal. I just find that an incredibly neat idea =)

Edit: An RC-filter and a schmitt trigger would also in effect turn a digital switch into an analog with hysteresis de-bouncing.
Title: Re: 0ms Switch Debouncer
Post by: wolfv on Mon, 21 November 2016, 07:21:31
This debouncer, implemented in firmware, takes care of debouncing and rejects spurious signals:
https://github.com/wolfv6/keybrd/blob/master/src/Debouncer_Samples.cpp