Our Latest News

Microcontroller captures multiple key signals with one I/O

Using the features of analog-to-digital conversion (ADC) it is possible to implement a microcontroller with one I/O to capture multiple key signals.

I. Brief description of the I/O port of the microcontroller for key detection

As we know, in general, a single I/O port of a microcontroller can only detect and recognize one key if it is used as a normal I/O port.

In daily design, if you encounter a large number of keys, you will use a row keyboard, such as the most common 4X4 matrix keyboard, which can achieve the detection of 16 keys with 8 I/O ports.

There is also the keyboard interface, typically the keyboard used on our computers, which uses the PS/2 interface, and now generally used on computers with a USB interface keyboard.

There is also the use of serial or IIC, SPI interface keyboard chip, these use the common serial, IIC, SPI communication protocols to achieve.

But these are more than one I/O port, not really with multiple keys.

So is there a simpler way to detect more keys using fewer I/O port resources?

Second, the AD keyboard based on analog-to-digital conversion

We know that key detection is actually detecting the high and low level value of the port connected to the key. When detecting a single key on a single I/O port, it is simply a matter of determining whether the level of the port connected to the key is high (+5V) or low (0V). So is it possible to detect if a key is pressed by a small change in level?

The following diagram shows the schematic of an A/D keyboard. From the diagram, it can be seen that when different keys are pressed, the voltages at the ADC endpoints are different, and by judging the different voltage values, it is possible to determine which key is pressed.

For microcontrollers with AD conversion, it is sufficient to connect directly to an AD channel. For microcontrollers without AD conversion function, an AD conversion module can be used.

For this kind of key, there are the following disadvantages.

1) For the voltage value at the same point, the results of A/D multiple sampling cannot be exactly the same.

2) The error of the resistor. The resistor value has a large error due to the accuracy of the resistor and the ambient temperature, so the voltage division at each key point of the A/D keyboard is not accurate.

3), in order to minimize the error, you can take to increase the resistance accuracy, increase the temperature compensation and other methods, in addition to the software processing to pay attention to eliminate key jitter and other factors, but also the actual conversion value and the standard value to give error compensation.

4) If the key is pressed, after A/D conversion, if the actual conversion value is within the allowable error range (need to actually measure the voltage at each point and calculate the average value of the voltage at each point), the key is considered pressed, otherwise the program does not respond.

5), the actual test process, but also consider the cumulative error of the resistor, the higher the precision of the resistor selected, the more the number of keys can be distinguished.

    GET A FREE QUOTE

    FPGA IC & FULL BOM LIST

    We'd love to

    hear from you

    Highlight multiple sections with this eye-catching call to action style.

      Contact Us

      Exhibition Bay South Squre, Fuhai Bao’an Shenzhen China

      • Sales@ebics.com
      • +86.755.27389663