Simple logic circuit for reading 16-key keyboard through single line

Through a simple logic circuit composed of two Johnson counters, single-line communication and continuous pulse protocol are used to solve the key reading complexity and resource occupation problems when I/O is insufficient, and realize efficient single-line reading of the 16-key keyboard, simplifying Circuit design and resource usage.

CN221929837UActive Publication Date: 2024-10-29SHENZHEN SHENGXI ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202420039486.9
Authority / Receiving Office
CN · China
Patent Type
Utility models(China)
Current Assignee / Owner
Filing Date
2024-01-08
Publication Date
2024-10-29
Estimated Expiration
2034-01-08

AI Technical Summary

Technical Problem

When the number of I/Os in the existing technology is insufficient, when the voltage division detection method is used to read the keys, the complexity is high, the resource usage is large, and the voltage margin is small, which can easily lead to reading errors, especially when the number of keys increases. , the circuit design becomes cumbersome and requires analog input pins, which increases the burden on the MCU.

Method used

A simple logic circuit composed of two Johnson counters is used to read the 16-key keyboard through single-line communication. It uses continuous pulses and high and low level protocols to simplify the circuit design, avoid communication modules and analog input and output, and achieve single-line communication and simple protocols.

Benefits of technology

It achieves simplification of the logic circuit, saves resources, makes it easy to add buttons, avoids coding complexity, and reads the button status through voltage difference detection, improving reading accuracy and circuit stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN221929837U_ABST
    Figure CN221929837U_ABST
Patent Text Reader

Abstract

The utility model relates to the technical field of keyboard logic circuits, and discloses a simple logic circuit for reading a 16-key keyboard through a single wire, which comprises a keyboard circuit formed by two counters, a communication cable between the two counters and a host only needs a single core wire, a single I / O data pin of a host end connected with the keyboard sends out continuous pulses, and the single I / O data pin is connected with the keyboard. The communication protocol of the host is that continuous high and low levels are emitted, the peak value limit of the high and low levels is 0.8-5V, the widths of the high and low levels are 0.8 mS, the keyboard circuit is a 4 * 4 keyboard which is arranged in four rows and four columns, the counter is a Johnson counter, the model of the counter is CD4017, the communication protocol is that the host reads 20-bit data codes during key pressing, every 5 bits form a group, four groups are arranged, and the communication protocol is a single-chip microcomputer. The codes are codes of four keys in each row. According to the utility model, high and low levels are read by utilizing the characteristics that the shift counter expands the key and the threshold value is reached through the increase of the current pressed by the key, the circuit is simple, single-line communication is realized, and resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The utility model relates to the technical field of keyboard logic circuits, in particular to a simple logic circuit for reading a 16-key keyboard through a single line. Background Art

[0002] In a project, when the MCU has enough I / Os, it is common to use matrix keyboard scanning to detect keys. However, when the number of I / Os is insufficient, other solutions must be considered.

[0003] Generally, the voltage division detection method is used, using an off-the-shelf I / O expander or a resistor row to set a unique voltage for each key, and then use the analog pin to read the voltage value to determine which key is pressed. On the one hand, this method requires the I / O expander to read and write data through a special communication protocol (such as I2C or SPI), and the MCU needs to have a built-in communication module, or the user needs to implement the relevant communication protocol software, which significantly increases the burden on the MCU. On the other hand, when the number of keys increases, it becomes cumbersome to assign unique voltages to each key through a resistor row, which will ultimately lead to a smaller voltage margin. In addition, since the resistance value changes with temperature, using a smaller voltage margin may lead to reading errors, and even switch bounce may become an important cause of voltage errors. Another disadvantage of this method is that it requires analog input pins in the MCU, so a simple logic circuit that reads a 16-key keyboard through a single line is urgently needed to solve the above technical problems. Utility Model Content

[0004] The utility model aims to provide a simple logic circuit for reading a 16-key keyboard through a single line, so as to solve the problems raised in the above background technology.

[0005] In order to achieve the above purpose, the utility model provides the following technical solutions:

[0006] A simple logic circuit for reading a 16-key keyboard through a single line includes two counters to form a keyboard circuit. The two counters and the host communication cable only need a single core wire. The single I / O data pin of the host end connected to the keyboard sends out continuous pulses. The communication protocol of the host is to send out continuous high and low levels. The peak value limit of the high and low levels is 0.8~5V, and the width of the high and low levels is 0.8mS.

[0007] As a preferred technical solution of the utility model, the keyboard circuit is a 4x4 keyboard arranged in 4 rows and 4 columns.

[0008] As a preferred technical solution of the present utility model, the counter is a Johnson counter, and the model is CD4017.

[0009] As a preferred technical solution of the utility model, the communication protocol adopts that the host reads 20-bit data code during key pressing, wherein each 5 bits form a group, and there are 4 groups in total, which are the codes of 4 keys in each row.

[0010] As a preferred technical solution of the utility model, the counter CD4017 is a 5-stage counter, which can output 10 parallel data bits and requires 20 bits of encoding, so each counter uses 5 bits of data output.

[0011] Compared with the prior art, the utility model has the following beneficial effects:

[0012] The utility model adopts a shift counter to expand the key, the logic circuit is simple, and the key is easy to add. It saves resources, does not require a communication module, analog input and output, single-line communication, and the protocol is simple and easy to operate. And when the circuit design is successful, there is no need to consider the specific coding. It is only necessary to check the voltage difference caused by the change of the counter current according to the pulse, and use the voltage difference to turn on the MOS tube, so that the host can read the corresponding high and low levels. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0014] Figure 1 This is the 4x4PCB layout diagram of the utility model;

[0015] Figure 2 It is a schematic diagram of the circuit principle diagram of the utility model;

[0016] Figure 3 This is a schematic diagram of the generation process of the Key1 key code of the utility model.

[0017] In the figure: 1. Counter; 2. Button. Implementation

[0018] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant utility model, rather than to limit the utility model. It should also be noted that, for ease of description, only the parts related to the utility model are shown in the accompanying drawings. The different types of section lines in the drawings in the embodiments of the utility model are not marked according to the national standard, nor are there any requirements for the materials of the components, but are used to distinguish the cross-sectional views of the components in the drawings.

[0019] See also Figure 1-3A simple logic circuit for reading a 16-key keyboard through a single line. This solution uses two Johnson counters 1CD4017 to form a 4x4 keyboard circuit. The communication cable with the host only needs a single core wire. The single I / O data pin of the host connected to this keyboard sends out continuous pulses to trigger the shift of counter 1, and starts reading keyboard data when this I / O data pin changes from low to high level. The communication protocol of the host is to send out continuous high and low levels, with a peak limit of 0.8~5V and a width of 0.8mS. Since the minimum trigger pulse width of CD4017 is nanoseconds (nS), this solution is sufficient to meet the requirements.

[0020] A 4x4 keyboard is arranged in 4 rows and 4 columns, such as Figure 2 As shown in the 4x4PCB layout diagram, when button 2 is pressed, there will be one and only one way turned on in the circuit at a certain moment, and when the data pin of U2 counter 1CD4017 is high, the power consumption of U2 circuit increases through circuit design, and the current increases, which is reflected in the increase of the total power supply of CD4017 power supply, thereby increasing the voltage drop of the series resistor of the power supply circuit. This voltage drop is enough to turn on MOS tubes M2 and M6. At this time, the host data I / O reads "0". If it does not affect the working current, that is, when the voltage drop does not change, the transistor is cut off and the host data I / O reads "1".

[0021] The communication protocol of this scheme adopts that the host reads 20-bit data code during key pressing, where each 5 bits form a group, with a total of 4 groups, which are the codes of 4 keys 2 in each row. Before reading the 20-bit data code, the host needs to read and identify 5 high-level and 5 low-level synchronization codes and then read the valid 20-bit key value, that is, the 10-bit synchronization code is "1111100000", which is equivalent to reading 30 coded data bits for one key press, each data bit is 1.6mS, a total of 48mS. Generally, the key pressing time is much longer than this time.

[0022] According to the above scheme, the circuit design is carried out. CD4017 is a 5-level counter 1, which can output 10 parallel data bits and requires 20-bit encoding. Therefore, each counter 1 uses 5-bit data output. As mentioned above, each group of 5 in the 20-bit encoding represents 4 buttons 2 in a row. Therefore, the first CD4017 of U1 takes 4 bits, which are OUTPUT1~OUTPUT4 respectively, and discards data OUTPUT0, such as Figure 3The first bit of every 5 codes is 0. The data pin OUTPUT5 of the first CD4017 of U1 is used as the trigger pulse of the second CD4017 of U2. At the same time, OUTPUT5 is connected to the forced reset pin MR of U1. When the first CD4017 counter 1 of U1 shifts to the 5th data output, the second CD4017 of U2 is triggered and starts to shift. This shift happens to be the 5-bit code group of the first CD4017 counter 1 of U1 moving to the new code segment. The second CD4017 counter 1 of U2 selects OUTPUT0~OUTPUT3. The data output of the second CD4017 counter 1 of U2 The 4th bit, i.e., OUTPUT4 is empty, and the 5th bit, i.e., OUTPUT5 is fixedly connected to the ground with an appropriate resistor. These two bits formally generate the synchronization code. When shifted to the 4th bit of the 2nd CD4017 counter 1 of U2, since this data pin is empty, it is equivalent to that no button 2 is pressed in the normal state, so 5 "1"s are output. When shifted to the 5th bit of the 2nd CD4017 counter 1 of U2, since this data pin is fixedly connected to the ground with a resistor, it is equivalent to that button 2 is pressed in the normal state, so 5 "0"s are output. When shifted to the 6th bit of the 2nd CD4017 counter 1 of U2, this data pin is connected to the forced reset MR of U2, and U2 starts to reset.

[0023] Circuit principle Figure 2 As shown, the 16-key 2-key keyboard is arranged in 4x4 rows and columns, with a 1.5k resistor in series in each row and a 1.5k resistor in series in each column. The 4 rows where the keyboard is located are connected to the output data pins OUTPUT0~OUTPUT3 of U2 counter 1CD4017, denoted as P1~P4; the 4 columns where the keyboard is located are connected to the output data pins OUTPUT1~OUTPUT4 of U1 counter 1CD4017, denoted as Q1~Q4.

[0024] When the host end DN sends a low level, M6 is turned off and the trigger pulse CP10 is a high level. At this time, U1 counter 1CD4017 starts to shift, that is, it moves back 1 in the order of Q1~Q4; conversely, when the host end DN sends a high level, M6 is turned on and the trigger pulse CP10 is a low level. At this time, U1 counter 1CD4017 remains unchanged (because both U1 and U2 counter 1 choose rising edge trigger).

[0025] When the DN pin changes from low to high, the host starts to read the data code. At this time, if key 2 is pressed, and the row where the pressed key is located is high, that is, the output pins P1~P4 of U2 are high, and the row where the key is located is low, that is, the output pins Q1~Q4 of U1 are low. At this time, key 2 is called a valid key. At this time, part of the power supply current of U2 is consumed by the key, that is, the 5V power supply passes through two 1.5k resistors, that is, the total power supply current of U2 increases by 5 / (1.5+1.5)=1.67mA, and the current flowing through the U2 power supply series resistor R19 also increases by 1.67mA accordingly. Therefore, the voltage drop generated by resistor R19 is: 1.67mA x 1k = 1.67V, that is, the VDD voltage is 1.67V lower than the power supply voltage when a valid key is pressed. This voltage is enough to turn on M2 and make M2 conductive. At this time, M3 is also conductive, and the DN read value is a low level "0". If key 2 is pressed but it is an invalid key, that is, the row where the pressed key is located is not a high level, and the column where the key is located is not a low level, then the VDD voltage is the same as when no key is pressed, that is, VDD is the same as the power supply 5V of U2. At this time, M2 is cut off, and M3 is also cut off. DN reads the high level "1" pulled up by the host end.

[0026] When no button 2 is pressed, the data code read by the DN pin is always high level "1", and when no button 2 is pressed, neither U1 nor U2 will be triggered, so there will be no shift, and therefore no synchronization code will be generated. When P1 of U1 counter 1 is 1, it represents the first group (the first 5 bits) of the 20-bit code, that is, the reading value of DN when Q0~Q4 of U1 counter 1 are 1 respectively. When Q5 of U1 is 1, on the one hand, it triggers U2 to shift, and on the other hand, forces U1 to reset, that is, starting from Q1 being 1. When P2, P3, and P4 are 1, it is the same as when P1 is 1. When P4 is 1, since the corresponding pin of P4 has no peripheral connection, it has nothing to do with key 2, which is equivalent to not pressing any key. At this time, corresponding to the 5-bit shift of U1, the value read by DN is "1"; and when P5 is 1, since its pin is fixedly connected to the ground with a 2.7k resistor, the voltage drop generated by VDD at this time is slightly greater than 1.67V. At this time, no matter the high or low level of the Q0~Q4 output of U1 counter 1, VDD is sufficient to turn on M2, and then turn on M3, and DN reads "0". This is the so-called synchronization code. When P6 is 1, U2 is forced to reset, starting from P1 being 1.

[0027] Take the key 2 at the first row and first column, named "Key'1'" as an example. When it is pressed, the synchronization code and 20-bit code are as follows: Figure 3 .

[0028] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the utility model involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the concept of the utility model. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) by each other to form a technical solution.

Claims

1. A simple logic circuit for reading a 16-key keyboard via a single line, comprising two counters (1) forming a keyboard circuit, characterized in that: The two counters (1) and the host communication cable only need a single core wire. The single I / O data pin of the host end connected to the keyboard sends out continuous pulses. The communication protocol of the host is to send out continuous high and low levels. The peak value limit of the high and low levels is 0.8~5V, and the width of the high and low levels is 0.8mS.

2. A simple logic circuit for reading a 16-key keyboard via a single line according to claim 1, characterized in that: The keyboard circuit is a 4x4 keyboard arranged in 4 rows and 4 columns.

3. A simple logic circuit for reading a 16-key keyboard via a single line according to claim 1, characterized in that: The counter (1) is a Johnson counter, and its model is CD4017.

4. A simple logic circuit for reading a 16-key keyboard via a single line according to claim 1, characterized in that: The communication protocol adopts that the host reads 20-bit data codes during key pressing, wherein each 5 bits form a group, and there are 4 groups in total, which are codes for 4 keys in each row.

5. A simple logic circuit for reading a 16-key keyboard via a single line according to claim 3, characterized in that: The counter (1) CD4017 is a 5-stage counter that can output 10 parallel data bits and requires 20 bits of encoding, so each counter uses 5 bits of data output.