CN111865289B - Touch key detection equipment and method - Google Patents

Touch key detection equipment and method Download PDF

Info

Publication number
CN111865289B
CN111865289B CN202010559903.9A CN202010559903A CN111865289B CN 111865289 B CN111865289 B CN 111865289B CN 202010559903 A CN202010559903 A CN 202010559903A CN 111865289 B CN111865289 B CN 111865289B
Authority
CN
China
Prior art keywords
touch
touch electrode
sampling value
value
voltage data
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.)
Active
Application number
CN202010559903.9A
Other languages
Chinese (zh)
Other versions
CN111865289A (en
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.)
Shenzhen Zhouligong Scm Co ltd
Original Assignee
Shenzhen Zhouligong Scm 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 Shenzhen Zhouligong Scm Co ltd filed Critical Shenzhen Zhouligong Scm Co ltd
Priority to CN202010559903.9A priority Critical patent/CN111865289B/en
Publication of CN111865289A publication Critical patent/CN111865289A/en
Application granted granted Critical
Publication of CN111865289B publication Critical patent/CN111865289B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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/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
    • H03K2017/9602Touch switches characterised by the type or shape of the sensing electrodes
    • H03K2017/9604Touch switches characterised by the type or shape of the sensing electrodes characterised by the number of electrodes
    • H03K2017/9606Touch switches characterised by the type or shape of the sensing electrodes characterised by the number of electrodes using one electrode only per touch switch

Landscapes

  • Electronic Switches (AREA)

Abstract

The embodiment of the application discloses a touch key detection device and a touch key detection method. According to the technical scheme, the main processing module is used for controlling the charging and discharging of the external capacitor, the external capacitor is charged firstly, the equivalent capacitor of the touch electrode is discharged, then the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input and output pins when the external capacitor reaches the balance voltage are detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and the accuracy of judging the touch state of the key is effectively improved.

Description

Touch key detection equipment and method
Technical Field
The embodiment of the application relates to the technical field of touch keys, in particular to a touch key detection device and a touch key detection method.
Background
With the development of technology, touch technology is increasingly applied to automobiles, such as door handles, skylights, air conditioning panels and the like, and high-end automobile models are controlled by touch.
The current common touch control principle is a capacitance detection principle, and the implementation scheme mainly comprises a scheme of counting charge and discharge time of a single micro control unit (Microcontroller Unit, MCU) and a scheme of adding a capacitance sensor to the MCU, so that the charge and discharge time of the capacitance and the equivalent capacitance of the touch electrode system are directly detected, and whether a touch key is pressed or not is judged according to different charge and discharge times.
However, the touch control module based on the single MCU capacitor charge-discharge time count has high requirement on the clock precision of the timer, and is easy to cause error judgment of the key touch state.
Disclosure of Invention
The embodiment of the application provides a touch key detection device and a touch key detection method, which are used for improving the accuracy of key touch state judgment.
In a first aspect, an embodiment of the present application provides a touch key detection device, including a main processing module and a touch key module, where the touch key module includes an external capacitor, a touch electrode, and a charge-discharge resistor, and the touch key module includes:
one end of the external capacitor is electrically connected with a first input/output pin of the main processing module, and the other end of the external capacitor is grounded;
the touch electrode is electrically connected with a second input/output pin of the main processing module;
two ends of the charge-discharge resistor are respectively and electrically connected with a first input-output pin and a second input-output pin of the main processing module;
the main processing module performs charge and discharge control on the external capacitor, voltage data of the first input and output pins are detected through the ADC module, and the main processing module determines a touch detection result of the touch electrode based on the voltage data.
Further, the touch key detection device further comprises a state feedback transceiver, and the state feedback transceiver is electrically connected to the data transceiver interface of the main processing module and is used for being in communication connection with an external terminal.
Further, the touch key detection device further comprises a linear motor with adjustable control parameters, the main processing module is electrically connected to a motor driver of the linear motor, and the main processing module adjusts the control parameters of the linear motor through the motor driver.
In a second aspect, an embodiment of the present application provides a touch key detection method, which is applied to the touch key detection device according to the first aspect, including:
based on charge and discharge control of an external capacitor, detecting the voltage of the first input and output pins through the ADC module to obtain voltage data;
filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value;
updating the reference value according to the comparison result of the sampling value and the reference value;
and determining a touch detection result of the touch electrode according to the sampling value and the reference value.
Further, the detecting, by the ADC module, the voltage of the first input/output pin based on the charge/discharge control of the external capacitor, to obtain voltage data includes:
configuring a first input/output pin and a second input/output pin as output modes, controlling the output voltage of the first input/output pin to be VDD and the output voltage of the second input/output pin to be VSS;
And configuring the first input/output pin and the second input/output pin as input modes, and detecting the voltage of the first input/output pin through the ADC module to obtain voltage data.
Further, the filtering updating of the voltage data based on the change condition of the voltage data relative to the previous sampling value to obtain the current sampling value includes:
judging whether the change direction of the voltage data relative to the last sampling value is consistent or not;
if the change directions are inconsistent, resetting the filter counter and the filter coefficient;
if the change directions are consistent, updating the accumulated number of the filter counter according to the change amplitude of the voltage data relative to the last sampling value, and increasing the filter coefficient when the accumulated number of the filter counter reaches a count threshold;
and calculating a sampling value of the time according to the voltage data and the filter coefficient.
Further, the calculating the sampling value according to the voltage data and the filter coefficient includes:
judging whether the voltage data is smaller than the last sampling value or not;
if the voltage data is smaller than the last sampling value, determining that the sampling value is: y is Y n =Y n-1 -(Y n-1 -X n ) X a/C, wherein Y n For the current sampling value, Y n-1 X is the last sample value n A is a filter coefficient, C is a coefficient endpoint value, and the filter coefficient is smaller than the coefficient endpoint value;
if the voltage data is greater than or equal to the last sampling value, determining that the sampling value at this time is: y is Y n =Y n-1 +(X n- Y n-1 )×a/C。
Further, the updating the reference value according to the comparison result of the sampling value and the reference value at this time includes:
judging whether the current main processing module is powered on for the first time;
if the current main processing module is electrified for the first time, taking the sampling value as a reference value;
if the current main processing module is not powered on for the first time, judging whether the touch electrode is in a touch state or not;
if the touch electrode is in a touch state, maintaining the current reference value;
if the touch electrode is in a non-touch state, judging whether the sampling value is larger than a reference value or not;
if the sampling value is greater than or equal to a reference value, executing an increasing operation on the reference value;
and if the sampling value is smaller than the reference value, executing a reducing operation on the reference value.
Further, the determining the touch detection result of the touch electrode according to the sampling value and the reference value at this time includes:
Judging whether the sampling value of the time reaches a touch judgment threshold value or not, wherein the touch judgment threshold value is the sum of the reference value and a preset threshold value;
if the sampling value reaches a touch judgment threshold value, determining the effective state of the touch electrode based on the false touch prevention judgment of the touch electrode, wherein the effective state of the touch electrode comprises touch effective and touch ineffective;
if the sampling value does not reach the touch judgment threshold value, judging whether the effective state of the touch electrode is effective;
if the effective state of the touch electrode is effective, determining that the touch detection result is effective;
if the effective state of the touch electrode is the touch invalidity, the touch detection result is determined to be the touch key invalidity.
Further, the determining the effective state of the touch electrode based on the false touch prevention judgment of the touch electrode includes:
marking the touch electrode as a pressing state, and judging whether other touch electrodes in a touch state exist or not;
if other touch electrodes in the touch state exist, determining that the effective state of the touch electrode is invalid;
if no other touch electrode in the touch state exists, judging whether the last touch electrode is marked as a pressed state or not;
If the last touch electrode mark is in the pressed state, judging whether the counting statistics of the pressed state of the touch electrode reaches a counting threshold value or not;
if the counting statistics reach the counting threshold value, determining that the effective state of the touch electrode is effective;
if the counting statistics does not reach the counting threshold value, determining that the effective state of the touch electrode is invalid;
and if the last touch electrode mark is in a lifting state, determining that the effective state of the touch electrode is invalid.
Further, after determining the touch detection result of the touch electrode according to the sampling value and the reference value, the method further includes:
and determining control logic of the linear motor in response to a touch detection result of the valid touch key, and adjusting control parameters of the linear motor based on the control logic.
Further, the control logic includes:
first control logic: controlling the linear motor to continuously run for a first length of time at a first frequency and a PWM output of a first duty cycle; or (b)
Second control logic: controlling the linear motor to continue operating at a second frequency, PWM output of a second duty cycle, for a second length of time; or (b)
Third control logic: the linear motor is controlled to continuously run for a third time length by PWM output of a first frequency and a first duty ratio, and then is controlled to continuously run for a fourth time length by PWM output of a second frequency and a second duty ratio, and the operation is repeated for preset times.
In a third aspect, an embodiment of the present application provides a touch key detection apparatus, which is applied to the touch key detection device according to the first aspect, and includes a data sampling module, a data filtering module, a reference updating module, and a touch judging module, where:
the data sampling module is used for detecting the voltage of the first input and output pins through the ADC module based on charge and discharge control of the external capacitor to obtain voltage data;
the data filtering module is used for filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value;
the reference updating module is used for updating the reference value according to the comparison result of the sampling value and the reference value;
and the touch judgment module is used for determining a touch detection result of the touch electrode according to the sampling value and the reference value.
In a fourth aspect, embodiments of the present application provide a computer device comprising: a memory and one or more processors;
the memory is used for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the touch key detection method as described in the second aspect.
In a fifth aspect, embodiments of the present application provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing the touch key detection method as described in the second aspect.
According to the embodiment of the application, the external capacitor is charged through the main processing module, the equivalent capacitor of the touch electrode is discharged, the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input/output pin when the external capacitor reaches the balance voltage is detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and accuracy of judging the touch state of a key is effectively improved.
Drawings
Fig. 1 is a block diagram of a touch key detection device according to an embodiment of the present application;
fig. 2 is a flowchart of a method for detecting a touch key according to an embodiment of the present application;
FIG. 3 is a first partial flowchart of another touch key detection method according to an embodiment of the present disclosure;
FIG. 4 is a second partial flowchart of another touch key detection method according to an embodiment of the present disclosure;
FIG. 5 is a flowchart for updating filter coefficients provided in an embodiment of the present application;
FIG. 6 is a flowchart of calculating a current sample value provided by an embodiment of the present application;
FIG. 7 is a flowchart of another method for detecting touch keys according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a touch key detection device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Reference numerals: 1. a main processing module; 2. touching the key module; 21. an external capacitor; 22. a touch electrode; 23. a charge-discharge resistor; 3. a status feedback transceiver; 31. a CAN transceiver; 32. a LIN transceiver; 4. a linear motor; 5. a pressure sensor; 6. an indicator light module; 7. an ADC module; 8. a motor driver.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the following detailed description of specific embodiments thereof is given with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the matters related to the present application are shown in the accompanying drawings.
In the description of the embodiments of the present application, unless explicitly specified and limited otherwise, the terms "connected," "connected," and "fixed" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally formed; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communicated with the inside of two elements or the interaction relationship of the two elements. The specific meaning of the terms in this application will be understood by those of ordinary skill in the art in a specific context.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Fig. 1 shows a block diagram of a touch key detection device according to an embodiment of the present application, and as shown in fig. 1, the touch key detection device includes a main processing module 1, a touch key module 2, a status feedback transceiver 3, a linear motor 4, a pressure sensor 5, and an indicator light module 6. Wherein the touch key module 2, the state feedback transceiver 3, the linear motor 4, the pressure sensor 5 and the indicator lamp module 6 are all electrically connected to the main processing module 1.
The main processing module 1 is connected with an ADC module 7 (Analog to Digital Converter), and the ADC module 7 may be one or more ADCs built in the main processing module 1, or an external ADC, for detecting voltage data of pins of the main processing module 1. The model selection of the main processing module 1 may be performed according to actual configuration requirements, and the application is not limited, for example, an MCU with a 12bit ADC built therein is selected as the main processing module 1, and the ADC is used as the ADC module 7 in this embodiment.
Further, the touch key module 2 includes an external capacitor 21, a touch electrode 22, and a charge-discharge resistor 23. One end of the external capacitor 21 is electrically connected to a first input/output PIN (PIN 1 of a general purpose input/output interface GPIO in the figure) of the main processing module 1, and the other end is grounded; the touch electrode 22 is electrically connected with a second input/output PIN (PIN 2 of a general purpose input/output interface GPIO in the figure) of the main processing module 1; both ends of the charge-discharge resistor 23 (R1 in the figure) are electrically connected to the first input-output pin and the second input-output pin of the main processing module 1, respectively. Meanwhile, the first input/output pin of the main processing module 1 is connected to the ADC module 7, and the ADC module 7 detects the voltage of the first input/output pin (the external capacitor 21) and outputs corresponding voltage data.
It can be understood that a plurality of touch key modules 2 for triggering different function instructions may be provided (in the figure, a touch key module 2 is illustrated as an example, and a plurality of touch key modules 2 are provided in practical application), the touch electrodes 22 are installed at different positions of the automobile, the external capacitors 21 are connected to different GPIO interfaces, and the ADC module 7 detects the voltage of each external capacitor 21.
The main processing module 1 performs charge and discharge control on the external capacitor 21 by configuring an operation mode (input or output mode) of the input/output pins (first input/output pin and second input/output pin), detects voltage data of the first input/output pin by the ADC module 7, and determines a touch detection result of the touch electrode 22 based on the voltage data.
In other embodiments, the ADC module 7 may detect the voltages of the first input/output pin and the second input/output pin at the same time, perform the integration processing according to the voltage data detected by the two pins, obtain the final voltage data, and use the final voltage data as the voltage data of the first input/output pin detected by the ADC module 7 in this embodiment. For example, the average value or the weighting value of the two voltage data may be taken, or the changing directions of the two voltage data may be determined, when the changing directions are consistent, the voltage data may be determined according to the above method, or the voltage data of the first input/output pin may be regarded as final voltage data, when the changing directions are inconsistent, the interference may be considered to occur, and the last determined voltage data may be regarded as final voltage data.
Further, the status feedback transceiver 3 is electrically connected to the data transceiver interface of the main processing module 1, and is used for communication connection with an external terminal. Specifically, the status feedback transceiver 3 may determine the communication type of the external terminal that needs to be connected.
The present embodiment takes ADAS (Advanced DrivingAssistance System) as an external terminal as an example. The status feedback transceiver 3 is illustratively a CAN transceiver (controller area network), a LIN transceiver (Local InterconnectNetwork, inter-networking), or a combination of both. The CAN transceiver is connected with the CAN interface and the SPI interface of the main processing module 1, and is used for being connected with an external CAN bus system. The LIN transceiver is connected to the UART interface of the main processing module 1, and is used for connecting to an external LIN bus system.
Further, the touch electrode 22 is installed in a key control panel inside the automobile, and the linear motor 4 is installed in the control panel. Alternatively, the linear motors 4 may be mounted in a one-to-one correspondence with the touch electrodes 22 and in a position close to the corresponding touch electrodes 22 in the key control surface, or one or more linear motors 4 independent of the touch electrodes 22 and mounted on the mount control panel.
In one embodiment, a linear motor 4 may be installed in the control panel, which has the effects of lower cost and smaller volume compared to the prior art scheme of matching a key with a linear motor 4 or piezoelectric ceramic. In addition, different control parameters can be determined according to the position or distance of each touch electrode 22 on the control panel relative to the linear motor 4, when the touch electrodes 22 at different positions are judged to be effective in touch, the corresponding control parameters are selected to control the linear motor 4, so that the effect of uniform shock feeling is achieved, and the use experience is improved.
Each linear motor 4 is provided with a motor driver 8, the motor driver 8 is electrically connected to the corresponding linear motor 4, and the motor driver 8 is electrically connected to the main process module 1. The linear motor 4 is a linear motor 4 with adjustable control parameters, the main processing module 1 adjusts the control parameters (frequency, duty ratio of PWM signal, running time, etc.) of the linear motor 4 through the motor driver 8, that is, the main processing module 1 sends a parameter adjustment command to the motor driver 8, and the motor driver 8 updates the control parameters of the linear motor 4 according to the parameter adjustment command, so that the linear motor 4 operates at the updated control parameters.
Further, the pressure sensor 5 is electrically connected to the main processing module 1 and to the ADC module 7. The pressure sensor 5 is installed at a position of the key control panel corresponding to the touch electrode 22, and is used for detecting the pressure pressed on the touch electrode 22, generating pressure detection information and sending the pressure detection information to the ADC module 7, and the ADC module 7 determines the pressure pressed on the corresponding touch electrode 22 according to the pressure detection information. It is understood that the pressure sensors 5 may be disposed in a one-to-one correspondence with the touch electrodes 22, or the pressure sensors 5 may be configured for a portion of the touch electrodes 22 according to configuration requirements.
The indication lamp module 6 comprises an indication LED and a backlight LED, is arranged at the position of the key control panel corresponding to the touch electrode 22, is controlled by the main processing module 1 to work, and is used for prompting the position or the touch state of the touch electrode 22.
In the above, the main processing module 1 performs charge and discharge control on the external capacitor 21, charges the external capacitor 21, discharges the equivalent capacitor of the touch electrode 22, then controls the external capacitor 21 to charge the equivalent capacitor of the touch electrode 22, so that the external capacitor 21 reaches the balance voltage, detects the voltage data of the first input/output pin when the external capacitor 21 reaches the balance voltage through the ADC module 7, and can determine the touch detection result of the touch electrode 22 according to the voltage data, thereby reducing the dependence on the clock precision of the timer in the prior art and effectively improving the accuracy of judging the key touch state.
Fig. 2 shows a flowchart of a touch key detection method according to an embodiment of the present application, which is applied to a touch key detection device according to the foregoing embodiment, where the touch key detection method according to the embodiment of the present application may be performed by a touch key detection device (e.g., a main processing module provided in the foregoing embodiment), and the touch key detection device may be implemented in hardware and/or software and integrated in a computer device.
The following describes an example of a touch key detection method performed by a touch key detection apparatus. Referring to fig. 2, the touch key detection method includes:
s101: based on charge and discharge control of the external capacitor, voltage of the first input and output pins is detected through the ADC module, and voltage data are obtained.
By way of example, the main processing module performs charge and discharge control on the external capacitor by using the working mode (input and output mode) of the input and output pins of the main processing module, that is, the external capacitor is charged first, and meanwhile, the equivalent capacitor of the touch electrode is discharged, and then the external capacitor is controlled to conveniently balance the equivalent capacitor until the external capacitor reaches voltage balance.
In the discharging process of the external capacitor, the voltage of the first input/output pin is detected through the ADC module, and when the external capacitor reaches voltage balance, the voltage of the first input/output pin is determined at the moment, and voltage data are obtained.
It can be understood that the equivalent capacitance of the touch electrode is different in the touch state and the non-touch state, and when the external capacitance reaches the voltage balance, the voltages of the first input and output pins are different, and the touch state of the touch electrode can be judged according to the voltage difference of the first input and output pins.
In this embodiment, the ADC module outputs 12bit voltage data according to the voltage of the first input/output pin, without converting the voltage data into a specific voltage value, where the range of the 12bit voltage data is 0-4095, so that the voltage change condition of the first input/output pin can be reflected more intuitively. Meanwhile, the voltage of the touch electrode with or without contact of the finger changes by about tens of mV, and the 12bit ADC module of the main processing module can recognize the difference of mV level.
S102: and filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value.
The voltage data obtained by the ADC module in the external capacitor voltage balancing is obtained, and then compared with the previous sampling value, and the voltage data is filtered and updated according to the comparison result, so as to obtain the current sampling value.
The filtering and updating of the voltage data is specifically as follows: when the voltage data is smaller than the last sampling value (and the last sampling value is smaller than the last sampling value), the voltage data is increased in the direction close to the last sampling value, and when the voltage data is larger than the last sampling value (and the last sampling value is larger than the last sampling value), the voltage data is decreased in the direction close to the last sampling value, namely, the voltage data is close to the last sampling value, and the updated voltage data is taken as the current sampling value. The purpose of filtering and updating the voltage data is to reduce fluctuation of the equivalent capacitance of the touch electrode caused by the outside world, so that fluctuation of the measured data is reduced, and the accuracy of touch key detection is improved.
S103: and updating the reference value according to the comparison result of the sampling value and the reference value.
The magnitude between the sampling value and the reference value is determined after the sampling value is obtained, and when the touch electrode is in the touch state, and when the sampling value is greater than the reference value, the reference value is increased, otherwise, the reference value is decreased, so that the reference value is adapted to the change of the environment. If the touch electrode is in the non-touch state, the reference value is kept unchanged.
The initial reference value may be determined according to a preset value, and the initial reference value may be determined as the preset value when the touch key detection device (or the main processor) is powered on for the first time. Wherein the initial reference value may be stored in a memory module (e.g., EEPROM) of the main processor.
S104: and determining a touch detection result of the touch electrode according to the sampling value and the reference value.
For example, after the determination of the sampling value and the update of the reference value are completed, a touch determination value for determining that the touch electrode is touched is determined according to the reference value (for example, a set determination threshold is added as the touch determination value on the basis of the reference value), and a touch detection result of the touch electrode is determined according to the sampling value and the touch determination value.
For example, comparing the sampling value with the touch judgment value, and when the sampling value is greater than or equal to the touch judgment value, determining that the touch electrode is touched, and generating a touch detection result reflecting the touch state of the touch electrode (or the touch key is valid); when the sampling value is smaller than the touch judgment value, the touch electrode is determined to be not touched, and a touch detection result reflecting the non-touch state of the touch electrode (or the invalid touch key) is generated.
In other embodiments, a transition range may be determined according to the reference value, where the data is considered to be in fluctuation in the transition range, and the current touch detection result is kept as the previous touch detection result, and the touch detection result reflecting the touch state of the touch electrode is determined above the transition range by the sampling value.
The external capacitor is charged through the main processing module, the equivalent capacitor of the touch electrode is discharged, the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input/output pin when the external capacitor reaches the balance voltage is detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and accuracy of judging the touch state of a key is effectively improved.
Fig. 3 shows a first partial flowchart of another touch key detection method provided in the embodiment of the present application, and fig. 4 shows a second partial flowchart of another touch key detection method provided in the embodiment of the present application, where the touch key detection method is embodied in the touch key detection method described above. Referring to fig. 3 and 4, the touch key detection method includes:
S201: the first input/output pin and the second input/output pin are configured to be in an output mode.
Illustratively, the first input-output pin and the second input-output pin are configured to be in an output mode, the output voltage of the first input-output pin is controlled to be VDD, and the output voltage of the second input-output pin is controlled to be VSS.
Specifically, the first input/output pin and the second input/output pin of the main processing module are both configured in an output mode, so that the output voltage of the first input/output pin is VDD (5V), and the output voltage of the second input/output pin is VSS (0V), which is equivalent to the charging of the external capacitor by the main processing module through the first input/output pin and the discharging of the equivalent capacitor of the touch electrode through the second input/output pin.
S202: the first input/output pin and the second input/output pin are configured as input modes, and voltage data is detected through the ADC module.
The first input/output pin and the second input/output pin are configured as input modes, and voltage of the first input/output pin is detected through the ADC module to obtain voltage data.
Specifically, the first input/output pin and the second input/output pin of the main processing module are configured to be in an input mode, and at this time, the first input/output pin and the second input/output pin are in a high-resistance state. At this time, the external capacitance charges the equivalent capacitance of the touch electrode through the charge-discharge resistor.
Further, after the first input/output pin and the second input/output pin are configured as input modes, the input/output modes of the two pins are kept unchanged, and the balance voltage of the first input/output pin is detected through the ADC module, so that voltage data are obtained.
S203: and judging whether the change directions of the voltage data relative to the last sampling value are consistent or not. If yes, go to step S205, otherwise, go to step S204.
Specifically, after voltage data of the external capacitor when voltage balance is determined, the voltage data is compared with a last sampling value, and a current change direction mark is set according to a comparison result. When the voltage data is greater than or equal to the last sampling value, the current change direction mark is set to be an increasing direction, and when the voltage data is less than the last sampling value, the current change direction mark is set to be a decreasing direction.
Further, after determining the current change direction flag, comparing the current change direction flag with the previous change direction flag, if the two change direction flags are consistent, the change direction of the voltage data relative to the previous sampling value is considered to be consistent, and the step S205 is skipped, otherwise the step S204 is skipped. It will be appreciated that the current direction of change flag may be used as the last direction of change flag in the next cycle.
S204: the filter counter and filter coefficients are reset.
Specifically, when the changing directions are inconsistent, the filter counter and the filter coefficient are reset, that is, the filter counter and the filter coefficient are cleared, and the process goes to step S206.
S205: updating the accumulated number of the filter counter according to the change amplitude of the voltage data relative to the last sampling value, and increasing the filter coefficient when the accumulated number of the filter counter reaches a count threshold.
Illustratively, when the change directions are identical, the cumulative number of the filter counter is updated according to the change amplitude of the voltage data with respect to the last sampling value, and when the cumulative number of the filter counter reaches the count threshold value, the filter coefficient is increased, and the process goes to step S206.
Fig. 5 shows a flowchart of updating a filter coefficient according to an embodiment of the present application. As shown in fig. 5, specifically, the above step of increasing the filter coefficient includes:
s2051: the accumulated number of filter counters is incremented by a first magnitude.
Specifically, the first amplitude may be set according to actual needs, and in this embodiment, the first amplitude is set to "1", that is, when the changing directions are consistent, the filtering counter is incremented by 1.
S2052: and judging whether the change amplitude of the voltage data relative to the last sampling value reaches a change threshold value or not. If yes, go to step S2053, otherwise, go to step S2054.
Specifically, it is determined whether the difference between the voltage data corresponding to the voltage data and the previous sampling value is greater than or equal to the change threshold, if yes, the step S2053 is skipped, otherwise, the step S2054 is skipped.
S2053: the accumulated number of filter counters is incremented by a second magnitude.
Specifically, when the difference is greater than or equal to the change threshold, the accumulated number of the filter counter is increased by the second amplitude, and the process goes to step S2054. The present embodiment sets the second amplitude to "2", i.e. the filter counter is incremented by 2.
S2054: it is determined whether the accumulated number of the filter counter reaches a count threshold. If yes, go to step S2055, otherwise, go to step S206.
Specifically, the accumulated number is compared with the count threshold, when the accumulated number is greater than or equal to the count threshold, the voltage data is considered to reach the threshold with respect to the previous sampling value change, the filter coefficient needs to be updated, and the step S2055 is skipped, otherwise, the step S206 is skipped.
S2055: and summing the filter coefficient and the coefficient increment to obtain an updated filter coefficient, and resetting the filter counter.
Specifically, when the accumulated number is greater than or equal to the count threshold, the filter coefficient is added by a coefficient increment, and the result of the summation is determined as the updated filter coefficient. The coefficient increment may be set according to practical situations, which is not limited in this embodiment.
Further, after the updating of the filter coefficient is completed, the filter counter is reset, i.e. the accumulated number is cleared.
S206: and calculating a sampling value of the time according to the voltage data and the filter coefficient.
After the resetting of the filter coefficient or the updating of the filter coefficient is completed, the sampling value of the time is calculated according to the voltage data and the filter coefficient.
Fig. 6 shows a flowchart of calculating a sampling value of this time according to an embodiment of the present application. As shown in fig. 6, specifically, the above specific steps for sampling values include steps S2061 to S2063:
s2061: and judging whether the voltage data is smaller than the last sampling value.
Specifically, the voltage data is compared with the previous sampling value, and when the voltage data is smaller than the previous sampling value, the step S2062 is skipped, otherwise, the step S2073 is skipped.
S2062: the sampling value of this time is determined as follows: y is Y n =Y n-1 -(Y n-1 -X n ) X a/C. After obtaining the current sampling value, the process goes to step S207.
If the voltage data is smaller than the last sampling value, determining that the sampling value is: y is Y n =Y n-1 -(Y n-1 -X n ) X a/C. Wherein Y is n For the current sampling value, Y n-1 X is the last sample value n For voltage data, a is a filter coefficient, C is a coefficient endpoint value, and the filter coefficient is less than the coefficient endpoint value. In this embodiment C, 256 is taken as an example for description, it is understood that when the filter coefficient is updated in step S2035, if the updated filter coefficient is greater than the coefficient endpoint value, the filter coefficient is redetermined to a value greater than the coefficient endpoint value, e.g. 255.
S2063: the sampling value of this time is determined as follows: y is Y n =Y n-1 +(X n- Y n-1 ) X a/C. After obtaining the current sampling value, the process goes to step S207
If the voltage data is greater than or equal to the last sampling value, determining that the sampling value at this time is: y is Y n =Y n-1 +(X n- Y n-1 ) X a/C. It will be appreciated that the determination of the current sample value is based on the ratio of the voltage data to the previous sample value, i.e. the determination of the current sample value may be based on the formula Y n =a×X n +(1-a)×Y n And 1, determining, wherein the formula is a result obtained by expanding the formula, and directly calculating a sampling value of the time by using the formula after obtaining an updated filter coefficient. In this embodiment, after the voltage data and the last sampling value are determined, the calculation is performed, so that the requirement on the calculation capability of the main processing module can be reduced, and the detection speed of the touch key is improved Degree.
In other embodiments, after resetting the filter coefficient, it is considered that the current voltage data can accurately reflect the detection condition of the touch electrode on the human body, and the current voltage data is directly used as the current sampling value.
S207: and judging whether the current main processing module is powered on for the first time.
Specifically, after determining the sampling value of this time, it is determined whether the current main processing module is powered on for the first time in this cycle, if so, the step is skipped to step S208, otherwise, the step is skipped to step S209.
S208: and taking the sampling value as a reference value.
Specifically, when the current main processing module is powered on for the first time, the sampling value of this time is used as a reference value. After the reference value is determined, the process goes to step S214.
S209: and judging whether the touch electrode is in a touch state.
Specifically, when the current main processing module is not powered on for the first time, whether the touch electrode is in a touch state is judged. The determination of whether the touch electrode is in the touched state may be based on the mark of the last touch electrode (pressed state or lifted state), that is, the touch electrode is determined to be in the non-touched state when the mark of the last touch electrode is in the lifted state, and the touch electrode is determined to be in the touched state when the mark of the last touch electrode is in the pressed state.
S210: the current reference value is maintained.
Specifically, if the touch electrode is in the touch state, the current reference value is maintained, and the process goes to step S214.
S211: and judging whether the sampling value is larger than a reference value. If yes, go to step S212, otherwise, go to step S213.
Specifically, when the touch electrode is in a non-touch state, comparing the sampling value with the reference value of the current buffer, and when the sampling value is greater than or equal to the reference value, jumping to step S212, otherwise, jumping to step S213.
S212: an increasing operation is performed on the reference value.
Specifically, when the sampling value is greater than or equal to the reference value, an increasing operation is performed on the reference value, an updated reference value is obtained, and the process goes to step S214. The increasing operation of the reference value may be to add a preset reference increment to the reference value, thereby obtaining an updated reference value.
S213: a decreasing operation is performed on the reference value.
Specifically, when the sampling value is smaller than the reference value, a reducing operation is performed on the reference value, and an updated reference value is obtained. The increasing operation of the reference value may be to subtract a preset reference increment from the reference value, thereby obtaining an updated reference value.
S214: and judging whether the sampling value reaches a touch judgment threshold value. If yes, go to step S215, otherwise go to step S223.
In this embodiment, the touch determination threshold is the sum of the reference value and the preset threshold. In other embodiments, the reference value may be directly used as the determination threshold.
Specifically, after the updated reference value is obtained, comparing the current sampling value with the updated reference value, and when the current sampling value is greater than or equal to the reference value, jumping to step S215 to determine the effective state of the touch electrode based on the erroneous touch prevention judgment of the touch electrode, wherein the effective state of the touch electrode includes touch effective and touch ineffective. When the current sampling value is smaller than the reference value, the process proceeds to step S223.
S215: the touch electrode is marked as a pressed state.
For example, when the current sampling value reaches the touch judgment threshold value, the touch electrode is marked as a pressed state. The marks on the touch electrode comprise a pressed state and a lifted state for indicating whether the current touch electrode is contacted by the (human body) again, respectively. For example, the pressed state and the lifted state may be marked with two values of 1 and 0, respectively.
S216: and judging whether other touch electrodes in a touch state exist or not. If yes, go to step S217, otherwise go to step S218.
Specifically, after the current touch electrode is marked as the pressed state, the marking state of other touch resistors is obtained (in this embodiment, 4 touch electrodes are set as an example), so as to determine whether other touch electrodes in the touch state exist, if so, the step S217 is skipped, and if not, the step S218 is skipped. For example, a value corresponding to a mark of another touch electrode may be found, and if the mark value is 1, the corresponding touch electrode is in a pressed state, and if it is 0, the corresponding touch electrode is in a lifted state.
S217: the active state of the touch electrode is determined to be touch inactive.
Specifically, when it is determined that other touch electrodes in a touch state exist, it is determined that the valid state of the touch electrode currently performing the touch key test is touch invalid. After determining that the active state of the touch electrode is touch inactive, it may return to step S201 to wait for the next detection cycle period.
S218: it is determined whether the last touch electrode is marked in the pressed state. If yes, go to step S219, otherwise go to step S222.
Specifically, if there are no other touch electrodes in the touch state, it is further determined whether the last touch electrode is marked as a pressed state. Optionally, after each time the touch electrode is marked, a state corresponding to the mark (corresponding mark value) is recorded, and the last marking state of the current touch electrode can be determined according to the timestamp or the recording position. When the last touch electrode mark is in the pressed state, the process goes to step S219, otherwise the process goes to step S222.
S219: and judging whether the counting statistics of the pressed states of the touch electrodes reach a counting threshold value or not. If yes, go to step S220, otherwise go to S221.
Specifically, when the last touch electrode is marked as a pressed state, whether the count statistics of the pressed state of the touch electrode reaches a count threshold is further judged. If the count statistics reach the count threshold, the process goes to step S220, otherwise the process goes to step S221.
For example, the count statistics of the pressed state of the touch electrode may be accumulated and counted, or may be counted each time the pressed state of the touch electrode is determined, and the corresponding count threshold may be determined according to the type of count statistics (for example, 1 second or 5-8 times).
S220: the active state of the touch electrode is determined to be touch active.
Specifically, when the count reaches the count threshold (for example, the pressed state of the touch electrode continues for 1 second or more), the valid state of the touch electrode is determined to be touch valid. Further, after determining that the valid state of the touch electrode is touch valid, the process may return to step S201 to wait for the next detection cycle period.
S221: the active state of the touch electrode is determined to be touch inactive.
Specifically, when it is determined that the count has not reached the count threshold (for example, the pressed state of the touch electrode has continued for less than 1 second), it is determined that the valid state of the touch electrode is touch invalid. Further, after determining that the valid state of the touch electrode is the touch invalid, it may return to step S201 to wait for the next detection cycle period.
S222: the active state of the touch electrode is determined to be touch inactive.
Specifically, when the last time the touch electrode is marked as being in the lifted state, the valid state of the touch electrode is determined to be invalid. Further, after determining that the valid state of the touch electrode is the touch invalid, it may return to step S201 to wait for the next detection cycle period.
S223: and judging whether the effective state of the touch electrode is effective. If yes, go to step S224, otherwise go to step S225.
Specifically, when the current sampling value does not reach the touch determination threshold, it is further determined whether the effective state of the touch electrode is touch-effective, and when the effective state of the touch electrode is touch-effective, the process goes to step S224, and when the effective state of the touch electrode is touch-ineffective, the process goes to step S225.
Further, when the current sampling value does not reach the touch judgment threshold, the touch electrode is marked in a lifted state, for example, the marking value of the current touch electrode is set to 0, and the current marking value is recorded. Meanwhile, counting statistics of the pressed states of the touch electrodes are cleared.
S224: and determining that the touch detection result is that the touch key is effective.
Specifically, when the valid state of the touch electrode is determined to be touch-valid (at this time, the touch electrode has been continuously marked as being pressed to reach the count threshold, and no other touch electrode is detected to be marked as being pressed during that time), it is determined that the touch detection result is that the touch key is valid. When the touch detection result is determined to be that the touch key is effective, the state feedback transceiver can feed back the touch detection result indicating that the touch key is effective to an external terminal (for example, an automobile ADAS system) so as to inform the external terminal to execute corresponding actions. After determining that the touch detection result is that the touch key is valid, the process may return to step S201 to wait for the next detection cycle period.
S225: and determining that the touch detection result is invalid.
Specifically, if the valid state of the touch electrode is touch invalid, it is determined that the touch detection result is touch key invalid, and the process returns to step S201 to wait for the next detection cycle.
The external capacitor is charged through the main processing module, the equivalent capacitor of the touch electrode is discharged, the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input/output pin when the external capacitor reaches the balance voltage is detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and accuracy of judging the touch state of a key is effectively improved. And the sampling value is determined according to the fluctuation condition of the voltage data, and the reference value is updated, so that the self-adaption to the environmental change is realized, and the accuracy of touch key detection is improved. Meanwhile, when the sampling value is determined according to the change amplitude of the voltage data relative to the last sampling value, the self-adaptive sensitivity to environmental change is improved.
Fig. 7 is a flowchart of another touch key detection method according to an embodiment of the present application, where the touch key detection method is implemented in the above touch key detection method. Referring to fig. 7, the touch key detection method includes:
s301: based on charge and discharge control of the external capacitor, voltage of the first input and output pins is detected through the ADC module, and voltage data are obtained.
S302: and filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value.
S303: and updating the reference value according to the comparison result of the sampling value and the reference value.
S304: and determining a touch detection result of the touch electrode according to the sampling value and the reference value.
S305: and determining control logic of the linear motor in response to a touch detection result of the valid touch key, and adjusting control parameters of the linear motor based on the control logic.
Specifically, when the touch detection result is that the touch key is effective, the control logic of the linear motor is determined based on the touch electrode corresponding to the touch detection result. The linear motors can be in one-to-one correspondence with the touch electrodes, or one linear motor corresponds to a plurality of touch electrodes.
Further, the determination of the control logic may be to determine the magnitude of the force pressed by the human hand according to the pressure detection information output by the pressure sensor corresponding to the current touch electrode, and select the corresponding control logic according to the range of the magnitude of the pressing force. Or different control logics are configured for the touch electrodes at different mounting positions, namely, different control logics are selected according to the distance between the touch electrodes and the linear motor.
It will be appreciated that the control logic may be operable to instruct the control parameters of the linear motor to cause the motor driver to control operation of the linear motor in accordance with the control parameters. The control logic may be set according to actual needs, and the present embodiment is not limited. The present embodiment sets three control logics, namely, a first control logic, a second control logic and a third control logic. For the first control logic: controlling the linear motor to operate at a PWM output of a first frequency (e.g., 160 Hz), a first duty cycle (e.g., 50%) for a first length of time (e.g., 300 ms); for the second control logic: controlling the linear motor to operate at a PWM output of a second frequency (e.g., 320 Hz), a second duty cycle (e.g., 50%) for a second length of time (e.g., 300 ms); for the third control logic: the linear motor is controlled to continuously operate for a third time period (for example, 50 ms) by the PWM output of the first frequency and the first duty ratio, and then is controlled to continuously operate for a fourth time period (for example, 30 ms) by the PWM output of the second frequency and the second duty ratio, and the preset times (for example, 6 times) are repeatedly operated.
Further, after determining the control logic of the linear motor, determining a parameter adjustment instruction for the linear motor according to the control logic, and sending the parameter adjustment instruction to the motor driver, wherein the motor driver updates the control parameter for the linear motor according to the parameter adjustment instruction, so that the linear motor operates at the updated control parameter.
The external capacitor is charged through the main processing module, the equivalent capacitor of the touch electrode is discharged, the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input/output pin when the external capacitor reaches the balance voltage is detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and accuracy of judging the touch state of a key is effectively improved. Meanwhile, the linear motor with adjustable control parameters is adopted, and the vibration feeling of each touch key is uniform and consistent through adjusting the parameters such as vibration frequency, vibration duration time, vibration intermittent time, circulation times and the like, so that the use experience is optimized.
Fig. 8 is a schematic structural diagram of a touch key detection device according to an embodiment of the present application. Referring to fig. 8, the touch key detection apparatus provided in this embodiment includes a data sampling module 81, a data filtering module 82, a reference updating module 83, and a touch judgment module 84.
The data sampling module 81 is configured to detect, by using the ADC module, a voltage of the first input/output pin based on charge/discharge control of the external capacitor, so as to obtain voltage data; the data filtering module 82 is configured to perform filtering update on the voltage data based on a change condition of the voltage data relative to a previous sampling value, so as to obtain a current sampling value; the reference updating module 83 is configured to update the reference value according to a comparison result between the current sampling value and the reference value; the touch judgment module 84 is configured to determine a touch detection result of the touch electrode according to the current sampling value and the reference value.
The external capacitor is charged through the main processing module, the equivalent capacitor of the touch electrode is discharged, the external capacitor is controlled to charge the equivalent capacitor of the touch electrode, the external capacitor is enabled to reach the balance voltage, the voltage data of the first input/output pin when the external capacitor reaches the balance voltage is detected through the ADC module, the touch detection result of the touch electrode can be determined according to the voltage data, dependence on clock precision of a timer in the prior art is reduced, and accuracy of judging the touch state of a key is effectively improved. Meanwhile, the linear motor with adjustable control parameters is adopted, and the vibration feeling of each touch key is uniform and consistent through adjusting the parameters such as vibration frequency, vibration duration time, vibration intermittent time, circulation times and the like, so that the use experience is optimized.
The embodiment of the application also provides computer equipment which can integrate the touch key detection device. Fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application. Referring to fig. 9, the computer apparatus includes: an input device 93, an output device 94, a memory 92, and one or more processors 91; the memory 92 is configured to store one or more programs; the one or more programs, when executed by the one or more processors 91, cause the one or more processors 91 to implement the touch key detection method as provided by the above-described embodiments. Wherein the input device 93, the output device 94, the memory 92 and the processor 91 may be connected by a bus or otherwise, for example in fig. 9.
The memory 92 is a computer readable storage medium, and may be used to store a software program, a computer executable program, and program instructions/modules corresponding to the touch key detection method according to any embodiment of the present application (for example, the data sampling module 81, the data filtering module 82, the reference updating module 83, and the touch determination module 84 in the touch key detection apparatus). The memory 92 may mainly include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the device, etc. In addition, memory 92 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 92 may further include memory remotely located relative to processor 91, which may be connected to the device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 93 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the device. The output 94 may include a display device such as a display screen.
The processor 91 executes various functional applications of the device and data processing by running software programs, instructions and modules stored in the memory 92, i.e., implements the touch key detection method described above.
The touch key detection device and the computer provided by the embodiment can be used for executing the touch key detection method provided by the embodiment, and have corresponding functions and beneficial effects.
The present application also provides a storage medium containing computer executable instructions, which when executed by a computer processor, are configured to perform the touch key detection method as provided in the above embodiments, the touch key detection method comprising: based on charge and discharge control of an external capacitor, detecting the voltage of the first input and output pins through the ADC module to obtain voltage data; filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value; updating the reference value according to the comparison result of the sampling value and the reference value; and determining a touch detection result of the touch electrode according to the sampling value and the reference value.
Storage media-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk or tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, lanbas (Rambus) RAM, etc.; nonvolatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a second, different computer system connected to the first computer system through a network such as the internet. The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present application is not limited to the touch key detection method described above, and may also perform the related operations in the touch key detection method provided in any embodiment of the present application.
The touch key detection device, the device and the storage medium provided in the foregoing embodiments may perform the touch key detection method provided in any embodiment of the present application, and technical details not described in detail in the foregoing embodiments may be referred to the touch key detection method provided in any embodiment of the present application.
The foregoing description is only of the preferred embodiments of the present application and the technical principles employed. The present application is not limited to the specific embodiments described herein, but is capable of numerous obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the present application. Therefore, while the present application has been described in connection with the above embodiments, the present application is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the claims.

Claims (12)

1. The touch key detection device is characterized by comprising a main processing module and a touch key module, wherein the touch key module comprises an external capacitor, a touch electrode and a charge-discharge resistor, and the touch key module comprises a main processing module, a touch electrode and a charge-discharge resistor, wherein the touch key module comprises a main processing module, a touch electrode and a touch electrode, wherein the main processing module comprises a touch electrode, a touch electrode and a touch electrode, wherein the touch electrode comprises a touch electrode, the touch electrode and the touch electrode, the touch electrode and:
one end of the external capacitor is electrically connected with a first input/output pin of the main processing module, and the other end of the external capacitor is grounded;
the touch electrode is electrically connected with a second input/output pin of the main processing module;
two ends of the charge-discharge resistor are respectively and electrically connected with a first input-output pin and a second input-output pin of the main processing module;
the main processing module is used for charging the external capacitor, discharging the equivalent capacitor of the touch electrode, controlling the external capacitor to charge the equivalent capacitor of the touch electrode so as to enable the external capacitor to reach balance voltage, detecting voltage data of a first input/output pin when the external capacitor reaches the balance voltage through the ADC module, and determining a touch detection result of the touch electrode according to the voltage data.
2. The touch key detection apparatus according to claim 1, further comprising a status feedback transceiver electrically connected to the data transceiver interface of the main processing module for communication connection with an external terminal.
3. The touch key detection apparatus according to claim 1, further comprising a linear motor with adjustable control parameters, wherein the main processing module is electrically connected to a motor driver of the linear motor, and wherein the main processing module adjusts the control parameters of the linear motor through the motor driver.
4. A touch key detection method applied to a touch key detection apparatus according to any one of claims 1 to 3, comprising:
based on charge and discharge control of an external capacitor, detecting the voltage of the first input and output pins through the ADC module to obtain voltage data;
filtering and updating the voltage data based on the change condition of the voltage data relative to the last sampling value to obtain the current sampling value;
updating the reference value according to the comparison result of the sampling value and the reference value;
and determining a touch detection result of the touch electrode according to the sampling value and the reference value.
5. The method for detecting a touch key according to claim 4, wherein the detecting the voltage of the first input/output pin by the ADC module based on the charge/discharge control of the external capacitor, to obtain the voltage data, includes:
Configuring a first input/output pin and a second input/output pin as output modes, controlling the output voltage of the first input/output pin to be VDD and the output voltage of the second input/output pin to be VSS;
and configuring the first input/output pin and the second input/output pin as input modes, and detecting the voltage of the first input/output pin through the ADC module to obtain voltage data.
6. The method for detecting a touch key according to claim 4, wherein the filtering and updating the voltage data based on the change condition of the voltage data with respect to the previous sampling value to obtain the current sampling value includes:
judging whether the change direction of the voltage data relative to the last sampling value is consistent or not;
if the change directions are inconsistent, resetting the filter counter and the filter coefficient;
if the change directions are consistent, updating the accumulated number of the filter counter according to the change amplitude of the voltage data relative to the last sampling value, and increasing the filter coefficient when the accumulated number of the filter counter reaches a count threshold;
and calculating a sampling value of the time according to the voltage data and the filter coefficient.
7. The method for detecting a touch key according to claim 6, wherein calculating the sampling value of this time according to the voltage data and the filter coefficient comprises:
Judging whether the voltage data is smaller than the last sampling value or not;
if the voltage data is smaller than the last sampling value, determining that the sampling value is: y is Y n =Y n-1 -(Y n-1 -X n ) X a/C, wherein Y n For the current sampling value, Y n-1 X is the last sample value n A is a filter coefficient, C is a coefficient endpoint value, and the filter coefficient is smaller than the coefficient endpoint value;
if the voltage data is greater than or equal to the last sampling value, determining that the sampling value at this time is: y is Y n =Y n-1 +(X n- Y n-1 )×a/C。
8. The method for detecting a touch key according to claim 4, wherein updating the reference value according to the comparison result between the current sampling value and the reference value comprises:
judging whether the current main processing module is powered on for the first time;
if the current main processing module is electrified for the first time, taking the sampling value as a reference value;
if the current main processing module is not powered on for the first time, judging whether the touch electrode is in a touch state or not;
if the touch electrode is in a touch state, maintaining the current reference value;
if the touch electrode is in a non-touch state, judging whether the sampling value is larger than a reference value or not;
if the sampling value is greater than or equal to a reference value, executing an increasing operation on the reference value;
And if the sampling value is smaller than the reference value, executing a reducing operation on the reference value.
9. The method for detecting a touch key according to claim 4, wherein the determining the touch detection result of the touch electrode according to the sampling value of the present time and the reference value comprises:
judging whether the sampling value of the time reaches a touch judgment threshold value or not, wherein the touch judgment threshold value is the sum of the reference value and a preset threshold value;
if the sampling value reaches a touch judgment threshold value, determining the effective state of the touch electrode based on the false touch prevention judgment of the touch electrode, wherein the effective state of the touch electrode comprises touch effective and touch ineffective;
if the sampling value does not reach the touch judgment threshold value, judging whether the effective state of the touch electrode is effective;
if the effective state of the touch electrode is effective, determining that the touch detection result is effective;
if the effective state of the touch electrode is the touch invalidity, the touch detection result is determined to be the touch key invalidity.
10. The touch key detection method according to claim 9, wherein the determining the valid state of the touch electrode based on the erroneous touch prevention judgment of the touch electrode includes:
Marking the touch electrode in a pressing state, judging whether other touch electrodes marked in the pressing state exist or not, and updating the marks of the touch electrodes into a lifting state when the sampling value does not reach a touch judgment threshold value;
if other touch electrodes marked as the pressed state exist, determining that the effective state of the touch electrodes is invalid;
if no other touch electrode marked in the pressed state exists, judging whether the last touch electrode is marked in the pressed state or not;
if the last touch electrode mark is in the pressed state, judging whether the counting statistics of the pressed state of the touch electrode reaches a counting threshold value or not;
if the counting statistics reach the counting threshold value, determining that the effective state of the touch electrode is effective;
if the counting statistics does not reach the counting threshold value, determining that the effective state of the touch electrode is invalid;
and if the last touch electrode mark is in a lifting state, determining that the effective state of the touch electrode is invalid.
11. The method for detecting a touch key according to claim 4, further comprising, after determining a touch detection result of the touch electrode according to the sampling value of the present time and the reference value:
and determining control logic of the linear motor in response to a touch detection result of the valid touch key, and adjusting control parameters of the linear motor based on the control logic.
12. The touch key detection method of claim 11, wherein the control logic comprises: first control logic: controlling the linear motor to continuously run for a first length of time at a first frequency and a PWM output of a first duty cycle; or (b)
Second control logic: controlling the linear motor to continue operating at a second frequency, PWM output of a second duty cycle, for a second length of time; or (b)
Third control logic: the linear motor is controlled to continuously run for a third time length by PWM output of a first frequency and a first duty ratio, and then is controlled to continuously run for a fourth time length by PWM output of a second frequency and a second duty ratio, and the operation is repeated for preset times.
CN202010559903.9A 2020-06-18 2020-06-18 Touch key detection equipment and method Active CN111865289B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010559903.9A CN111865289B (en) 2020-06-18 2020-06-18 Touch key detection equipment and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010559903.9A CN111865289B (en) 2020-06-18 2020-06-18 Touch key detection equipment and method

Publications (2)

Publication Number Publication Date
CN111865289A CN111865289A (en) 2020-10-30
CN111865289B true CN111865289B (en) 2024-03-26

Family

ID=72986220

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010559903.9A Active CN111865289B (en) 2020-06-18 2020-06-18 Touch key detection equipment and method

Country Status (1)

Country Link
CN (1) CN111865289B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113703659B (en) * 2021-09-01 2024-06-11 恒玄科技(上海)股份有限公司 State detection method and device, wearable device and readable storage medium
CN113708752B (en) * 2021-09-01 2024-01-30 恒玄科技(上海)股份有限公司 Detection device of electric capacity and wearable equipment
CN116909433A (en) * 2023-09-12 2023-10-20 宁波普瑞均胜汽车电子有限公司 Touch event detection method, device and system and computer equipment
CN117687535B (en) * 2024-02-01 2024-04-16 苏州华芯微电子股份有限公司 Capacitance touch key reference value correction method, device, equipment and readable medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499793A (en) * 2008-01-31 2009-08-05 杭州利尔达科技有限公司 Capacitor induction type touch press-key based on MCU and measuring method for touch press-key capacitance
KR20100038590A (en) * 2008-10-06 2010-04-15 엘지전자 주식회사 Touch sensor and method for recognizing a touch
CN104138209A (en) * 2014-07-08 2014-11-12 九阳股份有限公司 Sliding touch control soybean milk machine and sliding control method
CN104794433A (en) * 2015-03-27 2015-07-22 深圳市汇顶科技股份有限公司 Fingerprint recognition system and fingerprint recognition method
CN105302383A (en) * 2014-06-23 2016-02-03 炬力集成电路设计有限公司 Anti-interference method and device for capacitive touch sensor
CN105420995A (en) * 2014-08-14 2016-03-23 松下家电研究开发(杭州)有限公司 Cover opening and closing detecting method for clothes treating equipment and clothes treating equipment
CN207111911U (en) * 2017-05-18 2018-03-16 金龙机电(杭州)有限公司 A kind of automobile intelligent gear lever handle
CN208482002U (en) * 2018-03-19 2019-02-12 长荣玩具(东莞)有限公司 Twins' pet egg toy control circuit

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499793A (en) * 2008-01-31 2009-08-05 杭州利尔达科技有限公司 Capacitor induction type touch press-key based on MCU and measuring method for touch press-key capacitance
KR20100038590A (en) * 2008-10-06 2010-04-15 엘지전자 주식회사 Touch sensor and method for recognizing a touch
CN105302383A (en) * 2014-06-23 2016-02-03 炬力集成电路设计有限公司 Anti-interference method and device for capacitive touch sensor
CN104138209A (en) * 2014-07-08 2014-11-12 九阳股份有限公司 Sliding touch control soybean milk machine and sliding control method
CN105420995A (en) * 2014-08-14 2016-03-23 松下家电研究开发(杭州)有限公司 Cover opening and closing detecting method for clothes treating equipment and clothes treating equipment
CN104794433A (en) * 2015-03-27 2015-07-22 深圳市汇顶科技股份有限公司 Fingerprint recognition system and fingerprint recognition method
CN207111911U (en) * 2017-05-18 2018-03-16 金龙机电(杭州)有限公司 A kind of automobile intelligent gear lever handle
CN208482002U (en) * 2018-03-19 2019-02-12 长荣玩具(东莞)有限公司 Twins' pet egg toy control circuit

Also Published As

Publication number Publication date
CN111865289A (en) 2020-10-30

Similar Documents

Publication Publication Date Title
CN111865289B (en) Touch key detection equipment and method
US11408787B2 (en) Control methods for a force sensor system
CN102495681B (en) Control equipment with touch buttons
US8466899B2 (en) Touch panel
JP5193942B2 (en) Capacitive touch panel device
CN102667690B (en) Methods and apparatus for performing capacitive touch sensing and proximity detection
TWI452511B (en) Low power switching mode driving and sensing method for capacitive touch system
EP1930801B1 (en) Sensor device provided with a circuit for detection of single or multiple events for generating corresponding interrupt signals
CN101763195B (en) Method for preventing mobile terminal touch screen from being damaged and relevant device
US20110273400A1 (en) Integrator circuit with inverting integrator and non-inverting integrator
US20080116904A1 (en) Methods and systems for switched charge transfer capacitance measuring using shared components
US20110001494A1 (en) Methods and systems for sigma delta capacitance measuring using shared components
EP3640779A1 (en) Capacitance detection circuit, touch chip and electronic device
US10396785B2 (en) Reduction of capacitive touch sense electrode sample value change when electrode scan period is changed
CN103427817A (en) Proximity switch assembly having dynamic tuned threshold
WO2010021860A1 (en) System and method for measuring a capacitance and selectively activating an indicating transducer
EP3092542A2 (en) System and method for host-augmented touch processing
EP3550408A1 (en) Pressure measurement method and apparatus for active pen, and active pen
CN103729056A (en) System and method for controlling electronic equipment by knock
CN106445231A (en) Identification method and device of touches
EP3770738B1 (en) Capacitance detection circuit, capacitance detection method, touch chip and electronic device
CN217085101U (en) Capacitance detection circuit, touch control chip and electronic equipment
CN114487784A (en) Capacitance detection circuit, touch chip and electronic equipment
CN111106820B (en) Touch key control system and control method thereof
JP5028824B2 (en) Capacitance detection type switch device and wristwatch provided with the same

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
GR01 Patent grant
GR01 Patent grant