1
\$\begingroup\$

I just want to ask how is one of the basic components of electronics a push button implemented in professional grade equipment?

The most basic of a tactile switch circuit might look like this:

enter image description here

This itself is good enough in theory, but we know that in practice we will encounter some problems; such as switch bounce. It can solved by adding capacitors on the switches, adding a delay in your code and checks again if it was a valid press, or doing both. This solution is simple and easy to do, and is the go to of almost everyone doing DIY.

Now for my question, how do big companies where a button not registering could mean bad PR for their products and their brand. Examples of what I mean are, iPhone's (or other phone brands) home and volume button (6 plus and older on iPhones), keyboards, mice, arcade games, etc.

Here are some of specific questions on my mind:

  • on high end keyboards that has "anti ghosting", how did they implement this anti ghosting feature? Is this done in hardware or software or both? Are they still using a matrix of buttons to save some space on the keyboard chip?
  • Is there an IC for buttons that handles everything (or most), pull down/ups, capacitors, multiple button press, or some other feature, that just send a very clean signal to your controller chip/computer?
  • In software what are best practices in registering a button press, rising/falling edge, the classic approach, interrupts?
\$\endgroup\$
2
  • 3
    \$\begingroup\$ Jake, there isn't a single, bright-line answer. Even the examples you provided would likely have quite different answers: arcade game vs volume button, for example. Imagine what customers expect regarding responsiveness and accuracy when running Mario Cart as opposed to when pressing a volume-up button. Or when pressing an emergency shutdown button for a sawmill's saw? Best practices are associated with the application and context and regulation environment, to name just a few elements. The scope of your question would require a large book, I fear. \$\endgroup\$
    – jonk
    Aug 8, 2019 at 21:40
  • \$\begingroup\$ @jonk i guess what i am trying to get from this question, it would seem that i would be designing a lot of custom circuits for my projects and would like to know of a go to reliable solution for buttons. A clean signal for a microntroller/computer to read. So an IC perhaps ( well everything is an IC, a full bridge rectifier can even be an IC ). \$\endgroup\$
    – Jake quin
    Aug 9, 2019 at 20:57

5 Answers 5

2
\$\begingroup\$

First of all, bear in mind that all the approaches you cite are valid, it all depends on a lot of variables such as cost, space, already validated solutions, and so on.

To get to your questions:

  • I assume anti ghosting is some sort of feature that avoids registering double strokes, when the user only did a single stroke. But what is a double stroke? There is a time limit below which you say that the double stroke is invalid, e.g. 100 ms -> this is done in software.
  • yes, keys are organized in a matrix to save IOs. Keyboard controllers are IO limited, i.e. the silicon itself can be very small, but you need the IOs, so the full solution will be big (silicon + package). Matrix means less IO means less space means more money for your company
  • there are keyboard controllers with USB connection on one side, and 10x10 or 10x12 matrix on the other side, they take care of everything
  • best practice depends on what is best for your case, rising or falling edge depends if you want an action to happen on keypress, or key release. Interrupts is usually the way to go, but polling is acceptable in many cases too... Again, it all depends.
\$\endgroup\$
1
\$\begingroup\$

A keyboard tend to be inexpensive, extremely high volume products that can support the development and use of a specialized IC. Any extremely high volume product are is likely to use a specialized IC designed specifically to support many of the function required by that task. At some point, it's so ubiquitous that it becomes integrated onto an MCU (like capacitive touch).

There are dedicated debouncing ICs. I don't know of any that generally handle multiple button presses and holding or anything like that. But I'm sure some specialized ones exist for use in things like clocks, but they probably don't only do debouncing.

\$\endgroup\$
1
  • \$\begingroup\$ after googling debouncing IC, i found some that i might like to try out . Thanks ! \$\endgroup\$
    – Jake quin
    Aug 9, 2019 at 20:56
1
\$\begingroup\$

Keyboard circuitry looks like this, most of the debouncing is handled in the mechanical design. There is a pad and then a dimple on the opposite side, when a key is depressed they touch. This is somewhat different from other switches that have springs, the bigger the spring the more likely it is to bounce. Since keyboards have metal contacts that are small and dampers below the keys they are less likely to bounce.

Earlier keyboards did have springs and needed some debouncing, modern keyboards use a membrane switch that is not as 'bouncy'.

enter image description here
Source: http://www.technologyuk.net/computing/computer-hardware/keyboard.shtml

Is there an IC for buttons that handles everything (or most), pull down/ups, capacitors, multiple button press, or some other feature, that just send a very clean signal to your controller chip/computer?

It's typically on IC with maybe a few passives like pull ups something like this:

enter image description here
Source: http://www.quickbuilder.co.uk/qb/libs/dataentry.htm

In software what are best practices in registering a button press, rising/falling edge, the classic approach, interrupts?

The first thing you need is a cleaned up signal from the switch, and usually to limit switching that happens faster than the clock signal. There are a few ways to do this:

1) On an FPGA or ASIC use a dual rank synchronizer to sync with the clock to prevent metastabilty

2) On a regular microprocessor use a Schmidt trigger with some hysteresis before connecting to an interrupt or GPIO.

\$\endgroup\$
0
\$\begingroup\$

Many finished products that are going to recognize a bounce will recoginze that using a microcontroller of some kind. Often as part of the code for that micro you have a "debounce" built in that will account for this. Often a reference of the number of time to count the button over a set period of time. Usually in microseconds.

On a basic level Arduino has a sample debouce code they offer. This may lead you down the right path. https://www.arduino.cc/en/tutorial/debounce

\$\endgroup\$
0
\$\begingroup\$

When looking at keyboards of electronic instruments, they have just a diode for each button which enables the matrix to detect any combination without issues. Also with computer keyboards the keys can be arranged so that there is extra room in the matrix so in practice when using ten fingers it is impossible to hit a combination that would cause problems. If only using a handful of buttons then they can be read without a matrix, like the NES and SNES controllers. There has been a standard logic chip to scan a button matrix but it has been long obsolete. Instruments usually just scan the matrix in software. A microcontroller would just poll the matrix periodically, perhaps in a timer interrupt, or in the case of a PC keyboard, it has literally nothing else to do so it can just poll it all the time unless USB peripheral interrupts when it needs attention.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.