CN117459050A - Capacitive key recognition device and method - Google Patents

Capacitive key recognition device and method Download PDF

Info

Publication number
CN117459050A
CN117459050A CN202311577459.3A CN202311577459A CN117459050A CN 117459050 A CN117459050 A CN 117459050A CN 202311577459 A CN202311577459 A CN 202311577459A CN 117459050 A CN117459050 A CN 117459050A
Authority
CN
China
Prior art keywords
key
capacitor
port
charging
stage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311577459.3A
Other languages
Chinese (zh)
Inventor
陈雪峰
周玉洁
孙坚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hangxin Electronic Technology Co ltd
Original Assignee
Shanghai Hangxin Electronic Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Hangxin Electronic Technology Co ltd filed Critical Shanghai Hangxin Electronic Technology Co ltd
Priority to CN202311577459.3A priority Critical patent/CN117459050A/en
Publication of CN117459050A publication Critical patent/CN117459050A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03KPULSE TECHNIQUE
    • H03K17/00Electronic switching or gating, i.e. not by contact-making and –breaking
    • H03K17/94Electronic switching or gating, i.e. not by contact-making and –breaking characterised by the way in which the control signals are generated
    • H03K17/96Touch switches
    • H03K17/962Capacitive touch switches
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03KPULSE TECHNIQUE
    • H03K17/00Electronic switching or gating, i.e. not by contact-making and –breaking
    • H03K17/22Modifications for ensuring a predetermined initial state when the supply voltage has been applied

Landscapes

  • Input From Keyboards Or The Like (AREA)

Abstract

The invention discloses a capacitor key identification device, wherein a control unit is provided with a plurality of GPIO ports, the GPIO ports comprise control ports, a first detection port and a second detection port, and the number of the control ports is consistent with the number of key capacitors; one end of the key capacitor is electrically connected with the corresponding control port in sequence, and the other end of the key capacitor is electrically connected with one end of the charging capacitor; one end of the charging capacitor, which is connected with the key capacitor, is electrically connected with the first detection port, and the other end of the charging capacitor is electrically connected with the second detection port. The invention adopts the general input/output port of the MCU to simulate and realize the capacitive touch key without a special key touch chip and MCU with specific functions, has strong universality, can realize transplanting only by simply modifying software, has good portability, shortens the development period and saves the application cost. The invention is also used for improving the stability of the touch key through a filtering algorithm.

Description

Capacitive key recognition device and method
Technical Field
The invention belongs to the technical field of circuit design, and particularly relates to a capacitor key identification device and method.
Background
With the continuous development of electronic science and technology, capacitive touch keys are increasingly widely used, and traditional mechanical keys on consumer electronics and household appliances are gradually replaced by capacitive touch keys. The traditional mechanical key has the defects of complex realization circuit, easy abrasion, short service life and poor waterproof performance. The capacitive touch key has no mechanical parts, is not worn, has long service life and reduces the later maintenance cost; the capacitive touch key does not need a human body to directly contact metal, so that potential safety hazards can be eliminated; the capacitive touch key panel has the advantages that the patterns, the key sizes and the shapes of the capacitive touch key panel are designed arbitrarily, characters, trademarks, perspective windows and the like are matched arbitrarily, the capacitive touch key panel is attractive and fashionable in appearance, does not fade, does not deform and is durable; the capacitive touch key sensing portion can be placed behind any insulating layer (typically glass or plastic material) and is easily fabricated into a keyboard that is sealed from the surrounding environment with little impact from the surrounding environment.
Currently, two touch key solutions are mainstream in the market, one is an MCU matched with a special touch key chip, and the other is an MCU integrated with the touch keys. Both the two modes need to have the participation of a touch key module, so that the universality is not strong, the portability of software is not good, the development period is long, and the use cost is high.
Disclosure of Invention
The invention aims to provide a device and a method for identifying a capacitive key, which are used for solving the technical problems of poor universality and high use cost of the conventional touch key.
In order to solve the problems, the technical scheme of the invention is as follows:
a capacitive key recognition device, comprising:
a plurality of key capacitors, a charging capacitor and a control unit;
the control unit is provided with a plurality of GPIO ports, wherein the GPIO ports comprise control ports, a first detection port and a second detection port, and the number of the control ports is consistent with that of the key capacitors;
one end of the key capacitor is electrically connected with the corresponding control port in sequence, and the other end of the key capacitor is electrically connected with one end of the charging capacitor;
one end of the charging capacitor, which is connected with the key capacitor, is electrically connected with the first detection port, and the other end of the charging capacitor is electrically connected with the second detection port.
The control unit is used for controlling each GPIO port to realize different working state stages so as to realize detection of pressed key capacitors;
the working state stage comprises the following steps: a reset phase, a first charging phase, a second charging phase, and a reading phase;
in the resetting stage, the charges of the key capacitor and the charging capacitor are discharged;
charging the selected key capacitor in the first charging stage;
in the second charging stage, the key capacitor charges the charging capacitor;
in the reading phase, the voltage of the charging capacitor is read by the control unit.
Specifically, in the reset stage, the control port, the first detection port and the second detection port are all in an output low-level state;
in the first charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an output high-level state, and the second detection port is in an input state;
in the second charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an output low-level state;
in the reading stage, the selected control port is in an output low level state, the other control ports are in an input state, the first detection port is in the input state, and the second detection port is in the input state.
A capacitor key identification method is applied to the capacitor key identification device and comprises the following steps:
resetting the potential of each GPIO port, wherein the GPIO ports comprise a control port, a first detection port and a second detection port;
in the first charging stage, a control port and a key capacitor correspondingly and electrically connected with the control port are selected, so that the control port charges the key capacitor, the charging frequency is increased by 1, and the charging frequency is recorded;
the second charging stage is to make the charged key capacitor transfer charge to the charging capacitor electrically connected with the key capacitor;
a reading stage, namely, by reading the voltage of the first detection port and judging whether the voltage is high level or not, if so, repeating the first charging stage to the reading stage until all the control ports are detected;
and in the judging stage, the pressed key capacitor is judged according to the charging times of the key capacitor corresponding to each control port.
In the reset stage, the control port, the first detection port and the second detection port are all in an output low-level state;
in the first charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an output high-level state, and the second detection port is in an input state;
in the second charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an output low-level state;
in the reading stage, the selected control port is in an output low level state, the other control ports are in an input state, the first detection port is in the input state, and the second detection port is in the input state.
The judging stage specifically compares the charging times of each key capacitor with a preset reference value, and judges the key capacitor with the charging times smaller than the preset reference value as the pressed key capacitor.
Further preferably, in the judging stage, whether the pressed key capacitor exists or not is also required to be judged, if so, the filtering times are increased by 1, and if not, the resetting stage is skipped; wherein the initial value of the filtering times is 0.
Further preferably, in the judging stage, whether the filtering times are equal to a preset threshold value is also required to be judged, and if the filtering times are smaller than the preset threshold value, the resetting stage is skipped; if the preset threshold number of times is equal to the preset threshold number of times, judging whether the key capacitors obtained respectively are consistent, if so, judging that the key capacitors are pressed, otherwise, jumping to a reset stage.
By adopting the technical scheme, the invention has the following advantages and positive effects compared with the prior art:
the MCU has general purpose input/output (GPIO), the invention adopts the general purpose input/output port of MCU to simulate and realize the capacitive touch key, does not need special key touch chip and MCU with specific function, has strong universality, can realize transplanting only by simply modifying software, has good portability, shortens development period and saves application cost. The invention is also used for improving the stability of the touch key through a filtering algorithm.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention.
FIG. 1 is a schematic circuit diagram of a capacitive key recognition device according to the present invention;
FIG. 2 is a flow chart of the operation of a single key of the present invention;
FIG. 3 is a schematic view of the state of the GPIO ports at each stage of operation of the present invention;
FIG. 4 is a graph showing the relationship between the number of charges and the voltage of the first detection port according to the present invention;
fig. 5 is a flowchart of a capacitive key recognition method according to the present invention.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will explain the specific embodiments of the present invention with reference to the accompanying drawings. It is evident that the drawings in the following description are only examples of the invention, from which other drawings and other embodiments can be obtained by a person skilled in the art without inventive effort.
For the sake of simplicity of the drawing, the parts relevant to the present invention are shown only schematically in the figures, which do not represent the actual structure thereof as a product. Additionally, in order to simplify the drawing for ease of understanding, components having the same structure or function in some of the drawings are shown schematically with only one of them, or only one of them is labeled. Herein, "a" means not only "only this one" but also "more than one" case.
The invention provides a capacitive key recognition device and a capacitive key recognition method, which are further described in detail below with reference to the accompanying drawings and specific embodiments. Advantages and features of the invention will become more apparent from the following description and from the claims.
Examples
Example 1
Referring to fig. 1, the present embodiment provides a capacitive key identification device, including: a plurality of key capacitors, a charging capacitor and a control unit. The control unit is provided with a plurality of GPIO ports, wherein the GPIO ports comprise control ports, first detection ports and second detection ports, and the number of the control ports is consistent with that of the key capacitors. One end of the key capacitor is electrically connected with the corresponding control port in sequence, and the other end of the key capacitor is electrically connected with one end of the charging capacitor; one end of the charging capacitor, which is connected with the key capacitor, is electrically connected with the first detection port, and the other end of the charging capacitor is electrically connected with the second detection port.
Specifically, fig. 1 is specifically illustrated, but not limited thereto. The control unit utilizes 6 GPIO ports of the control unit to conveniently distinguish the control unit from the control unit, and the control unit is named as GPIO1, GPIO2, GPIO3, GPIO4, GPIO5 and GPIO6, wherein the 4 key capacitances Cx1, cx2, cx3 and Cx4 and 1 charging capacitor Cs are arranged in total, and the 4 key capacitances correspond to the key 1, the key 2, the key 3 and the key 4 respectively. One end of the key capacitor Cx1 is electrically connected with the GPIO1 port, and the other end of the key capacitor Cx1 is electrically connected with one end of the charging capacitor Cs; one end of the key capacitor Cx2 is electrically connected with the GPIO2 port, and the other end of the key capacitor Cx2 is electrically connected with one end of the charging capacitor Cs; one end of the key capacitor Cx3 is electrically connected with the GPIO3 port, and the other end of the key capacitor Cx3 is electrically connected with one end of the charging capacitor Cs; one end of the key capacitance Cx4 is electrically connected to the GPIO4 port, and the other end of the key capacitance Cx4 is electrically connected to one end of the charging capacitance Cs. One end of the charging capacitor Cs is electrically connected to the GPIO5 port (first detection port), and the other end of the charging capacitor Cs is electrically connected to the GPIO6 port (second detection port).
In this embodiment, the control unit may control each GPIO port to implement different working state phases, so as to sequentially detect each key capacitance, thereby identifying which key is pressed. Specifically, the working state phase may be divided into: the reset phase, the first charging phase, the second charging phase, and the read phase are described in connection with fig. 3. In the reset stage, charges of the key capacitor and the charging capacitor need to be discharged, namely the control port, the first detection port and the second detection port are all in an output low-level state. In the first charging stage, the selected key capacitor needs to be charged, namely, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an output high-level state, and the second detection port is in an input state. In the second charging stage, the key capacitor charges the charging capacitor, namely, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an output low-level state. In the reading stage, the control unit reads the voltage of the charging capacitor, the selected control port is in an output low-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an input state.
Referring to fig. 1 to 5, the present embodiment provides a capacitive key identification method, which is applied to a capacitive key identification device as in embodiment 1, and specifically includes the following steps. For convenience of description, the naming of the device of embodiment 1 is used in this embodiment, as shown in fig. 1.
Referring to fig. 2 and 5, a reset phase is first entered to reset the potential of each GPIO port, thereby discharging both the charge capacitance Cs and the key capacitances Cx1, cx2, cx3, and Cx4 so that they are not charged. The GPIO ports comprise control ports GPIO1, GPIO2, GPIO3 and GPIO4, and a first detection port GPIO5 and a second detection port GPIO6. In the reset stage, the control ports GPIO1 to GPIO4, the first detection port GPIO5 and the second detection port GPIO6 are all in an output low level state.
Then, a first charging stage is entered, a control port GPIO and a key capacitance Cxn correspondingly and electrically connected with the control port are selected, so that the control port GPIO charges the key capacitance Cxn. And adding 1 to the charging times of each charging time, and recording the charging times. Assuming that the selected control port is GPIO1, the key capacitance Cx1 is charged. In the first charging stage, the selected control port GPIO n is in an output high level state, the other control ports are in an input state, the first detection port GPIO5 is in an output high level state, and the second detection port GPIO6 is in an input state.
Then, the second charging stage is entered, and the charged key capacitance Cxn is transferred to the charging capacitor Cs electrically connected thereto. In the second charging stage, the selected control port GPIO n is in an output high level state, the other control ports are in an input state, the first detection port GPIO5 is in an input state, and the second detection port GPIO6 is in an output low level state.
Further, the reading phase is entered, by reading the voltage of the first detection port GPIO5 and determining whether it is at a high level, if it is at a low level, repeating the first charging phase until the reading phase is at a high level, and the obtained charging order value is the required data. In the reading stage, the selected control port GPIO is in an output low level state, the other control ports are in an input state, the first detection port GPIO5 is in an input state, and the second detection port GPIO6 is in an input state. The above stages are repeated to detect all control ports.
Referring to fig. 3, for a more straight-forward explanation, a stepwise explanation will be made assuming that the scan key 1 is scanned. In the reset phase, the states of the ports are: GPIO1-GPIO6 are all output low states, with the corresponding effect of discharging the charge of capacitances Cx1, cx2, cx3, cx4 and Cs.
The first charging phase is to charge Cx 1. The state of the port is: GPIO1 outputs a high level state, GPIO2-GPIO4 is an input state, GPIO5 outputs a high level state, and GPIO6 is an input state. The function of this step is to charge Cx1 until the capacitance Cx1 corresponding to the key 1 is full of charge.
The second charging phase is Cx1 charging Cs. The state of the port is: GPIO1 outputs a high level state, GPIO2-GPIO4 is an input state, GPIO5 is an input state, and GPIO6 outputs a low level state. This step acts to transfer the charge of Cx1 to Cs until the voltage on Cx1 and the voltage on Cs are equal.
The read phase is to read the voltage on GPIO 5. The state of the port is: GPIO1 outputs a low state and GPIO2-GPIO6 is an input state. The function of this step is to determine whether the voltage across the capacitor Cs reaches the input high level value (VI H) corresponding to IO.
And finally, entering a judging stage, and judging the pressed key capacitor according to the charging times of the key capacitor corresponding to each control port. The judging stage specifically compares the charging times of each key capacitor with a preset reference value, and judges the key capacitor with the charging times smaller than the preset reference value as the pressed key capacitor. The principle is shown in fig. 4, the scanning process of a key is the charging process of the key capacitance Cxn to Cs, so that the voltage on the GPIO5 reaches the input high level value (VI H) of IO, and the voltage on the GPIO5 is the voltage at two ends of the charging capacitor Cs. The number of charges countn may reflect the size of the key capacitance Cxn. When the touch key n is touched by a finger, the capacitance value of the Cxn is increased, and the countn is decreased, so that the user can know which touch key is touched by comparing the charging number countn with the preset reference value.
Referring to fig. 5, the complete flow of the present embodiment is as follows: for 4 touch keys: key 1, key 2, key 3, key 4. The control unit scans each key one by one, that is, executes each working stage described above for each key 1 to each key 4 respectively until the voltage at both ends of Cs reaches VI H, and saves the charging times. And setting a reference value when a touch key is not touched, wherein the scanned charging times are smaller than the reference value, and the key is in a touched state at the moment, or in a non-touched state, returning to the first charging stage. After scanning four keys, firstly finding out the channel number m of the touched key, if no key is touched (i.e. the channel number m of the touched key does not exist), clearing 0 the filtering times, returning to the reset stage, and scanning from the key 1 again. If a key is touched, the number of filtering times is increased by 1, the reset phase is returned, and the scanning is performed again from the key 1. When the number of filtering times is 3 times and the channel numbers of the touch keys of the three times are consistent, the key m is considered to be pressed.
The embodiments of the present invention have been described in detail with reference to the drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, it is within the scope of the appended claims and their equivalents to fall within the scope of the invention.

Claims (8)

1. A capacitive key recognition device, comprising:
a plurality of key capacitors, a charging capacitor and a control unit;
the control unit is provided with a plurality of GPIO ports, wherein the GPIO ports comprise control ports, first detection ports and second detection ports, and the number of the control ports is consistent with that of the key capacitors;
one end of the key capacitor is electrically connected with the corresponding control port in sequence, and the other end of the key capacitor is electrically connected with one end of the charging capacitor;
one end of the charging capacitor, which is connected with the key capacitor, is electrically connected with the first detection port, and the other end of the charging capacitor is electrically connected with the second detection port.
2. The capacitive key identification device of claim 1, wherein the control unit is configured to control each GPIO port to implement different operating state phases to implement detection of the pressed key capacitance;
the working state stage comprises the following steps: a reset phase, a first charging phase, a second charging phase, and a reading phase;
in the reset stage, discharging charges of the key capacitor and the charging capacitor;
charging the selected key capacitor in the first charging stage;
in the second charging stage, the key capacitor charges the charging capacitor;
and in the reading stage, the voltage of the charging capacitor is read by the control unit.
3. The capacitive key identification device of claim 2, wherein,
in the reset stage, the control port, the first detection port and the second detection port are all in an output low-level state;
in the first charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an output high-level state, and the second detection port is in an input state;
in the second charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an output low-level state;
in the reading stage, the selected control port is in an output low-level state, the rest of the control ports are in an input state, the first detection port is in an input state, and the second detection port is in an input state.
4. A capacitive key recognition method, applied to the capacitive key recognition device according to any one of claims 1 to 3, comprising the steps of:
resetting the potential of each GPIO port, wherein the GPIO ports comprise a control port, a first detection port and a second detection port;
in the first charging stage, selecting one control port and a key capacitor correspondingly and electrically connected with the control port, enabling the control port to charge the key capacitor, adding 1 to the charging times, and recording the charging times;
the second charging stage is to make the charged key capacitor transfer charge to the charging capacitor electrically connected with the key capacitor;
a reading stage, namely reading the voltage of the first detection port and judging whether the voltage is high level, if so, repeating the first charging stage to the reading stage until all the control ports are detected;
and judging the pressed key capacitor according to the charging times of the key capacitor corresponding to each control port.
5. The method of claim 4, wherein,
in the reset stage, the control port, the first detection port and the second detection port are all in an output low-level state;
in the first charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an output high-level state, and the second detection port is in an input state;
in the second charging stage, the selected control port is in an output high-level state, the other control ports are in an input state, the first detection port is in an input state, and the second detection port is in an output low-level state;
in the reading stage, the selected control port is in an output low-level state, the rest of the control ports are in an input state, the first detection port is in an input state, and the second detection port is in an input state.
6. The method according to claim 4, wherein the determining step is specifically to compare the number of charges of each of the key capacitors with a preset reference value, and determine the key capacitor having the number of charges smaller than the preset reference value as the pressed key capacitor.
7. The method of claim 4, wherein,
under the judging stage, judging whether the pressed key capacitor exists or not, if so, adding 1 to the filtering times, and if not, jumping to the resetting stage; wherein, the initial value of the filtering times is 0.
8. The method for identifying a capacitive key according to claim 7, wherein in the determining step, it is further required to determine whether the number of times of filtering is equal to a preset threshold, and if the number of times of filtering is smaller than the preset threshold, skip to the resetting step;
and if so, judging whether the key capacitors obtained respectively are consistent after the preset threshold times are circulated, if so, judging that the key capacitors are pressed, otherwise, jumping to the reset stage.
CN202311577459.3A 2023-11-23 2023-11-23 Capacitive key recognition device and method Pending CN117459050A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311577459.3A CN117459050A (en) 2023-11-23 2023-11-23 Capacitive key recognition device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311577459.3A CN117459050A (en) 2023-11-23 2023-11-23 Capacitive key recognition device and method

Publications (1)

Publication Number Publication Date
CN117459050A true CN117459050A (en) 2024-01-26

Family

ID=89585472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311577459.3A Pending CN117459050A (en) 2023-11-23 2023-11-23 Capacitive key recognition device and method

Country Status (1)

Country Link
CN (1) CN117459050A (en)

Similar Documents

Publication Publication Date Title
EP1381160B1 (en) Capacitive keyboard with reduced keying ambiguity
US7256714B2 (en) Keyboard with reduced keying ambiguity
US8258986B2 (en) Capacitive-matrix keyboard with multiple touch detection
US8179380B2 (en) Method and apparatus for implementing a capacitive touch slider
US8629686B2 (en) Noise measurement in capacitive touch sensors
US9547399B2 (en) Injected touch noise analysis
US9024790B2 (en) Capacitive keyboard with non-locking reduced keying ambiguity
CN106055183B (en) Capacitive detection circuit
CN104794433A (en) Fingerprint recognition system and fingerprint recognition method
EP2667156A1 (en) Capacitive position sensor system
CN107194331A (en) A kind of fingerprint identification method and mobile terminal
US8159462B1 (en) Reference voltage offset for capacitive touch-sensor measurement
CN103713784A (en) Capacitive touch detecting circuit, device and identification method capable of preventing mistakes caused by stains
EP2434377A1 (en) Capacitive touch panel
WO2007129811A1 (en) Input device
CN110084082B (en) Electronic equipment, fingerprint identification device and finger touch detection circuit thereof
CN114355056A (en) Capacitance measuring circuit, capacitance measuring system, touch device and electronic equipment
CN108777574A (en) A kind of capacitance touch button circuit
CN107609527B (en) Low-power-consumption capacitance detection device for fingerprint identification
CN114356145A (en) Touch detection circuit, touch device and electronic equipment
CN106547309A (en) Terminal unit and its operational approach
CN117459050A (en) Capacitive key recognition device and method
CN112039512A (en) Capacitive touch key system and key detection method thereof
CN113541668A (en) Touch sensing method, circuit and electronic equipment
CN107515696A (en) A kind of touch detecting method and touch module

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination