A method for reducing mechanical key misjudgment

By introducing a charging current-limiting resistor, a noise-reducing resistor, and a filtering capacitor into the mechanical button circuit, and combining this with microcontroller-controlled button power supply time detection, dual verification of the mechanical buttons is achieved. This solves the problems of misjudgment and electromigration failure of mechanical buttons, and improves the reliability of the buttons.

CN116346115BActive Publication Date: 2026-11-27HAINAN POWER GRID CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310308422.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-27
Publication Date
2026-11-27
Estimated Expiration
2043-03-27

AI Technical Summary

Technical Problem

Existing mechanical button circuits are susceptible to moisture and salt spray, leading to impedance changes, electromigration failures, and misjudgments. Furthermore, the lack of a dual verification mechanism increases the probability of misjudgments.

Method used

The hardware circuit includes a charging current-limiting resistor, a noise reduction resistor, a filter capacitor, and a microcontroller. By detecting the change time of the button capacitor voltage and combining it with the microcontroller to control the button power supply, a dual verification is performed to determine the button status.

Benefits of technology

This reduces the risk of button misjudgment, decreases the possibility of electromigration failure, and improves the reliability of mechanical buttons.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116346115B_ABST
    Figure CN116346115B_ABST
Patent Text Reader

Abstract

The application provides a method for reducing mechanical key misjudgment, which reduces the risk of electro-migration corrosion failure between two poles in the key by reducing the time of applying voltage on the key through a single-chip microcomputer, detects the charging time when the mechanical key is not pressed by the single-chip microcomputer when the key is powered for the first time, records the corresponding time T1, detects the time spent by the voltage of the key capacitor reaching a preset threshold when the mechanical key is pressed by the single-chip microcomputer, records the corresponding time T2, compares T2 with T1 to determine whether the mechanical key is pressed, and outputs a signal when it is determined that the mechanical key is pressed, wherein the method adopts the mode of double verification of capacitor charging time judgment and key pressing to reduce the risk of misjudgment, and can significantly improve the reliability of the mechanical key.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mechanical button status detection technology, and in particular to a method for reducing false judgments of mechanical buttons. Background Technology

[0002] Conventional mechanical button circuits typically use, for example Figure 1 The circuit shown is used to collect button signals. This signal acquisition scheme has several drawbacks: First, after long-term exposure to moisture and salt spray, the impedance between the two poles may decrease when the button is disconnected (e.g., from infinity to 10kΩ). To reduce power consumption (considering the button might be pressed for extended periods), the pull-up resistor is typically large. This can lead to misjudgments of the button's status after prolonged operation. Second, because buttons are difficult to completely seal, the combined effect of salt ions and moisture can cause salt ions to enter the button's interior, leading to electromigration failure. Long-term electromigration failure can corrode the metal electrodes inside the button, resulting in failure. Third, this scheme can only determine whether the button is pressed by checking the continuity of the circuit. Due to the mechanical characteristics of the button, it may vibrate when pressed, increasing the probability of misjudgment, and lacks a mutual verification mechanism. Summary of the Invention

[0003] Therefore, the purpose of this invention is to provide a method for reducing misjudgments of mechanical buttons, so as to solve or at least partially solve the above-mentioned problems existing in the prior art.

[0004] To achieve the above-mentioned objective, this invention provides a method for reducing false triggering of mechanical buttons. The method is applied to a mechanical button, which includes a button capacitor Cs, a charging pin, and a detection pin. The method includes the following steps:

[0005] S101. Deploy a hardware circuit connected to the mechanical button. The hardware circuit includes a charging current limiting resistor R1, a noise reduction resistor R2, a filter capacitor C1, and a microcontroller. R1 is set in the connection circuit between the button capacitor and the charging pin, R2 is set in the connection circuit between the button capacitor and the detection pin, C1 is connected in parallel with the button capacitor Cs, and the charging pin and the detection pin are respectively connected to the microcontroller.

[0006] S102. Upon first power-on, the microcontroller detects the charging time when the mechanical button is not pressed and records the corresponding time T1.

[0007] S103. When the mechanical button is pressed, the microcontroller detects the time it takes for the voltage of the button capacitor to reach a preset threshold, records the corresponding time T2, compares T2 with T1 to determine whether the mechanical button is pressed, and outputs a signal when it is determined that the mechanical button is pressed.

[0008] Furthermore, in step S102, before detecting time T1, an interrupt is first performed. After entering the interrupt, the microcontroller I / O port connected to the charging pin is set to push-pull output and given a high level. Then, the timer is turned on, and the microcontroller I / O port connected to the detection pin is set to ADC sampling.

[0009] Furthermore, in step S102, when the voltage sampled by the ADC reaches Vth, the timer is turned off, and the timing time recorded by the timer is recorded as T1.

[0010] Furthermore, after recording time T1, the microcontroller I / O port connected to the charging pin and detection pin is set to push-pull output and given a low level to discharge the capacitor and wait for the next interrupt.

[0011] Furthermore, in step S103, before detecting time T2, an interrupt is first entered. After entering the interrupt, the microcontroller I / O port connected to the charging pin is set to push-pull output and given a high level. Then, the timer is turned on, and the microcontroller I / O port connected to the detection pin is set to ADC sampling.

[0012] Furthermore, in step S103, when the voltage sampled by the ADC reaches Vth, the timer is turned off, and the timing time recorded by the timer is recorded as T2.

[0013] Furthermore, after recording time T2, it is determined whether T2 is greater than T1, and whether the voltage sampled by the ADC after the timer is turned off is 0V. If T2 is greater than T1 and the voltage sampled by the ADC is 0V, it is determined that the mechanical button is pressed; otherwise, it is determined that the mechanical button is not pressed.

[0014] Furthermore, in step S103, after completing the button state judgment, the microcontroller I / O port connected to the charging pin and the detection pin is set to push-pull output and given a low level to discharge the capacitor and wait for the next interrupt.

[0015] Compared with the prior art, the beneficial effects of the present invention are:

[0016] This invention provides a method to reduce misjudgments of mechanical buttons. By using a microcontroller to control button sampling enable, the impedance of the button is reduced when it is disconnected, thereby reducing the risk of misjudgment. Since the microcontroller's I / O port controls the power supply of the button, the time when there is voltage between the two poles of the button is reduced, thereby reducing the time of electromigration failure and reducing the risk of electromigration failure. This invention can significantly reduce the risk of program misjudgment by using capacitor charging time judgment and button on / off dual verification. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only preferred embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of the button signal acquisition circuit used in conventional buttons in existing technology.

[0019] Figure 2 This is a schematic diagram of the hardware circuit provided in an embodiment of the present invention.

[0020] Figure 3 This is a schematic diagram of the charging curve of the RC circuit provided in an embodiment of the present invention.

[0021] Figure 4 This is a schematic diagram of the method steps for reducing misjudgments of mechanical buttons provided in an embodiment of the present invention. Detailed Implementation

[0022] The principles and features of the present invention are described below with reference to the accompanying drawings. The listed embodiments are only used to explain the present invention and are not intended to limit the scope of the present invention.

[0023] Reference Figure 2 This embodiment provides a method to enhance the reliability of mechanical buttons and reduce false triggering, and the hardware circuit used is as follows: Figure 2 As shown. R1 is the charging current-limiting resistor, with a resistance value between several hundred kilohms and several megahms. R2 is the noise reduction resistor, used to reduce noise interference, typically 10 kΩ. C1 is the filter capacitor. This method is applied to mechanical buttons, which include a button capacitor, a charging pin, and a detection pin. A gap exists between the two metal plates of the mechanical button, and an insulator is placed between the two metal plates to form a simple capacitor, denoted as Cs. When the shape and spacing of the two metal plates are fixed, the capacitance of the button capacitor is also relatively fixed. The expression for a capacitor with a dielectric is:

[0024]

[0025] Where ε is the relative permittivity of the dielectric, S is the area of ​​the capacitor plates facing each other, d is the distance between the capacitor plates, and k is the electrostatic constant. Equation 1 shows that when the distance between the two metal plates decreases (corresponding to a button being pressed), the capacitance Cs of the capacitor formed by the two metal plates increases.

[0026] Figure 2The filter capacitor C1 is connected in parallel with the key capacitor Cs, which is denoted as Cx, and Cx=C1+Cs; the resistor R1 and Cx form an RC circuit, and the charging formula of the RC circuit is shown as follows:

[0027]

[0028] Where V(t) is the voltage across the capacitor at time t, VCC is the supply voltage, e is the natural constant, R is the resistance value connected in series between the capacitor and the power supply, C is the capacitance, and t is the time.

[0029] In combination with Figure 3 , it can be known that the larger the capacitor, the longer it takes to charge to a certain fixed voltage (Vth). When the key is not pressed, it is assumed that Cx=Cx1; after the key is pressed, Cx=Cx2, and Cx1<Cx2. According to Equation 2 and Figure 3 , it can be known that the time for charging Cx1 to a certain fixed voltage is less than the time for charging Cx2 to a certain fixed voltage, which is denoted as t(Cx1)<t(Cx2).

[0030] Referring to Figure 4 , based on the above principles, the method for reducing misjudgment of mechanical keys provided by this embodiment includes the following steps:

[0031] S101: Deploy a hardware circuit connected to the mechanical key. The hardware circuit includes a charging current-limiting resistor R1, a noise reduction resistor R2, a filter capacitor C1, and a microcontroller. R1 is disposed in the connection circuit between the key capacitor and the charging pin, R2 is disposed in the connection circuit between the key capacitor and the detection pin, C1 is connected in parallel with the key capacitor Cs, and the charging pin and the detection pin are respectively connected to the microcontroller.

[0032] S102: During the first power-on, the microcontroller detects the charging time when the mechanical key is not pressed, and records the corresponding time T1.

[0033] S103: When the mechanical key is pressed, the microcontroller detects the time taken for the voltage of the key capacitor to reach a preset threshold, records the corresponding time T2, and compares T2 with T1 to determine whether the mechanical key is pressed. A signal is output when it is determined that the mechanical key is pressed.

[0034] In step S102, recording the charging time T1 when the key is not pressed specifically includes the following steps:

[0035] S201: Trigger an interrupt once. After entering the interrupt, set the microcontroller IO port connected to the charging pin to push-pull output and apply a high level.

[0036] S202: Turn on the timer, and set the microcontroller IO port connected to the detection pin to ADC sampling.

[0037] S203. When the voltage sampled by the ADC reaches Vth, the timer is turned off and the timing time is recorded as T1, where T1 is the charging time when the button is not pressed.

[0038] S204. Set the microcontroller I / O port connected to the charging pin and the detection pin to push-pull output, give it a low level to discharge the capacitor, and wait for the next interrupt.

[0039] Step S103 specifically includes the following steps:

[0040] S301. Entering the interrupt: After entering the interrupt, the microcontroller I / O port connected to the charging pin is set to push-pull output and given a high level.

[0041] S302. Turn on the timer and set the microcontroller I / O port connected to the detection pin as an ADC sampling port.

[0042] S303. When the voltage sampled by the ADC reaches Vth, the timer is turned off and the timing period is recorded as T2.

[0043] S304, the button travel ends, the two ends of the button are turned on, and the voltage obtained by the ADC sampling is 0V.

[0044] S305. Determine whether T2 is greater than T1 and whether the ADC sampling voltage is 0V after the timer is turned off. If the above conditions are met, determine that the mechanical button is pressed and output the corresponding signal; otherwise, determine that the mechanical button is not pressed.

[0045] S306. After completing the button status judgment, set the microcontroller I / O port connected to the charging pin and the detection pin to push-pull output, give it a low level to discharge the capacitor, and wait for the next interrupt.

[0046] The method provided in this embodiment reduces the time when the voltage is applied to the button by controlling the I / O port of the microcontroller, thereby reducing the risk of electromigration corrosion failure between the two electrodes inside the button. It also adopts a dual verification method of capacitor charging time judgment and button pressing to reduce the risk of misjudgment, which can significantly improve the reliability of mechanical buttons.

[0047] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for reducing false judgments of mechanical buttons, characterized in that, The method is applied to a mechanical button, the mechanical button including a button capacitor Cs, a charging pin, and a detection pin, and the method includes the following steps: S101. Deploy a hardware circuit connected to the mechanical button. The hardware circuit includes a charging current limiting resistor R1, a noise reduction resistor R2, a filter capacitor C1, and a microcontroller. R1 is set in the connection circuit between the button capacitor and the charging pin, R2 is set in the connection circuit between the button capacitor and the detection pin, C1 is connected in parallel with the button capacitor Cs, and the charging pin and the detection pin are respectively connected to the microcontroller. S102. Upon first power-on, the microcontroller detects the charging time when the mechanical button is not pressed and records the corresponding time T1. Before detecting time T1, an interrupt is initiated. After entering the interrupt, the microcontroller I / O port connected to the charging pin is set to push-pull output and given a high level. Then, the timer is turned on, and the microcontroller I / O port connected to the detection pin is set to ADC sampling. When the voltage sampled by the ADC reaches Vth, the timer is turned off, and the timing time recorded by the timer is recorded as T1. After recording time T1, the microcontroller I / O port connected to the charging pin and the detection pin is set to push-pull output and given a low level to discharge the capacitor and wait for the next interrupt. S103. When the mechanical button is pressed, the microcontroller detects the time it takes for the button capacitor voltage to reach a preset threshold and records the corresponding time T2. Before detecting time T2, an interrupt is entered. After entering the interrupt, the microcontroller I / O port connected to the charging pin is set to push-pull output and given a high level. Then, the timer is turned on, and the microcontroller I / O port connected to the detection pin is set to ADC sampling. When the voltage sampled by the ADC reaches Vth, the timer is turned off, and the timing time recorded by the timer is recorded as T2. T2 is compared with T1 to determine whether the mechanical button is pressed. When it is determined that the mechanical button is pressed, a signal is output. Specifically, after completing the recording of time T2, it is determined whether T2 is greater than T1, and whether the voltage sampled by the ADC after the timer is turned off is 0V. If T2 is greater than T1 and the voltage sampled by the ADC is 0V, it is determined that the mechanical button is pressed; otherwise, it is determined that the mechanical button is not pressed.

2. The method for reducing false judgments of mechanical buttons according to claim 1, characterized in that, In step S103, after completing the button state judgment, the microcontroller I / O port connected to the charging pin and the detection pin is set to push-pull output and given a low level to discharge the capacitor and wait for the next interrupt.

Citation Information

Patent Citations

  • Capacitive touch key and key judging method thereof

    CN102394622A

  • Capacitive sensing touch control key and key judging method thereof

    CN105306038A