Hacker News new | ask | show | jobs
by doix 1351 days ago
I don't get the multiplexer vs matrix argument. Wouldn't multiplexers add their own problems? You need to wait for the output to become stable when you change the input select. I'm guessing as part of the scanning, they are changing the SEL of the muxes and then waiting? The article seems to gloss over that completely.

I would have thought they'd be super cheap anyway, if you're looking at $200 keyboards, spending a dollar or so to get a few muxes doesn't seem like a big deal. If they were truly better, I imagine every keyboard enthusiast would be using them.

Edit: I guess since they have multiple muxes, they change the SEL well in advance before scanning the key. So it just requires "clever" scheduling. Just like a matrix requires "clever" diodes, I really don't buy that muxes are an advantage here.

Disclaimer: somehow graduated with an EE, but am an idiot.

2 comments

Multiplexers are only better for N-key rollover.

The settling time of the switch is the same, regardless of the scanning technique used.

But with a multiplexer, the output of one switch has no impact on the output of another – you can independently actuate each key. They are all essentially isolated switches with individual pull-up resistors.

The multiplexing can be done in a number of different ways, none of which need to be particularly clever. The simplest scheme is simply to connect each key directly to a GPIO on a large-pinout microcontroller, like a TQFP-144. The fewer the keys, the less GPIO you need.

This is the best way to build a keyboard, since input can be done at the clock speed of the MCU, and debouncing can happen on all pins in parallel simultaneously.

Slightly more complex would be to use a smaller MCU with a multiplexer on each input, like a 4051 or 4067. The switching time is like 20-50ns on these parts, so while it's not quite as fast as a GPIO register read, it's still pretty quick, more than fast enough for keyboards.

If you really wanted to get crazy, you could read each switch with a high speed ADC and use an ML model to debounce the keys. But at that point, you're better off just using optical switches which don't really need debouncing.

Okay, I can kind of see how it makes a difference for n-key rollover.

> The switching time is like 20-50ns on these parts, so while it's not quite as fast as a GPIO register read, it's still pretty quick, more than fast enough for keyboards.

I guess my point was that if you change which input you're reading from the mux and then immediately sample with the MCU, you'll get unstable data. 50ns is 20MHz, I can easily see an MCU used in a keyboard being fast enough to hit this.

It's obviously easy to work around, but so is ghosting.

This keyboard actually uses optical switches and reads them using an ADC. It does do debouncing but with orders of magnitude shorter delay.
optical switches don't really use debouncing, it's more of a schmitt trigger where there are different voltage thresholds for key down and key up. As the optical gate closes, the voltage on the phototransistor lowers proportionally to the degree of closure So the only way to get a key down voltage level is to actually travel the switch to the down position, and likewise for key up.
> You need to wait for the output to become stable when you change the input select.

The switching time of multiplexers is on the scale of 100 nanoseconds, so it's negligible (assuming there's no extra RC components behind the multiplexer to lengthen its settling time further, a reasonable assumption for pure software denouncing).