5 ms·
It looks like he keyboard state is read by the driver, rather than the keyboard sending the state to the OS. How would you denounce on a hardware level with suc
by halpert 5y ago
It looks like he keyboard state is read by the driver, rather than the keyboard sending the state to the OS. How would you denounce on a hardware level with such a setup?
- gridspy 5y agoOne way is a RC circuit - where the switch (the keyboard button) in series with a resistor then charges a capacitor. You specify the ratio of resistance to capacitance so it takes long enough for the switch to stop bouncing before the capacitor output rises to the sense level of your digital input. But if you want to reduce hardware cost, you can eliminate many capacitors and resistors by doing it in firmware instead.
- halpert 5y agoI’m not too familiar with hardware, but would you be able to differentiate between the unpressed state with such a scheme?
- alar44 5y agoOf course. Hardware debouncing came long before software. It's basic electronics. Many switches have it built in.
- gridspy 5y agoTypically in a 5v system you'd treat capacitor output voltages under 2.3V as pressed and over 2.3V as released. There is a "pullup" resistor and the switch is wired to "pull down" the circuit towards ground, through the mentioned resistor. Most Microcontrollers have the pullup resistor built in. Modern ones even let you turn the pull-up feature on and off per pin with a SFR (a special register /fixed memory address you can write to where you change hardware settings). Often you can also choose between reading a pin or driving it as an output. The most important thing to know about debouncing is that any hardware switch bounces from 50-200 times over a very very short interval when you press it. You can use an oscilloscope to see that. The bouncing is not as bad on release but I imagine it still exists there too. Another fun hardware trick is that when you turn off a magnet (like a relay) you can get a massive over-voltage pulse back (10x typical drive) for a moment. You need to protect yourself from that, for instance with a Schottky diode. Here's a discussion on that fun detail [1]. [1] https://forum.allaboutcircuits.com/threads/reduce-voltage-spike-on-relay-coil.184312/ https://forum.allaboutcircuits.com/threads/reduce-voltage-sp...
- alar44 5y agoYeah, I get where you're coming from, but a few dozen SMD caps and resistors ordered in that kind of bulk probably raises the cost by a penny. Of course you do technically have more points of failure I guess.
- baybal2 5y agoI had clients who were going to bargain for less than a penny
- spookthesunset 5y agoFor ten million units, a penny is $100,000. You could give an engineer an entire quarter to come up with a software debounce for less than that. That shit adds up. BOM costs are everything for consumer goods.
- bserge 5y ago
- tmzt 5y agoI've always wondered why the same logic doesn't apply to using a commercial BIOS. Doesn't the per-unit cost for someone like Compal add up to more than the value in using a customized Phoenix firmware? Even with UEFI the branded option is generally used.
- alar44 5y agoAnd if you make $10 on each of those that's .1%. Or even if it's only $1 that's 1%. So be it! I don't want to encourage shitty design for pennies at any level. Stop making shitty shit.
- avianlyric 5y agoThere aren’t that many 1% in 100% or even that many 0.1% in 100%. Saving a penny on the keyboard will be one of hundreds of places where a penny was saved. Good engineering and product design is about trade offs and compromise, not taking absolute positions about what’s shitty or not.
- Findecanor 5y agoComputer keyboards tend to have switches in a matrix so that only (columns + rows) number of GPIO pins would be needed on the keyboard controller. Each column gets strobed at once in turn, and the rows sensed. Cherry once made a software/hardware hybrid but it didn't have any advantages compared to software debouncing, and it needed more power, so there was only one model. If I understand it correctly, debouncing with a capacitor delay events somewhat. With software debouncing (done right) you are only required to have a minimum time between the press and release events.