Author Topic: 0ms Switch Debouncer  (Read 2592 times)

0 Members and 1 Guest are viewing this topic.

Offline deadall127

  • Thread Starter
  • Posts: 17
  • Location: France
0ms Switch Debouncer
« 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:



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]--;)
« Last Edit: Sat, 12 November 2016, 05:51:17 by deadall127 »

Offline tufty

  • Posts: 347
  • Location: French Alps
Re: 0ms Switch Debouncer
« Reply #1 on: Sun, 13 November 2016, 07:37:29 »

Offline bpiphany

  • Posts: 1033
  • Location: Stockholm, Sweden
  • bpiph is a special type of crazy. //mkawa
Re: 0ms Switch Debouncer
« Reply #2 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.

Offline dorkvader

  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: 0ms Switch Debouncer
« Reply #3 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.

Offline deadall127

  • Thread Starter
  • Posts: 17
  • Location: France
Re: 0ms Switch Debouncer
« Reply #4 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:

Offline bpiphany

  • Posts: 1033
  • Location: Stockholm, Sweden
  • bpiph is a special type of crazy. //mkawa
Re: 0ms Switch Debouncer
« Reply #5 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.
« Last Edit: Mon, 21 November 2016, 00:45:28 by bpiphany »

Offline wolfv

  • Posts: 269
Re: 0ms Switch Debouncer
« Reply #6 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