method for reducing interference between capacitive touch keys

文档序号:1579572 发布日期:2020-01-31 浏览:11次 中文

阅读说明:本技术 一种降低电容式触摸按键之间干扰的方法 (method for reducing interference between capacitive touch keys ) 是由 汪蕾 于 2019-10-14 设计创作,主要内容包括:一种降低电容式触摸按键之间干扰的方法,其特征在于,该抗干扰处理方法包括有如下步骤:一、程序启动,初始化;二、判断其他中断标志位是否置位,如是,则执行下一步骤;如否,则执行步骤四;三、进入其他中断程序;四、判断按键中断标志位是否置位,如是,则执行下一步骤;如否,则执行步骤六;五、进入按键中断程序;六、延时时间K;七、执行按键处理函数,并开启下一按键通道;八、执行其他程序,然后返回步骤二。本发明的优点在于:在按键中断程序执行后,设置延时环节,确保灵敏度调节电容Cadj上的电压完全放电完成,保证了灵敏度调节电容Cadj上的起始电压都是一致,有效减小充电时间TKCNT的波动。(A method for reducing interference among capacitive touch keys is characterized in that the anti-interference processing method comprises the following steps of , starting and initializing a program, secondly, judging whether other interrupt flag bits are set or not, if so, executing , if not, executing step IV, if not, entering other interrupt programs, fourthly, judging whether the interrupt flag bits of the keys are set or not, if so, executing , if not, executing step VI, entering the key interrupt program, if sixth, delaying time K, seventh, executing a key processing function, starting a key channel, and eighth, executing other programs, and then returning to the step II.)

1, A method for reducing interference between capacitive touch keys, characterized in that, the anti-interference processing method includes the following steps:

step , starting the program, and initializing the setting;

step two, judging whether other interrupt flag bits are set, if so, executing a step , otherwise, executing a step four;

step three, entering other interrupt programs;

step four, judging whether the key interruption flag bit is set, if so, executing a step , otherwise, executing a step six;

step five, entering a key interruption program;

sixthly, delaying time K, wherein K is the discharge delay time of the sensitivity adjusting capacitor Cadj;

step seven, executing the key processing function and starting a lower key channel;

and step eight, executing other programs, and then returning to the step two.

2. The method of reducing interference between capacitive touch keys of claim 1, wherein: the key interruption program of the fifth step comprises the following steps:

(5-1) clearing the key interruption zone bit;

(5-2) starting a timer, and timing the key-press duration;

(5-3) judging whether the key pressing time length reaches the preset key pressing time length Tb, if so, pressing a key, and executing the step , otherwise, not pressing the key, and turning to the step six;

(5-4) resetting the timer and processing the key data;

and 5-5, obtaining the key value of the current key operation, and then executing the step six.

3. The method of reducing interference between capacitive touch keys of claim 2, wherein: and (5) the value range of the preset key pressing time Tb in the step (5-3) is 50 ms-150 ms.

4. The method of reducing interference between capacitive touch keys of claim 1, wherein: in the fourth step, the following method is adopted for judging whether the key interruption flag bit is set:

(4-1) whether the reference voltage on the sensitivity adjusting capacitor Cadj in the touch key circuit reaches a preset reference voltage Vref or not, if so, executing a step , otherwise, circulating the step;

and (4-2) reversing the comparator to generate a key interruption flag bit.

5. The method of reducing interference between capacitive touch keys of claim 4, wherein: the value range of the preset reference voltage Vref in the step (4-1) is 3V-5V.

6. The method of reducing interference between capacitive touch keys of claim 1, wherein: the value range of the delay time K in the sixth step is as follows: k is more than or equal to ToverWherein, ToverThe time for which the capacitor Cadj is completely discharged is adjusted for sensitivity, and ToverSatisfy the requirement of

Figure FDA0002232707990000021

Technical Field

The invention relates to capacitive touch keys, in particular to methods for reducing interference among capacitive touch keys.

Background

The basic principle of the capacitive touch key is charge transfer, as shown in fig. 3, which is a circuit control schematic diagram of a touch key in the prior art, a distributed capacitor Cp on the touch-sensitive key is formed by a finger-sensitive capacitor Cf and a circuit capacitor Cx, when the finger touches the touch key, the charge of the distributed capacitor Cp on the touch-sensitive key is transferred to a sensitivity adjustment capacitor Cadj until the voltage of the sensitivity adjustment capacitor Cadj reaches a reference voltage Vref, a comparator is inverted to generate a key interruption flag bit, and the charging time TKCNT is counted during the charge transfer.

In the using process, the fluctuation of the TKCNT can cause the touch key to be misjudged, the interference can be judged as a key possibly, and the anti-interference capability is poor.

Disclosure of Invention

The technical problem to be solved by the present invention is to provide methods for effectively reducing interference between capacitive touch keys, aiming at the above-mentioned current state of the art, and the anti-interference processing method not only can solve the problem of external interference, but also can solve the problem of mutual interference between keys.

methods for reducing interference between capacitive touch keys, characterized in that the anti-interference processing method comprises the following steps:

step , starting the program, and initializing the setting;

step two, judging whether other interrupt flag bits are set, if so, executing a step , otherwise, executing a step four;

step three, entering other interrupt programs;

step four, judging whether the key interruption flag bit is set, if so, executing a step , otherwise, executing a step six;

step five, entering a key interruption program;

sixthly, delaying time K, wherein K is the discharge delay time of the sensitivity adjusting capacitor Cadj;

step seven, executing the key processing function and starting a lower key channel;

and step eight, executing other programs, and then returning to the step two.

Preferably, the key interruption procedure of step five includes the following steps:

(5-1) clearing the key interruption zone bit;

(5-2) starting a timer, and timing the key-press duration;

(5-3) judging whether the key pressing time length reaches the preset key pressing time length Tb, if so, pressing a key, and executing the step , otherwise, not pressing the key, and turning to the step six;

(5-4) resetting the timer and processing the key data;

and 5-5, obtaining the key value of the current key operation, and then executing the step six.

Preferably, in the step , the value range of the key press duration Tb preset in the step (5-3) is 50ms to 150 ms.

Preferably, the step four of determining whether the key interruption flag bit is set adopts the following method:

(4-1) whether the reference voltage on the sensitivity adjusting capacitor Cadj in the touch key circuit reaches a preset reference voltage Vref or not, if so, executing a step , otherwise, circulating the step;

and (4-2) reversing the comparator to generate a key interruption flag bit.

Preferably, in the step , the preset reference voltage Vref in the step (4-1) has a value range of 3V to 5V.

Considering that theoretically, the discharge voltage of the capacitor can reach 0V only when the time reaches infinity, and three bits (i.e., 0.001V to 0.009V) after the discharge voltage of the sensitivity adjustment capacitor Cadj reaches a decimal point of 0V are set as complete discharge in practice, preferably, the value range of the delay time K in the step six is as follows: k is more than or equal to ToverWherein, ToverFor adjusting sensitivityThe time that the capacitor Cadj is completely discharged, and ToverSatisfy the requirement of

Figure BDA0002232708000000031

Above VtAdjusting the discharge voltage, V, of the capacitor Cadj for sensitivityrefIn order to generate the reference voltage of the key interruption zone bit, R is a discharge resistor, C is a discharge capacitor, and R and C jointly form a discharge circuit.

Compared with the prior art, the method has the advantages that the hardware structure is not changed, only the software is improved, a time delay link is set after the key interruption program is executed, the voltage on the sensitivity adjusting capacitor Cadj is ensured to be completely discharged, and then the lower key channel is opened, so that the initial voltage on the sensitivity adjusting capacitor Cadj is ensured to be when the current keys are started each time, the fluctuation of the charging time TKCNT is effectively reduced, the consumed time is short, the design cost is low, the problem of external interference from the keys can be solved, and the problem of mutual interference among the touch keys can be solved.

Drawings

Fig. 1 is a general flowchart of an anti-interference processing method according to an embodiment of the present invention.

Fig. 2 is a flowchart of a key interrupt processing procedure of the anti-interference processing method according to the embodiment of the present invention.

Fig. 3 is a schematic diagram of a touch key circuit in the prior art.

Detailed Description

The invention is described in further detail with reference to the following embodiments of the drawings.

The basic principle of the touch key is charge transfer, as shown in fig. 3, the distributed capacitance Cp on the touch sensing key is formed by the finger sensing capacitance Cf and the circuit capacitance Cx, the charge of the distributed capacitance Cp on the touch sensing key is transferred to the sensitivity adjustment capacitance Cadj in the process of touching the key, meanwhile, the timer counts the charging time TKCNT in the process of charge transfer until the voltage on the sensitivity adjustment capacitance Cadj reaches the preset reference voltage Vref, and the comparator is inverted to generate the interrupt flag bit.

When no key is pressed down, the distributed capacitance Cp is equal to the circuit capacitance Cx, and the time for transferring Cp charges to the sensitivity adjusting capacitance Cadj is the reference value of the charging time; when a key is pressed down, the distributed capacitance Cp is equal to the circuit capacitance Cx plus the finger sensing capacitance Cf; for reaching the same reference voltage Vref, the smaller the capacitance value of the distributed capacitance Cp, the longer the charging time, the larger the TKCNT value; the larger the value of the distributed capacitance Cp, the shorter the charging time, and accordingly, the smaller the value of TKCNT.

After the interrupt flag bit is generated, the interrupt program starts to read the charging time TKCNT, judges the variation of the charging time TKCNT value (namely the charging time TKCNT after the key is pressed is different from the charging time reference value when no key is pressed), starts the time counting of the pressed time duration of the key, considers that the key is pressed only when the variation of the charging time TKCNT reaches the set limit and the time duration reaches the preset time, and excludes the key touch possibly caused by external interference, so that the external interference resistance of the key is ensured, wherein the limit representing the pressed key can be set by the variation of the charging time TKCNT before and after the finger is pressed, so that the sensitivity of the key is ensured.

During the interruption process, the sensitivity adjusting capacitor Cadj is discharged, after the interruption process is completed, the lower key channels are opened, and the charge transfer is performed again, at this time, the charging initial voltage of the sensitivity adjusting capacitor Cadj is the voltage discharged last times, and the initial voltage is determined by the discharging time length of the sensitivity adjusting capacitor Cadj in the interruption process last times.

In order to avoid the fluctuation of the charging time TKCNT caused by the starting voltage of , this embodiment adopts a pure software control method, and methods for reducing the interference between the capacitive touch keys are designed, as shown in fig. 1 and fig. 2, the anti-interference processing method includes the following steps:

step , program start, initialize settings.

And step two, judging whether other interrupt flag bits are set or not, if so, executing a step , and if not, executing a step four.

And step three, entering other interrupt programs.

Step four, judging whether the key interruption flag bit is set, if so, executing a step , otherwise, executing a step six, wherein the method for judging whether the key interruption flag bit is set adopts the following method:

(4-1) whether the reference voltage on the sensitivity adjusting capacitor Cadj in the touch key circuit reaches a preset reference voltage Vref or not is judged, if so, the step is executed, and if not, the step is circulated, wherein the value range of the preset reference voltage Vref is 3V-5V;

and (4-2) reversing the comparator to generate a key interruption flag bit.

Step five, entering a key interruption program;

(5-1) clearing the key interruption zone bit;

(5-2) starting a timer, and timing the key-press duration;

(5-3) judging whether the key time duration reaches the preset key time duration Tb, if so, pressing the key, and executing the step , otherwise, pressing no key, and turning to the step six, wherein the value range of the preset key time duration Tb is 50-150 ms;

(5-4) resetting the timer and processing the key data;

and 5-5, obtaining the key value of the current key operation, and then executing the step six.

And step six, delaying time K, wherein K is the discharge delay time of the sensitivity adjusting capacitor Cadj.

And step seven, executing the key processing function and starting a lower key channel.

And step eight, executing other programs, and then returning to the step two.

In the present embodiment, a delay time K is set after the key interruption procedure, and the delay time K must satisfy the condition that the sensitivity adjustment capacitor Cadj is completely discharged, and generally, in the touch key circuit, adopts an RC discharge circuit as shown in fig. 3, and the RC discharge circuit satisfies the following formula:

Vt=Vref×exp(-Tover/RC)

wherein, VtAdjusting the discharge voltage, V, of the capacitor Cadj for sensitivityrefFor generating a reference voltage for the key-off flag, ToverAdjusting the time for the capacitor Cadj to completely discharge for sensitivity; r is a discharge resistor, C is a discharge capacitor, and R and C jointly form a discharge circuit.

As can be seen from the above formula, the discharge voltage of the sensitivity adjustment capacitor Cadj can reach 0V only when the time reaches infinity, and the discharge voltage V of the sensitivity adjustment capacitor Cadj is set in practicetThe value of 0.001V to 0.009V is complete discharge (the number of digits after the decimal point can be adjusted according to the precision requirement, and three digits after the decimal point are taken in the embodiment);

thus, when ToverSatisfies the following conditions:

Figure BDA0002232708000000051

when the time is over, the sensitivity adjusting capacitor Cadj is considered to be completely discharged, and the value range of the delay time K is only required to satisfy that K is more than or equal to ToverThe complete discharge of the sensitivity adjustment capacitor Cadj can be ensured.

According to the embodiment, a hardware structure does not need to be changed, the consumed time is short, the design cost is low, improvement is performed on software, after each time of key interruption program execution, the delay time K is further executed, and the voltage on the sensitivity adjusting capacitor Cadj is ensured to be completely discharged, so that the discharge voltage of the sensitivity adjusting capacitor Cadj is ensured to be the same, the initial voltage of times of key starting is , the fluctuation of the charging time TKCNT is effectively reduced, the problem of external interference of keys can be solved, the problem of mutual interference among touch keys can be solved, and the whole control method is simple and easy to implement.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种电容触摸按键的场景式信号自适应处理方法及电子装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类