[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN113867577B - Digital detection system, chip and detection method for capacitive touch keys - Google Patents

Digital detection system, chip and detection method for capacitive touch keys Download PDF

Info

Publication number
CN113867577B
CN113867577B CN202111116357.2A CN202111116357A CN113867577B CN 113867577 B CN113867577 B CN 113867577B CN 202111116357 A CN202111116357 A CN 202111116357A CN 113867577 B CN113867577 B CN 113867577B
Authority
CN
China
Prior art keywords
key
touch
capacitance value
time
real
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
CN202111116357.2A
Other languages
Chinese (zh)
Other versions
CN113867577A (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.)
Zhuhai Amicro Semiconductor Co Ltd
Original Assignee
Zhuhai Amicro Semiconductor 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 Zhuhai Amicro Semiconductor Co Ltd filed Critical Zhuhai Amicro Semiconductor Co Ltd
Priority to CN202111116357.2A priority Critical patent/CN113867577B/en
Publication of CN113867577A publication Critical patent/CN113867577A/en
Application granted granted Critical
Publication of CN113867577B publication Critical patent/CN113867577B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/03Arrangements for converting the position or the displacement of a member into a coded form
    • G06F3/041Digitisers, e.g. for touch screens or touch pads, characterised by the transducing means
    • G06F3/044Digitisers, e.g. for touch screens or touch pads, characterised by the transducing means by capacitive means
    • G06F3/0441Digitisers, e.g. for touch screens or touch pads, characterised by the transducing means by capacitive means using active external devices, e.g. active pens, for receiving changes in electrical potential transmitted by the digitiser, e.g. tablet driving signals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Human Computer Interaction (AREA)
  • Electronic Switches (AREA)

Abstract

The invention discloses a digital detection system, a chip and a detection method of a capacitive touch key, wherein in the digital detection system, a real-time capacitance value register is used for sampling the real-time capacitance value of the same touch key once every other polling period; the reference capacitance value register stores a reference capacitance value of the corresponding touch key; the average filtering unit is used for averaging the real-time capacitance values of the first preset sampling number sampled in the current key detection cycle period when the real-time capacitance value register samples the same touch key in the key detection cycle period to obtain the first preset sampling number, and outputting an average sampling value corresponding to the touch key; and the touch judgment unit is used for determining the detection result of the touch key according to the comparison result of the average sampling value of the corresponding touch key output by the average filtering unit and the reference capacitance value of the touch key.

Description

Digital detection system, chip and detection method for capacitive touch keys
Technical Field
The invention belongs to the technical field of touch keys, and particularly relates to a digital detection system, a chip and a detection method of a capacitive touch key.
Background
The general touch key arrangement mode is mainly N x M matrix arrangement, the internal design mainly comprises matrix key scanning, processing, encoding and other modules, the implementation modes of each module are different, such as row-column scanning, state machine scanning, delay debouncing, state machine debouncing, register debouncing, RS trigger debouncing, RC filtering, median filtering, BCD encoding and other modes, and different arrangement combinations form different touch key digital part design structures. The capacitive touch detection is based on the principle of frequency change of an RC oscillator, when a hand of a person touches a touch key, the equivalent capacitance of the touch key to the ground is increased, so that the frequency of the RC oscillator connected with the touch key changes along with the change, the change of the equivalent capacitance can be detected by using the count value of square waves output by the RC oscillator in a reference clock period, namely the occurrence of a touch event can be detected, but the occurrence of false triggering is likely to occur due to interference of external noise.
Currently, some touch key design architectures include an analog circuit portion, and the analog circuit portion directly outputs a key judgment result (binary signal); the design architecture of the touch key comprises an analog circuit part and a digital logic module, the design architecture of the touch key usually constructs the digital logic module according to the design mode of the analog circuit part, wherein the analog circuit part directly transmits the sampling capacitance value or the charging time value of the capacitor to the digital logic module, for example, the design architecture of the touch key designs the RC oscillator as the analog circuit part, and the RC oscillator can be used as a common capacitance value acquisition circuit and can convert the sampling capacitance or the charging time parameter into the capacitance value to be transmitted to the digital logic module for touch key detection. However, the design of the analog circuit portion is prone to interference, affecting the sensitivity of the touch key.
Disclosure of Invention
In order to overcome the technical defects, the invention discloses a digital detection system, a chip and a detection method of a capacitive touch key, which adopt a combination mode of average value filtering and polling scanning to process a sampling capacitance value sent by an analog circuit part of the touch key, and finally realize the detection of the touch key in a more accurate mode, and the specific technical scheme is as follows:
The digital detection system of a kind of capacitive touch key, there is electrical connection in the digital detection system and capacitance value acquisition circuit, the capacitance value acquisition circuit is configured to be used for obtaining the real-time capacitance value of a touch key connected; the digital detection system comprises a real-time capacitance value register, an average filtering unit, a reference capacitance value register, a polling control unit and a touch judgment unit; wherein the polling control unit is a state machine; the real-time capacitance value register is connected with the capacitance value acquisition circuit and is used for sampling the real-time capacitance value of the same touch key once every other polling period under the scheduling of the polling control unit; the reference capacitance value register is used for storing the reference capacitance value of the corresponding touch key; the real-time capacitance value register is connected with the average filtering unit, and the average filtering unit is used for averaging the real-time capacitance values of the first preset sampling number sampled in the current key detection cycle period when the real-time capacitance value register samples the same touch key in the key detection cycle period to be a first preset sampling number under the scheduling of the polling control unit, and then configuring the output average value as an average sampling value of the corresponding touch key; the touch judgment unit is respectively connected with the average filtering unit and the reference capacitance value register, and is used for determining the detection result of the touch key according to the comparison result of the average sampling value of the corresponding touch key output by the average filtering unit and the reference capacitance value of the touch key under the scheduling of the polling control unit.
Compared with the prior art, the digital detection system disclosed by the technical scheme continuously samples the real-time capacitance value of each touch key for multiple times sequentially through the digital circuit (a state machine scheduling mode), averages the real-time capacitance values obtained by multiple rounds of each touch key, and shares the part detection processing function which originally belongs to the analog circuit part of the key detection circuit in the prior art and should be born, thereby reducing the interference problem easily caused by the analog circuit part, overcoming the problem that errors easily occur in single sampling value and improving the detection sensitivity of the touch key.
Further, the digital detection system is used for detecting the touch state of each touch key in a row of capacitive touch keys; the number of the touch keys arranged in the row of the capacitive touch keys is larger than 1; in a row of capacitive touch keys, each touch key is respectively connected with a corresponding capacitance value acquisition circuit; the number of the real-time capacitance value registers included in the digital detection system is equal to the number of all touch keys in the row of capacitive touch keys, and each real-time capacitance value register is connected with a corresponding capacitance value acquisition circuit so that the capacitance of each touch key corresponds to the corresponding real-time capacitance value register; the number of reference capacitance value registers included in the digital detection system is equal to the number of all touch keys in the row of capacitive touch keys, and each reference capacitance value register is matched with a corresponding capacitance value acquisition circuit so that each touch key corresponds to a corresponding reference capacitance value register. The universality of the digital detection system is improved, and the digital detection system can be applied to detection of the touch state or the pressing state of touch keys in various permutation and combination.
Further, the polling control unit comprises a key scanning counter and a polling counter; the key scanning counter is used for triggering one real-time capacitance value register to sample the real-time capacitance value of a corresponding touch key in a row of capacitive touch keys when a key scanning signal is generated, and determining to finish one-round sampling of the real-time capacitance values of all the touch keys in the row of capacitive touch keys when the increment of the count value reaches the difference value between the preset key number and the value 1; the number of touch keys arranged in one row of capacitive touch keys is a preset key number; the polling counter is used for counting once every time the real-time capacitance value register completes one-round sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys, and triggering the touch judging unit to output one-time detection results of all touch keys in the row of capacitive touch keys after the increment of the count value reaches the difference value between the first preset sampling number and the value 1; and acquiring one detection result of all touch keys in a row of capacitive touch keys every other key detection cycle.
The technical scheme designs a counter for marking the polling working state to form the polling control unit; the key scanning counter finishes one round of scanning of the real-time capacitance values of all touch keys in a row of capacitive touch keys when counting the preset key number, wherein the key scanning counter jumps to a new working state when counting once; the first preset sampling number is counted by the polling counter every time, the real-time capacitance value of each touch key is sampled for a plurality of times, and each time the polling counter counts up once, the polling counter records that one row of capacitive touch keys is scanned; and the polling control unit is ensured to schedule corresponding working states according to a time sequence so as to control the detection precision of the functional units.
Further, the polling control unit sends the key scanning signal to a corresponding capacitance value acquisition circuit whenever generating one key scanning signal, triggers the corresponding capacitance value acquisition circuit to acquire the real-time capacitance value of a touch key connected with the corresponding capacitance value acquisition circuit, and receives a sampling end mark signal when the corresponding capacitance value acquisition circuit stores the real-time capacitance value of the touch key into the real-time capacitance value register; the touch judgment unit is used for combining the detection results of all the touch keys into a key coding signal according to the arrangement sequence of the corresponding touch keys in the row of capacitive touch keys every time the detection results of all the touch keys in the row of capacitive touch keys are obtained under the scheduling of the polling control unit, wherein the bit width of the key coding signal is equal to the preset key number, and the detection result of one touch key is expressed as a one-bit binary number. The bit width of the key code signal is equal to the preset key number, and the detection result of one touch key is expressed as one-bit binary number. The real-time capacitance value of each touch key can be stably sampled into the real-time capacitance value register, and then the signals coded and output by the touch judging unit are low in noise and interference.
Further, when the increment of the count value of the polling counter reaches the difference value between the first preset sampling number and the value 1, the touch judging unit is scheduled to output a key code signal which is newly combined, so that detection results of all touch keys in a row of capacitive touch keys are accurately and comprehensively reflected, the delay influence of a sampling end mark signal between key code signals correspondingly output after two adjacent touch keys are simultaneously touched is overcome, and invalid signals existing between key code signals correspondingly output after two adjacent touch keys are successively touched are prevented from being read; and after the real-time capacitance value of the same touch key is continuously sampled by the first preset sampling number by the real-time capacitance value register, the touch key is subjected to averaging processing by an average filtering unit, and a detection result is determined by the touch judging unit.
Further, the digital detection system further comprises a reference value processing unit, and the reference capacitance value register, the capacitance value acquisition circuit and the touch judgment unit are all connected with the reference value processing unit; the reference value processing unit is used for updating the average sampling value output by the average filtering unit into the reference capacitance value stored in the reference capacitance value register when the touch judging unit outputs a result which is not touched; and the reference value processing unit is also used for keeping the reference capacitance value stored in the reference capacitance value register unchanged when the touch judging unit outputs the touched result. Each reference capacitance value register is connected with a corresponding capacitance value acquisition circuit through the same reference value processing unit, so that each reference capacitance value register is matched with the corresponding capacitance value acquisition circuit. The reference value processing unit provided by the technical scheme updates the currently stored reference capacitance value according to the comparison result (detection result of the corresponding touch key) of the average sampling value of the corresponding touch key and the reference capacitance value of the touch key output by the average filtering unit, so as to realize self-adaptive correction of the reference capacitance value; and the detection sensitivity can be improved by using the updated reference capacitance for comparison so as to adapt to the influence of the external environment on the equivalent capacitance value of the touch key.
Further, the reference value processing unit is further configured to sample a real-time capacitance value of the same touch key once every other scanning period in the non-touch scanning time set by the polling control unit, and store the real-time capacitance value as a capacitance value of the touch key in a non-touch state; wherein, in the non-touch scanning time, all touch keys are not touched; the reference value processing unit is configured to average the currently acquired real-time capacitance values of the second preset sampling number when the number of the real-time capacitance values of the same touch key is the second preset sampling number in the non-touch scanning time, configure the obtained average value as an initial reference capacitance value corresponding to the touch key, output the initial reference capacitance value to the reference capacitance value register, and trigger the real-time capacitance value register to start sampling; wherein the initial reference capacitance value is a reference capacitance value that has not been updated. According to the technical scheme, in the state that the row of capacitive touch keys is not touched, the capacitance sampling values obtained in multiple rounds are averaged to obtain a reference capacitance value in an initial state, namely, the capacitance value of each touch key in the initial state after power-on.
Further, the polling control unit comprises a key scanning counter and a polling counter; the key scanning counter is used for triggering the reference value processing unit to sample the real-time capacitance value of the corresponding touch key in a row of capacitive touch keys every time a key scanning signal is generated in the non-touch scanning time until the increment of the count value reaches the difference value between the preset key number and the value 1, and completing one-round sampling of the real-time capacitance values of all the touch keys in the row of capacitive touch keys; the number of touch keys arranged in one row of capacitive touch keys is a preset key number; and the polling counter is used for counting once every time the reference value processing unit completes one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys in the non-touch scanning time, triggering the reference value processing unit to average the capacitance value of the second preset sampling number acquired currently after the increment of the count value reaches the second preset sampling number, configuring the obtained average value as an initial reference capacitance value of the corresponding touch key, and outputting the initial reference capacitance value to a corresponding reference capacitance value register.
In the polling control unit of the present technical solution, one round of scanning of real-time capacitance values of all touch keys in a row of capacitive touch keys is completed when the same key scanning counter counts the preset key number; the polling counter finishes sampling the second preset sampling number for each real-time capacitance value of each touch key every time when counting the second preset sampling number; the polling control unit is ensured to schedule corresponding working states according to time sequence, the initialization precision of the reference capacitance value is realized, the reference capacitance value is also adapted to the parameter environment of the key non-touch state, and the detection accuracy is improved.
Further, the touch judgment unit is used for judging that the touch key is not touched so as not to execute key operation when detecting that the average sampling value of the corresponding touch key output by the average filtering unit is smaller than or equal to the reference capacitance value of the touch key; the touch judgment unit is further used for judging that the touch key is touched to execute key operation when detecting that the average sampling value of the corresponding touch key output by the average filtering unit is larger than the reference capacitance value of the touch key. According to the technical scheme, the touch state of the touch key is judged according to the comparison result of the average sampling value of the corresponding touch key output by the average filtering unit and the reference capacitance value of the touch key, the influence of noise on the capacitance sampling value of the touch key is weakened, and the problem that errors are easy to occur in single sampling value is solved.
Further, the digital detection system further comprises a preprocessing unit, wherein an initial capacitance threshold value is stored in the preprocessing unit; the preprocessing unit is used for taking a touch key corresponding to the real-time capacitance value as a polling starting point when the real-time capacitance value acquired by the capacitance value acquisition circuit is larger than an initial capacitance threshold value after the digital detection system is electrified and started, so that a first polling period is started, and the capacitance value sampled by the real-time capacitance value register for the first time is one capacitance value in the real-time capacitance values of the same touch key in a first preset sampling number, and is also the capacitance value which is acquired by the capacitance value acquisition circuit for the first time and is larger than the initial capacitance threshold value.
According to the technical scheme, an initial capacitance threshold is set, a touch key with a real-time capacitance value larger than the initial capacitance threshold, which is sampled for the first time, is used as a polling starting point of the polling control unit, so that a first polling period in a key detection cycle period is started, and the touch judgment unit starts to detect from a touch key with the first real-time capacitance value meeting the threshold.
Further, the polling control unit includes a key scan counter; and the key scanning counter is used for starting counting and sending a key scanning signal after the digital detection system is electrified and started and the preprocessing unit judges that the real-time capacitance value of the touch key acquired by the capacitance value acquisition circuit is larger than the initial capacitance threshold value for the first time, triggering the real-time capacitance value register to sample the real-time capacitance value of the corresponding touch key in the row of capacitance type touch keys, and then generating a new key scanning signal and sending the new key scanning signal to the corresponding capacitance value acquisition circuit every time the real-time capacitance value register samples the real-time capacitance value of the current touch key in the row of capacitance type touch keys so as to trigger the real-time capacitance value register to sample the real-time capacitance value of the next touch key in the row of capacitance type touch keys until one round of sampling of the real-time capacitance values of all touch keys in the row of capacitance type touch keys is completed.
In this technical scheme, after the digital detection system is powered on each time, if the preprocessing unit determines that the real-time capacitance value of the touch key acquired by the capacitance value acquisition circuit is greater than the initial capacitance threshold value for the first time, the currently determined touch key is set as the first key position participating in polling detection, and the current time is set as the starting time of the first polling period and is also the starting time of the key detection cycle period, so that the preprocessing unit provides a trigger signal for starting operation for the polling control unit.
Further, each time a capacitance value acquisition circuit stores the real-time capacitance value of the touch key to be connected to the corresponding real-time capacitance value register, the capacitance value acquisition circuit generates a sampling end flag signal and is received by the polling control unit; every time a capacitance value acquisition circuit does not completely store the real-time capacitance value of the touch key to be connected into the corresponding real-time capacitance value register, the capacitance value acquisition circuit does not generate a sampling end mark signal, and meanwhile, the polling control unit enters a waiting state until the sampling end mark signal generated by the capacitance value acquisition circuit is received. According to the technical scheme, the sampling end mark signal is set to feed back the information that the sampling and storage operation of the current touch key is completed to the polling control unit, and then the next touch key is scanned based on the feedback information, so that each sampled real-time capacitance value can be completely stored in the real-time capacitance value register.
Further, each time the digital detection system receives a sampling end flag signal sent by one of the capacitance value acquisition circuits, the key scanning counter is controlled to stop counting until a preset jitter elimination time is completed. And misjudgment caused by shaking of the touch keys is prevented.
Further, the digital detection system further comprises a key timer, wherein the number of the key timers is the number of all touch keys in the row of capacitive touch keys, and each touch key is matched with one key timer; and the key timer is used for adding a count once when a corresponding touch key passes through one key detection cycle period, and configuring the product of the increment of the latest count value and the key detection cycle period as the touch time of the corresponding touch key. The key timer disclosed in this embodiment configures a key detection cycle period to be a unit time for judging an abnormal condition of a key, so as to ensure the detection accuracy of a touch key and the integrity of a detection result.
Further, after the touch judgment unit judges that one touch key is touched, the key timer is triggered to start timing, when the count value of the key timer is larger than a preset key delay threshold value, the touch key is determined to be in a key abnormal state, and then an interrupt signal is sent to a CPU (central processing unit) outside the digital detection system to control the digital detection system to stop working, so that the digital detection system is motivated to restart to initialize the reference capacitance value, the sensitivity of touch key detection is ensured, and the risk of false recognition of the touch key is reduced.
Further, when the touch judgment unit judges that one touch key is touched, the digital detection system starts to record the time for keeping the touch key touched, if the digital detection system judges that the current recorded time is longer than the preset key scanning time, the touch key is determined to be in a touch invalid state, otherwise, the touch key is determined to be in a touch valid state; when the touch judgment unit judges that one touch key is not touched, the digital detection system starts to record the time when the touch key is not touched, if the digital detection system judges that the current recorded time is longer than the preset key scanning time, the touch key is determined to be in a release invalid state, otherwise, the touch key is determined to be in a non-touch valid state; wherein the preset key scan time is on the order of milliseconds.
According to the technical scheme, the influence of key jitter is eliminated by delaying from the two states of touching and not touching the touch key respectively, and the accuracy of the detection result of the touch judging unit is ensured.
A chip comprising the digital detection system. The real-time capacitance value of each touch key is sampled and averaged continuously for many times in sequence in a digital state machine scheduling mode, and then the reference capacitance value parameter is automatically updated according to the detection result so as to adapt to the key detection of the next key detection cycle period, so that the influence of the noise signal of a chip circuit and the interference of the external environment are inhibited, the sensitivity of touch induction is improved, the use of an analog circuit is also saved, and the chip area is reduced.
A detection method based on the digital detection system, comprising the following steps: step S1, sampling the real-time capacitance value of each touch key in each polling period in sequence; step S2, when the sampling times of the real-time capacitance value of the same touch key is equal to the first preset sampling number, averaging the real-time capacitance value of the touch key to obtain an average sampling value of the touch key; and S3, determining a detection result of the touch key according to a comparison result of the average sampling value of the touch key and the reference capacitance value of the touch key. According to the technical scheme, the influence of different sampling values on the detection result is eliminated, the problem that errors are easy to occur in single sampling values is solved, and the detection sensitivity and accuracy of the touch keys are improved.
Further, the step S3 specifically includes: when the average sampling value of one touch key is larger than the reference capacitance value of the touch key, judging that the touch key is touched; and when the average sampling value of one touch key is smaller than or equal to the reference capacitance value of the touch key, judging that the touch key is not touched. According to the technical scheme, the touch state of the touch key is judged according to the comparison result of the average sampling value of the touch key and the reference capacitance value of the touch key, the influence of noise generated by the environment on the capacitance sampling value of the touch key is weakened, the problem that errors occur in single sampling value easily is solved, and the detection sensitivity and accuracy of the touch key are improved.
Further, the step S3 further includes: when the touch key is judged to be touched, maintaining the reference capacitance value corresponding to the touch key unchanged; and when the touch key is judged not to be touched, updating the average sampling value of the touch key to be the reference capacitance value of the touch key. According to the technical scheme, the influence of noise generated under the action of environmental interference on the capacitance sampling value of the touch key is weakened, and the detection sensitivity and accuracy of the touch key are improved.
Further, the step S3 further includes: when the touch key is judged to be touched, the reference capacitance value corresponding to the touch key is kept unchanged; and when the touch key is judged not to be touched, updating the average sampling value of the touch key to be the reference capacitance value of the touch key. Updating the currently stored reference capacitance value to realize self-adaptive correction of the reference capacitance value; and the detection sensitivity can be improved by using the updated reference capacitance for comparison so as to adapt to the influence of the external environment on the equivalent capacitance value of the touch key.
Further, when step S2 obtains an average sampling value of all the touch keys, and step S3 determines that a key detection cycle period has been spent after determining the detection results of all the touch keys; wherein one of the polling periods is the time taken for the real-time capacitance value of each touch key in a row of capacitive touch keys to be sampled once, respectively; wherein the product of the first preset number of samples and a polling period is equal to one of the key detection cycle periods.
The technical scheme sets the polling period as a small cycle period as the sum of time required for completing one round of scanning of real-time capacitance values of all touch keys in a row of capacitive touch keys; setting the key detection cycle period as a large cycle period, and taking the large cycle period as the sum of time required by continuously sampling a first preset sampling number and sampling a real-time capacitance value of each touch key in a row of capacitive touch keys; and creating sampling conditions and calculating conditions for calculating the average value of the real-time capacitance values of the touch keys.
Further, before executing step S1, the method further includes: step S0, sequentially sampling real-time capacitance values of each touch key for multiple times in a set non-touch scanning time; and when the sampling times of the real-time capacitance value of the same touch key is equal to the second preset sampling number, averaging the currently acquired capacitance value of the second preset sampling number, and configuring the averaged value as a reference capacitance value of the corresponding touch key until all the touch keys are traversed.
According to the technical scheme, the average capacitance value of each touch key in a non-touch state is acquired in a polling mode and is used as a reference capacitance value of the corresponding key, namely the capacitance value of each touch key in an initial state after power-on is performed, and the average capacitance value is used for participating in the comparison detection operation in the step S3.
Further, before executing step S1, the method further includes: step S0, sequentially sampling real-time capacitance values of each touch key for multiple times in a set non-touch scanning time; and when the sampling times of the real-time capacitance values of the same touch key are equal to the second preset sampling number, averaging the currently acquired capacitance values of the second preset sampling number, and configuring the averaged value as a reference capacitance value of the corresponding touch key until all touch keys in a row of capacitive touch keys are traversed. According to the technical scheme, the capacitance value of each touch key in the initial state after being electrified is set and is used for participating in the comparison detection operation in the step S3. Step S0 is also made the parameter initialization step of the detection method.
Further, before executing step S1, if the real-time capacitance value of one touch key is detected to be greater than the initial capacitance threshold, step S1 is entered, and the touch key corresponding to the real-time capacitance value is used as the starting point of the polling, so as to start the first polling period.
According to the technical scheme, the touch key with the real-time capacitance value larger than the initial capacitance threshold value sampled for the first time is used as the polling starting point of the step S1 and is also used as the detection starting point of the first polling period, so that the first polling period in one key detection cycle period is started.
Drawings
Fig. 1 is a schematic block diagram of a digital detection system for capacitive touch keys according to an embodiment of the present invention.
FIG. 2 is a signal timing diagram of the associated signals of the digital detection system in an embodiment in which two touch keys are touched sequentially.
FIG. 3 is a signal timing diagram of the associated signals of the digital detection system in an embodiment in which three touch keys are simultaneously touched.
Fig. 4 is a flowchart of a detection method based on the digital detection system according to another embodiment of the present invention.
Detailed Description
The following describes the technical solution in the embodiment of the present invention in detail with reference to the drawings in the embodiment of the present invention. For further illustration of the various embodiments, the invention is provided with the accompanying drawings. The accompanying drawings, which are incorporated in and constitute a part of this disclosure, illustrate embodiments and together with the description, serve to explain the principles of the embodiments.
Unless defined otherwise, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs. The terms "a" and "an" and "the" and similar referents in the context of describing the application are not intended to be limiting in number but may be construed to stand in the singular or in the plural. The terms "comprising," "including," "having," and any variations thereof, as used herein, are intended to cover a non-exclusive inclusion, such as: a process, method, system article, or apparatus that comprises a list of steps or modules is not limited to the particular steps or elements shown, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "first," "second," "third," and the like, as used herein, are merely used to distinguish similar correspondence and do not represent a particular ordering for objects.
In the prior art, an RC oscillation unit is used for sending an oscillation waveform to a detection port of a touch key, and the capacitance inside the RC oscillation unit is related to the equivalent capacitance of the existing touch key; in the prior art, a fixed time length is obtained by counting a reference clock, a waveform counter is used for counting a port feedback waveform in the fixed time length to obtain a count value, the change of the detected port capacitance is identified and judged according to the change of the count value, when the change value reaches a certain threshold value relative to a measured reference value, the touch key is judged to be pressed or touched, but noise interference is superimposed, the noise interference comprises noise from a power supply and environmental strong noise interference, and misjudgment on the state of the touch key is easily caused.
In order to overcome the technical defects, the embodiment of the invention discloses a digital detection system of a capacitive touch key, wherein the digital detection system is electrically connected with a capacitance value acquisition circuit, and the capacitance value acquisition circuit is configured to have an electrical connection relationship with a capacitance of a corresponding touch key and is used for acquiring a real-time capacitance value of the connected touch key, wherein the capacitance connection of the capacitance value acquisition circuit and the capacitance of the corresponding touch key is a sampling branch; the touch key is equivalent to the capacitance of the detection port to the ground, namely the connected capacitance below the touch key shown in fig. 1, and when a finger touches, the capacitance value changes, namely the capacitance value of the touch key changes. As shown in fig. 1, the digital detection system includes a real-time capacitance value register, an average filtering unit, a reference capacitance value register, a polling control unit, and a touch judgment unit.
In this embodiment, the digital detection system is configured to detect a touch state of each touch key in a row of capacitive touch keys; the number of the touch keys arranged in the row of the capacitive touch keys is larger than 1; in a row of capacitive touch keys, each touch key is respectively connected with a corresponding capacitance value acquisition circuit, and the capacitance value acquisition circuit is used for acquiring the real-time capacitance value of one connected touch key to form a one-to-one matching sampling relationship.
The polling control unit is a state machine and is used for sequentially generating polling scanning signals of each touch key in a counting mode, so that the capacitance value acquisition circuit samples the real-time capacitance value of the corresponding touch key under the action of the corresponding polling scanning signals, wherein the polling scanning signals are equivalent to scheduling signals, and the purpose of switching from scanning one touch key to scanning another touch key (generally adjacent touch keys) is achieved; the capacitance value acquisition circuit belongs to an analog circuit, and is preferably an RC oscillating circuit; in some embodiments, each capacitance value acquisition circuit is integrated in an analog sampling circuit module, and each capacitance value acquisition circuit becomes a branch of the analog sampling circuit module, and when a polling scan signal of a key gates a corresponding branch, the analog sampling circuit module is configured to acquire a real-time capacitance value of a touch key connected to the branch.
As shown in fig. 1, the real-time capacitance value register is connected to the capacitance value acquisition circuit, and is configured to sample the real-time capacitance value of the same touch key (may be any touch key in the row of capacitive touch keys) once every other polling period under the scheduling of the polling control unit, and store the currently sampled real-time capacitance value. Preferably, the number of real-time capacitance value registers included in the digital detection system is equal to the number of all touch keys in the row of capacitive touch keys, and each real-time capacitance value register is connected with a corresponding capacitance value acquisition circuit, so that the capacitance of each touch key corresponds to a corresponding real-time capacitance value register.
As shown in fig. 1, the reference capacitance value register is configured to store a reference capacitance value of a corresponding touch key, where the reference capacitance value is used as a reference for detecting a touch state or a change in capacitance value of the corresponding touch key, and is enabled to be refreshed to adapt to a change applied to a real-time capacitance value of the touch key by an external environment. In some embodiments, the digital detection system includes a number of reference capacitance value registers equal to a number of all touch keys in the row of capacitive touch keys, each reference capacitance value register being matched to a corresponding one of the capacitance value acquisition circuits such that each touch key corresponds to a corresponding one of the reference capacitance value registers. It should be noted that, the reference capacitance value register and the real-time capacitance value register associated with the same touch key are two different branches. The universality of the digital detection system is improved, and the digital detection system can be applied to detection of the touch state or the pressing state of touch keys in various permutation and combination.
As shown in fig. 1, the real-time capacitance value register is connected to the average filtering unit, and the average filtering unit is configured to average the real-time capacitance values of the first preset number of samples sampled in the current key detection cycle, and then configure the output average value as the average sampling value corresponding to the touch key as the filtering sampling capacitance value, when the real-time capacitance value register samples the real-time capacitance value of the same touch key in the key detection cycle for a first preset number of samples, that is, the same real-time capacitance value register continuously performs the first preset number of samples of the real-time capacitance value of the same touch key and sequentially transmits the first preset number of samples to the average filtering unit under the scheduling of the polling control unit; in this embodiment, the product of the first preset number of samples and one polling period is equal to one of the key detection cycle periods.
Preferably, the real-time capacitance value register and the reference capacitance value register are both buffers with a depth of 8 and a bit width of 12 bits, so that the buffers are formed by connecting 8 12bit memory cells in series, and are used for storing a plurality of capacitance values, but the buffers are not necessarily filled; the real-time capacitance value of each touch key stored in the real-time capacitance value register is provided for the average filtering unit; and the reference capacitance value of each touch key stored in the reference capacitance value register is provided for the touch judgment unit to use.
The specific operation of averaging by the average filtering unit is that the average filtering unit continuously accumulates the real-time capacitance value transmitted by the same real-time capacitance value register, and when the accumulated times of the real-time capacitance value of one touch key reaches (the first preset sampling number-1) times in one key detection cycle period, the accumulated results are averaged. It should be noted that, in the average filtering unit, the accumulator is used to perform the foregoing accumulating operation, and the frequency divider or the divider averages the accumulated result.
As shown in fig. 1, the touch judgment unit is respectively connected with the average filtering unit and the reference capacitance value register, and the touch judgment unit is configured to determine a detection result of the touch key according to a comparison result of an average sampling value of the corresponding touch key output by the average filtering unit and a reference capacitance value of the touch key under the scheduling of the polling control unit, where preferably, a specific judgment operation may be implemented by a comparator and a selector outputs a corresponding detection result. Of course, the detection results of all the touch keys in the row of capacitive touch keys can be obtained sequentially according to the time sequence, and then the current touch key or keys can be known. When the detection result of the touch key is determined, the touch judging unit can send out a key operation signal with 1 bit for a CPU or other related main control equipment. It should be noted that, each time the touch judgment unit outputs the detection result of all the touch keys in the row of capacitive touch keys, the detection result is recorded as the current round of detection operation of the capacitive touch keys completed by the digital detection system.
Therefore, compared with the prior art, the digital detection system disclosed in this embodiment samples the real-time capacitance value of each touch key continuously and repeatedly through the digital circuit (in a state machine scheduling manner), averages the real-time capacitance values obtained by multiple rounds of each touch key, and not only filters the sampled capacitance values, but also shares the part of the detection processing function which should be borne by the analog circuit part of the key detection circuit originally belonging to the prior art, thereby reducing the interference problem easily caused by the analog circuit part and overcoming the problems of error and noise easily caused by single sampling value. And improving the detection sensitivity of the touch key.
Specifically, according to the comparison result of the average sampling value of the corresponding touch key output by the average filtering unit and the reference capacitance value of the touch key, the method for determining the detection result of the touch key comprises the following steps: when the touch judgment unit detects that the average sampling value of the corresponding touch key output by the average filtering unit is smaller than or equal to the reference capacitance value of the touch key, the touch key is judged not to be touched so as not to execute key operation, preferably, the key operation signal sent by the touch judgment unit is in a low level, and the touch key is in a state of not being touched; the touch judgment unit is further configured to determine that the touch key is touched to perform a key operation when detecting that the average sampling value of the corresponding touch key output by the average filtering unit is greater than the reference capacitance value of the touch key, and preferably, the key operation signal sent by the touch judgment unit is at a high level, which indicates that the touch key is in a touched state. The influence of noise on the capacitance sampling value of the touch key is weakened, and the risk of detection errors is reduced.
As an embodiment, the polling control unit includes a key scan counter and a polling counter; the key scanning counter is used for triggering one real-time capacitance value register to sample the real-time capacitance value of a corresponding touch key in one row of capacitive touch keys when a key scanning signal is generated, and completing one-round scanning of the real-time capacitance values of all the touch keys in one row of capacitive touch keys when the increment of the count value reaches the difference value between the preset key number and the value 1; in the embodiments shown in fig. 2 and 3, 4 touch KEYs are set in a row of capacitive touch KEYs, and the polling control unit is configured to generate KEY scanning signals key_ SCANN [2:0] for the 4 touch KEYs, and sequentially scan the 4 touch KEYs, where the KEY scanning signal values are 3'd0, 3'd1, 3'd2, and 3'd3 in sequence; the KEY scan signals key_ SCANN [2:0] are generated by the KEY scan counter, and the KEY scan signals are generated corresponding to the signals key_cnt shown in fig. 2 and 3.
After the power-on is started, the initial value of the count value of the KEY scanning counter is 0, namely, the position of key_cnt=0, at this time, the signal key_cnt triggers one of the real-time capacitance value registers to sample the real-time capacitance value of the first touch KEY arranged (in rows or columns) in one row of capacitive touch KEYs, corresponding to the first K1 position of the signal CAP shown in fig. 2 and 3, which is equivalent to the real-time capacitance value of the first touch KEY represented by K1; then, the real-time capacitance value of the first touch KEY is stored in the real-time capacitance value register corresponding to the first touch KEY, at this time, the polling control unit or the KEY scanning counter receives a sampling end flag signal, that is, a first high-level ENOC signal in fig. 2 and 3, to confirm that the sampling operation of the first touch KEY is ended currently, and then the KEY scanning counter adds a new KEY scanning signal to generate, and the KEY scanning signal changes to the position of key_cnt=1.
In the timing charts of fig. 2 and 3, the nth signal of the same signal refers to the nth signal from left to right along a line timing chart where the signal is located.
The count value of the KEY scan counter is 1, i.e. the position of key_cnt=1, at which time the signal key_cnt triggers one of the real-time capacitance registers to sample the real-time capacitance value of the second touch KEY arranged (in rows or columns) in the row of capacitive touch KEYs, corresponding to the first K2 position of the signal CAP shown in fig. 2 and 3, equivalent to representing the real-time capacitance value of the second touch KEY with K2; then, the real-time capacitance value of the second touch KEY is stored in the real-time capacitance value register corresponding to the second touch KEY, at this time, the polling control unit or the KEY scanning counter receives a sampling end flag signal, that is, a signal ENOC of the second high level in fig. 2 and 3, to confirm that the sampling operation of the second touch KEY is ended currently, and then the KEY scanning counter adds a new KEY scanning signal to generate a position of key_cnt=2.
The count value of the KEY scan counter is 2, i.e. the position of key_cnt=2, at which time the signal key_cnt triggers one of the real-time capacitance registers to sample the real-time capacitance value of the third touch KEY arranged (in rows or columns) in the row of capacitive touch KEYs, corresponding to the first K3 position of the signal CAP shown in fig. 2 and 3, equivalent to representing the real-time capacitance value of the third touch KEY with K3; and then saving the real-time capacitance value of the third touch KEY into a real-time capacitance value register corresponding to the third touch KEY, wherein at the moment, the polling control unit or the KEY scanning counter receives a sampling end mark signal, namely a third high-level ENOC signal in fig. 2 and 3, and confirms that the sampling operation of the third touch KEY is ended currently, and then the KEY scanning counter adds a new KEY scanning signal to generate, and the KEY scanning signal is changed to a position of key_cnt=3.
The count value of the KEY scan counter is 3, i.e. the position of key_cnt=3, at which time the signal key_cnt triggers one of the real-time capacitance registers to sample the real-time capacitance value of the fourth touch KEY arranged (in rows or columns) in the row of capacitive touch KEYs, corresponding to the first K4 position of the signal CAP shown in fig. 2 and 3, equivalent to representing the real-time capacitance value of the fourth touch KEY with K4; then, saving the real-time capacitance value of the fourth touch key into a real-time capacitance value register corresponding to the fourth touch key, wherein at the moment, the polling control unit or the key scanning counter receives a sampling end mark signal, namely a signal ENOC with a fourth high level in fig. 2 and 3, and confirms that the sampling operation of the fourth touch key is finished currently, at the moment, the increment of the count value generated by the key scanning counter reaches the difference value of the preset key number and the value 1, and determining that one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys is completed in one polling period, and at the moment, the signal AVER_NUM_ GLAG in fig. 2 and 3 jumps from a low level to a high level to indicate that the polling control unit finishes one time of polling; wherein the number of touch keys set in a row of capacitive touch keys is a preset key number, which is 4 in the embodiments shown in fig. 2 and 3; one such polling period refers to the period of time between the position of the first key_cnt=0 to the position of the first key_cnt=3 (including the position of key_cnt=0 and the position of key_cnt=3). The KEY scan counter is then reset, and the corresponding KEY scan signal is key_cnt=0, and signal average_num_ GLAG of fig. 2 and 3 transitions from high to low to start a new round of sampling.
It should be noted that, in the above embodiment, the polling control unit sends the key scanning signal to the corresponding capacitance value acquisition circuit whenever one key scanning signal is generated, and triggers the corresponding capacitance value acquisition circuit to acquire the real-time capacitance value of one touch key connected thereto, preferably, the real-time capacitance values sampled under four key scanning signals sequentially generated in one polling period correspond to K1, K2, K3 and K4 in the timing diagrams of the signal CAP in fig. 2 and 3. When the corresponding capacitance value acquisition circuit stores the real-time capacitance value of the touch key into the real-time capacitance value register, the polling control unit receives a sampling end mark signal which is a high-level ENOC signal and belongs to a pulse signal. Because the capacitance value transmission of the different capacitance value acquisition circuits is time-sharing transmission, idle signals exist between two adjacent effective signals in the effective signals K1, K2, K3 and K4 in the time sequence diagram of the signal CAP, and under the time corresponding to the idle signals, the ENOC signal jumps from high level to low level and becomes invalid signal.
On the basis of the foregoing embodiment, whenever a capacitance value acquisition circuit stores the real-time capacitance value of the touch key to be connected to the corresponding real-time capacitance value register, the capacitance value acquisition circuit generates a sampling end flag signal, that is, a ENOC signal set to a high level, belonging to a high level pulse signal, and received by the polling control unit; every time a capacitance value acquisition circuit does not generate a sampling end flag signal when the real-time capacitance value of the touch key to be connected is not completely stored in the corresponding real-time capacitance value register, at this time, the ENOC signal is in a low-level state, the capacitance value acquisition circuit does not output a high-level pulse, and meanwhile, the polling control unit enters a waiting state until receiving the sampling end flag signal generated by the capacitance value acquisition circuit, namely waiting until the ENOC signal jumps from the low level to the high level. According to the embodiment, the sampling end mark signal is set to feed back the information that the sampling and storage operation of the current touch key is completed to the polling control unit, and then the next touch key is scanned based on the feedback information, so that each sampled real-time capacitance value can be completely stored in the real-time capacitance value register.
The polling counter is used for counting once when the real-time capacitance value register completes one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys or is regarded as completing one round of scanning of the capacitive touch keys, specifically, counting once is added until the increment of the count value reaches the difference value between the first preset sampling number and the value 1, and then the touch judging unit is triggered to output one detection result of all the touch keys in the row of capacitive touch keys; wherein each time a count signal is generated, one of the polling periods is experienced; and acquiring one detection result of all touch keys in a row of capacitive touch keys every other key detection cycle.
The embodiment designs a counter for marking the polling working state, and the counter forms the polling control unit; the key scanning counter finishes one round of scanning of the real-time capacitance values of all touch keys in a row of capacitive touch keys when counting the preset key number, wherein the key scanning counter jumps to a new working state when counting once; the first preset sampling number is counted by the polling counter every time, the real-time capacitance value of each touch key is sampled for a plurality of times, and each time the polling counter counts up once, the polling counter records that one row of capacitive touch keys is scanned; and the polling control unit is ensured to schedule corresponding working states according to a time sequence so as to control the detection precision of the functional units.
In the embodiments shown in fig. 2 and 3, the initial value of the count value of the polling counter is 0, which is held for a polling period taken by key_cnt=0 to key_cnt=3. When signal AVER_NUM_ GLAG transitions high for the first time, indicating that the current round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys is completed, the polling counter is incremented by one count, corresponding to the embodiment shown in FIGS. 2 and 3, the count value AVER_CNT of the polling counter is incremented from 0 to 1, thereby starting a new round of sampling of the real-time capacitance values of all touch keys in the same row of capacitive touch keys triggered by the key scan counter according to the previous embodiment.
In the embodiment shown in fig. 2 and fig. 3, the first preset number of samples is 3, that is, when the polling counter starts counting from the count value 0 to the count value 2, 3 times of polling is completed, and the increment of the count value is 2, at this time, the touch judgment unit outputs one detection result of all the touch keys in a row of capacitive touch keys according to the time sequence, where each touch key continuously performs 3 times of sampling, and then an average sampling value obtained in the average filtering unit of the real-time capacitance values of 3 times of continuous sampling corresponding to each touch key is compared with a preset reference capacitance value, so as to determine one detection result of the corresponding touch key.
In the embodiment shown in fig. 2, in a period (equivalent to a polling period) in which the counter value aver_cnt is equal to 2, at time t1, key_cnt=0, the real-time capacitance value of the fourth K1 position of the signal CAP is stored in the real-time capacitance value register corresponding to the first touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the real-time capacitance value register and sends the average result to the touch determining unit for comparison, so as to obtain the detection result of the first touch KEY, for example, the signal of key1_ pressed in fig. 2 is set to a high level, which indicates that the first touch KEY is in a touch state, while in fig. 2, the signal of key2_ pressed is set to a low level, the signal of key3_ pressed is set to a low level, and the signal of key4_ pressed is set to a low level.
At time t2, key_cnt=1, the real-time capacitance value of the fourth K2 position of the signal CAP is stored in the real-time capacitance value register corresponding to the second touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the corresponding real-time capacitance value register and sends the average value result to the touch judging unit for comparison, so as to obtain the detection result of the second touch KEY, that is, the signal key2_ pressed of fig. 2 is set to be low level, which indicates that the second touch KEY is in a state of not being touched, and meanwhile, in fig. 2, the signal key1_ pressed is set to be high level, which indicates that the first touch KEY is being touched; the Key3_ pressed signal is set low and the Key4_ pressed signal is set low.
At time t3, key_cnt=2, the real-time capacitance value of the fourth K3 position of the signal CAP is stored in the real-time capacitance value register corresponding to the third touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the corresponding real-time capacitance value register and sends the average value result to the touch judging unit for comparison, so as to obtain the detection result of the third touch KEY, that is, the signal key3_ pressed in fig. 2 is set to a low level to indicate that the third touch KEY is in a state of not being touched, and meanwhile, in fig. 2, the signal key1_ pressed is set to a high level to indicate that the first touch KEY is being touched; the Key2_ pressed signal is set low, indicating that the second touch Key is not touched; the Key4_ pressed signal is set low.
At time t4, key_cnt=3, the real-time capacitance value of the fourth K3 position of the signal CAP is stored in the real-time capacitance value register corresponding to the fourth touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the corresponding real-time capacitance value register and sends the average value result to the touch judging unit for comparison, so as to obtain the detection result of the fourth touch KEY, that is, the signal key4_ pressed in fig. 2 is set to a low level to indicate that the fourth touch KEY is in a state of not being touched, and meanwhile, in fig. 2, the signal key1_ pressed is set to a high level to indicate that the first touch KEY is being touched; the Key2_ pressed signal is set low, indicating that the second touch Key is not touched; the Key3_ pressed signal is set low.
Until time t4, the touch determination unit has obtained one detection result of all the touch keys in the row of capacitive touch keys, and then combines the detection results of all the touch keys into a Key code signal according to the arrangement sequence of the corresponding touch keys in the row of capacitive touch keys, which is represented as a signal key_value [3 ] of the last row of the timing chart of fig. 2: 0], in two polling periods after time t4 and time t4, key_value [3:0] =4' b1000, so as to reflect the touch state of each touch key in a row of capacitive touch keys to the outside at the same time, namely, the first touch key is touched, the second touch key is not touched, the third touch key is not touched, the fourth touch key is not touched, wherein the bit width of the key coding signal is equal to the preset key number, the detection result of one touch key is expressed as a one-bit binary number, the real-time capacitance value of each touch key is ensured to be stably sampled into the real-time capacitance value register, and the signal coded and output by the touch judging unit is low in noise and less in interference. In this embodiment, key_value [3 ] generated at time t 4: and 0] is output to the outside of the digital detection system by the touch judgment unit, namely 4' b1000 is taken as a detection result reflecting all touch keys in a row of capacitive touch keys in the current key detection cycle period. In this embodiment, when the increment of the count value of the polling counter reaches the difference value between the first preset sampling number and the value 1 each time, the touch judgment unit is scheduled to output a key code signal of the latest combination, so as to accurately and comprehensively reflect the detection results of all the touch keys in the row of capacitive touch keys.
As shown in fig. 2, the first key detection cycle period is before time t4, and the count value aver_cnt of the poll counter has been increased from 0to 2; after time t4, the count value aver_cnt of the polling counter changes from 2 to 0, and starts to enter the second key detection cycle, while the ENOC signal transitions from high to low, and the signal aver_num_ GLAG transitions from high to low, so as to start to perform a round of sampling in a new polling cycle.
According to the three-cycle sampling process of the foregoing embodiment, in the third polling period of the second KEY detection cycle, the count value aver_cnt is re-equal to 2 (equivalent to one polling period), at time t5, key_cnt=0, the real-time capacitance value of the sixth K1 position of the signal CAP is saved in the real-time capacitance value register corresponding to the first touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the real-time capacitance value register in the three polling periods of the second KEY detection cycle, and sends the average result to the touch determining unit for comparison, so as to obtain the detection result of the first touch KEY in the second KEY detection cycle, for example, the key1_ pressed signal is set to a low level, which indicates that the first touch KEY is not touched, while in fig. 2, the key2_ pressed signal is set to a low level, the key3_ pressed signal is set to a low level, and the key4_ pressed signal is set to a low level.
At time t6, key_cnt=1, the real-time capacitance value of the sixth K2 position of the signal CAP is stored in the real-time capacitance value register corresponding to the second touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the corresponding real-time capacitance value register in three polling periods of the second KEY detection cycle, and sends the average result to the touch judging unit for comparison, so as to obtain the detection result of the second touch KEY, that is, the key2_ pressed signal of fig. 2 is set to be high level to indicate that the second touch KEY is in a touched state, and meanwhile, in fig. 2, the key1_ pressed signal is set to be low level to indicate that the first touch KEY is still not touched; the Key3_ pressed signal is set low and the Key4_ pressed signal is set low.
It should be noted that, between time t5 and time t6 (excluding time t 6), since the ENOC signal has a low-level state, there is a delay in the sampling operation, so that the touch determination unit cannot obtain the detection result of the second touch Key yet, so that the detection result of a part of touch keys in a row of capacitive touch keys is still the detection result obtained in the first Key detection cycle period, and the corresponding combined Key code signal is key_value [3:0] =4' b0000, which obviously cannot reflect the detection result of each touch key of the row of capacitive touch keys in the second key detection cycle period, so that the detection result cannot be output.
According to the time sequence characteristics in the first Key detection cycle period until the time t8, the touch judging unit has obtained one detection result (understood as the second detection result) of all the touch keys in the row of capacitive touch keys in the second Key detection cycle period, and then combines the detection results of all the touch keys into a Key coding signal according to the arrangement sequence of the corresponding touch keys in the row of capacitive touch keys, which is expressed as a time key_value [ 3] at the time t 8: 0] =4' b0100 to reflect the touch state of each touch key in a row of capacitive touch keys to the outside at the same time, i.e., the first touch key is not touched, the second touch key is touched, the third touch key is not touched, and the fourth touch key is not touched. In this embodiment, key_value [ 3] generated at time t 8: 0] is output to the outside of the digital detection system by the touch judgment unit, namely 4' b0100 is used as a detection result reflecting all touch keys in a row of capacitive touch keys in a second key detection cycle period, but key coding signals generated between the time t5 and the time t8 are not directly output, so that invalid signals existing between corresponding output key coding signals after two adjacent touch keys are touched successively are prevented from being read, and misjudgment is caused; therefore, in this embodiment, when the increment of the count value of the polling counter reaches the difference value between the first preset sampling number and the value 1 each time, the touch determination unit is scheduled to output a key code signal of the latest combination, so as to accurately and comprehensively reflect the detection results of all the touch keys in the row of capacitive touch keys.
In summary, in the embodiment shown in fig. 2, based on the key code signal output by the touch determination unit at the last time of each key detection cycle, it is known that in a row of capacitive touch keys, 4 touch keys cannot be touched simultaneously in the same key detection cycle, but a first touch key is touched in a first key detection cycle, then a second touch key is touched in a second key detection cycle, and the first touch key is released.
Preferably, the frequency of the driving clock CLK of fig. 2 and 3 includes, but is not limited to, 15KHz, 12MHz, 6MHz, 32KHz and 8MHz, depending on key sensitivity, pad of touch key, etc. in practical applications.
In the embodiment shown in fig. 3, in a period (equivalent to a polling period) when the counter value aver_cnt is equal to 2, at time t11, key_cnt=0, the real-time capacitance value of the fourth K1 position of the signal CAP is stored in the real-time capacitance value register corresponding to the first touch KEY, at this time, the average filtering unit averages the 4 real-time capacitance values sampled by the real-time capacitance value register and sends the average value result to the touch judging unit for comparison, so as to obtain the detection result of the first touch KEY, for example, the signal of key1_ pressed in fig. 3 is set to a high level, which indicates that the first touch KEY is in a touch state; meanwhile, in fig. 3, the key2_ pressed signal is set to low level, which can be used as the initial detection result of the second touch Key; the Key3_ pressed signal is set to be low level and can be used as an initial detection result of a third touch Key; the Key4_ pressed signal is set to be low level and can be used as an initial detection result of a fourth touch Key; the signal key_value [ 3] represented as the last row of the timing diagram of fig. 3:0] =4' b1000.
Between time t11 and time t12 (excluding time t 12), since the ENOC signal has a low level state, there is a delay in the sampling operation of the real-time capacitance value of the second touch Key, so that the touch determination unit cannot obtain the detection result of the second touch Key yet, so that the detection result of a part of touch keys in a row of capacitive touch keys still is the detection result obtained originally, and the corresponding combined Key code signal is key_value [3:0] =4' b1000, which obviously cannot reflect the detection result of each touch key of the row of capacitive touch keys in the current polling period, so that the detection result cannot be output.
At time t12, key_cnt=1, the real-time capacitance value of the fourth K2 position of the signal CAP is stored in the real-time capacitance value register corresponding to the second touch KEY, and at this time, the touch judgment unit compares the real-time capacitance values to obtain the detection result of the second touch KEY, that is, the signal key2_ pressed in fig. 3 is set to a high level to indicate that the second touch KEY is in a touched state, and meanwhile, in fig. 3, the signal key1_ pressed is kept to a high level to indicate that the first touch KEY is touched; the Key3_ pressed signal is set low and the Key4_ pressed signal is set low.
At time t13, key_cnt=2, the real-time capacitance value of the fourth K3 position of the signal CAP is stored in the real-time capacitance value register corresponding to the third touch KEY, and at this time, the touch judging unit obtains the detection result of the third touch KEY, that is, the signal key3_ pressed in fig. 3 is set to a low level to indicate that the third touch KEY is in a state of not being touched, and at the same time, in fig. 3, the signal key1_ pressed is set to a high level to indicate that the first touch KEY is being touched; the Key2_ pressed signal is set low, indicating that the second touch Key is touched; the Key4_ pressed signal is set low.
Between time t12 and time t13 (excluding time t 13), since the ENOC signal has a low level state, there is a delay in the sampling operation of the real-time capacitance value of the third touch Key, so that the touch determination unit cannot obtain the detection result of the third touch Key yet, so that the detection result of a part of touch keys in a row of capacitive touch keys still is the detection result obtained originally, and the corresponding combined Key code signal is key_value [3:0] =4' b1100, which obviously cannot reflect the detection result of each touch key of the row of capacitive touch keys in the current polling period, so that the detection result cannot be output.
At time t14, key_cnt=3, and the real-time capacitance value of the fourth K3 position of the signal CAP is stored in the real-time capacitance value register corresponding to the fourth touch KEY, where the touch determination unit obtains the detection result of the fourth touch KEY, that is, the signal key4_ pressed in fig. 3 is set to a high level to indicate that the fourth touch KEY is in a touched state, and meanwhile in fig. 3, the signal key1_ pressed is set to a high level to indicate that the first touch KEY is touched; the Key2_ pressed signal is set high, indicating that the second touch Key is also touched; the Key3_ pressed signal is set low.
Between time t13 and time t14 (excluding time t 14), since the ENOC signal has a low level state, there is a delay in the sampling operation of the real-time capacitance value of the fourth touch Key, so that the touch determining unit cannot obtain the detection result of the fourth touch Key yet, so that the detection result of a part of touch keys in a row of capacitive touch keys still is the detection result obtained originally, and the corresponding combined Key code signal is key_value [3:0] =4' b1100, which obviously cannot reflect the detection result of each touch key of the row of capacitive touch keys in the current polling period, so that the detection result cannot be output.
At time t14, the touch determination unit has obtained one detection result of all the touch keys in the row of capacitive touch keys, and then combines the detection results of all the touch keys into a Key code signal according to the arrangement sequence of the corresponding touch keys in the row of capacitive touch keys, which is represented as a signal key_value [3 ] of the last row of the timing chart of fig. 3:0], in two polling periods after time t14 and time t14, key_value [3:0] =4' b1101 to reflect the touch state of each touch key in a row of capacitive touch keys to the outside at the same time, i.e., the state that the first touch key is touched, the second touch key is also touched, the third touch key is not touched, and the fourth touch key is also touched, is regarded as the state that three touch keys are simultaneously touched, as the detection result of the row of capacitive touch keys in the first key detection cycle period. It should be added that, since the analog circuit is a time-division sampling capacitance value, it is impossible for the digital part to detect that 3 touch keys are touched at the same time.
Therefore, the present embodiment sets key_value [3 ] generated at time t 14: and 0] is output to the outside of the digital detection system by the touch judgment unit, namely 4' b1101 is taken as a detection result reflecting all touch keys in a row of capacitive touch keys in the current key detection cycle period. And after each polling control unit receives the polling scanning signals with the first preset sampling number, the touch judgment unit is scheduled to output a newly combined key code signal so as to accurately and comprehensively reflect the detection results of all touch keys in a row of capacitive touch keys, thereby overcoming the delay influence of a sampling end mark signal between the key code signals correspondingly output after two adjacent touch keys are simultaneously touched and preventing incomplete detection results from being output.
It should be noted that, as shown in fig. 2 and fig. 3, after the average value is obtained through the large cycle of 3 polling periods, if the comparison finds that the real-time capacitance value of one of the touch keys meets the reference value comparison condition, the detection result of the touch key is set to be at a high level, and the touch key is reduced to be at a low level when the high level is kept until the next large cycle is not met; otherwise, if the comparison finds that the real-time capacitance value of the touch key does not meet the reference value comparison condition, the detection result of the touch key is set to be low level, and the touch key is kept low level until the next large cycle is met and then is raised to be high level. And after the real-time capacitance value of the same touch key is continuously sampled by the first preset sampling number by the real-time capacitance value register, the touch key is subjected to averaging processing by an average filtering unit, and a detection result is determined by the touch judging unit.
As another embodiment, the digital detection system further includes a reference value processing unit, as shown in fig. 1, to which the reference capacitance value register, the capacitance value acquisition circuit, and the touch judgment unit are connected; and the reference value processing unit is used for feeding back the capacitance change caused by the physical factors to the reference capacitance value when the touch judging unit outputs a result of being not touched, and in some embodiments, water drops on the touch keys (the surfaces of the touch electrodes) or temperature change of the touch keys possibly occur, so that the average sampling value output by the average filtering unit is required to be updated to the reference capacitance value stored in the reference capacitance value register and used for participating in the next detection operation of a row of capacitive touch keys so as to improve the detection sensitivity. The reference value processing unit is further configured to maintain the reference capacitance value stored in the reference capacitance value register unchanged when the touch judgment unit outputs the touched result, and if the reference capacitance value is adjusted at this time, the accuracy of detection is affected, in particular, the next detection operation of the row of capacitive touch keys. It should be noted that, each reference capacitance value register is connected to a corresponding capacitance value acquisition circuit through the same reference value processing unit, so that each reference capacitance value register is matched with a corresponding capacitance value acquisition circuit. The reference value processing unit provided in this embodiment updates the currently stored reference capacitance value according to the comparison result (detection result of the corresponding touch key) between the average sampling value of the corresponding touch key and the reference capacitance value of the touch key output by the average filtering unit, so as to adaptively correct the reference capacitance value when the reference capacitance value of each touch key is different from the initial value due to environmental change or other factor change; and the detection sensitivity can be improved by using the updated reference capacitance for comparison so as to adapt to the influence of the external environment on the equivalent capacitance value of the touch key.
On the basis of the above embodiment, the reference value processing unit is further configured to sample, during the non-touch scanning time set by the polling control unit, a real-time capacitance value of the same touch key (may be any touch key in the row of capacitive touch keys) once every other scanning period, and store the real-time capacitance value as a capacitance value of the touch key in a non-touch state, which may be specifically stored by a dedicated register; wherein, in the non-touch scanning time, all touch keys are not touched; the scanning period is implemented by state machine scheduling, preferably the scanning period is equal to the polling period. The reference value processing unit is used for averaging the currently acquired capacitance values of the second preset sampling number when the number of the real-time capacitance values of the same touch key is the second preset sampling number in the non-touch scanning time, configuring the averaged value to be an initial reference capacitance value of the corresponding touch key, outputting the initial reference capacitance value to the reference capacitance value register, and triggering the real-time capacitance value register to start sampling the real-time capacitance value of a corresponding touch key in the row of capacitive touch keys; wherein the initial reference capacitance value is a reference capacitance value that has not been updated; the specific operation of the reference value processing unit for averaging is to continuously accumulate the real-time capacitance values transmitted by the same capacitance value acquisition circuit, and average the accumulated results after the accumulated times of the real-time capacitance values of one touch key in one non-touch scanning time reach (the second preset sampling number-1) times. It should be noted that, in the reference value processing unit, the accumulator is used to perform the foregoing accumulating operation, and the frequency divider or the divider is used to average the result output by the accumulator, where the second preset number of samples may be configured as a frequency division coefficient. Wherein the product of the second preset number of samples and the scanning period is equal to one of the non-touch scanning times. In this embodiment, the reference value processing unit averages the capacitance sampling values obtained in multiple rounds in a state that the row of capacitive touch keys is not touched, so as to obtain a reference capacitance value in an initial state, that is, a capacitance value of each touch key in the initial state after power-on, and is used for a capacitance reference value of a subsequent comparison operation.
On the basis of the embodiment of the foregoing reference value processing unit, the polling control unit includes a key scan counter and a polling counter; the key scanning counter is used for triggering the reference value processing unit to sample the real-time capacitance value of the corresponding touch key in a row of capacitive touch keys every time a key scanning signal is generated in the non-touch scanning time, the key scanning signal is equivalent to a counting signal and is used for triggering a matched capacitance value acquisition circuit under the current counting condition, the matched capacitance value acquisition circuit samples the real-time capacitance value of the connected touch key (the touch key which is currently sampled is not touched) and then transmits the real-time capacitance value to the reference value processing unit, and meanwhile, the key scanning counter keeps counting operation, namely counting up according to a given scheduling time sequence; when the increment of the count value reaches the difference value between the preset key number and the value 1, namely, counting from zero to the difference value between the preset key number and the value 1, or counting from 1 to the preset key number, completing one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys in the non-touch scanning time; the number of touch keys arranged in one row of capacitive touch keys is a preset key number.
And the polling counter is used for counting once every time the reference value processing unit completes one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys in the non-touch scanning time, specifically adding one count once until the increment of the count value reaches the difference value between the second preset sampling number and the value 1, triggering the reference value processing unit to average the capacitance value of the second preset sampling number which is acquired currently, configuring the obtained average value as an initial reference capacitance value of the corresponding touch key, and outputting the initial reference capacitance value to a corresponding reference capacitance value register. Wherein each time a polling scan signal is generated, one of the polling periods is experienced. Preferably, the second preset number of samples is equal to the first preset number of samples, so as to ensure that the accuracy of average filtering is consistent.
In the polling control unit of this embodiment, one round of scanning of real-time capacitance values of all touch keys in a row of capacitive touch keys is completed when the same key scanning counter counts the preset key number; the polling counter finishes sampling the second preset sampling number for each real-time capacitance value of each touch key every time when counting the second preset sampling number; the polling control unit is ensured to schedule corresponding working states according to time sequence, the initialization precision of the reference capacitance value is realized, the reference capacitance value is also adapted to the parameter environment of the key non-touch state, and the detection accuracy is improved.
As an embodiment, the digital detection system further includes a preprocessing unit, where an initial capacitance threshold is stored in the preprocessing unit and is used to participate in the comparison operation of the real-time capacitance values of all touch keys, where the initial capacitance threshold is a capacitance threshold configured for each power-on restart of the digital detection system, and is applicable to all touch keys that need to be detected in a current key detection cycle period.
The preprocessing unit is used for starting from the touch key corresponding to the real-time capacitance value when the real-time capacitance value acquired by the capacitance value acquisition circuit is larger than the initial capacitance threshold value after the digital detection system is electrified and started, taking the touch key corresponding to the real-time capacitance value as a polling starting point to start a first polling period, triggering a key scanning counter to generate a key scanning signal under the dispatching of the polling control unit, scanning the real-time capacitance value of a corresponding touch key in a row of capacitance touch keys in sequence until the increment of the count value reaches the difference value of the preset key number and the value 1, completing one round of scanning of the real-time capacitance values of all touch keys in a row of capacitance touch keys, continuously scanning polling for a first preset number on the basis, and triggering the average filtering unit to start averaging the currently sampled real-time capacitance values belonging to the first preset sampling number of the same touch key; the triggering actions of the reference units are similar, but the environmental conditions of the touch keys are limited, so that the details are not repeated. And the preprocessing unit starts a first polling period or the scanning period, and determines a polling starting point of the polling control unit, so that the capacitance value sampled by the real-time capacitance value register for the first time is one capacitance value in the real-time capacitance values of the first preset sampling number of the same touch key, and is also the capacitance value which is acquired by the capacitance value acquisition circuit for the first time and is larger than the initial capacitance threshold value.
Preferably, when the real-time capacitance value acquired by the capacitance value acquisition circuit is greater than the initial capacitance threshold value, the detection start signal is set high, the INIT_BEGIN signal corresponding to the signal in FIG. 2 and FIG. 3 is turned from low level to high level, and then the INIT_BEGIN signal is always kept at high level unless the digital detection system is powered off and restarted; after the INIT_BEGIN signal becomes high level, the KEY scan counter starts counting, so that the polling control unit generates KEY scan signals KEY_ SCANN [2:0], and the count value KEY_CNT in a corresponding polling period is 0,1, 2 and 3 in sequence. Wherein the polling start point of the polling control unit is the first K1 position of the signal CAP shown in fig. 2 and 3, and the time of this position is taken as the start point of the first polling period.
In one embodiment, the reference capacitance value register has received the reference capacitance value before the real-time capacitance value is compared to an initial capacitance threshold; in another embodiment, before the comparison between the real-time capacitance value and the initial capacitance threshold value, the reference capacitance value register does not receive the reference capacitance value, and the reference value processing unit also needs to compare the real-time capacitance value and the initial capacitance threshold value in advance to determine the execution starting point of the non-touch scanning time, because the reference value processing unit also needs to calculate an average value by continuously polling and scanning each touch key to calculate the reference capacitance value.
Therefore, the preprocessing unit sets an initial capacitance threshold value to take a touch key with the real-time capacitance value larger than the initial capacitance threshold value sampled for the first time as a polling starting point of the polling control unit, so as to start a first polling period in a key detection cycle period, and the touch judging unit starts to detect from the touch key with the first real-time capacitance value meeting the threshold value.
On the basis of the above embodiment, the polling control unit includes a key scan counter; after the digital detection system is powered on and started and the preprocessing unit judges that the real-time capacitance value of the touch key acquired by the capacitance value acquisition circuit is larger than the initial capacitance threshold value for the first time, the INIT_BEGIN signals of fig. 2 and 3 are turned from low level to high level, the key scanning counter is used for sending an initial key scanning signal and sending the initial key scanning signal to the corresponding capacitance value acquisition circuit, triggering the real-time capacitance value register to sample the real-time capacitance value of the first touch key to be sampled in one row of capacitive touch keys, and then generating a new key scanning signal and sending the new key scanning signal to the corresponding capacitance value acquisition circuit every time the real-time capacitance value register samples the real-time capacitance value of the touch key to be sampled in the current row of capacitive touch keys until one round of scanning of the real-time capacitance values of all touch keys in the row of capacitive touch keys is completed. In addition, the calculation concept of the reference capacitance value is similar, except that the unit performing the data processing and the unit storing the data are different. In this embodiment, after each power-on start of the digital detection system, if the preprocessing unit determines that the real-time capacitance value of the touch key acquired by the capacitance value acquisition circuit is greater than the initial capacitance threshold value for the first time, the currently determined touch key is set as the first key position participating in polling detection, and the current time is set as the start time of the first polling period, which is also the start time of the key detection cycle period, so that the preprocessing unit provides a trigger signal for starting operation for the polling control unit.
Preferably, each time the digital detection system receives a sampling end flag signal sent by one of the capacitance value acquisition circuits, that is, receives a ENOC signal corresponding to a touch key with a high level, the key scanning counter is controlled to stop counting, at this time, the current sampling operation is completed, meanwhile, the average filtering unit is controlled to stop averaging, the touch judging unit is controlled to stop comparing operation until a period of preset jitter elimination time is delayed, and then the unit module which is previously stopped is started to continue the detection operation of the touch key. The preferred embodiment selects to perform delay jitter elimination when ENOC signals are detected, and can enable the sampling value with variation to have enough time to be stabilized, so that the sampling value is stored in a related register more stably, and erroneous judgment caused by touch key jitter is prevented. Wherein the preset debounce time is preferably 60ms.
Preferably, the digital detection system further comprises a key timer, wherein the number of key timers is the number of all touch keys in the row of capacitive touch keys, and each touch key is matched with one key timer; and the key timer is used for adding a count once when a corresponding touch key passes through one key detection cycle period, and configuring the product of the increment of the latest count value and the key detection cycle period as the touch time of the corresponding touch key. Because the digital detection system outputs one effective detection result of all the touch keys in the row of capacitive touch keys every other key detection cycle period, the key timer disclosed in this embodiment configures one key detection cycle period as a unit time for judging the abnormal condition of the key, so as to ensure the detection precision of the touch keys and the integrity of the detection result.
Preferably, after the touch judgment unit judges that one touch key is touched, the key timer is triggered to start timing, when the count value of the key timer is larger than a preset key delay threshold value, the touch key is determined to be in a key abnormal state, then an interrupt signal is sent to a CPU (central processing unit) outside the digital detection system, preferably, the digital detection system is controlled to stop working, so that the digital detection system is motivated to restart to initialize the reference capacitance value, and an external CPU is used for processing a key abnormal event of the touch key. Therefore, the sensitivity of touch key detection is ensured, and the risk of false recognition of the touch key is reduced. Wherein the preset key delay threshold is set to 30s.
Preferably, when the touch judgment unit judges that a touch key is touched, the digital detection system starts to record the time when the touch key is kept touched, belonging to recording duration time information, if the digital detection system judges that the current recorded time is greater than the preset key scanning time, the touch key is determined to be in a touch invalid state, and if the digital detection system further judges that the current recorded time is greater than the preset key delay threshold, the touch key is determined to be in a key abnormal state; if the digital detection system judges that the current recorded time is less than or equal to the preset key scanning time, the touch key is determined to be in a touch effective state, so that the detection result output by the touch judgment unit is effective and can be identified and used by the CPU.
When the touch judgment unit judges that one touch key is not touched, the digital detection system starts to record the time when the touch key is kept not touched, if the digital detection system judges that the current recorded time is larger than the preset key scanning time, the touch key is determined to be in a release invalid state, namely the touch key cannot be regarded as being in a state of being not touched by the CPU, and if the digital detection system judges that the current recorded time is larger than the preset key delay threshold value, the touch key is determined to be in a key abnormal state. If the digital detection system determines that the current recorded time is less than or equal to the preset key scanning time, the touch key is determined to be in a non-touch effective state, namely the touch key can be regarded as being in a state of being not touched by the CPU, which is equivalent to the fact that the touch key is restored to the original physical state after being not touched. Wherein the preset key scan time is on the order of milliseconds. According to the embodiment, the influence of key jitter is eliminated by delaying from the two states of touching and not touching the touch key respectively, and the accuracy of the detection result of the touch judging unit is ensured.
As an embodiment, a chip is also disclosed, which chip comprises the digital detection system. The real-time capacitance value of each touch key is sampled and averaged continuously for many times in sequence in a digital state machine scheduling mode, and then the reference capacitance value parameter is automatically updated according to the detection result so as to adapt to the key detection of the next key detection cycle period, so that the influence of the noise signal of a chip circuit and the interference of the external environment are inhibited, the sensitivity of touch induction is improved, the use of an analog circuit is also saved, and the chip area is reduced.
The embodiment of the invention also discloses a detection method based on the digital detection system, as shown in fig. 4, comprising the following steps:
step S1, sampling the real-time capacitance value of each touch key in each polling period in sequence; in each execution of step S1, in fact, in a polling period, the real-time capacitance values of all the touch keys in the row of capacitive touch keys are sampled once in turn according to a preset sequence, and a specific sampling and storing manner can refer to the embodiment of the digital detection system.
Step S2, when the sampling times of the real-time capacitance value of the same touch key is equal to the first preset sampling number, averaging the real-time capacitance value of the touch key to obtain an average sampling value of the touch key; and then proceeds to step S3. When the number of polling periods executed in the step S1 reaches a first preset sampling number, the sampling number of the real-time capacitance values of the same touch key is equal to the first preset sampling number, and the step S2 can be entered to calculate the average value of the real-time capacitance values with the number of the first preset sampling number, so as to obtain an average sampling value as a result of the real-time capacitance value average filtering of the touch key. Any touch key in the row of capacitive touch keys needs to execute step S2 to obtain an average sampling value (average capacitance value) of the corresponding touch key.
And S3, determining a detection result of the touch key according to a comparison result of the average sampling value of the touch key and the reference capacitance value of the touch key. The detection results of all the touch keys in the row of capacitive touch keys can be obtained sequentially according to the time sequence, and finally, the current touch key or the current touch keys are known. It should be noted that, each time the detection results of all the touch keys in the row of capacitive touch keys are obtained, the current detection operation of the row of capacitive touch keys is recorded as completed, and then the step S1 may be returned to execute the detection operation of the next round.
According to the embodiment, the average filtering of the capacitance value of the touch key is completed in a polling mode, the influence of different sampling values on the detection result each time is eliminated, the problem that errors are easy to occur in single sampling values is solved, and the detection sensitivity and accuracy of the touch key are improved.
As a specific embodiment, the step S3 specifically includes: when the average sampling value of one touch key is larger than the reference capacitance value of the touch key, the touch key is judged to be touched, and key operation can be performed. When the average sampling value of one touch key is smaller than or equal to the reference capacitance value of the touch key, the touch key is judged to be not touched, and key operation cannot be performed. The problem that errors are easy to occur in single sampling values is solved, the influence of noise generated under the action of environmental interference on capacitance sampling values of the touch keys is weakened, and the detection sensitivity and accuracy of the touch keys are improved.
As a specific embodiment, the step S3 further includes: when the touch key is judged to be touched, the reference capacitance value corresponding to the touch key is kept unchanged, and if the reference capacitance value is adjusted at the moment, the detection accuracy is affected, and particularly the next detection operation of the row of capacitive touch keys is affected. And when the touch key is judged not to be touched, updating the average sampling value of the touch key to be the reference capacitance value of the touch key. In some embodiments, there may be a water drop on the touch key (on the surface of the touch electrode) or a temperature change of the touch key, and then the capacitance change caused by the foregoing physical factor needs to be fed back to the reference capacitance value, so that the average sampling value of the latest output needs to be updated to the reference capacitance value, so as to participate in the next detection operation of a row of capacitive touch keys, so as to improve the detection sensitivity. According to the embodiment, according to the comparison result (corresponding to the detection result of the touch key) of the average sampling value of the corresponding touch key and the reference capacitance value of the touch key output by the average filtering unit, updating operation is performed on the currently stored reference capacitance value, so that under the condition that the reference capacitance value of each touch key is different from the initial value due to environmental change or other factor change, the reference capacitance value is adaptively corrected; and the detection sensitivity can be improved by using the updated reference capacitance for comparison so as to adapt to the influence of the external environment on the equivalent capacitance value of the touch key.
It should be noted that, when step S2 obtains an average sampling value of all the touch keys, and step S3 determines that one key detection cycle period has been spent after determining detection results of all the touch keys; wherein one of the polling periods is the time taken for the real-time capacitance value of each touch key in a row of capacitive touch keys to be sampled once, respectively; the product of the first preset number of samples and a polling period is equal to one of the key detection cycle periods. Setting the polling period as a small cycle period as the sum of time required for completing one round of scanning of the real-time capacitance values of all touch keys in a row of capacitive touch keys; setting the key detection cycle period as a large cycle period, and taking the large cycle period as the sum of time required by continuously sampling a first preset sampling number and sampling a real-time capacitance value of each touch key in a row of capacitive touch keys; thus, sampling conditions and calculation conditions are created for calculating the average value of the real-time capacitance values of the touch keys in a polling mode.
As an embodiment, before performing step S1, further includes: step S0, sequentially sampling real-time capacitance values of each touch key for multiple times in a set non-touch scanning time; and when the sampling times of the real-time capacitance values of the same touch key are equal to the second preset sampling number, averaging the currently acquired capacitance values of the second preset sampling number, and configuring the averaged value as a reference capacitance value of the corresponding touch key until all touch keys in a row of capacitive touch keys are traversed. The specific implementation manner refers to the foregoing embodiment of the reference value processing unit, and is not described herein again. In this embodiment, the average capacitance value of each touch key in the non-touch state is obtained by a polling manner and is used as the reference capacitance value of the corresponding key, that is, the capacitance value of each touch key in the initial state after power-up, so as to participate in the comparison detection operation in step S3. Step S0 is also made the parameter initialization step of the detection method.
As an embodiment, before executing step S1, if the real-time capacitance value of one touch key is detected to be greater than the initial capacitance threshold, step S1 is entered, and the touch key corresponding to the real-time capacitance value is used as the starting point of polling to start the first polling period, where in step S1, the real-time capacitance value of the first preset number of samples of the same touch key sampled for the first time is the real-time capacitance value sampled for the first time to be greater than the initial capacitance threshold. Specifically, starting from the touch key corresponding to the real-time capacitance value, taking the touch key corresponding to the real-time capacitance value as a polling starting point to start a first polling period, sequentially scanning the real-time capacitance value of a corresponding touch key in a row of capacitive touch keys by generating a key scanning signal, completing one round of scanning of the real-time capacitance values of all touch keys in the row of capacitive touch keys until the increment of the count value reaches the difference value between the preset key number and the value 1, continuously scanning the polling for a first preset number of times on the basis, and then starting to average the currently sampled real-time capacitance values belonging to the first preset sampling number of the same touch key. In this embodiment, the touch key with the real-time capacitance value greater than the initial capacitance threshold value sampled for the first time is used as the polling start point of the step S1, and is also the detection start point of the first polling period, so as to start the first polling period in one key detection cycle period.
Additionally, in some embodiments, the reference capacitance value has been calculated prior to comparing the real-time capacitance value to the initial capacitance threshold; in some embodiments, before the comparison between the real-time capacitance value and the initial capacitance threshold value, the reference capacitance value is not obtained, and the execution start point of the non-touch scanning time is determined by comparing the real-time capacitance value with the initial capacitance threshold value in advance, because the average value is also obtained by continuously polling and scanning each touch key in order to obtain the reference capacitance value, the calculation action of the initial value of the reference capacitance value is similar, and only the environmental condition of the touch key is limited, so that the description is omitted.
The foregoing embodiments are merely illustrative of the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the present invention and to implement the same according to the present invention, not to limit the scope of the present invention. All changes and modifications that come within the meaning and range of equivalency of the invention are to be embraced within their scope.

Claims (23)

1. The digital detection system of a kind of capacitive touch key, there is electrical connection in the digital detection system and capacitance value acquisition circuit, the capacitance value acquisition circuit is configured to be used for obtaining the real-time capacitance value of a touch key connected;
The digital detection system is characterized by comprising a real-time capacitance value register, an average filtering unit, a reference capacitance value register, a polling control unit and a touch judgment unit; wherein the polling control unit is a state machine;
The real-time capacitance value register is connected with the capacitance value acquisition circuit and is used for sampling the real-time capacitance value of the same touch key once every other polling period under the scheduling of the polling control unit;
The reference capacitance value register is used for storing the reference capacitance value of the corresponding touch key;
The real-time capacitance value register is connected with the average filtering unit, and the average filtering unit is used for averaging the real-time capacitance values of the first preset sampling number sampled in the current key detection cycle period when the real-time capacitance value register samples the same touch key in the key detection cycle period to be a first preset sampling number under the scheduling of the polling control unit, and then configuring the output average value as an average sampling value of the corresponding touch key;
The touch judgment unit is respectively connected with the average filtering unit and the reference capacitance value register, and is used for determining the detection result of the touch key according to the comparison result of the average sampling value of the corresponding touch key output by the average filtering unit and the reference capacitance value of the touch key under the scheduling of the polling control unit.
2. The digital detection system of claim 1, wherein the digital detection system is configured to detect a touch state of each touch key in a row of capacitive touch keys; the number of the touch keys arranged in the row of the capacitive touch keys is larger than 1;
In a row of capacitive touch keys, each touch key is respectively connected with a corresponding capacitance value acquisition circuit;
the number of the real-time capacitance value registers included in the digital detection system is equal to the number of all touch keys in the row of capacitive touch keys, and each real-time capacitance value register is connected with a corresponding capacitance value acquisition circuit so that the capacitance of each touch key corresponds to the corresponding real-time capacitance value register;
the number of reference capacitance value registers included in the digital detection system is equal to the number of all touch keys in the row of capacitive touch keys, and each reference capacitance value register is matched with a corresponding capacitance value acquisition circuit so that each touch key corresponds to a corresponding reference capacitance value register.
3. The digital detection system of claim 2, wherein the polling control unit comprises a key scan counter and a polling counter;
The key scanning counter is used for triggering one real-time capacitance value register to sample the real-time capacitance value of a corresponding touch key in a row of capacitive touch keys when a key scanning signal is generated, and determining to finish one-round sampling of the real-time capacitance values of all the touch keys in the row of capacitive touch keys when the increment of the count value reaches the difference value between the preset key number and the value 1; the number of touch keys arranged in one row of capacitive touch keys is a preset key number;
The polling counter is used for counting once every time the real-time capacitance value register completes one-round sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys, and triggering the touch judging unit to output one-time detection results of all touch keys in the row of capacitive touch keys after the increment of the count value reaches the difference value between the first preset sampling number and the value 1;
And acquiring one detection result of all touch keys in a row of capacitive touch keys every other key detection cycle.
4. The digital detection system according to claim 3, wherein the polling control unit sends a key scanning signal to a corresponding one of the capacitance value acquisition circuits each time the key scanning signal is generated, and triggers the corresponding one of the capacitance value acquisition circuits to acquire a real-time capacitance value of a touch key connected thereto, and receives a sampling end flag signal when the corresponding one of the capacitance value acquisition circuits stores the real-time capacitance value of the touch key in the real-time capacitance value register;
The touch judgment unit is used for combining the detection results of all the touch keys into a key coding signal according to the arrangement sequence of the corresponding touch keys in the row of capacitive touch keys every time the detection results of all the touch keys in the row of capacitive touch keys are obtained under the scheduling of the polling control unit, wherein the bit width of the key coding signal is equal to the preset key number, and the detection result of one touch key is expressed as a one-bit binary number.
5. The digital detection system according to claim 4, wherein the touch determination unit is scheduled to output a newly combined key code signal each time the count value increment of the poll counter reaches a difference between the first preset number of samples and a value of 1;
and after the real-time capacitance value of the same touch key is continuously sampled by the first preset sampling number by the real-time capacitance value register, the touch key is subjected to averaging processing by an average filtering unit, and a detection result is determined by the touch judging unit.
6. The digital detection system according to claim 2, further comprising a reference value processing unit, wherein the reference capacitance value register, the capacitance value acquisition circuit, and the touch judgment unit are all connected to the reference value processing unit;
The reference value processing unit is used for updating the average sampling value output by the average filtering unit into the reference capacitance value stored in the reference capacitance value register when the touch judging unit outputs a result which is not touched;
The reference value processing unit is also used for keeping the reference capacitance value stored in the reference capacitance value register unchanged when the touch judging unit outputs the touched result;
Each reference capacitance value register is connected with a corresponding capacitance value acquisition circuit through the same reference value processing unit, so that each reference capacitance value register is matched with the corresponding capacitance value acquisition circuit.
7. The digital detection system according to claim 6, wherein the reference value processing unit is further configured to sample a real-time capacitance value of the same touch key once every other scanning period in the non-touch scanning time set by the polling control unit, and store the real-time capacitance value as a capacitance value of the touch key in a non-touch state; wherein, in the non-touch scanning time, all touch keys are not touched;
The reference value processing unit is configured to average the currently acquired real-time capacitance values of the second preset sampling number when the number of the real-time capacitance values of the same touch key is the second preset sampling number in the non-touch scanning time, configure the obtained average value as an initial reference capacitance value corresponding to the touch key, output the initial reference capacitance value to the reference capacitance value register, and trigger the real-time capacitance value register to start sampling; wherein the initial reference capacitance value is a reference capacitance value that has not been updated.
8. The digital detection system of claim 7, wherein the polling control unit comprises a key scan counter and a polling counter;
The key scanning counter is used for triggering the reference value processing unit to sample the real-time capacitance value of the corresponding touch key in a row of capacitive touch keys every time a key scanning signal is generated in the non-touch scanning time until the increment of the count value reaches the difference value between the preset key number and the value 1, and completing one-round sampling of the real-time capacitance values of all the touch keys in the row of capacitive touch keys; the number of touch keys arranged in one row of capacitive touch keys is a preset key number;
And the polling counter is used for counting once every time the reference value processing unit completes one round of sampling of the real-time capacitance values of all touch keys in a row of capacitive touch keys in the non-touch scanning time, triggering the reference value processing unit to average the capacitance value of the second preset sampling number acquired currently after the increment of the count value reaches the second preset sampling number, configuring the obtained average value as an initial reference capacitance value of the corresponding touch key, and outputting the initial reference capacitance value to a corresponding reference capacitance value register.
9. The digital detection system according to claim 8, wherein the touch judgment unit is configured to judge that the touch key is not touched to perform no key operation when it is detected that the average sampling value of the corresponding touch key output by the average filtering unit is less than or equal to the reference capacitance value of the touch key;
The touch judgment unit is further used for judging that the touch key is touched to execute key operation when detecting that the average sampling value of the corresponding touch key output by the average filtering unit is larger than the reference capacitance value of the touch key.
10. The digital detection system of claim 9, further comprising a preprocessing unit, wherein an initial capacitance threshold is stored within the preprocessing unit;
And the preprocessing unit is used for taking a touch key corresponding to the real-time capacitance value as a polling starting point to start a first polling period when the real-time capacitance value acquired by the capacitance value acquisition circuit is larger than an initial capacitance threshold value after the digital detection system is electrified and started.
11. The digital detection system of claim 10, wherein the polling control unit comprises a key scan counter;
And the key scanning counter is used for starting counting and sending a key scanning signal after the digital detection system is electrified and started and the preprocessing unit judges that the real-time capacitance value of the touch key acquired by the capacitance value acquisition circuit is larger than the initial capacitance threshold value for the first time, triggering the real-time capacitance value register to sample the real-time capacitance value of the corresponding touch key in the row of capacitance type touch keys, and then generating a new key scanning signal and sending the new key scanning signal to the corresponding capacitance value acquisition circuit every time the real-time capacitance value register samples the real-time capacitance value of the current touch key in the row of capacitance type touch keys so as to trigger the real-time capacitance value register to sample the real-time capacitance value of the next touch key in the row of capacitance type touch keys until one round of sampling of the real-time capacitance values of all touch keys in the row of capacitance type touch keys is completed.
12. The digital detection system according to claim 9, wherein whenever a capacitance value acquisition circuit saves the real-time capacitance value of the touch key to be connected to the corresponding real-time capacitance value register, the capacitance value acquisition circuit generates a sampling end flag signal and is received by the polling control unit;
Every time a capacitance value acquisition circuit does not completely store the real-time capacitance value of the touch key to be connected into the corresponding real-time capacitance value register, the capacitance value acquisition circuit does not generate a sampling end mark signal, and meanwhile, the polling control unit enters a waiting state until the sampling end mark signal generated by the capacitance value acquisition circuit is received.
13. The digital detection system of claim 12, wherein the key scan counter is controlled to stop counting until a predetermined debounce time has elapsed each time the digital detection system receives an end of sample flag signal from one of the capacitance acquisition circuits.
14. The digital detection system of claim 9, further comprising a key timer, the number of key timers being the number of all touch keys in the row of capacitive touch keys, wherein each touch key matches a key timer;
And the key timer is used for adding a count once when a corresponding touch key passes through one key detection cycle period, and configuring the product of the increment of the latest count value and the key detection cycle period as the touch time of the corresponding touch key.
15. The digital detection system according to claim 14, wherein after the touch judgment unit judges that one touch key is touched, the key timer is triggered to start timing, when the count value of the key timer is greater than a preset key delay threshold value, it is determined that the touch key is in a key abnormal state, and then an interrupt signal is sent to a CPU outside the digital detection system.
16. The digital detection system according to claim 9, wherein when the touch judgment unit judges that a touch key is touched, the digital detection system starts recording the time when the touch key is kept touched, if the digital detection system judges that the current recorded time is greater than the preset key scanning time, the touch key is determined to be in a touch invalid state, otherwise, the touch key is determined to be in a touch valid state;
When the touch judgment unit judges that one touch key is not touched, the digital detection system starts to record the time when the touch key is not touched, if the digital detection system judges that the current recorded time is longer than the preset key scanning time, the touch key is determined to be in a release invalid state, otherwise, the touch key is determined to be in a non-touch valid state;
Wherein the preset key scan time is on the order of milliseconds.
17. A chip comprising the digital detection system of any one of claims 1 to 16.
18. A detection method based on the digital detection system according to any one of claims 1 to 16, characterized by comprising the steps of:
step S1, sampling the real-time capacitance value of each touch key in each polling period in sequence;
step S2, when the sampling times of the real-time capacitance value of the same touch key is equal to the first preset sampling number, averaging the real-time capacitance value of the touch key to obtain an average sampling value of the touch key;
and S3, determining a detection result of the touch key according to a comparison result of the average sampling value of the touch key and the reference capacitance value of the touch key.
19. The method according to claim 18, wherein the step S3 specifically includes:
When the average sampling value of one touch key is larger than the reference capacitance value of the touch key, judging that the touch key is touched;
And when the average sampling value of one touch key is smaller than or equal to the reference capacitance value of the touch key, judging that the touch key is not touched.
20. The method according to claim 18 or 19, wherein the step S3 further comprises:
when the touch key is judged to be touched, the reference capacitance value corresponding to the touch key is kept unchanged;
And when the touch key is judged not to be touched, updating the average sampling value of the touch key to be the reference capacitance value of the touch key.
21. The detecting method according to claim 18, wherein when step S2 obtains an average sampling value of all the touch keys and step S3 determines that the detection result of all the touch keys has been spent for one key detection cycle period;
wherein one of the polling periods is the time taken for the real-time capacitance value of each touch key in a row of capacitive touch keys to be sampled once, respectively;
wherein the product of the first preset number of samples and a polling period is equal to one of the key detection cycle periods.
22. The method of detecting according to claim 18, further comprising, prior to performing step S1:
Step S0, sequentially sampling real-time capacitance values of each touch key for multiple times in a set non-touch scanning time; and when the sampling times of the real-time capacitance values of the same touch key are equal to the second preset sampling number, averaging the currently acquired capacitance values of the second preset sampling number, and configuring the averaged value as a reference capacitance value of the corresponding touch key until all touch keys in a row of capacitive touch keys are traversed.
23. The method according to claim 18, wherein, before executing step S1, if the real-time capacitance value of one touch key is detected to be greater than the initial capacitance threshold, step S1 is entered, and the touch key corresponding to the real-time capacitance value is used as a starting point of polling to start the first polling period.
CN202111116357.2A 2021-09-23 2021-09-23 Digital detection system, chip and detection method for capacitive touch keys Active CN113867577B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111116357.2A CN113867577B (en) 2021-09-23 2021-09-23 Digital detection system, chip and detection method for capacitive touch keys

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111116357.2A CN113867577B (en) 2021-09-23 2021-09-23 Digital detection system, chip and detection method for capacitive touch keys

Publications (2)

Publication Number Publication Date
CN113867577A CN113867577A (en) 2021-12-31
CN113867577B true CN113867577B (en) 2024-06-14

Family

ID=78993458

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111116357.2A Active CN113867577B (en) 2021-09-23 2021-09-23 Digital detection system, chip and detection method for capacitive touch keys

Country Status (1)

Country Link
CN (1) CN113867577B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108696271A (en) * 2018-05-28 2018-10-23 珠海慧联科技有限公司 A kind of slip gesture recognition methods and system based on capacitance touch button
CN109428579A (en) * 2018-11-30 2019-03-05 珠海巨晟科技股份有限公司 A kind of anti-interference detection device of capacitance type touch key and detection method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100845144B1 (en) * 2006-12-29 2008-07-09 주식회사 켐트로닉스 Apparatus and method for preventing mal-touch sensing operation resulted from a noise and record media recoded program realizing the same
CN102385447B (en) * 2011-11-23 2015-03-11 江苏惠通集团有限责任公司 Touch identification method and device, space mouse and control method thereof
CN111198626B (en) * 2018-11-16 2021-06-11 珠海格力电器股份有限公司 Reference value correction method and device for capacitive touch key and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108696271A (en) * 2018-05-28 2018-10-23 珠海慧联科技有限公司 A kind of slip gesture recognition methods and system based on capacitance touch button
CN109428579A (en) * 2018-11-30 2019-03-05 珠海巨晟科技股份有限公司 A kind of anti-interference detection device of capacitance type touch key and detection method

Also Published As

Publication number Publication date
CN113867577A (en) 2021-12-31

Similar Documents

Publication Publication Date Title
JP4755278B2 (en) Contact sensor and method of operating the same
US5761206A (en) Message packet protocol for communication of remote sensor information in a wireless security system
US20100100799A1 (en) Fault detection apparatus, fault detection method, and fault detection program
US5805063A (en) Wireless security sensor transmitter
US20100002821A1 (en) Clock determination for a sensor
CN110120815B (en) Low power synchronization of multiple analog-to-digital converters
EP2965458B1 (en) Dithering circuit for sampling serial data transmission
CN103368676A (en) Periodical pulse signal-based different place data synchronous acquisition method and periodical pulse signal-based different place data synchronous acquisition system
CN102594741A (en) Communication circuit and method of adjusting sampling clock signal
CN113867577B (en) Digital detection system, chip and detection method for capacitive touch keys
CN102053189A (en) Digital oscilloscope with sequential trigger function and control method thereof
US5134481A (en) Method of automatically measuring the horizontal scan frequency of a composite synchronism signal, and an electronic circuit operating in accordance with the method
CN104184449A (en) Capacitive touch control apparatus, method, and system
US20170060288A1 (en) Capacitive touch sensing with lumped sensors
CN201611875U (en) Analog digital-signal switching system and television adopting the systems design
US7827377B2 (en) Method for reading out sensor data
CN114337634A (en) Capacitive touch key detection circuit and detection method thereof
CN115001474A (en) Digital processing system and chip based on touch keys
CN112782474A (en) Frequency detection circuit and frequency detection method
JP3894787B2 (en) Receiver circuit
JPH0846603A (en) Signal interrupt monitor circuit and signal period detection circuit
CN111428847B (en) Touch detection counter
CN111062116A (en) Method for accurately identifying analog quantity key information with unknown characteristics
CN111078118B (en) Device and method for carrying out anti-shake treatment on keys
CN109038709B (en) Key identification circuit and method and stirrer

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