Electronic – arduino – Not debouncing on a MIDI keyboard

arduinodebouncemidiswitches

I am modifying an old 90s keyboard (CTK-450 by CASIO) to make it a MIDI controller. I'm going for an Arduino that goes over the matrix layout of the keyboard.

The issue I have is with debouncing. Now I know the best idea would be to add some small capacitors in there to make sure there are no issues with bouncing switches, but I'm wondering whether I could just ignore the problem. My reasoning is as follows:

  1. I don't really care if I get bogus input, as it's a MIDI controller. It isn't some button that deals with menu scrolling or what not.
  2. The RC circuit on the original PCB for the keyboard is R = 1kOhm, C = 1nF or 0.1 nF depending on the exact circuit, which gives me a time constant t <= 1µs. I'm going to be polling the keystates at a much slower rate to start with (Arduino digitalRead() takes 1-4 µs, and I have to go over around 60 keys plus some overhead), and it's extremely unlikely that the reading will happen exactly at the time the key is in a bouncing state.
  3. Even if I manage to sometimes read the key while the signal is bouncing, it shouldn't really matter. If I read logical low when I just pressed the key, by the time I go through all the keys again, the bouncing will have stopped and I will have a solid digital high to read, and vice versa.

I think the key to this is the fact that the time constant for the RC debouncing filter is so small. Is it really believable that the switches in the keys will have such a short bouncing time? I understand the bouncing time doesn't necessarily have to be the exact same as the time constant, but even if it happened to be a bit bigger, assuming it's around that order of magnitude, arguments 1 and 3 still hold, I would assume.

Thus, can I completely avoid putting those debouncing caps into the circuit, even if in principle, it isn't a good idea for every situation?

Best Answer

I guess the 1us RC lowpass filtering tries to keep off false keyhits caused by phones and other radio transmitters. The debouncing is performed with software.

Do not add slowness to the circuit which detects if a key is pressed. Players hate delays. There's enough it already (MIDI transmission,communication between the MIDI interface and the computer application, sound generating DSP, sound system DSP, distance to the loudspeaker). As much as 20ms total in circuits (+ the distance to the loudspeaker) is well achievable by bad design and it makes a MIDI keyboard painful experience for a competent player.

Make your system to react as soon as possible to a keypress. Leave debouncing delay for the key scanning software and let it affect only to the time when the releasing of the key is taken into the account. Playing a sound a little too long is much less annoying than a delayed start.

A simple debouncing strategy in software is to scan the keys say in every 3 millisecond if the caused 0...3 ms extra delay is not a problem. The maximum value 3 ms is equivalent with about 1 meter extra distance to the speaker which can be acceptable.