Key signal jitter elimination method with feedback correction, device, equipment and storage medium

文档序号:1941198 发布日期:2021-12-07 浏览:20次 中文

阅读说明:本技术 带反馈校正的按键信号消抖方法、装置、设备及存储介质 (Key signal jitter elimination method with feedback correction, device, equipment and storage medium ) 是由 雷帅锋 戴宇辉 郭立强 于 2021-08-05 设计创作,主要内容包括:本发明公开了一种带反馈校正的按键信号消抖方法、装置、设备及存储介质,所述方法包括:对用户按键的输入信号进行采样,将此信号输入状态统计单元。对连续的N次采样结果进行统计和保存;其中,在状态统计单元统计过程中,对高频噪声或低频噪声进行滤波处理。判断连续的N次采样结果是否稳定,当连续的N次采样结果不均为高电平(或低电平)时,则认定当前状态仍为之前的状态,不满足按键触发条件;当连续的N次采样结果均为高电平(或低电平)时,则认定当前的状态为高电平(或低电平),满足按键触发条件。通过本方法消除了毛刺状态的影响,可以有效降低按键状态不稳定而造成误判的可能性,并且能够保证实时性要求。(The invention discloses a key signal jitter eliminating method, a device, equipment and a storage medium with feedback correction, wherein the method comprises the following steps: the input signal of the user key is sampled and input into the state statistical unit. Counting and storing continuous N times of sampling results; and in the statistical process of the state statistical unit, filtering high-frequency noise or low-frequency noise. Judging whether the continuous N-time sampling results are stable or not, and determining that the current state is still the previous state and does not meet the key triggering condition when the continuous N-time sampling results are not all high levels (or low levels); and when the continuous N sampling results are all high level (or low level), determining that the current state is high level (or low level), and meeting the key triggering condition. The method eliminates the influence of the burr state, can effectively reduce the possibility of misjudgment caused by unstable key state, and can ensure the real-time requirement.)

1. A key signal jitter elimination method with feedback correction is characterized in that: the method comprises the following steps:

s100, sampling an input signal of a user key, and inputting the signal into a state statistical unit;

s200, counting and storing continuous N-time sampling results by adopting a state counting unit;

s300, judging whether continuous N-time sampling results are stable or not by adopting an output state decision unit, and determining that the current state is a high level (or a low level) when the continuous N-time sampling results are all high levels (or low levels) to meet a key triggering condition; and when the continuous N sampling results are not all high level (or low level), determining that the current state is still the previous state and the key triggering condition is not met.

2. The method of claim 1, wherein the method further comprises: s100 further comprises the steps of:

the user key input signal can be high level or low level, and when the user key input signal is high level, polarity inversion is not needed; when the user presses the key input signal to be in low level, the signal polarity is reversed and input into the state statistical unit.

3. The method of claim 1, wherein the method further comprises: and in the statistical process of the state statistical unit and the judgment process of the output state decision unit, filtering the high-frequency noise or the low-frequency noise.

4. The method of claim 1, wherein the method further comprises: s300 further comprises the steps of:

and feeding back the signal output by the state to the output state decision unit, and correcting the signal output by the state decision unit.

5. The utility model provides a take button signal of feedback correction to remove trembles device which characterized in that: the key input device comprises a key input sampling unit (201), a configuration unit (202), a polarity inversion unit (203), a state statistics unit (204), a filtering window limit mask (205), a state output unit (206) and an output state decision unit (207), wherein the key input unit and the configuration unit (202) are both connected with the polarity inversion unit (203), and the state statistics unit (204) is connected with the polarity inversion unit (203) and used for counting and storing key input states; the filtering window limit mask (205) is respectively connected with the state statistic unit (204) and the output state decision unit (207) to carry out noise filtering on the two; the output state decision unit (207) is respectively connected with the state statistical unit (204) and the state output unit (206), and determines the next output state through the feedback of the state output unit (206), the state statistical unit (204) and the filtering window limit mask (205) to judge whether the trigger key condition is met.

6. The key signal jitter elimination apparatus with feedback correction as claimed in claim 5, wherein: the key input unit is used for storing a sampling value of a key at a certain moment, the sampling value of the key input sampling unit (201) is a Boolean variable A,

when the sampling value is at a high level, A is 1, and when the sampling value is at a low level, A is 0;

the configuration unit (202) is set by a user according to the option configured by the active level, and is set as a Boolean type variable B, wherein when the key state input high level is active, B is 0, and when the key state input low level is active, B is 1;

the logic operation formula of the polarity reversing unit (203) is P ═ A ^ B (A exclusive OR B).

7. The key signal jitter elimination apparatus with feedback correction as claimed in claim 5, wherein: the state statistical unit (204) uses a static variable S to store the latest continuous N sampling results, wherein S ═ S < <1) | P & C;

wherein C is a variable of the filter window limit mask (205), C2 ^ N-1; s is initially 0, N represents a sampling threshold,and the delta T is a time slice for executing the key acquisition program of the user, and the T is a preset interference signal time slice.

8. The key signal jitter elimination apparatus with feedback correction as claimed in claim 5, wherein: the output state decision unit (207) is set as a variable U, and the specific decision process is as follows:

if Q is equal to 0, U is equal to S & C, when U! When Q is equal to 0, Q is not changed, otherwise, Q is equal to! Q;

if Q is 1, U is S & C, when U! When Q is equal to 0, Q is not changed, otherwise, Q is equal to! And Q.

9. An electronic device, characterized in that: the keyboard comprises a key, a program memory, a data memory and a processor, wherein the key is used for being connected with a key circuit and generating a key signal which can be identified by the processor; the program memory is used for storing a key signal jitter elimination program, and the data memory is used for an intermediate data carrier generated in the program operation process; the processor is used for implementing the method of any one of claims 1 to 4 when executing the key signal jitter elimination program stored in the program memory, and can access the data memory.

10. A computer-readable storage medium having a key signal debouncing program stored thereon, characterized in that: the method of any one of claims 1-4 can be implemented when the key signal debounce program is executed.

Technical Field

The invention relates to the technical field of digital filtering, in particular to a key signal jitter elimination method with feedback correction, a device, equipment and a storage medium.

Background

Keys are widely used in various control devices, and since key signals are generated mechanically, the mechanical characteristics of the keys determine that an unstable state, generally called "jitter", exists during the pressing or releasing of the keys, and thus the key signals always appear as burrs due to mechanical contact.

At present, the following processing methods are generally used for dealing with the glitch appearing in the key signal:

delay sampling: and when a key pressing signal is received, delaying for a period of time, judging the key state again when the key state is stable, and if the key is still in the pressing state, performing corresponding processing on the key.

However, the existing treatment method has the following defects:

1. because time delay is needed for re-judgment, the key cannot be immediately responded;

2. in a conventional keyboard "jitter elimination" scheme, the jitter elimination is performed for a relatively short time around the state change, the jitter time becomes long, or the dynamic state is uncertain, and even after a time delay, the key state may still be unstable, thereby causing misjudgment.

Disclosure of Invention

The invention aims to provide a key signal jitter elimination method with feedback correction, equipment and a storage medium, which can ensure the real-time requirement, eliminate the influence of a burr state and effectively reduce the possibility of misjudgment caused by unstable key state.

In order to achieve the purpose, the invention adopts the following technical scheme:

a key signal jitter elimination method with feedback correction comprises the following steps:

s100, sampling an input signal of a user key, and inputting the signal into a state statistical unit;

s200, counting and storing continuous N-time sampling results by adopting a state counting unit;

s300, judging whether continuous N-time sampling results are stable or not by adopting an output state decision unit, and determining that the current state is a high level (or a low level) when the continuous N-time sampling results are all high levels (or low levels) to meet a key triggering condition; and when the continuous N sampling results are not all high level (or low level), determining that the current state is still the previous state and the key triggering condition is not met.

Further setting the following steps: s100 further comprises the steps of: the user key input signal can be high level or low level, and when the user key input signal is high level, polarity inversion is not needed; when the user presses the key input signal to be in low level, the signal polarity is reversed and input into the state statistical unit.

Further setting the following steps: and in the statistical process of the state statistical unit and the judgment process of the output state decision unit, filtering the high-frequency noise or the low-frequency noise.

Further setting the following steps: s300 further comprises the steps of:

and feeding back the signal output by the state to the output state decision unit, and correcting the signal output by the state decision unit.

The invention also provides a key signal jitter eliminating device with feedback correction, which comprises a key input sampling unit, a configuration unit, a polarity overturning unit, a state counting unit, a filtering window limiting mask code, a state output unit and an output state decision unit, wherein the key input unit and the configuration unit are both connected with the polarity overturning unit, and the state counting unit is connected with the polarity overturning unit and used for counting and storing the key input state; the filtering window limit mask is respectively connected with the state statistic unit and the output state decision unit, and noise filtering is carried out on the state statistic unit and the output state decision unit; the output state decision unit is respectively connected with the state statistical unit and the state output unit, and jointly decides the next output state through the feedback of the state output unit, the state statistical unit and the filtering window limit mask to judge whether the trigger key condition is met.

Further setting the following steps: the key input unit is used for storing a sampling value of a key at a certain moment, the sampling value of the key input sampling unit is a Boolean variable A,

when the sampling value is at a high level, A is 1, and when the sampling value is at a low level, A is 0;

the configuration unit is set by a user according to the option configured by the active level and is set as a Boolean type variable B, wherein when the key state input high level is active, B is 0, and when the key state input low level is active, B is 1;

the logic operation formula of the polarity inversion unit is P ═ A ^ B (A exclusive OR B).

Further setting the following steps: the state statistical unit uses a static variable S to store the latest continuous N times of sampling results, wherein S is (S < <1) > P & C;

wherein, C is a variable of the filter window limit mask, and C is 2^ N-1; s is initially 0, N represents a sampling threshold,and the delta T is a time slice for executing the key acquisition program of the user, and the T is a preset interference signal time slice.

Further setting the following steps: the output state decision unit is set as a variable U, and the specific decision process is as follows:

if Q is equal to 0, U is equal to S & C, when U! When Q is equal to 0, Q is not changed, otherwise, Q is equal to! Q;

if Q is 1, U is S & C, when U! When Q is equal to 0, Q is not changed, otherwise, Q is equal to! And Q.

The invention also provides electronic equipment which comprises a key, a program memory, a data memory and a processor, wherein the key is used for being connected with the key circuit and generating a key signal which can be identified by the processor; the program memory is used for storing a key signal jitter elimination program, and the data memory is used for an intermediate data carrier generated in the program operation process; the processor is used for realizing the key signal jitter elimination method with feedback correction when executing the key signal jitter elimination program stored in the program memory, and can access the data memory.

A computer readable storage medium, on which a key signal jitter elimination program is stored, wherein the key signal jitter elimination program can implement the above-mentioned key signal jitter elimination method with feedback correction when executed.

In conclusion, the beneficial technical effects of the invention are as follows:

(1) through carrying out continuous N sampling to the key input signal to carry out feedback correction with the output result, compare in prior art, can eliminate the influence of burr state, effectively reduce the key state unstability and cause the possibility of erroneous judgement, and do not need the time delay to judge again, can guarantee the real-time requirement.

(2) The high-frequency noise can be filtered by setting a large sampling threshold value N and a relatively small sampling period delta T, the low-frequency noise can be filtered by setting a small sampling threshold value N and a relatively large sampling period delta T, and the tolerance to the noise is higher.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.

Fig. 1 is a flowchart illustrating a method for eliminating jitter of a key signal with feedback correction according to an embodiment 1 of the present disclosure;

fig. 2 is a schematic diagram of a key triggering signal with jitter according to embodiment 1, in which fig. 2(a) is a schematic diagram of high-level triggering, and fig. 2(b) is a schematic diagram of low-level triggering;

fig. 3 is a schematic diagram of an analog signal, a digital signal and a digital sampling signal with noise interference occurring when a key is pressed in embodiment 1;

fig. 4 is a connection block diagram of a key signal jitter elimination apparatus with feedback correction according to embodiment 2 disclosed in the present invention;

fig. 5 is a structural diagram of a key signal jitter elimination device with feedback correction according to embodiment 2 of the disclosure.

Reference numerals: 201. a key input sampling unit; 202. a configuration unit; 203. a polarity inversion unit; 204. a state counting unit; 205. a filtering window limit mask; 206. a state output unit; 207. an output state decision unit; 301. pressing a key; 302. a program memory; 303. a data storage; 304. a processor; 3021. and a key signal jitter elimination program.

Detailed Description

The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.

In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.

Example 1

Referring to fig. 1, the method for eliminating jitter of a key signal with feedback correction disclosed by the invention comprises the following steps:

s101, sampling an input signal of a user key, and inputting the signal into a state statistical unit 204; the user key input signal can be high level or low level, and when the user key input signal is high level, polarity inversion is not needed; when the user presses the key to input the signal at a low level, the polarity of the signal is reversed and the signal is input to the state counting unit 204.

S102, counting and storing continuous N-time sampling results by using a state counting unit 204; in the statistical process of the state statistical unit 204, filtering processing is performed on the high-frequency noise or the low-frequency noise.

S103, judging whether the continuous N-time sampling results are stable by using the output state decision unit 207, and if the continuous N-time sampling results are not all high level (or low level), determining that the current state is still the previous state and the key triggering condition is not met; and when the continuous N sampling results are all high level (or low level), determining that the current state is high level (or low level), and meeting the key triggering condition.

In the judgment process of the output state decision unit 207, filtering processing is performed on the high-frequency noise or the low-frequency noise.

Step S103 further includes sub-steps S1031 and S1032: the signal output by the state decision unit is fed back to the output state decision unit 207, and the signal output by the state decision unit is corrected.

S1031, if the current output state is high level and the continuous N-time sampling results are not all low levels, the key triggering condition is not met, the current state is determined as the previous state, and the signal state output by the output state unit is kept unchanged; and if the current output state is high level and the continuous N times of sampling results are low levels, the key triggering condition is met.

S1032, if the current output state is a high level and the continuous N-time sampling results are not all low levels, the key triggering condition is not met, the current state is determined as the previous state, and the signal state output by the output state unit is kept unchanged; and if the current output state is high level and the continuous N times of sampling results are low levels, the key triggering condition is met.

Generally, a key activation signal having a wobble signal is divided into a high level activation signal and a low level activation signal as shown in fig. 2. The noise interference degree of the trigger signal is different according to the interference resistance of the hardware circuit, fig. 2 is only an illustration, and the noise may have a plurality of peaks.

Referring to fig. 3, taking high level triggering as an example, an analog signal with noise interference occurring when a key is pressed is only divided into high and low levels for the inside of the digital chip, and the analog signal input is equivalent to the digital signal input in fig. 3, and the digital signal input is a key input signal.

At the time of digital sampling t, t +1, t +2, t +3, t +4, and t +5, the states of N consecutive times are not all high level, which indicates that the signal is unstable, and at this time, the key state is still the previous stable state (low level). The time t +6 of digital sampling indicates that the states of N times of succession are all high levels, indicates that the stable state at this moment is high level, and meets the condition of triggering the key.

The method eliminates the influence of the burr state, can effectively reduce the possibility of erroneous judgment caused by unstable key state, does not need time delay for judgment, and can ensure the real-time requirement.

Example 2

Referring to fig. 4, the key signal jitter elimination apparatus with feedback correction disclosed in the present invention includes a key input sampling unit 201, a configuration unit 202, a polarity inversion unit 203, a state statistics unit 204, a filtering window limit mask 205, a state output unit 206, and an output state decision unit 207, where the key input unit is configured to store a sampling value of a key at a certain time, the sampling value of the key input sampling unit 201 is a boolean variable a, where a is 1 when the sampling value is a high level, and a is 0 when the sampling value is a low level. The configuration unit 202 is set by the user according to the option of active level configuration, and is set to a boolean variable B, where B is 0 when the key state input is active high and B is 1 when the key state input is active low.

The key input unit and the configuration unit 202 are both connected with the polarity inversion unit 203, and the state statistics unit 204 is connected with the polarity inversion unit 203 and is used for performing statistics and storage on the key input state. The logical operation formula of the polarity inverting unit 203 is P ═ a ^ B (exclusive or B), that is, the input state counting unit 204 when P is high.

The filtering window limit mask 205 is connected to the state counting unit 204 and the output state decision unit 207, respectively, and performs noise filtering on the two. C is a variable of the filter window limit mask 205, C ═ 2^ N-1. N represents a sampling threshold value and N represents a sampling threshold value,and the integer is rounded up, the delta T is a time slice executed by a key acquisition program of a user, and the T is a preset interference signal time slice. Wherein N ismax=64,Nmin2, by setting a large sampling threshold N and a relatively small sampling period Δ T, high-frequency noise can be filtered, and by setting a small sampling threshold N and a relatively large sampling period Δ T, low-frequency noise can be filtered, so that the tolerance of the device to noise is higher.

The state statistics unit 204 uses a static variable S to store the latest N consecutive sampling results, where S ═ S < <1) | P & C, where S is initially 0.

The output state decision unit 207 is connected to the state statistics unit 204 and the state output unit 206, and determines the next output state through the feedback of the state output unit 206, the state statistics unit 204, and the filtering window limit mask 205, and determines whether the trigger key condition is satisfied. The output state decision unit 207 is set as a variable U, and the specific decision process is as follows:

if Q is equal to 0, U is equal to S & C, when U! When 0, Q is unchanged; when U! When 1, Q! And Q. That is, if the current output state is at a low level, the key trigger condition is that the N consecutive sampling results are at a stable high level. If the current output state is a low level and the continuous N-time sampling results are not all high levels, the key triggering condition is not met, the current state is determined as the previous state, and the state of the signal output by the output state unit is kept unchanged; and if the current output state is low level and the continuous N times of sampling results are all high levels, the key triggering condition is met.

If Q is 1, U is S & C, when U! When 0, Q is unchanged; when U! When 1, Q! And Q. That is, if the current output state is at a high level, the key trigger condition is that the N consecutive sampling results are at a stable low level. If the current output state is a high level and the continuous N-time sampling results are not all low levels, the key triggering condition is not met, the current state is determined as the previous state, and the state of the signal output by the output state unit is kept unchanged; and if the current output state is high level and the continuous N times of sampling results are low levels, the key triggering condition is met.

The device can solve the burr problem of the key, effectively reduces the possibility of misjudgment caused by unstable key state, does not need time delay to judge again, and can ensure the real-time requirement.

Embodiment 2 is an embodiment of the apparatus corresponding to embodiment 1, and the detailed description may refer to embodiment one, which is not repeated herein.

In addition, the apparatus disclosed in the present embodiment is not specific to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the embodiments of the present disclosure as described herein, and any descriptions of specific languages are provided above to disclose the best modes of the present disclosure.

An embodiment of the present disclosure further provides an electronic device, referring to fig. 5, including a key 301, a program memory 302, a data memory 303, and a processor 304, wherein the key is configured to be connected to a key circuit and generate a key signal recognizable to the processor.

The program memory is used for storing a key signal jitter elimination program 3021, and the data memory is used as an intermediate data carrier generated during the program operation.

The processor 304 may access the data memory 303 and be configured to implement a key signal debounce method with feedback correction of the foregoing embodiments when executing the key signal debounce program 3021 stored in the program memory 302.

The electronic device disclosed in this embodiment may be a mobile terminal such as a mobile phone, a tablet computer, a notebook computer, a palm computer, a PDA, a PMA, a navigation device, a wearable device, an intelligent bracelet, a pedometer, etc., and a fixed terminal such as a digital TV, a desktop computer, etc., and may also be an FPGA, a single chip microcomputer, etc., which is not particularly limited herein.

Embodiments of the present disclosure also provide a computer-readable storage medium having a key signal jitter elimination program stored thereon, which, when executed by a processor of an electronic device, enables the electronic device to implement a key signal jitter elimination method with feedback correction of the foregoing embodiments.

Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:半导体电路

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!