A capacitive touch button detection circuit and method for general microcontroller

By integrating the capacitive touch key detection circuit of the driving module, timing control module, ADC module and processing module on the microcontroller, the problems of high hardware cost and complex design in the existing technology are solved, and a highly sensitive capacitive touch key is realized. detection.

CN117811561BActive Publication Date: 2024-10-18SHANGHAI XINBIDA MICROELECTRONICS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311820234.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2024-10-18
Estimated Expiration
2043-12-27

AI Technical Summary

Technical Problem

Existing capacitive touch button detection solutions require additional dedicated capacitance detection chips, which increases hardware costs. In addition, inconsistent power supply voltages require the design of additional power supply circuits and level conversion circuits, which complicates hardware design.

Method used

Design a capacitive touch key detection circuit that includes a driver module, a timing control module, an ADC module and a processing module. It uses the idle pins of the microcontroller to drive the detection electrodes, and collects voltage signals through the timing control module and ADC module. By analyzing the voltage Changes determine touch operations, simplifying hardware design and saving costs.

Benefits of technology

Effectively utilize microcontroller resources, simplify hardware design, save hardware costs, and improve detection sensitivity to achieve reliable capacitive touch button detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117811561B_ABST
    Figure CN117811561B_ABST
Patent Text Reader

Abstract

The present invention discloses a capacitive touch key detection circuit and method applied to a general microcontroller, wherein the detection circuit comprises a driving module, a timing control module, an ADC module and a processing module; wherein the driving module is respectively connected to the timing control module and the detection electrode, and is used to drive the detection electrode to charge or discharge according to the driving control signal provided by the timing control module; the ADC module is respectively connected to the timing control module and the detection electrode, and is used to collect the voltage on the detection electrode according to the sampling trigger signal provided by the timing control module; the processing module is connected to the ADC module, and is used to determine whether there is a touch operation according to the collected voltage. The present invention can simplify the hardware design, save the hardware cost, and achieve better detection sensitivity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of electronic technology, and in particular relates to a capacitive touch key detection circuit and method applied to a general microcontroller. Background Art

[0002] Compared with traditional mechanical buttons, capacitive touch buttons have many advantages in appearance, service life, cost, etc., and have gradually replaced mechanical buttons in many applications. Capacitive touch button applications generally use self-capacitance detection circuits, that is, the capacitance change between the detection electrode and the system ground is used to determine the touch operation. When the user touches the detection electrode with his hand, the capacitance between the electrode and the system ground increases. When the detection circuit detects that the increase in self-capacitance exceeds the set threshold, it is determined that the user has performed a touch operation.

[0003] Most of the existing capacitive touch button applications use dedicated capacitive detection chips, which are connected to the microcontroller (MCU) through serial buses such as I2C or SPI to report touch operation related information. This application requires the use of an additional dedicated capacitive detection chip, which increases the hardware cost. In some cases, the power supply voltage of these dedicated capacitive detection chips is inconsistent with the power supply voltage of the microcontroller, and additional power supply circuits and level conversion circuits need to be designed, which further increases the hardware cost. Summary of the invention

[0004] In order to overcome the above-mentioned deficiencies of the prior art, the present invention provides a capacitive touch button detection circuit and method applied to a general microcontroller, which can simplify hardware design, save hardware costs, and achieve better detection sensitivity.

[0005] According to one aspect of the present invention specification, there is provided a capacitive touch button detection circuit for a general microcontroller, comprising a driving module, a timing control module, an ADC module and a processing module; wherein the driving module is respectively connected to the timing control module and the detection electrode, and is used to drive the detection electrode to charge or discharge according to a driving control signal provided by the timing control module; the ADC module is respectively connected to the timing control module and the detection electrode, and is used to collect the voltage on the detection electrode according to a sampling trigger signal provided by the timing control module; the processing module is connected to the ADC module, and is used to determine whether there is a touch operation according to the collected voltage.

[0006] As a further technical solution, the detection electrode is connected to a drive pin of a microcontroller via a drive resistor, and the drive pin is connected to an output end of a drive module; the detection electrode is also connected to an input end of an ADC module via a detection pin of the microcontroller.

[0007] As a further technical solution, the timing control module includes a PWM module or a timing module capable of generating a stable timing.

[0008] As a further technical solution, the driving control signal is associated with the sampling trigger signal in terms of timing, so that the ADC module can collect the voltage on the detection electrode at a predetermined position.

[0009] As a further technical solution, the sampling trigger signal has a delay relative to the driving control signal, and the delay is adjustable.

[0010] As a further technical solution, the sampling trigger signal triggers the ADC module to collect data at the rising edge and / or falling edge of the detection electrode voltage.

[0011] According to one aspect of the present invention, a detection method for a capacitive touch button detection circuit applied to a general microcontroller is provided, comprising:

[0012] Determine the best sampling point;

[0013] Establishing benchmark values ​​for testing;

[0014] Calculate the difference between the latest sampling value and the detection reference value;

[0015] When a touch operation is detected, determine whether the difference is less than the hand-off threshold. If so, determine that there is no touch operation. If not, determine that the current touch operation state is in progress.

[0016] When it is detected that there is no touch operation currently, it is determined whether the difference is greater than the touch threshold. If so, it is determined that the current state is a touch operation state. If not, it is determined that there is no touch operation currently.

[0017] As a further technical solution, the best sampling point is calculated based on the measured capacitance of the detection electrode to the system ground and the capacitance generated by the touch operation in combination with the driving resistance.

[0018] As a further technical solution, when measurement conditions are not met, the best sampling point is searched through a traversal method or a successive approximation method.

[0019] Compared with the prior art, the present invention has the following beneficial effects:

[0020] The present invention uses an idle pin of a microcontroller to drive a detection electrode, and uses another idle pin of the microcontroller to connect the detection electrode, and the pin is connected to the input end of an ADC module inside the microcontroller; a timing control module is used to control the timing of driving and sampling, which drives the driving module to output a square wave at a fixed frequency, and triggers the ADC module to collect the voltage on the detection electrode at a specific timing; the driving resistor and the detection electrode connected in series form an RC circuit, and when a user touches the electrode, the charging and discharging speed slows down, and the data collected by the ADC module will also change accordingly; the ADC module sends the collected results to a processing module for further calculation and processing, and determines whether there is a touch operation by analyzing the changes in the sampled data.

[0021] The present invention can effectively utilize on-chip resources of a general microcontroller, reliably detect self-capacitive touch button applications, simplify hardware design, save hardware costs, and has good sensitivity. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 The figure is a schematic diagram of the structure of a capacitive touch button detection circuit applied to a general microcontroller according to an embodiment of the present invention.

[0023] Figure 2 FIG. 4 is a schematic diagram of circuit operation waveforms according to an embodiment of the present invention.

[0024] Figure 3 FIG. 4 is a schematic diagram of circuit operation waveforms according to another embodiment of the present invention.

[0025] Figure 4 It is a schematic diagram of the voltage waveform and the waveform difference on the detection electrode when there is no touch operation and when there is a touch operation according to another embodiment of the present invention.

[0026] Figure 5 FIG. 4 is a flowchart of a process for detecting a touch operation according to an embodiment of the present invention.

[0027] Figure 6 It is a schematic diagram of determining whether there is a touch operation according to the signal amount according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In view of the current situation that the hardware cost of existing capacitive touch button detection is high and the circuit design is complex, the present invention provides a capacitive touch button detection circuit and method implemented using the microcontroller's own module, which can simplify the hardware design, save hardware costs, and achieve better detection sensitivity.

[0029] The following will clearly and completely describe the technical solutions of various embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0030] In some processes described in the specification and claims of the present invention and the above-mentioned drawings, multiple operations appearing in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. For example, step S501, step S502, etc. are only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel.

[0031] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or mutual communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0032] The present invention uses an idle pin of a microcontroller, usually a GPIO (General Purpose Input / Output), to drive the detection electrode. A resistor is connected in series between the drive pin and the detection electrode to slow down the speed at which the drive pin charges and discharges the detection electrode. Another idle pin of the microcontroller is used to connect the detection electrode, and the pin is connected to the input end of an ADC (Analog-to-Digital Converter) inside the microcontroller.

[0033] The present invention uses a timing control module to control the timing of driving and sampling. The timing control module can be a PWM (Pulse Width Modulation) module, or a module that can generate a stable timing, such as a timer, which drives the driving module to output a square wave at a fixed frequency, and triggers the ADC to collect the voltage on the touch electrode at a specific timing. The resistor and the touch electrode in series form an RC circuit. When the user touches the electrode, the charging and discharging speed slows down, and the data collected by the ADC will change accordingly.

[0034] The present invention uses ADC to send the collected results to the processing module for further calculation and processing, and determines whether there is a touch operation by analyzing the changes in the sampled data.

[0035] like Figure 1 As shown, the driving pin of the microcontroller 100 is connected to the detection electrode 110 through a resistor Rs, and the detection pin is directly connected to the detection electrode 100. The background capacitance of the detection electrode 110 to the system ground is Cb, and Cf is the capacitance added when the human body touches the detection electrode. When there is no touch operation, Cf does not exist.

[0036] The microcontroller 100 includes a driving module 101 , a timing control module 102 , an ADC module 103 and a processing module 104 .

[0037] The timing control module 102 can generate a fixed frequency signal DRV_TRG to the driving module 101, so that the driving module 101 outputs a fixed frequency square wave to the driving pin. The driving pin charges and discharges the detection electrode 110 through the series resistor Rs.

[0038] The timing control module 102 also provides the sampling trigger signal SENS_TRG to the ADC module 103, so that the ADC module 103 collects the instantaneous voltage of the detection electrode 110 at a specific moment. The driving control signal DRV_TRG and the sampling trigger signal SENS_TRG generated by the timing control module 102 are related in timing, so that the ADC module 103 clock can collect the voltage on the detection electrode 110 at a predetermined position.

[0039] The ADC module 103 converts the collected analog voltage into a digital quantity and transmits it to the processing module 104 for processing.

[0040] The processing module runs a predetermined program and algorithm to further determine whether there is a touch operation.

[0041] like Figure 2 As shown, DRV_TRG is the signal output by the timing control module 102 to the driving module 101, and Vdrv is the signal output by the driving module 101, which are in the same frequency and phase in the time domain. SENS_TRG is the signal output by the timing control module 102 to the ADC module 103, which is used to trigger the ADC module 103 to start collecting voltage. The rising edge of the SENS_TRG signal has a time delay Tdly relative to the rising edge of DRV_TRG, and the delay can be adjusted.

[0042] Vpad is the voltage signal on the detection electrode 110. Due to the effect of the resistor Rs, the rising and falling edges of the voltage signal on the detection electrode 110 are much slower than those of the Vdrv signal. At the rising edge of the SENS_TRG signal, the ADC module 103 collects the voltage Vpad on the detection electrode 110, and the collected voltage value is Va1, and converts it into a digital value and sends it to the processing module 104.

[0043] When the user touches the detection electrode 110 with his hand, the capacitance of the detection electrode 110 to the system ground will increase by Cf. Due to the increase in capacitance, the speed at which the driving module 101 charges the detection electrode 110 through Rs slows down, and the voltage on the detection electrode 110 becomes Vpad_touch. Under the same delay Tdly, the Vpad_touch voltage is collected, and the voltage value collected by the ADC module 103 becomes Vb1. It is easy to know that the value of Vb1 is lower than the value of Va1. It can be obtained that the voltage change collected by the ADC module due to the touch operation is Vdiff = Va1-Vb1.

[0044] In another embodiment, Figure 2 compared to, Figure 3 The SENS_TRG signal output by the timing control module 102 triggers the ADC module 103 to collect data not only at the rising edge of the Vpad signal, but also at the falling edge of the Vpad signal. When calculating the voltage change caused by the touch operation, there is

[0045] Vdiff=(Va1-Vb1)-(Va2-Vb2) (1)

[0046] Figure 3 The sampling method is relative to Figure 2 The main benefits are as follows: First, the signal generated when the driving module 101 discharges the detection electrode 110 can be effectively utilized, so that more sampling points can be obtained in the same time, with a higher detection signal-to-noise ratio; or in other words, obtaining the same number of sampling points can save half the time, thereby saving power consumption. Second, the idea of ​​correlated double sampling is used, which can effectively reduce the low-frequency noise in the circuit, thereby improving the signal-to-noise ratio.

[0047] Figure 4It is a schematic diagram of the voltage waveform and waveform difference on the detection electrode when there is no touch operation and when there is a touch operation in another embodiment of the present invention. Vpad is the voltage waveform on the detection electrode 110 when there is no touch operation, Vpad_touch is the voltage waveform on the detection electrode 110 when there is a touch operation, and Vdiff is the difference waveform of the Vpad waveform minus the Vpad_touch waveform. It can be seen that the difference waveform has a maximum value during the charging process of the detection electrode 110 and a minimum value during the discharge process. Therefore, setting a suitable sampling time can maximize the detection signal, and the setting of the sampling time is achieved by adjusting Tdly between the DRV_TRG and SENS_TRG signals generated by the timing control module 102.

[0048] The following briefly describes the theoretical calculation of Tdly and the value determination method in engineering applications.

[0049] When there is no touch operation, the driving module 101 charges the detection electrode 110, and the relationship between voltage and time is:

[0050]

[0051] After the touch, the capacitance of the detection electrode 110 to the system ground increases to Cb+Cf. At this time, the relationship between the charging voltage and time becomes

[0052]

[0053] The difference between the voltage without touch and the voltage after touch is

[0054]

[0055] By differentiating this formula, we can obtain the time when Vdiff reaches its maximum value:

[0056]

[0057] Therefore, the best sampling time can be calculated by measuring the capacitance Cb of the detection electrode 110 to the system ground and the capacitance Cf generated by the user's touch operation in combination with the driving resistor Rs used.

[0058] In applications, measuring capacitance often requires precision instruments. In some cases, the conditions for measurement may not be available. Therefore, in engineering, the target value is often found through traversal method, successive approximation method, etc. Substituting equation (5) into equation (1), we get

[0059]

[0060] In general, the capacitance Cf generated by touch is much smaller than the background capacitance Cb of the detection electrode to the system ground, so we can find the limit of equation (6) and get

[0061]

[0062] Combining formula (7), we can get a method for searching the optimal Tdly by traversal method: set Tdly to gradually increase from 0, and use ADC module 103 to collect the voltage value on the touch electrode after each step, and stop searching when it is determined that the collected voltage value reaches 0.632VCC.

[0063] Figure 5 FIG. 4 is a flowchart of a process for detecting a touch operation according to an embodiment of the present invention.

[0064] In step S501, the capacitive touch key detection function is started.

[0065] In step S502, the optimal Tdly is searched and obtained according to the aforementioned traversal method, so that the ADC module 103 can collect the maximum value of the touch signal, or a value close to the maximum value.

[0066] In step S503, a reference value is established after data processing based on the voltage value currently collected by the ADC module 103. In step S504, the latest voltage value collected by the ADC module 103 is compared with the reference value to determine whether there is a touch operation or whether the touch operation is terminated.

[0067] Before determining the touch operation, first check whether a touch operation has been detected, that is, enter step S505. If the touch state has not been entered, determine whether the difference obtained in stage S504 is greater than the touch threshold, that is, enter step S506. If the difference calculated in stage S504 is greater than the touch threshold, it is determined that there is a touch operation; otherwise, it is determined that there is no touch operation.

[0068] If it is determined in stage S505 that there is a touch operation, it is determined whether the difference value obtained in stage S504 is less than the hand-off threshold, that is, at this time, it is only determined whether the touch operation is ended, that is, the process proceeds to step S508. If the difference value calculated in stage S504 is less than the hand-off threshold, it is determined that the current touch operation has ended, that is, there is no touch operation; otherwise, it is determined that the current touch operation is still in the state of touch operation.

[0069] Figure 6 This is a schematic diagram of determining whether a touch operation has occurred based on the signal magnitude according to an embodiment of the present invention. Since actual signals contain noise, there may also be some jitter during a touch operation, so different thresholds need to be used when determining whether a touch operation has occurred and when a touch operation has ended. Figure 6 In the embodiment, the touch threshold is the threshold for judging whether a touch operation has occurred, and the hand-off threshold is the threshold for judging whether a touch operation has ended. The touch threshold must be higher than the hand-off threshold. Figure 6The F in the middle means that after a touch operation is judged, the data drops to a certain extent, and the drop amplitude is lower than the touch threshold, but not lower than the hand-off threshold, so it will not be judged as the end of the touch operation. This approach ensures a certain ability to resist noise and interference and reduce misjudgment of touch operations.

[0070] In summary, the present invention finds the best sampling point by traversing the delay between the sampling moment of the ADC module and the moment when the driving module starts to charge or discharge the detection electrode, and determines whether there is a touch operation according to the difference between the sampling value and the reference value.

[0071] The detection circuit of the present invention comprises a driving module, a timing control module, an ADC module, and a data processing module. The timing control module can control the delay of the sampling moment of the ADC module relative to the moment when the driving module starts to charge or discharge the detection electrode, and the delay is adjustable. The ADC module collects the voltage on the detection electrode during the process of the driving module charging or discharging the detection electrode, and the voltage collected is a transient voltage. The data collection and processing also uses the correlated double sampling technology, which can effectively reduce the low-frequency noise in the circuit and improve the signal-to-noise ratio.

[0072] In the description of this specification, the description with reference to the terms "one embodiment", "certain embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.

Claims

1. A capacitive touch key detection circuit applied to a general microcontroller, characterized in that: Two idle pins of the microcontroller are used as a driving pin and a detection pin respectively, and a resistor is connected in series between the driving pin and the detection electrode, including a driving module, a timing control module, an ADC module and a processing module; wherein the driving module is respectively connected to the timing control module and the detection electrode, and is used to drive the detection electrode to charge or discharge according to a driving control signal provided by the timing control module, and the driving module outputs a square wave, which drives the detection electrode after passing through the series resistor, and generates a slowly changing voltage edge on the detection electrode; the ADC module is respectively connected to the timing control module and the detection electrode, and is used to collect the transient voltage on the slowly changing edge when the detection electrode is charged or discharged according to the sampling trigger signal provided by the timing control module; the processing module is connected to the ADC module, and is used to determine whether there is a touch operation according to the change of the collected voltage.

2. A capacitive touch key detection circuit applied to a general microcontroller according to claim 1, characterized in that: The detection electrode is connected to a driving pin of a microcontroller through a driving resistor, and the driving pin is connected to an output end of a driving module; the detection electrode is also connected to an input end of an ADC module through a detection pin of the microcontroller.

3. The capacitive touch key detection circuit applied to a general microcontroller according to claim 1, characterized in that: The timing control module includes a PWM module or a timing module capable of generating a stable timing.

4. The capacitive touch key detection circuit applied to a general microcontroller according to claim 1, characterized in that: The driving control signal is associated with the sampling trigger signal in terms of timing, so that the ADC module can collect the voltage on the detection electrode at a predetermined position.

5. A capacitive touch key detection circuit applied to a general microcontroller according to claim 4, characterized in that: The sampling trigger signal has a delay relative to the driving control signal, and the delay is adjustable.

6. The capacitive touch key detection circuit applied to a general microcontroller according to claim 1, characterized in that: The sampling trigger signal triggers the ADC module to collect data at the rising edge and / or falling edge of the detection electrode voltage.

7. A detection method for a capacitive touch button detection circuit applied to a general microcontroller, implemented by using the detection circuit described in any one of claims 1 to 6, characterized in that: include: Determine the best sampling point; Establishing benchmark values ​​for testing; Calculate the difference between the latest sampling value and the detection reference value; When a touch operation is detected, determine whether the difference is less than the hand-off threshold. If so, determine that there is no touch operation. If not, determine that the current touch operation state is in progress. When it is detected that there is no touch operation currently, it is determined whether the difference is greater than the touch threshold. If so, it is determined that the current state is a touch operation state. If not, it is determined that there is no touch operation currently.

8. The detection method of the capacitive touch key detection circuit applied to a general microcontroller according to claim 7, characterized in that: The best sampling point is calculated based on the measured capacitance of the detection electrode to the system ground and the capacitance generated by the touch operation, combined with the driving resistance.

9. A detection method for a capacitive touch key detection circuit applied to a general microcontroller according to claim 8, characterized in that: When measurement conditions are not met, the best sampling point is searched by ergodic method or successive approximation method.

Citation Information

Patent Citations

  • Touch key detection method and detection circuit, microcontroller and touch detection system

    CN115202515A