Close

Re: switch bouncing

A project log for Pro Trinket USB Keyboard

A USB keyboard for custom shortcuts based on the Pro Trinket and Pro Micro

stefan-lochbrunnerStefan Lochbrunner 05/20/2015 at 23:359 Comments

I played around with some capacitor values to get rid of the bouncing of the tact switches. I tried some caps in the pF an nF range but they either had no noticeable effect or lead to the neighboring button in the next column being read as pressed as well. Implementing a proper RC filter (with no footprints for the resistors) didn't improve it much either. However, adding some software debouncing in the form of 250us delay after a column is polled pretty much got rid of the bouncing, I haven't been able to replicate the issue since. This goes for for all of the above mentioned configurations (including no caps) so I'm glad I won't have to change the PCB... at least until a major redesign.

Discussions

davedarko wrote 05/21/2015 at 00:03 point

http://pcbheaven.com/wikipages/How_Key_Matrices_Works/

could it be that you have some ghosting issues as well? Maybe the encoder pollutes a switch sometimes? anyway, debouncing has to be taken care off, too.

  Are you sure? yes | no

Stefan Lochbrunner wrote 05/21/2015 at 10:32 point

Yes, ghosting could be an issue, too. I didn't take this into account when planning the device but I don't think it's a problem in this case. When the buttons are programmed with key combinations (for each key) there should be no need to press multiple buttons simultaneously. As I mentioned in the last log, I also don't think one's going to do fast typing on it, which might also cause ghosting. That's due to the way I see this device being used and the "click action" of the buttons. I know I'm making a lot of assumptions here but otherwise complexity would rise and I'm trying to keep the cost down.

Regarding the encoders, since the rotation is read on two pins that are separate from the key matrix the only way of pollution/interference is also ghosting. But for that to happen you'd have to turn two encoders and press a button which is unlikely. There are use cases where this could happen (mixing music maybe?) but the ones I'm thinking about require less "action". I'm thinking about things like:

Default/Multimedia: copy/paste/cut, change window/tab, close window/tab, volume, mute, play/pause, fwd/rew,...

Eagle: Zoom, scroll (which is a pain on a laptop with only a trackpad), undo/redo, tool selection

Photoshop (or any other image editing software for that matter): Zoom, brush size, tool selection

Maybe in the future I'll take care of the ghosting but as you said bouncing is the major issue that has to be fixed first. I also had quite some variation in the individual switches where only a few exhibited bouncing and others didn't. But that has to be expected when you buy the cheapest ones off of eBay ;)

  Are you sure? yes | no

davedarko wrote 05/21/2015 at 11:09 point

Thanks for replying :) Regarding your expected use cases you're totally right, you should be fine. But be sure to expect the unexpected use case - people always surprise me with ways to brake or repurpose things, you'd never thought of... anyway, happy hacking, good to see someone keeping up the work from the trinket contest :) 

  Are you sure? yes | no

Stefan Lochbrunner wrote 05/21/2015 at 11:57 point

Thanks. Yeah, I've had it happen before, too, that people do that. At first you try to think of every possibility and then get stuck with those ideas. Another thing I'd like to use it for, is to control the software for my Xprotolab Plain, where the buttons and encoders are pretty much like the controls on a proper oscilloscope.

What use cases do you see for such a device?

  Are you sure? yes | no

davedarko wrote 05/21/2015 at 12:03 point

A midi controller would come up instantly, people love that :D may be a serial controller for a robot arm? I don't know. 

  Are you sure? yes | no

Stefan Lochbrunner wrote 05/21/2015 at 12:23 point

I kind of saw the midi controller coming ;)

Midi and serial are both kind of out of the scope of a USB keyboard though, aren't they? Oh the other hand, if the provisions for a proper keyboard are in place, anyone who is interested could hack it into a midi device, especially with most of the pins available on the Pro Trinket footprint.

Thanks for the input :)

  Are you sure? yes | no

davedarko wrote 05/21/2015 at 12:49 point

you should check the projects on the V-USB page https://www.obdev.at/products/vusb/projects-de.html - especially the interfaces and adapters page ;) 

  Are you sure? yes | no

Stefan Lochbrunner wrote 05/21/2015 at 14:39 point

I looked through these projects a couple of times before but was never really interested in midi. That must be why I didn't remember these midi over USB projects which would only be a software change to this project. Oh well, I guess people who need a better key pad will have to wait for the redesign with all sorts of optional footprints ;)

  Are you sure? yes | no

davedarko wrote 05/21/2015 at 15:13 point

I've never done anything with midi before... but it was something that came up - especially because of V-USB. 

  Are you sure? yes | no