CN107979358A - Key pulse de-jittering method - Google Patents
Key pulse de-jittering method Download PDFInfo
- Publication number
- CN107979358A CN107979358A CN201711134005.3A CN201711134005A CN107979358A CN 107979358 A CN107979358 A CN 107979358A CN 201711134005 A CN201711134005 A CN 201711134005A CN 107979358 A CN107979358 A CN 107979358A
- Authority
- CN
- China
- Prior art keywords
- pulse
- value
- signal
- key
- output
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 230000002441 reversible effect Effects 0.000 claims abstract description 38
- 238000005070 sampling Methods 0.000 claims description 107
- 210000001367 artery Anatomy 0.000 claims 1
- 210000003462 vein Anatomy 0.000 claims 1
- 230000000694 effects Effects 0.000 abstract description 10
- 238000001914 filtration Methods 0.000 abstract description 7
- 206010044565 Tremor Diseases 0.000 abstract 1
- 230000000052 comparative effect Effects 0.000 abstract 1
- 230000001186 cumulative effect Effects 0.000 description 43
- 230000008859 change Effects 0.000 description 13
- 230000006870 function Effects 0.000 description 13
- 230000008569 process Effects 0.000 description 6
- 230000000630 rising effect Effects 0.000 description 6
- 239000003990 capacitor Substances 0.000 description 3
- 230000003247 decreasing effect Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 239000013256 coordination polymer Substances 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 230000009977 dual effect Effects 0.000 description 1
- 230000003446 memory effect Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03K—PULSE TECHNIQUE
- H03K5/00—Manipulating of pulses not covered by one of the other main groups of this subclass
- H03K5/125—Discriminating pulses
- H03K5/1252—Suppression or limitation of noise or interference
Landscapes
- Physics & Mathematics (AREA)
- Nonlinear Science (AREA)
- Manipulation Of Pulses (AREA)
Abstract
Description
技术领域technical field
本发明涉及脉冲电路信号处理领域,尤其是一种按键脉冲去抖动方法。The invention relates to the field of pulse circuit signal processing, in particular to a key pulse debounce method.
背景技术Background technique
数字信号电路中,经常要求机械按键开关按下操作时输出脉冲。机械按键开关在按下或者松开时,会因为触点的抖动使按键脉冲产生抖动干扰脉冲。采用软件消除开关抖动时需要耗费CPU的工作时间,大大浪费了系统资源。当需要采用电路消除按键开关抖动脉冲的影响时,常用的方法是RS触发器和RC滤波电路。采用RS触发器时,要求按键开关同时具有常闭开关和常开开关,其应用受到限制。采用RC滤波电路,当抖动干扰为连续的窄脉冲干扰时,需要加大滤波时间常数,影响电路的快速响应能力;或者是按键电路存在连续的窄脉冲干扰时,RC滤波电路存在直流记忆效应,前面的窄脉冲会影响后面窄脉冲的过滤。In digital signal circuits, it is often required to output pulses when the mechanical key switch is pressed. When the mechanical key switch is pressed or released, the key pulse will generate a jitter interference pulse due to the jitter of the contact. Using software to eliminate switch jitter needs to consume CPU working time, which greatly wastes system resources. When it is necessary to use a circuit to eliminate the influence of the jitter pulse of the key switch, the commonly used methods are RS flip-flop and RC filter circuit. When the RS trigger is used, the key switch is required to have a normally closed switch and a normally open switch at the same time, and its application is limited. When the RC filter circuit is used, when the jitter interference is continuous narrow pulse interference, the filter time constant needs to be increased to affect the rapid response capability of the circuit; or when there is continuous narrow pulse interference in the button circuit, the RC filter circuit has a DC memory effect. The previous narrow pulse will affect the filtering of the following narrow pulse.
发明内容Contents of the invention
为了解决上述的问题,本发明提供了一种按键脉冲去抖动方法,包括:In order to solve the above problems, the present invention provides a key pulse debounce method, comprising:
在采样时钟脉冲边沿对按键脉冲进行采样得到按键脉冲采样值;可逆限幅计数单元受按键脉冲采样值电平状态的控制处于加计数状态或者是减计数状态;可逆限幅计数单元的输出为限幅累积计数值;根据限幅累积计数值与上限比较阈值和下限比较阈值的比较结果,产生控制输出脉冲电平状态的信号去控制输出脉冲的电平状态;所述限幅累积计数值为二进制计数值;所述限幅累积计数值的下限幅值为0,上限幅值为N;所述N为大于等于2的整数。所述上限比较阈值为大于N/2(N除以2)且小于等于N的整数;所述下限比较阈值为大于等于0且小于N/2的整数。On the edge of the sampling clock pulse, the key pulse is sampled to obtain the key pulse sampling value; the reversible limiter counting unit is in the counting up state or the counting down state under the control of the level state of the key pulse sampling value; the output of the reversible limiter counting unit is limited Amplitude cumulative count value; According to the comparison result of the limit cumulative count value and the upper limit comparison threshold and the lower limit comparison threshold, a signal for controlling the output pulse level state is generated to control the level state of the output pulse; the limit limit cumulative count value is binary A count value; the lower limit value of the limiting cumulative count value is 0, and the upper limit value is N; the N is an integer greater than or equal to 2. The upper limit comparison threshold is an integer greater than or equal to N/2 (N divided by 2) and less than or equal to N; the lower limit comparison threshold is an integer greater than or equal to 0 and less than N/2.
所述控制输出脉冲电平状态的信号为第一置位信号和第二置位信号,由第一置位信号和第二置位信号控制输出脉冲的电平状态;当限幅累积计数值大于等于上限比较阈值时,令第一置位信号有效,否则第一置位信号无效;当限幅累积计数值小于等于下限比较阈值时,令第二置位信号有效,否则第二置位信号无效。The signal for controlling the level state of the output pulse is a first set signal and a second set signal, and the level state of the output pulse is controlled by the first set signal and the second set signal; when the limiting cumulative count value is greater than or equal to When the upper limit comparison threshold is reached, the first set signal is valid, otherwise the first set signal is invalid; when the clipping cumulative count value is less than or equal to the lower limit comparison threshold, the second set signal is valid, otherwise the second set signal is invalid.
由第一置位信号和第二置位信号控制输出脉冲电平状态的方法是,输入的第一置位信号有效且第二置位信号无效时,将输出脉冲置为1;输入的第一置位信号无效且第二置位信号有效时,将输出脉冲置为0;输入的第一置位信号和第二置位信号均无效时,输出脉冲状态不变。由第一置位信号和第二置位信号控制输出脉冲电平状态的方法或者是,输入的第一置位信号有效且第二置位信号无效时,将输出脉冲置为0;输入的第一置位信号无效且第二置位信号有效时,将输出脉冲置为1;输入的第一置位信号和第二置位信号均无效时,输出脉冲状态不变。The method of controlling the output pulse level state by the first set signal and the second set signal is that when the input first set signal is valid and the second set signal is invalid, the output pulse is set to 1; When the set signal is invalid and the second set signal is valid, the output pulse is set to 0; when both the input first set signal and the second set signal are invalid, the state of the output pulse remains unchanged. The method of controlling the output pulse level state by the first set signal and the second set signal or, when the input first set signal is valid and the second set signal is invalid, the output pulse is set to 0; When the first setting signal is invalid and the second setting signal is valid, the output pulse is set to 1; when both the input first setting signal and the second setting signal are invalid, the state of the output pulse remains unchanged.
可逆限幅计数单元处于加计数状态且限幅累积计数值大于等于上限幅值N时,不对采样时钟脉冲进行加计数;可逆限幅计数单元处于减计数状态且限幅累积计数值等于下限幅值0时,不对采样时钟脉冲进行减计数。When the reversible limiting counting unit is in the counting state and the limiting cumulative counting value is greater than or equal to the upper limit value N, the sampling clock pulse is not counted up; the reversible limiting counting unit is in the counting down state and the limiting cumulative counting value is equal to the lower limiting value When 0, do not count down the sampling clock pulse.
可逆限幅计数单元由具有双时钟输入的可逆计数器和限幅及加减控制电路组成。The reversible limiting and counting unit is composed of a reversible counter with double clock input and limiting and adding and subtracting control circuits.
本发明的有益效果是:能够自动滤除按键脉冲中的边沿抖动干扰和随机窄脉冲干扰;滤除脉冲干扰的效果能够通过调节限幅累积计数值上限幅值的大小或者是改变上限比较阈值、下限比较阈值的大小进行调节。The beneficial effect of the present invention is: can automatically filter out the edge jitter interference and the random narrow pulse interference in key pulse; The lower limit is adjusted by comparing the size of the threshold.
附图说明Description of drawings
图1为按键脉冲过滤电路实施例;Fig. 1 is an embodiment of a key pulse filtering circuit;
图2为N=6时采样单元和可逆限幅计数单元实施例;Fig. 2 is an embodiment of sampling unit and reversible limit counting unit when N=6;
图3为N=6时比较阈值设定单元实施例;Fig. 3 compares the threshold value setting unit embodiment when N=6;
图4为N=6时上限值比较器单元的实施例;Fig. 4 is the embodiment of upper limit value comparator unit when N=6;
图5为N=6时下限值比较器单元的实施例;Fig. 5 is the embodiment of lower limit value comparator unit when N=6;
图6为输出控制单元实施例;Fig. 6 is an embodiment of an output control unit;
图7为振荡器单元实施例;Fig. 7 is an oscillator unit embodiment;
图8为N=6时按键脉冲过滤电路抗干扰效果示意图;Figure 8 is a schematic diagram of the anti-interference effect of the key pulse filter circuit when N=6;
图9为按键脉冲电路实施例。FIG. 9 is an embodiment of a key pulse circuit.
具体实施方式Detailed ways
以下结合附图对本发明作进一步说明。所述按键脉冲去抖动方法由按键脉冲过滤电路具体实现。The present invention will be further described below in conjunction with accompanying drawing. The key pulse debounce method is specifically implemented by a key pulse filter circuit.
如图1所示为按键脉冲过滤电路实施例。图1中,按键脉冲电路10输出按键脉冲P1,按键脉冲P1送至由采样单元100、可逆限幅计数单元101、比较阈值设定单元102、上限值比较器单元103、下限值比较器单元104、输出控制单元105、振荡器单元106组成的按键脉冲过滤电路,按键脉冲过滤电路输出去除了抖动脉冲的输出脉冲P2。Figure 1 shows an embodiment of a key pulse filter circuit. In Fig. 1, the key pulse circuit 10 outputs the key pulse P1, and the key pulse P1 is sent to the sampling unit 100, the reversible limit counting unit 101, the comparison threshold setting unit 102, the upper limit comparator unit 103, and the lower limit comparator The key pulse filtering circuit composed of the unit 104 , the output control unit 105 and the oscillator unit 106 , the key pulse filtering circuit outputs the output pulse P2 with the shaking pulse removed.
采样单元100的输入为按键脉冲P1和采样时钟脉冲CP1,输出按键脉冲采样值P1*;可逆限幅计数单元101的输入为按键脉冲采样值P1*和采样时钟脉冲CP1,输出为限幅累积计数值X1,限幅累积计数值X1的上、下限幅值分别为N、0;比较阈值设定单元102的输出为上限比较阈值Y1和下限比较阈值Y2;上限值比较器单元103的输入为限幅累积计数值X1和上限比较阈值Y1,输出为第一置位信号SE1;下限值比较器单元104的输入为限幅累积计数值X1和下限比较阈值Y2,输出为第二置位信号RE1;输出控制单元105的输入为第一置位信号SE1和第二置位信号RE1,输出为按键脉冲过滤电路的输出脉冲P2;振荡器单元106输出采样时钟脉冲CP1。The input of the sampling unit 100 is the key pulse P1 and the sampling clock pulse CP1, and the output key pulse sampling value P1*; the input of the reversible limiter counting unit 101 is the key pulse sampling value P1* and the sampling clock pulse CP1, and the output is the limiting cumulative counting Value X1, the upper and lower limit amplitude values of the limit cumulative count value X1 are N, 0 respectively; The output of the comparison threshold setting unit 102 is the upper limit comparison threshold Y1 and the lower limit comparison threshold Y2; the input of the upper limit comparator unit 103 is The limited cumulative count value X1 and the upper limit comparison threshold Y1 are output as the first set signal SE1; the input of the lower limit comparator unit 104 is the limited limited cumulative count value X1 and the lower limit comparison threshold Y2, and the output is the second set signal RE1; the input of the output control unit 105 is the first set signal SE1 and the second set signal RE1, and the output is the output pulse P2 of the key pulse filter circuit; the oscillator unit 106 outputs the sampling clock pulse CP1.
下面的按键脉冲过滤电路实施例中,N=6。In the following key pulse filtering circuit embodiment, N=6.
图2为N=6时采样单元和可逆限幅计数单元的实施例。采样单元由D触发器FF1组成。图2中,D触发器FF1的CP触发信号为上升沿有效,采样时刻为采样时钟脉冲的上升沿;在采样时钟脉冲CP1的上升沿,D触发器FF1对按键脉冲P1进行采样,在其同相输出端Q得到按键脉冲采样值P1*并将该次按键脉冲采样值P1*保持到下一次采样时钟脉冲CP1的上升沿,采样得到新的按键脉冲采样值P1*;按键脉冲采样值P1*也可以从D触发器的反相输出端输出。按键脉冲采样值P1*有高电平和低电平2种状态,即P1*有1和0这2种状态,P1*的两种状态控制可逆限幅计数单元处于加计数状态或者是减计数状态,分别对采样时钟脉冲CP1进行加计数或者减计数。图2中,P1*的高电平、低电平状态分别控制可逆限幅计数单元处于加计数状态、减计数状态。也可以令P1*的高电平、低电平分别控制可逆限幅计数单元处于减计数状态、加计数状态。采样单元也可以在采样时钟脉冲的下降沿对按键脉冲P1进行采样。Fig. 2 is an embodiment of the sampling unit and the reversible clipping and counting unit when N=6. The sampling unit is composed of D flip-flop FF1. In Figure 2, the CP trigger signal of D flip-flop FF1 is valid on the rising edge, and the sampling time is the rising edge of the sampling clock pulse; on the rising edge of the sampling clock pulse CP1, D flip-flop FF1 samples the key pulse P1, and in its in-phase The output terminal Q obtains the key pulse sampling value P1* and holds the key pulse sampling value P1* until the rising edge of the next sampling clock pulse CP1, and obtains a new key pulse sampling value P1* by sampling; the key pulse sampling value P1* also Can be output from the inverting output of the D flip-flop. The key pulse sampling value P1* has two states of high level and low level, that is, P1* has two states of 1 and 0, and the two states of P1* control the reversible limiter counting unit to be in the counting state or counting down state , to count up or down the sampling clock pulse CP1 respectively. In Fig. 2, the high level and low level states of P1* respectively control the reversible limiter counting unit to be in the counting up state and the counting down state. It is also possible to make the high level and low level of P1* respectively control the reversible limiter counting unit to be in the down counting state and the up counting state. The sampling unit can also sample the key pulse P1 at the falling edge of the sampling clock pulse.
图2中,FC1为4位二进制可逆计数器74HC193,为具有双时钟输入的可逆计数器;FC1的清零输入端MR输入0、置位控制输入端PL输入1,FC1工作在可逆计数状态。与非门FA1、FA2、FA3、FA4组成限幅及加减控制电路,FC1和限幅及加减控制电路共同组成可逆限幅计数单元。图2中,P1*的2种状态分别通过与非门FA3、FA4控制FC1进行加计数或者减计数。当P1*=1时,通过FA4使FC1的减计数脉冲输入端CPD等于1,CP1通过FA3连接至FC1的加计数脉冲输入端CPU。FC1有4位二进制输出Q3、Q2、Q1、Q0,使用其中的低3位Q2、Q1、Q0即可构成上限幅值为6的计数器,Q2、Q1、Q0分别为组成限幅累积计数值X1的x13、x12、x11。计数输出x13、x12、x11在CP1的下降沿加1,即P1*=1时,可逆限幅计数单元进行加计数。当P1*=0时,通过FA3使FC1的加计数脉冲输入端CPU等于1,CP1通过FA4连接至FC1的减计数脉冲输入端CPD,FC1的计数输出x13、x12、x11在CP1的下降沿减1,即P1*=0时,可逆限幅计数单元进行减计数。In Figure 2, FC1 is a 4-bit binary reversible counter 74HC193, which is a reversible counter with dual clock inputs; FC1's clear input terminal MR inputs 0, and the set control input terminal PL input 1, FC1 works in the reversible counting state. The NAND gates FA1, FA2, FA3 and FA4 form a limiting and addition and subtraction control circuit, and FC1 and the limiting and addition and subtraction control circuit together form a reversible limiting and counting unit. In Fig. 2, the two states of P1* control FC1 to count up or count down through NAND gates FA3 and FA4 respectively. When P1*=1, the down-counting pulse input terminal CPD of FC1 is equal to 1 through FA4, and CP1 is connected to the up-counting pulse input terminal CPU of FC1 through FA3. FC1 has 4-bit binary outputs Q3, Q2, Q1, and Q0. The lower 3 bits of Q2, Q1, and Q0 can be used to form a counter with an upper limit value of 6, and Q2, Q1, and Q0 are respectively composed of the limiting cumulative count value X1. x13, x12, x11. The counting outputs x13, x12, and x11 add 1 at the falling edge of CP1, that is, when P1*=1, the reversible limiter counting unit performs counting up. When P1*=0, the up-counting pulse input terminal CPU of FC1 is equal to 1 through FA3, CP1 is connected to the down-counting pulse input terminal CPD of FC1 through FA4, and the counting outputs x13, x12 and x11 of FC1 decrease at the falling edge of CP1. 1, that is, when P1*=0, the reversible limiter counting unit performs down counting.
图2中,与非门FA1实现加计数限幅控制;当x13、x12同时为1时,与非门FA1输出低电平,与非门FA3被封锁,CP1无法通过,FC1的加计数脉冲输入端CPU无计数脉冲输入,在P1*=1时,FC1在采样时钟脉冲CP1的下降沿维持输出状态不变,可逆限幅计数单元处于上限值限幅状态,不进行加计数;x13、x12同时为1包括2种情况,x13、x12、x11为1、1、0时,可逆限幅计数单元的输出等于上限幅值6;x13、x12、x11为1、1、1时,可逆限幅计数单元的输出等于7,处于超限状态,该情况只有在系统启动时的初始状态有可能出现,可逆限幅计数单元经减计数进入正常限幅计数区间后,输出的超限状态不会再出现。与非门FA2实现减计数限幅控制;当FC1的计数输出x13、x12、x11同时为0时,与非门FA2输出低电平,与非门FA4被封锁,CP1无法通过,FC1的减计数输入端CPD无计数脉冲输入;在P1*=0时,FC1在采样时钟脉冲CP1的下降沿维持输出状态不变,可逆限幅计数单元处于下限值限幅状态,不进行减计数。In Figure 2, the NAND gate FA1 realizes the up-counting limit control; when x13 and x12 are 1 at the same time, the NAND gate FA1 outputs low level, the NAND gate FA3 is blocked, CP1 cannot pass through, and the up-counting pulse input of FC1 End CPU has no counting pulse input, when P1*=1, FC1 maintains the output state unchanged at the falling edge of sampling clock pulse CP1, and the reversible limiting counting unit is in the upper limit limit state, and does not count up; x13, x12 Simultaneously 1 includes two cases, when x13, x12, x11 are 1, 1, 0, the output of the reversible limiter counting unit is equal to the upper limit value 6; when x13, x12, x11 are 1, 1, 1, the reversible limiter The output of the counting unit is equal to 7, and it is in an over-limit state. This situation may only occur in the initial state when the system is started. Appear. NAND gate FA2 realizes down-counting limit control; when the counting outputs x13, x12, and x11 of FC1 are 0 at the same time, NAND gate FA2 outputs low level, NAND gate FA4 is blocked, CP1 cannot pass, and FC1's down-counting The input terminal CPD has no counting pulse input; when P1*=0, FC1 maintains the output state unchanged at the falling edge of the sampling clock pulse CP1, and the reversible limiter counting unit is in the lower limit limiter state, and does not count down.
N为其他数值时,可以增减图2中进行计数限幅控制的与非门数量,以及增减各与非门的输入信号数量来实现。可逆限幅计数单元的功能也可以采用其他器件或者是电路来实现,例如,采用74HC192替换74HC193,或者是采用触发器和门电路组成同步可逆计数器。When N is other values, it can be realized by increasing or decreasing the number of NAND gates for counting and limiting control in FIG. 2 , and increasing or decreasing the number of input signals of each NAND gate. The function of the reversible limiting counting unit can also be realized by other devices or circuits, for example, 74HC193 is replaced by 74HC192, or a synchronous reversible counter is formed by using flip-flops and gate circuits.
图3为N=6时比较阈值设定单元的实施例。图3中,+VCC为供电电源,GND为公共地,电阻R91、R92、R93和开关K91、K92、K93组成上限比较阈值Y1设定电路;当K91、K92、K93分别处于断开、闭合、断开状态时,比较阈值设定单元输出的上限比较阈值Y1为5,其3位二进制输出y13、y12、y11为1、0、1。电阻R94、R95、R96和开关K94、K95、K96组成下限比较阈值Y2设定电路;当K94、K95、K96分别处于闭合、闭合、断开状态时,比较阈值设定单元输出的下限比较阈值Y2为1,其3位二进制输出y23、y22、y21为0、0、1。比较阈值设定单元还可以由二进制拨码开关,或者是BCD拨码开关,或者是控制0、1输出的多个上拉电阻及电路短接点,以及其他能够输出多位二进制设定值的电路组成。FIG. 3 is an embodiment of the comparison threshold setting unit when N=6. In Fig. 3, +VCC is the power supply, GND is the common ground, resistors R91, R92, R93 and switches K91, K92, K93 form the upper limit comparison threshold Y1 setting circuit; In the off state, the upper limit comparison threshold Y1 output by the comparison threshold setting unit is 5, and its 3-bit binary outputs y13, y12, y11 are 1, 0, 1. Resistors R94, R95, R96 and switches K94, K95, K96 form a lower limit comparison threshold Y2 setting circuit; when K94, K95, K96 are in the closed, closed, and disconnected states respectively, the lower limit comparison threshold Y2 output by the comparison threshold setting unit is 1, its 3-bit binary output y23, y22, y21 is 0, 0, 1. The comparison threshold setting unit can also be composed of a binary dial switch, or a BCD dial switch, or a plurality of pull-up resistors and circuit short contacts for controlling 0, 1 output, and other circuits capable of outputting multi-bit binary set values composition.
上限值比较器单元的功能是,当输入的限幅累积计数值大于等于上限比较阈值时,令第一置位信号有效,否则第一置位信号无效。图4为N=6时上限值比较器单元的实施例,由四位二进制数值比较器FC2和或门FO1组成上限值比较器单元,FC2的型号为74HC85。限幅累积计数值X1的3位二进制输出x13、x12、x11分别连接至FC2的A2、A1、A0输入端,上限比较阈值Y1的3位二进制输出y13、y12、y11分别连接至FC2的B2、B1、B0输入端,输入端A3、B3均输入0。FC2的输入端A>B IN和A<B IN均输入0,输入端A=B IN输入1。FC2的输出端A>BOUT、A=B OUT分别连接至或门FO1的输入端,或门FO1的输出端为第一置位信号SE1。图4中上限值比较器单元实现的功能是,当限幅累积计数值X1大于等于上限比较阈值Y1时,输出SE1为高电平,否则SE1为低电平。图4中SE1为高电平有效;将或门FO1改为或非门,则SE1为低电平有效。The function of the upper limit comparator unit is to enable the first set signal to be valid when the input limiting cumulative count value is greater than or equal to the upper limit comparison threshold, otherwise the first set signal is invalid. Fig. 4 is the embodiment of the upper limit comparator unit when N=6, the upper limit comparator unit is composed of four-bit binary value comparator FC2 and OR gate FO1, the model of FC2 is 74HC85. The 3-bit binary outputs x13, x12, and x11 of the limited cumulative count value X1 are respectively connected to the A2, A1, and A0 input terminals of FC2, and the 3-bit binary outputs y13, y12, and y11 of the upper limit comparison threshold Y1 are respectively connected to B2, y11 of FC2. B1, B0 input terminals, input terminals A3, B3 all input 0. The input terminals A>B IN and A<B IN of FC2 both input 0, and the input terminal A=B IN inputs 1. The output terminals A>BOUT and A=B OUT of FC2 are respectively connected to the input terminals of the OR gate FO1, and the output terminal of the OR gate FO1 is the first set signal SE1. The function realized by the upper limit comparator unit in Fig. 4 is that when the limited cumulative count value X1 is greater than or equal to the upper limit comparison threshold Y1, the output SE1 is high level, otherwise SE1 is low level. In Figure 4, SE1 is active at high level; if the OR gate FO1 is changed to a NOR gate, SE1 is active at low level.
下限值比较器单元的功能是,当输入的限幅累积计数值小于等于下限比较阈值时,令第二置位信号有效,否则第二置位信号无效。图5为N=6时下限值比较器单元的实施例,由四位二进制数值比较器FC3和或门FO2组成下限值比较器单元,FC3的型号为74HC85。限幅累积计数值X1的3位二进制输出x13、x12、x11分别连接至FC3的A2、A1、A0输入端,下限比较阈值Y2的3位二进制输出y23、y22、y21分别连接至FC2的B2、B1、B0输入端,输入端A3、B3均接0。FC3的输入端A>B IN和A<B IN均接0,输入端A=B IN接1。FC3的输出端A<B OUT、A=BOUT分别连接至或门FO2的输入端,或门FO2的输出端为第二置位信号RE1。图5中下限值比较器单元实现的功能是,当限幅累积计数值X1小于等于下限比较阈值Y2时,输出RE1为高电平,否则SE1为低电平。图5中RE1为高电平有效;将或门FO2改为或非门,则RE1为低电平有效。The function of the lower limit comparator unit is to enable the second setting signal to be valid when the input limiting accumulated count value is less than or equal to the lower limit comparison threshold, otherwise the second setting signal is invalid. Figure 5 is an embodiment of the lower limit comparator unit when N=6, the lower limit comparator unit is composed of a four-bit binary value comparator FC3 and an OR gate FO2, and the model of FC3 is 74HC85. The 3-bit binary outputs x13, x12, and x11 of the limited cumulative count value X1 are respectively connected to the A2, A1, and A0 input terminals of FC3, and the 3-bit binary outputs y23, y22, and y21 of the lower limit comparison threshold Y2 are respectively connected to B2, y21 of FC2. B1, B0 input terminals, input terminals A3, B3 are all connected to 0. The input terminals A>B IN and A<B IN of FC3 are both connected to 0, and the input terminal A=B IN is connected to 1. The output terminals A<B OUT and A=BOUT of FC3 are respectively connected to the input terminals of the OR gate FO2, and the output terminal of the OR gate FO2 is the second set signal RE1. The function realized by the lower limit comparator unit in Fig. 5 is that when the limited cumulative count value X1 is less than or equal to the lower limit comparison threshold Y2, the output RE1 is high level, otherwise SE1 is low level. In Figure 5, RE1 is active at high level; if the OR gate FO2 is changed to NOR gate, RE1 is active at low level.
当N值较大时,可以选择2片或者多片74HC85组成多位二进制数值比较器实现上限值比较器单元或者下限值比较器单元的功能;也可以采用1片或者多片四位二进制数值比较器CD4063实现上限值比较器单元或者下限值比较器单元的功能,或者是采用其他组合逻辑电路来实现上限值比较器单元或者下限值比较器单元的功能。When the value of N is large, you can choose two or more pieces of 74HC85 to form a multi-bit binary value comparator to realize the function of the upper limit comparator unit or the lower limit value comparator unit; you can also use one or more pieces of four-bit binary The numerical comparator CD4063 implements the function of the upper limit comparator unit or the lower limit comparator unit, or uses other combinational logic circuits to realize the function of the upper limit comparator unit or the lower limit comparator unit.
图6为输出控制单元实施例。图6中,由或非门FO3、FO4组成RS触发器实现输出控制单元功能,第一置位信号SE1和第二置位信号RE1均高电平有效;第一置位信号SE1为RS触发器的置位信号,第二置位信号RE1为RS触发器的复位信号;输出脉冲P2从RS触发器的同相输出端输出。当SE1有效、RE1无效时,将从同相输出端FO4输出的输出脉冲P2置为1;SE1无效、RE1有效时,将输出脉冲P2置为0;当SE1和RE1均无效时,输出脉冲P2的状态不变。输出脉冲P2也可以从反相输出端,即从或非门FO3输出端输出。输出控制单元也可以采用其他形式的RS触发器。Fig. 6 is an embodiment of an output control unit. In Figure 6, the RS flip-flop is composed of NOR gates FO3 and FO4 to realize the function of the output control unit, the first set signal SE1 and the second set signal RE1 are both active at high level; the first set signal SE1 is an RS flip-flop The set signal, the second set signal RE1 is the reset signal of the RS flip-flop; the output pulse P2 is output from the non-inverting output terminal of the RS flip-flop. When SE1 is valid and RE1 is invalid, the output pulse P2 output from the non-inverting output terminal FO4 is set to 1; when SE1 is invalid and RE1 is valid, the output pulse P2 is set to 0; when both SE1 and RE1 are invalid, the output pulse P2 is The state is unchanged. The output pulse P2 can also be output from the inverting output terminal, that is, the output terminal of the NOR gate FO3. The output control unit can also adopt other forms of RS flip-flops.
图7为振荡器单元实施例。图7中,CMOS非门FN1和FN2、电阻R97、电容C97组成多谐振荡器,采样时钟脉冲CP1从FN2输出端输出。CP1的频率通过调整电阻R97、电容C97的值来改变。振荡器单元还可以采用其他类型的多谐振荡器。Fig. 7 is an embodiment of an oscillator unit. In Fig. 7, CMOS NOT gates FN1 and FN2, resistor R97 and capacitor C97 form a multivibrator, and the sampling clock pulse CP1 is output from the output terminal of FN2. The frequency of CP1 is changed by adjusting the value of resistor R97 and capacitor C97. The oscillator unit can also use other types of multivibrator.
上述N=6的按键脉冲过滤电路实施例中,上限比较阈值Y1取值为5,下限比较阈值Y2取值为1。当限幅累积计数值X1大于等于5时,输出SE1为高电平,将输出脉冲P2置为1;当限幅累积计数值X1小于等于1时,输出RE1为高电平,将输出脉冲P2置为0。In the above N=6 key pulse filtering circuit embodiment, the upper limit comparison threshold Y1 takes a value of 5, and the lower limit comparison threshold Y2 takes a value of 1. When the limiting cumulative count value X1 is greater than or equal to 5, the output SE1 is high level, and the output pulse P2 is set to 1; when the limiting cumulative count value X1 is less than or equal to 1, the output RE1 is high level, and the output pulse P2 is set to 0.
图8为N=6时按键脉冲过滤电路抗干扰效果示意图。图8中给出了与15个采样时钟脉冲CP1对应的按键脉冲P1,对按键脉冲P1的采样值P1*,由P1*控制得到的FC1加计数脉冲CPU和减计数脉冲CPD,FC1计数得到的限幅累积计数值X1,以及相应的输出脉冲P2。限幅累积计数值X1及输出脉冲P2的改变滞后于采样值P1*的改变,在P1*的每个采样点后,准确地说,是在每个CP1上升沿采样得到P1*,在采样得到P1*之后的CP1下降沿,限幅累积计数值X1及相应的输出脉冲P2才改变,比采样得到P1*的时间滞后一个CP1的高电平宽度时间。后面的分析中,对该滞后时间不再特别提及与说明。FIG. 8 is a schematic diagram of the anti-interference effect of the key pulse filter circuit when N=6. Figure 8 shows the key pulse P1 corresponding to 15 sampling clock pulses CP1, the sampling value P1* of the key pulse P1, the FC1 counting pulse CPU and the counting down pulse CPD obtained by the control of P1*, and the FC1 counting obtained Limiting cumulative count value X1, and the corresponding output pulse P2. The change of the limiting cumulative count value X1 and the output pulse P2 lags behind the change of the sampling value P1*. After each sampling point of P1*, to be precise, P1* is obtained by sampling at each rising edge of CP1. After sampling, P1* is obtained. On the falling edge of CP1 after P1*, the limiting cumulative count value X1 and the corresponding output pulse P2 will change, which is one CP1 high-level width time later than the time when P1* is obtained by sampling. In the following analysis, the lag time will not be specifically mentioned or explained.
加计数脉冲CPU在P1*等于1且X1小于上限限幅值6时,为CP1的反相状态,否则为高电平;减计数脉冲CPD在P1*等于0且X1大于下限限幅值0时,为CP1的反相状态,否则为高电平。由于P1*是受CP1上升沿控制触发产生,在P1*由高电平变为低电平时,加计数脉冲CPU有可能产生尖锋输出;在P1*由低电平变为高电平时,减计数脉冲CPD有可能产生尖锋输出;输出CPU、CPD信号的器件的输出电容和电路板上分布电容通常会滤除该尖锋输出,也可以人为地在CPU、CPD信号处并联小电容滤除该尖锋输出。将采样单元的D触发器FF1改成下降沿触发,在每个CP1下降沿采样得到P1*,FC1在CP1下降沿,受上一次CP1下降沿采样得到的P1*控制计数得到的限幅累积计数值X1,以及相应的输出脉冲P2,即限幅累积计数值X1及相应的输出脉冲P2改变,比采样得到P1*的时间滞后一个CP1的周期时间,滞后时间延长,但此时能够避免在加计数脉冲CPU、减计数脉冲CPD上产生尖锋输出。不直接用P1信号,而是用采样单元输出的采样值P1*去控制图2中的FA3、FA4,是为了避免CP1高电平期间因P1的变化产生错误的CPU或者CPD信号,造成限幅累积计数值X1的错误计数。When the counting pulse CPU is equal to 1 and X1 is less than the upper limit value 6, it is the inversion state of CP1, otherwise it is high level; the counting pulse CPD is equal to 0 when P1* is equal to 0 and X1 is greater than the lower limit value 0. , is the inversion state of CP1, otherwise it is high level. Since P1* is triggered by the rising edge of CP1, when P1* changes from high level to low level, the counting pulse CPU may generate a sharp output; when P1* changes from low level to high level, the decrement The counting pulse CPD may produce a sharp output; the output capacitance of the device that outputs the CPU and CPD signals and the distributed capacitance on the circuit board usually filter out the sharp output, or artificially connect a small capacitor in parallel at the CPU and CPD signals to filter out The spike output. Change the D flip-flop FF1 of the sampling unit to a falling edge trigger, and obtain P1* by sampling on each CP1 falling edge, and FC1 is on the CP1 falling edge, and is controlled by the P1* control count obtained by the last CP1 falling edge sampling. Value X1, and the corresponding output pulse P2, that is, the limited cumulative count value X1 and the corresponding output pulse P2 change, lagging behind the time of sampling P1* by a cycle time of CP1, the lag time is extended, but at this time can avoid The counting pulse CPU and the down counting pulse CPD generate sharp output. Instead of directly using the P1 signal, use the sampling value P1* output by the sampling unit to control FA3 and FA4 in Figure 2, in order to avoid the wrong CPU or CPD signal due to the change of P1 during the high level period of CP1, resulting in clipping Error count of cumulative count value X1.
设在图8中CP1的采样点1之前CP1对按键脉冲P1的6个采样值P1*均为0,输出脉冲P2为0。图8中,按键脉冲P1在CP1的采样点2前至采样点3后出现了正脉冲干扰,导致X1在采样点2、采样点3采样得到P1*的干扰值1;按键脉冲P1在CP1的采样点4至采样点5之间出现了正窄脉冲随机干扰,但该正窄脉冲宽度小于采样周期且处于2个采样点之间,未影响采样结果P1*,即采样过程自动滤除了该正窄脉冲干扰。按键脉冲P1在CP1的采样点6之后开始从0变1,从0变1过程中出现了2次边沿抖动,其中的第2个正窄脉冲抖动干扰被采样过程自动滤除,采样点7、采样点8的值分别为1、0。图8中,在时钟脉冲CP1的采样点1至采样点15得到的按键脉冲采样值P1*、输出脉冲P2和限幅累积计数值X1见表1。Assuming that the six sampling values P1* of the key pulse P1 by CP1 before the sampling point 1 of CP1 in FIG. 8 are all 0, the output pulse P2 is 0. In Figure 8, the key pulse P1 has a positive pulse interference before the sampling point 2 of CP1 and after the sampling point 3, resulting in X1 sampling at sampling points 2 and 3 to obtain the interference value 1 of P1*; the key pulse P1 is at the CP1 There is positive narrow pulse random interference between sampling point 4 and sampling point 5, but the positive narrow pulse width is smaller than the sampling period and is between two sampling points, which does not affect the sampling result P1*, that is, the sampling process automatically filters out the positive narrow pulse. Narrow pulse interference. The key pulse P1 starts to change from 0 to 1 after sampling point 6 of CP1, and there are 2 edge jitters in the process of changing from 0 to 1, and the second positive narrow pulse jitter interference is automatically filtered out by the sampling process. Sampling points 7, The values of sampling point 8 are 1 and 0 respectively. In FIG. 8 , see Table 1 for the key pulse sampling value P1*, output pulse P2 and clipping cumulative count value X1 obtained at sampling point 1 to sampling point 15 of the clock pulse CP1.
表1采样点1-15的按键脉冲采样值P1*、限幅累积计数值X1和输出脉冲P2Table 1 Key pulse sampling value P1*, limiting cumulative count value X1 and output pulse P2 of sampling points 1-15
观察表1中采样点的情况,在采样点1-2,X1小于等于Y2,RE1有效,SE1无效,P2置为0;在采样点3,X1大于Y2且小于Y1,SE1、RE1均无效,P2维持为0;在采样点4-9,X1小于等于Y2,RE1有效,SE1无效,P2置为0;在采样点10-12,X1大于Y2且小于Y1,SE1、RE1均无效,P2维持为0;在采样点13-15,X1大于等于Y1,SE1有效,RE1无效,P2置为1。N=6时,可逆限幅计数单元的计数区间为0-N;在表1中的采样点5,X1已经达到了下限幅值0,CPD维持为高电平,在采样点6,P1*=0,X1也不再进行减计数,X1维持为下限幅值0;在采样点14,X1已经达到了上限幅值6,CPU维持为高电平,在采样点15,P1*=1,X1也不再进行加计数,X1维持为上限幅值6。Observe the sampling points in Table 1. At sampling points 1-2, X1 is less than or equal to Y2, RE1 is valid, SE1 is invalid, and P2 is set to 0; at sampling point 3, X1 is greater than Y2 and smaller than Y1, SE1 and RE1 are invalid. P2 remains at 0; at sampling points 4-9, X1 is less than or equal to Y2, RE1 is valid, SE1 is invalid, and P2 is set to 0; at sampling points 10-12, X1 is greater than Y2 and less than Y1, SE1 and RE1 are invalid, and P2 remains is 0; at sampling point 13-15, X1 is greater than or equal to Y1, SE1 is valid, RE1 is invalid, and P2 is set to 1. When N=6, the counting interval of the reversible limiter counting unit is 0-N; at sampling point 5 in Table 1, X1 has reached the lower limit amplitude value 0, CPD remains high, and at sampling point 6, P1* = 0, X1 does not count down anymore, and X1 maintains the lower limit amplitude value of 0; at sampling point 14, X1 has reached the upper limit amplitude value of 6, and the CPU maintains a high level; at sampling point 15, P1*=1, X1 is no longer counting up, and X1 remains at the upper limit value of 6.
图8给出的是按键脉冲过滤电路在按键脉冲P1为0时的抗正脉冲干扰效果,以及按键脉冲P1由0变为1的条件与过程。按键脉冲过滤电路在按键脉冲P1为1时的抗负脉冲干扰效果,以及按键脉冲P1由1变为0的条件与过程,与按键脉冲P1为0时的抗正脉冲干扰效果,以及按键脉冲P1由0变为1的条件与过程相同。Figure 8 shows the anti-positive pulse interference effect of the key pulse filter circuit when the key pulse P1 is 0, and the conditions and process of the key pulse P1 changing from 0 to 1. The anti-negative pulse interference effect of the key pulse filter circuit when the key pulse P1 is 1, and the conditions and process of the key pulse P1 changing from 1 to 0, and the anti-positive pulse interference effect when the key pulse P1 is 0, and the key pulse P1 The conditions for changing from 0 to 1 are the same as the process.
设在时钟脉冲CP1的采样点31之前CP1对按键脉冲P1的6个采样值P1*均为1,输出脉冲P2为1。采样点31至采样点45得到的按键脉冲采样值P1*、限幅累积计数值X1和输出脉冲P2见表2。It is assumed that the six sampling values P1 * of the key pulse P1 by CP1 before the sampling point 31 of the clock pulse CP1 are all 1, and the output pulse P2 is 1. See Table 2 for the key pulse sampling value P1*, limiter cumulative count value X1 and output pulse P2 obtained from sampling point 31 to sampling point 45.
表2采样点31-45的按键脉冲采样值P1*、限幅累积计数值X1和输出脉冲P2Table 2 Key pulse sampling value P1*, limiting cumulative count value X1 and output pulse P2 of sampling points 31-45
观察表2中采样点的情况,在采样点31-32,X1大于等于Y1,SE1有效,RE1无效,P2置为1;在采样点33,X1大于Y2且小于Y1,SE1、RE1均无效,P2维持为1;在采样点34,X1大于等于Y1,SE1有效,RE1无效,P2置为1;在采样点35-39,X1大于Y2且小于Y1,SE1、RE1均无效,P2维持为1;由于在采样点31-40之间,采样值P1*处于0多1少状态,可逆限幅计数单元累积计数的结果是限幅累积计数值X1趋向于减小,到采样点40,X1小于等于Y2,RE1有效,SE1无效,P2置为0;在采样点41,X1大于Y2且小于Y1,SE1、RE1均无效,P2维持为0;在采样点42-45,X1小于等于Y2,RE1有效,SE1无效,P2置为0。在表2中的采样点43,X1已经达到了下限幅值0,在采样点44-45,P1*=0,X1也不再进行减计数,X1维持为下限幅值0。Observe the sampling points in Table 2. At sampling points 31-32, X1 is greater than or equal to Y1, SE1 is valid, RE1 is invalid, and P2 is set to 1; at sampling point 33, X1 is greater than Y2 and less than Y1, SE1 and RE1 are invalid. P2 remains at 1; at sampling point 34, X1 is greater than or equal to Y1, SE1 is valid, RE1 is invalid, and P2 is set to 1; at sampling point 35-39, X1 is greater than Y2 and less than Y1, SE1 and RE1 are invalid, and P2 remains at 1 ;Because between the sampling points 31-40, the sampling value P1* is in the state of more than 0 and less than 1, the result of the cumulative counting of the reversible limiter counting unit is that the limiter cumulative count value X1 tends to decrease, and at the sampling point 40, X1 is less than Equal to Y2, RE1 is valid, SE1 is invalid, and P2 is set to 0; at sampling point 41, X1 is greater than Y2 and smaller than Y1, SE1 and RE1 are invalid, and P2 remains 0; at sampling point 42-45, X1 is less than or equal to Y2, RE1 Valid, SE1 is invalid, P2 is set to 0. At sampling point 43 in Table 2, X1 has reached the lower limit amplitude value of 0, and at sampling points 44-45, P1*=0, X1 does not count down any more, and X1 remains at the lower limit amplitude value of 0.
在本N=6的按键脉冲过滤电路实施例中,输出脉冲P2与按键脉冲P1之间为同相关系。如果将可逆限幅计数单元的功能改为:P1=1时,按键脉冲采样值P1*控制可逆限幅计数单元进行减计数;P1=0时,按键脉冲采样值P1*控制可逆限幅计数单元进行加计数,则输出脉冲P2与按键脉冲P1之间为反相关系。或者是在图6中将输出脉冲P2改为从或非门FO3输出,则功能改变为,当SE1有效、RE1无效时,将输出脉冲P2置为0;当SE1无效、RE1有效时,将输出脉冲P2置为1;当SE1和RE1均无效时,输出脉冲P2的状态不变;此时输出脉冲P2与按键脉冲P1之间为反相关系。如果同时进行上述修改,则输出脉冲P2与按键脉冲P1之间为同相关系。In this embodiment of the key pulse filter circuit where N=6, the output pulse P2 and the key pulse P1 are in-phase. If the function of the reversible limit counting unit is changed to: when P1=1, the key pulse sampling value P1* controls the reversible limit counting unit to count down; when P1=0, the key pulse sampling value P1* controls the reversible limit counting unit When counting up, the relationship between the output pulse P2 and the key pulse P1 is inverse. Or change the output pulse P2 to output from the NOR gate FO3 in Figure 6, then the function is changed to, when SE1 is valid and RE1 is invalid, the output pulse P2 is set to 0; when SE1 is invalid and RE1 is valid, the output The pulse P2 is set to 1; when both SE1 and RE1 are invalid, the state of the output pulse P2 remains unchanged; at this time, the relationship between the output pulse P2 and the key pulse P1 is inverse. If the above modification is carried out at the same time, the output pulse P2 and the key pulse P1 are in-phase.
以输出脉冲P2与按键脉冲P1之间为同相关系为例,从表1、表2及电路的工作原理可以得出结论,由于可逆限幅计数单元具有累积效应,当按键脉冲P1的采样值P1*在一段时间之内1的数量多于0的数量时,限幅累积计数值X1会趋向增大,使X1大于等于Y1并将输出脉冲P2置为1;当按键脉冲P1的采样值P1*在一段时间之内0的数量多于1的数量时,限幅累积计数值X1会趋向减小,使X1小于等于Y2并将输出脉冲P2置为0;该特性使本发明电路的限幅计数单元具有自启动能力,限幅作用及按键脉冲采样值P1*中的0,会使限幅计数单元进入正常的限幅计数区间进行限幅加减计数。当初始的限幅累积计数值X1大于N,处于超限状态时,X1大于等于上限比较阈值Y1,上限值比较器单元输出的SE1有效,下限值比较器单元输出RE1的无效,P2被置为1。Taking the in-phase relationship between the output pulse P2 and the key pulse P1 as an example, it can be concluded from Table 1, Table 2 and the working principle of the circuit that due to the cumulative effect of the reversible limiter counting unit, when the sampling value of the key pulse P1 P1* When the number of 1s is greater than the number of 0s within a period of time, the limiting cumulative count value X1 will tend to increase, making X1 greater than or equal to Y1 and setting the output pulse P2 to 1; when the sampling value of the key pulse P1 is P1 * When the quantity of 0 is more than the quantity of 1 within a period of time, the limiting cumulative count value X1 will tend to decrease, so that X1 is less than or equal to Y2 and the output pulse P2 is set to 0; this characteristic makes the limiter of the circuit of the present invention The counting unit has self-starting capability, and the limit function and 0 in the key pulse sampling value P1* will cause the limit count unit to enter the normal limit count interval for limit addition and subtraction counting. When the initial limiting cumulative count value X1 is greater than N and is in an over-limit state, X1 is greater than or equal to the upper limit comparison threshold Y1, SE1 output by the upper limit comparator unit is valid, RE1 output by the lower limit comparator unit is invalid, and P2 is set to 1.
由于上限比较阈值Y1为大于N/2且小于等于N的整数,下限比较阈值Y2为大于等于0且小于N/2的整数,第一置位信号SE1和第二置位信号RE1不可能同时有效,因此,输出控制单元的输出不会出现逻辑状态不确定的情况。Since the upper limit comparison threshold Y1 is an integer greater than N/2 and less than or equal to N, and the lower limit comparison threshold Y2 is an integer greater than or equal to 0 and less than N/2, the first set signal SE1 and the second set signal RE1 cannot be valid at the same time , therefore, the output of the output control unit will not have an uncertain logic state.
以输出脉冲P2与按键脉冲P1之间为同相关系为例做进一步的说明。当按键脉冲P1使限幅累积计数值X1小于等于下限比较阈值Y2,输出脉冲P2置为0后,只要限幅累积计数值X1一直小于上限比较阈值Y1,则输出脉冲P2不会变为1;当按键脉冲P1使限幅累积计数值X1大于等于上限比较阈值Y1,输出脉冲P2置为1后,只要限幅累积计数值X1一直大于下限比较阈值Y2,则输出脉冲P2不会变为0。当P1、P2都为低电平时,只要在P1中出现的正脉冲使P1采样值中连续出现大于等于Y1个为1的值,或者是,在连续Y1+2个P1采样值中出现Y1+1个为1的值,等等,则能够从P2输出与该P1中正脉冲相对应的正脉冲;当P1、P2都为高电平时,只要在P1中出现的负脉冲使P1采样值中连续出现大于等于N-Y2个为0的值,或者是,在连续N-Y2+2个P1采样值中出现N-Y2+1个为0的值,等等,则能够从P2输出与该P1中负脉冲相对应的负脉冲。当按键脉冲P1由0变为1后,输出脉冲P2需要限幅累积计数值X1经过几个采样脉冲周期的加计数延迟,才能使限幅累积计数值X1大于等于上限比较阈值Y1,将P2置1;当按键脉冲P1由1变为0后,输出脉冲P2需要限幅累积计数值X1经过几个采样脉冲周期的减计数延迟,才能使限幅累积计数值X1小于等于下限比较阈值Y2,将P2置0。当上限比较阈值Y1的取值越大时,输出脉冲P2从0变1的条件更加苛刻,电路的低电平抗正脉冲干扰效果更好;当下限比较阈值Y2的取值越小时,输出脉冲P2从1变0的条件更加苛刻,电路的高电平抗负脉冲干扰效果更好。当N的取值变大时,按键脉冲过滤电路将输出脉冲P2从0变1,以及从1变0的条件变严格,抗干扰效果变好,但输出脉冲P2相对于按键脉冲P1的延迟时间变大;当N的取值变小时,按键脉冲过滤电路将输出脉冲P2从0变1,以及从1变0的条件变宽,抗干扰效果变小,但输出脉冲P2相对于按键脉冲P1的延迟时间变小。Taking the in-phase relationship between the output pulse P2 and the key pulse P1 as an example for further description. When the key pulse P1 makes the limiter cumulative count value X1 less than or equal to the lower limit comparison threshold Y2, after the output pulse P2 is set to 0, as long as the limiter cumulative count value X1 is always smaller than the upper limit comparison threshold Y1, the output pulse P2 will not become 1; When the key pulse P1 makes the limiting cumulative count value X1 greater than or equal to the upper limit comparison threshold Y1, after the output pulse P2 is set to 1, as long as the limiting limit cumulative count value X1 is always greater than the lower limit comparison threshold Y2, the output pulse P2 will not become 0. When both P1 and P2 are at low level, as long as the positive pulse that appears in P1 makes P1 sampled values greater than or equal to Y1 values of 1 appear continuously, or Y1+ appears in consecutive Y1+2 P1 sampled values One value is 1, etc., then the positive pulse corresponding to the positive pulse in P1 can be output from P2; when both P1 and P2 are high level, as long as the negative pulse appearing in P1 makes the sampling value of P1 continuous If there are more than or equal to N-Y2 values of 0, or, in consecutive N-Y2+2 P1 sampling values, N-Y2+1 values of 0 appear, etc., then it can be output from P2 and the P1 Negative pulses corresponding to negative pulses. When the key pulse P1 changes from 0 to 1, the output pulse P2 requires the limiter cumulative count value X1 to be counted up and delayed by several sampling pulse cycles, so that the limiter cumulative count value X1 is greater than or equal to the upper limit comparison threshold Y1, and P2 is set to 1; When the key pulse P1 changes from 1 to 0, the output pulse P2 requires the limiter cumulative count value X1 to go through a countdown delay of several sampling pulse cycles, so that the limiter cumulative count value X1 is less than or equal to the lower limit comparison threshold Y2, and will P2 is set to 0. When the value of the upper limit comparison threshold Y1 is larger, the condition for the output pulse P2 to change from 0 to 1 is more severe, and the low level of the circuit has a better anti-positive pulse interference effect; the smaller the value of the lower limit comparison threshold Y2, the output pulse The conditions for P2 to change from 1 to 0 are more severe, and the high level of the circuit has a better anti-negative pulse interference effect. When the value of N becomes larger, the key pulse filter circuit will change the output pulse P2 from 0 to 1, and the conditions from 1 to 0 will become stricter, and the anti-interference effect will become better, but the delay time of the output pulse P2 relative to the key pulse P1 become larger; when the value of N becomes smaller, the key pulse filter circuit will change the output pulse P2 from 0 to 1, and the condition from 1 to 0 will be widened, and the anti-interference effect will become smaller, but the output pulse P2 is relatively smaller than the key pulse P1 The delay time becomes smaller.
采样时钟脉冲的周期和高电平宽度要根据按键脉冲P1的脉冲宽度、变化速度和干扰脉冲的宽度确定。例如,若按键脉冲P1来自于普通按钮开关的控制输出,由于普通按钮开关的形成的脉冲宽度至少有100ms,普通按钮开关的抖动干扰脉冲宽度小于10ms,因此,可以选择采样时钟脉冲的周期为10ms左右,N在3至7范围内取值。The period and high-level width of the sampling clock pulse are determined according to the pulse width, change speed and width of the interference pulse of the key pulse P1. For example, if the key pulse P1 comes from the control output of an ordinary button switch, since the pulse width formed by the ordinary button switch is at least 100ms, the jitter interference pulse width of the ordinary button switch is less than 10ms, so the period of the sampling clock pulse can be selected as 10ms Around, N takes a value in the range of 3 to 7.
图9为按键脉冲电路的实施例,由按键S10及其上拉电阻R10组成,+VCC为供电电源,GND为公共地,输出按键脉冲P1。Fig. 9 is an embodiment of the key pulse circuit, which is composed of key S10 and its pull-up resistor R10, +VCC is the power supply, GND is the common ground, and the key pulse P1 is output.
按键脉冲过滤电路中可逆限幅计数单元、比较阈值设定单元、上限值比较器单元、下限值比较器单元、输出控制单元、振荡器单元中的全部,或者是部分功能可以采用PAL、GAL、CPLD、FPGA,或者是其他可编程逻辑器件、逻辑单元来实现。All of the reversible limiter counting unit, comparison threshold setting unit, upper limit comparator unit, lower limit comparator unit, output control unit, oscillator unit, or some of the functions in the key pulse filter circuit can use PAL, GAL, CPLD, FPGA, or other programmable logic devices and logic units.
除说明书所述的技术特征外,均为本领域技术人员所掌握的常规技术。Except for the technical features described in the description, all are conventional techniques mastered by those skilled in the art.
Claims (7)
- A kind of 1. key pulse de-jittering method, it is characterised in that:Key pulse is sampled at sample clock pulse edge to obtain key pulse sampled value;Reversible clip counting unit by The control of key pulse sampled value level state is in plus count status either subtracts count status, is exported as to sampling clock arteries and veins Rush in the amplitude limit stored counts value of row counting;Threshold value is compared according to amplitude limit stored counts value and the upper limit and lower limit compares the ratio of threshold value Compared with as a result, the signal for producing control output impulse level state removes the level state of control output pulse;The amplitude limit stored counts value is binary count value;The Lower Limit Amplitude of the amplitude limit stored counts value is 0, upper limit magnitude For N;The N is the integer more than or equal to 2.
- 2. key pulse de-jittering method according to claim 1, it is characterised in that:The upper limit compare threshold value be more than N/2 and the integer less than or equal to N;The lower limit compares threshold value for the integer more than or equal to 0 and less than N/2.
- 3. key pulse de-jittering method according to claim 2, it is characterised in that:The control output impulse level shape The signal of state is the first set signal and the second set signal, by the first set signal and the control output pulse of the second set signal Level state;When amplitude limit stored counts value compares threshold value more than or equal to the upper limit, make the first set signal effective, otherwise first Set invalidating signal;When amplitude limit stored counts value compares threshold value less than or equal to lower limit, make the second set signal effective, otherwise Two set invalidating signals.
- 4. key pulse de-jittering method according to claim 3, it is characterised in that:Put by the first set signal and second The method of position signal control output impulse level state is, the first set signal of input is effectively and the second set invalidating signal When, output pulse is set to 1;When the first set invalidating signal and effective the second set signal of input, output pulse is set to 0;When the first set signal and invalid the second set signal of input, output pulse condition is constant.
- 5. key pulse de-jittering method according to claim 3, it is characterised in that:Put by the first set signal and second The method of position signal control output impulse level state is, the first set signal of input is effectively and the second set invalidating signal When, output pulse is set to 0;When the first set invalidating signal and effective the second set signal of input, output pulse is set to 1;When the first set signal and invalid the second set signal of input, output pulse condition is constant.
- 6. the key pulse de-jittering method according to any one of claim 1-5, it is characterised in that:Reversible clip counting Unit does not add sample clock pulse in when adding count status and amplitude limit stored counts value is more than or equal to upper limit magnitude N Count;Reversible clip counting unit, which is in, subtracts count status and when amplitude limit stored counts value is equal to Lower Limit Amplitude 0, not to sampling when Clock carries out subtracting counting.
- 7. the key pulse de-jittering method according to any one of claim 1-5, it is characterised in that:Reversible clip counting Unit is made of the forward-backward counter and amplitude limit and add-subtract control circuit inputted with doubleclocking.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711134005.3A CN107979358A (en) | 2017-11-16 | 2017-11-16 | Key pulse de-jittering method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711134005.3A CN107979358A (en) | 2017-11-16 | 2017-11-16 | Key pulse de-jittering method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107979358A true CN107979358A (en) | 2018-05-01 |
Family
ID=62013629
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711134005.3A Pending CN107979358A (en) | 2017-11-16 | 2017-11-16 | Key pulse de-jittering method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107979358A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4667338A (en) * | 1984-06-01 | 1987-05-19 | Sanyo Electric Co., Ltd. | Noise elimination circuit for eliminating noise signals from binary data |
US4961014A (en) * | 1988-05-26 | 1990-10-02 | Toshiro Kasahara | Filter circuit utilizing reversible counter for generating a satisfactory hysteresis |
EP1330031A1 (en) * | 2002-01-21 | 2003-07-23 | Mitsubishi Electric Information Technology Centre Europe B.V. | Generation of a sequence of pulse trains |
CN101568237A (en) * | 2009-05-19 | 2009-10-28 | 中兴通讯股份有限公司 | Method and device for eliminating signal noise |
CN201388187Y (en) * | 2008-11-26 | 2010-01-20 | 苏州市华芯微电子有限公司 | Circuit of wireless receiving decoding chip for judging burrs |
CN103647548A (en) * | 2013-11-22 | 2014-03-19 | 简玉君 | Programmable counting circuit for photoelectric encoder |
-
2017
- 2017-11-16 CN CN201711134005.3A patent/CN107979358A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4667338A (en) * | 1984-06-01 | 1987-05-19 | Sanyo Electric Co., Ltd. | Noise elimination circuit for eliminating noise signals from binary data |
US4961014A (en) * | 1988-05-26 | 1990-10-02 | Toshiro Kasahara | Filter circuit utilizing reversible counter for generating a satisfactory hysteresis |
EP1330031A1 (en) * | 2002-01-21 | 2003-07-23 | Mitsubishi Electric Information Technology Centre Europe B.V. | Generation of a sequence of pulse trains |
CN201388187Y (en) * | 2008-11-26 | 2010-01-20 | 苏州市华芯微电子有限公司 | Circuit of wireless receiving decoding chip for judging burrs |
CN101568237A (en) * | 2009-05-19 | 2009-10-28 | 中兴通讯股份有限公司 | Method and device for eliminating signal noise |
CN103647548A (en) * | 2013-11-22 | 2014-03-19 | 简玉君 | Programmable counting circuit for photoelectric encoder |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107976626B (en) | Relay life detection device | |
CN104901657A (en) | Full-digital debouncing circuit and method | |
CN208461792U (en) | A kind of key applied to FPGA/CPLD, which disappears, trembles logic circuit | |
Sun et al. | Comments on “distributed event-triggered control of multi-agent systems with combinational measurements” | |
CN107979358A (en) | Key pulse de-jittering method | |
CN107947768A (en) | Mechanical switch electric pulse anti-shaking method | |
CN107968640A (en) | Sample accumulation formula disturbing pulse filter method | |
CA1043429A (en) | Digital noise discriminator | |
CN104065361A (en) | A Serial Cascaded Single-bit Filter Structure for Eliminating Glitch Signals | |
CN107800407A (en) | Accumulate discriminate disturbing pulse filter method | |
US6728649B2 (en) | Method and apparatus for removing digital glitches | |
CN107715241B (en) | Infusion dripping speed monitoring device | |
CN107800409B (en) | Accumulation type interference pulse filtering method | |
US10404446B2 (en) | Controlling a reference voltage for a clock and data recovery circuit | |
CN103647524B (en) | A kind of PLC programmable filter | |
CN107947785A (en) | Sampling type disturbing pulse filtering method | |
CN107809224A (en) | Disturbing pulse filter method | |
CN107800408A (en) | Burst pulse filtering method | |
CN107979357A (en) | Sampling type disturbing pulse filter method | |
CN107809225B (en) | Narrow Interference Pulse Filtering Method | |
CN107947767A (en) | Pulse signal circuit disturbing pulse sampling type filtering method | |
JPH01227519A (en) | Comparator and digital filter circuit | |
CN113765505A (en) | Debounce method, device, device and storage medium for key signal with feedback correction | |
CN215186702U (en) | Phase-locked detection device and phase-locked loop | |
CN107862371B (en) | Vehicle loading counting control system |
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 | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180501 |
|
WD01 | Invention patent application deemed withdrawn after publication |