CN105703780B - Matrix keyboard Scan orientation circuit - Google Patents
Matrix keyboard Scan orientation circuit Download PDFInfo
- Publication number
- CN105703780B CN105703780B CN201610003614.4A CN201610003614A CN105703780B CN 105703780 B CN105703780 B CN 105703780B CN 201610003614 A CN201610003614 A CN 201610003614A CN 105703780 B CN105703780 B CN 105703780B
- Authority
- CN
- China
- Prior art keywords
- state
- key
- keyboard
- row
- buffer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 239000011159 matrix material Substances 0.000 title claims abstract description 70
- 239000000872 buffer Substances 0.000 claims abstract description 93
- 238000005070 sampling Methods 0.000 claims description 57
- 230000000630 rising effect Effects 0.000 claims description 16
- 230000006870 function Effects 0.000 abstract description 15
- 238000012423 maintenance Methods 0.000 abstract description 12
- 230000003247 decreasing effect Effects 0.000 abstract description 4
- 239000013256 coordination polymer Substances 0.000 description 53
- 238000000034 method Methods 0.000 description 13
- 238000010586 diagram Methods 0.000 description 10
- 230000003111 delayed effect Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 3
- 230000001960 triggered effect Effects 0.000 description 3
- 102100040856 Dual specificity protein kinase CLK3 Human genes 0.000 description 2
- 101000749304 Homo sapiens Dual specificity protein kinase CLK3 Proteins 0.000 description 2
- 102100040862 Dual specificity protein kinase CLK1 Human genes 0.000 description 1
- 102100040844 Dual specificity protein kinase CLK2 Human genes 0.000 description 1
- 102100040858 Dual specificity protein kinase CLK4 Human genes 0.000 description 1
- 101000749294 Homo sapiens Dual specificity protein kinase CLK1 Proteins 0.000 description 1
- 101000749291 Homo sapiens Dual specificity protein kinase CLK2 Proteins 0.000 description 1
- 101000749298 Homo sapiens Dual specificity protein kinase CLK4 Proteins 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000033228 biological regulation Effects 0.000 description 1
- 230000001934 delay Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/02—Input arrangements using manually operated switches, e.g. using keyboards or dials
- G06F3/0202—Constructional details or processes of manufacture of the input device
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M11/00—Coding in connection with keyboards or like devices, i.e. coding of the position of operated keys
- H03M11/20—Dynamic coding, i.e. by key scanning
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Input From Keyboards Or The Like (AREA)
Abstract
一种矩阵式键盘扫描定位电路,由矩阵式键盘、缓冲寄存器、状态码寄存器、编码器组成。所述电路经由时钟脉冲扫描,将对单键操作、组合键操作、键盘维持状态操作的定位,转换成同一二进制长度的有效状态码和无效状态码,编码器输出与每一个有效状态码对应的有效键号或者是输出与所有无效状态码对应的无效键号;不同的单键操作、组合键操作、键盘维持状态操作仅体现在状态码的不同上;如果需要增减按键操作功能或者是调整按键操作功能,不需要修改键盘扫描电路结构,只需根据增减后的状态码与键号之间的对应关系更改编码器即可。所述发明电路不用编写和运行程序,工作可靠。
A matrix keyboard scanning positioning circuit is composed of a matrix keyboard, a buffer register, a status code register and an encoder. The circuit converts the positioning of single-key operation, combined key operation, and keyboard maintenance state operation into valid state codes and invalid state codes of the same binary length through clock pulse scanning, and the encoder outputs the corresponding to each valid state code. Valid key numbers or output invalid key numbers corresponding to all invalid state codes; different single-key operations, key combination operations, and keyboard maintenance state operations are only reflected in the different state codes; if you need to increase or decrease key operation functions or adjust The key operation function does not need to modify the structure of the keyboard scanning circuit, but only needs to change the encoder according to the corresponding relationship between the increased and decreased state code and the key number. The inventive circuit does not need to write and run programs, and works reliably.
Description
技术领域technical field
本发明涉及一种键盘的扫描电路,尤其是一种矩阵式键盘扫描定位电路。The invention relates to a keyboard scanning circuit, in particular to a matrix keyboard scanning and positioning circuit.
背景技术Background technique
随着嵌入式技术的不断发展,当前各类电子产品普遍采用微控制器作为控制核心,键盘作为主要的输入设备,得到了广泛的应用。With the continuous development of embedded technology, various electronic products generally use microcontrollers as the control core, and keyboards as the main input device, which have been widely used.
目前的键盘扫描主要由微控制器所控制,需要通过运行微控制器中的程序来进行,遇到干扰,造成程序飞跑,扫描程序将不能正常工作。The current keyboard scanning is mainly controlled by the microcontroller, which needs to be carried out by running the program in the microcontroller. When encountering interference, the program will run away, and the scanning program will not work normally.
申请号为CN201010153560.2的发明专利“一种矩阵键盘的快速扫描定位方法”采用键盘中断触发的方式进入键盘的扫描定位过程,采用多次重复键盘扫描步骤的方法判断按键是否有效,并对所获得的键值进行状态判断;如果多次采样状态相同,则处于稳定状态,键值有效;如果多次采样状态不同,键值无效。单键操作或组合键操作需要单独判断,如是单键操作,则进入单键处理模式;如是组合键操作,则进入组合键处理模式。该专利所述方法解决了由于键盘自身的机械特性造成的键盘抖动而引起错键、连续触键等错误问题,以及对组合键和重复按键的支持问题。但所述方法单键操作与组合键操作需要分别处理;没有考虑键盘状态维持一段时间到后才执行有效操作的键盘操作功能;增减按键操作功能或者是调整按键操作功能时,需要修改键盘扫描定位程序结构。The invention patent with the application number CN201010153560.2 "A Quick Scanning and Positioning Method for a Matrix Keyboard" adopts the method of keyboard interrupt triggering to enter the scanning and positioning process of the keyboard, and uses the method of repeating the keyboard scanning steps several times to determine whether the keys are valid, and The state of the obtained key value is judged; if the state of multiple sampling is the same, it is in a stable state, and the key value is valid; if the state of multiple sampling is different, the key value is invalid. A single key operation or a key combination operation needs to be judged separately. If it is a single key operation, enter the single key processing mode; if it is a key combination operation, enter the key combination processing mode. The method described in this patent solves the problems of wrong keys, continuous key touches and other errors caused by the keyboard shaking caused by the mechanical characteristics of the keyboard itself, as well as the problem of support for combination keys and repeated keys. However, the single-key operation and the combined key operation of the method need to be processed separately; the keyboard operation function of effective operation is not performed after the keyboard state is maintained for a period of time; when increasing or decreasing the key operation function or adjusting the key operation function, it is necessary to modify the keyboard scan Locating the program structure.
发明内容Contents of the invention
为了解决现有键盘扫描定位方法存在的上述技术问题,本发明提供了一种矩阵式键盘扫描定位电路,由矩阵式键盘、缓冲寄存器、状态码寄存器、编码器组成。In order to solve the above-mentioned technical problems existing in the existing keyboard scanning positioning method, the present invention provides a matrix keyboard scanning positioning circuit, which is composed of a matrix keyboard, a buffer register, a status code register, and an encoder.
所述矩阵式键盘共有X行、Y列,设有N位键盘状态信号输出端;所述N位键盘状态信号为电平信号;所述N=X+Y。The matrix keyboard has X rows and Y columns in total, and is provided with an N-bit keyboard status signal output terminal; the N-bit keyboard status signal is a level signal; and the N=X+Y.
所述缓冲寄存器为N位二进制寄存器;缓冲寄存器的N位数据输入端连接至N位键盘状态信号输出端。The buffer register is an N-bit binary register; the N-bit data input end of the buffer register is connected to the N-bit keyboard state signal output end.
所述状态码寄存器为2×N位二进制寄存器;状态码寄存器的2×N位数据输入端中的N位连接至N位键盘状态信号输出端,另外N位连接至缓冲寄存器的N位数据输出端。The status code register is a 2×N bit binary register; the N bits in the 2×N bit data input terminals of the status code register are connected to the N bit keyboard status signal output terminals, and the other N bits are connected to the N bit data output of the buffer register end.
所述编码器有2×N位编码输入端,所述2×N位编码输入端连接至状态码寄存器的2×N位数据输出端;所述编码器有M位键号输出端。The encoder has a 2×N-bit coding input terminal, and the 2×N-bit coding input terminal is connected to the 2×N-bit data output terminal of the state code register; the encoder has an M-bit key number output terminal.
所述缓冲寄存器的接收脉冲输入端和状态码寄存器的接收脉冲输入端均连接至时钟脉冲。Both the receiving pulse input end of the buffer register and the receiving pulse input end of the status code register are connected to the clock pulse.
所述矩阵式键盘由X行-Y列按键矩阵、行三态缓冲器、列三态缓冲器、行状态寄存器、列状态寄存器组成;所有按键矩阵的行线分别连接至行三态缓冲器的输出端,所有按键矩阵的列线分别连接至列三态缓冲器的输出端;行三态缓冲器和列三态缓冲器的所有输入端连接至低电平;所有按键矩阵的行线分别连接至行状态寄存器的输入端,所有按键矩阵的列线分别连接至列状态寄存器的输入端;所述行状态寄存器的输出端与列状态寄存器的输出端共同组成键盘状态信号输出端。Described matrix type keyboard is made up of X row-Y row button matrix, row tristate buffer, row tristate buffer, row status register, column status register; Output terminals, the column lines of all key matrixes are respectively connected to the output terminals of the column tri-state buffers; all input terminals of the row tri-state buffers and column tri-state buffers are connected to low level; the row lines of all key matrixes are respectively connected to To the input end of the row state register, all the column lines of the key matrix are respectively connected to the input end of the column state register; the output end of the row state register and the output end of the column state register together form a keyboard state signal output end.
所述矩阵式键盘由取样脉冲控制获取键盘状态信号;所述行三态缓冲器在取样脉冲的低电平使能有效时,要求列状态寄存器在取样脉冲的上升沿进行数据锁存、列三态缓冲器在取样脉冲的高电平使能有效、行状态寄存器在取样脉冲的下降沿进行数据锁存;或者是,行三态缓冲器在取样脉冲的高电平使能有效时,要求列状态寄存器在取样脉冲的下降沿进行数据锁存、列三态缓冲器在取样脉冲的低电平使能有效、行状态寄存器在取样脉冲的上升沿进行数据锁存。The matrix keyboard is controlled by the sampling pulse to obtain the keyboard state signal; when the low level of the sampling pulse is enabled and valid, the row tri-state buffer requires the column state register to perform data latching and column three on the rising edge of the sampling pulse. The state buffer is enabled at the high level of the sampling pulse, and the row status register performs data latching at the falling edge of the sampling pulse; or, when the row tri-state buffer is enabled at the high level of the sampling pulse, it requires the column The status register performs data latching on the falling edge of the sampling pulse, the column tri-state buffer is enabled and valid at the low level of the sampling pulse, and the row status register performs data latching on the rising edge of the sampling pulse.
所述缓冲寄存器和状态码寄存器在时钟脉冲的上升沿同时进行数据锁存,或者在时钟脉冲的下降沿同时进行数据锁存;所述状态码寄存器2×N位数据输出端输出2×N位的状态码;所述状态码由有效状态码和无效状态码组成;所述编码器输出的键号由有效键号和无效键号组成;所述有效状态码由有效键盘操作或状态产生,编码器输入每一个有效状态码时对应输出相应的有效键号;所述无效状态码由无效键盘操作或状态产生,编码器输入所有无效状态码时都对应输出无效键号。The buffer register and the status code register perform data latching simultaneously on the rising edge of the clock pulse, or simultaneously perform data latching on the falling edge of the clock pulse; the 2×N bit data output terminals of the status code register output 2×N bit The status code; the status code is composed of valid status code and invalid status code; the key number output by the encoder is composed of valid key number and invalid key number; The corresponding valid key number is output when the encoder inputs each valid status code; the invalid status code is generated by an invalid keyboard operation or state, and the encoder outputs corresponding invalid key numbers when all invalid status codes are input.
所述编码器有M位键号输出端,M值的选择应满足2M大于等于有效键号与无效键号的数量之和。The encoder has an M-bit key number output terminal, and the selection of the M value should meet the requirement that 2 M be greater than or equal to the sum of the valid key numbers and the invalid key numbers.
所述时钟脉冲的周期为20~100ms;所述取样脉冲的周期不大于所述时钟脉冲的周期,其特例是所述取样脉冲为所述时钟脉冲。The period of the clock pulse is 20-100 ms; the period of the sampling pulse is not greater than the period of the clock pulse, and a special example is that the sampling pulse is the clock pulse.
所述的矩阵式键盘扫描定位电路还包括振荡器;所述振荡器输出时钟脉冲和取样脉冲。The matrix keyboard scanning positioning circuit also includes an oscillator; the oscillator outputs clock pulses and sampling pulses.
所述的矩阵式键盘扫描定位电路还包括键盘状态变化脉冲产生单元,用于判断矩阵式键盘输出的键号是否发生改变,当矩阵式键盘输出的键号发生改变时,输出键盘状态变化脉冲。The matrix keyboard scanning positioning circuit also includes a keyboard state change pulse generating unit for judging whether the key numbers output by the matrix keyboard change, and outputting keyboard state change pulses when the key numbers output by the matrix keyboard change.
所述键盘状态变化脉冲产生单元由M位延迟缓冲器、M个异或门和或门组成;M位延迟缓冲器用于对矩阵式键盘输出的M位键号分别进行信号延迟;M个异或门的输入分别为M位延迟缓冲器的输入、输出信号;M个异或门的输出分别连接至或门的输入端;或门的输出端输出键盘状态变化脉冲。The keyboard state change pulse generation unit is made up of an M-bit delay buffer, M exclusive-or gates and an OR gate; the M-bit delay buffer is used to respectively carry out signal delay on the M-bit key numbers output by the matrix keyboard; M exclusive-or gates The inputs of the gates are the input and output signals of the M-bit delay buffer respectively; the outputs of the M XOR gates are respectively connected to the input terminals of the OR gates; the output terminals of the OR gates output keyboard state change pulses.
所述的N位、2×N位、M位均指二进制位数据。The N bits, 2×N bits, and M bits all refer to binary bit data.
本发明的有益效果是:将对单键操作、组合键操作、键盘维持状态操作的定位,由时钟脉冲扫描转换成同一二进制长度的状态码,采用统一编码的方式进行处理,单键操作、组合键操作、键盘维持状态操作仅体现在状态码的不同上;如果需要增减按键操作功能或者是调整按键操作功能,不需要修改键盘扫描电路结构,只需根据增减后的状态码与键号之间的对应关系更改编码器、即重新写入只读存储器的存储内容即可。所述发明电路没有使用单片机、ARM等微控制器,不用运行程序,工作可靠。The beneficial effects of the present invention are: the positioning of single-key operation, combined key operation, and keyboard maintenance state operation is converted into a state code of the same binary length by clock pulse scanning, and is processed in a unified coding manner. Single-key operation, combination Key operation and keyboard maintenance state operation are only reflected in the difference of the status code; if it is necessary to increase or decrease the key operation function or adjust the key operation function, there is no need to modify the keyboard scanning circuit structure, just according to the increased or decreased status code and key number The corresponding relationship between the coder can be changed, that is, the stored content of the read-only memory can be rewritten. The circuit of the invention does not use microcontrollers such as single-chip microcomputers and ARMs, does not need to run programs, and works reliably.
附图说明Description of drawings
图1是矩阵式键盘扫描定位电路原理框图;Fig. 1 is a schematic block diagram of a matrix keyboard scanning positioning circuit;
图2是本发明实施例的矩阵式键盘电路图;Fig. 2 is a matrix keyboard circuit diagram of an embodiment of the present invention;
图3是本发明实施例的扫描定位电路图;Fig. 3 is the scanning positioning circuit diagram of the embodiment of the present invention;
图4是本发明实施例的键盘状态变化脉冲产生单元的电路图;Fig. 4 is the circuit diagram of the keyboard state change pulse generation unit of the embodiment of the present invention;
图5是本发明实施例的键盘有效操作的相关波形示意图。FIG. 5 is a schematic diagram of waveforms related to the effective operation of the keyboard according to the embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明作进一步说明。The present invention will be further described below in conjunction with accompanying drawing.
图1是矩阵式键盘扫描定位电路原理框图,由矩阵式键盘400、缓冲寄存器100、状态码寄存器200、编码器300、振荡器500组成。1 is a schematic block diagram of a matrix keyboard scanning and positioning circuit, which is composed of a matrix keyboard 400 , a buffer register 100 , a status code register 200 , an encoder 300 and an oscillator 500 .
振荡器500为多谐振荡器,设有CP时钟脉冲输出端和CK取样脉冲输出端,CP时钟脉冲的周期为20~100ms,CK取样脉冲的周期不大于CP时钟脉冲的周期。The oscillator 500 is a multivibrator with a CP clock pulse output terminal and a CK sampling pulse output terminal. The period of the CP clock pulse is 20-100 ms, and the period of the CK sampling pulse is not greater than the period of the CP clock pulse.
图2是本发明实施例的矩阵式键盘400的电路图,共有2行、2列,共4个按键,由按键S1、按键S2、按键S3、按键S4和连接至电源+VCC的上拉电阻R1、上拉电阻R2、上拉电阻R3、上拉电阻R4,以及行三态缓冲器401、列三态缓冲器402、行状态寄存器403、列状态寄存器404组成。行三态缓冲器401的2个输出端Y1、Y2分别连接至2根行线,列三态缓冲器402的2个输出端Y3、Y4分别连接至2根列线;行三态缓冲器401和列三态缓冲器402的所有输入端X1~X4连接至低电平。2 is a circuit diagram of a matrix keyboard 400 according to an embodiment of the present invention. There are 2 rows and 2 columns, and 4 keys in total, consisting of key S1, key S2, key S3, key S4 and the pull-up resistor R1 connected to the power supply +VCC , pull-up resistor R2, pull-up resistor R3, pull-up resistor R4, row tri-state buffer 401, column tri-state buffer 402, row status register 403, and column status register 404. The two output terminals Y1 and Y2 of the row tri-state buffer 401 are respectively connected to two row lines, and the two output terminals Y3 and Y4 of the column tri-state buffer 402 are respectively connected to two column lines; the row tri-state buffer 401 All input terminals X1 ˜ X4 of the sum column tri-state buffer 402 are connected to low level.
行状态寄存器403的2个输入端D41、D42分别连接至2根行线,列状态寄存器404的2个输入端D43、D44分别连接至2根列线;行状态寄存器403的2个输出端Q41、Q42输出行状态信号I1、I2,列状态寄存器404的2个输出端Q43、Q44输出列状态信号I3、I4;行状态寄存器403的2个输出端与列状态寄存器404的2个输出端共同组成4位键盘状态信号输出端,输出键盘状态信号I1、I2、I3、I4。The two input terminals D41 and D42 of the row status register 403 are respectively connected to two row lines, and the two input terminals D43 and D44 of the column status register 404 are respectively connected to two column lines; the two output terminals Q41 of the row status register 403 , Q42 output row status signals I1, I2, 2 output terminals Q43, Q44 of column status register 404 output column status signals I3, I4; 2 output terminals of row status register 403 are common with 2 output terminals of column status register 404 4-bit keyboard status signal output terminals are formed to output keyboard status signals I1, I2, I3, and I4.
实施例中,行三态缓冲器401的使能输入EN1低电平有效,列三态缓冲器402的使能输入EN2高电平有效;EN1和EN2均连接至振荡器500的CK取样脉冲输出端。行状态寄存器403与列状态寄存器404的接收脉冲输入端CLK3、CLK4均连接至振荡器500的CK取样脉冲输出端,行状态寄存器403在CK取样脉冲的下降沿进行数据锁存,列状态寄存器404在CK取样脉冲的上升沿进行数据锁存。In an embodiment, the enable input EN1 of the row tri-state buffer 401 is active at low level, and the enable input EN2 of the column tri-state buffer 402 is active at high level; both EN1 and EN2 are connected to the CK sampling pulse output of the oscillator 500 end. The receiving pulse input terminals CLK3 and CLK4 of the row status register 403 and the column status register 404 are all connected to the CK sampling pulse output terminal of the oscillator 500, the row status register 403 performs data latching on the falling edge of the CK sampling pulse, and the column status register 404 Data is latched on the rising edge of the CK sampling pulse.
当行三态缓冲器401和列三态缓冲器402使用同型号的三态缓冲器,例如,同时使用三态缓冲器74HC241时,74HC241的使能输入为高电平有效,因此,在CK取样脉冲输出端与行三态缓冲器401的使能输入端EN1之间,需要增加一个非门。同样地,当行状态寄存器403和列状态寄存器404使用同型号的数据寄存器,例如,行状态寄存器403和列状态寄存器404均使用双D触发器74HC74组成数据寄存器时,74HC74的触发输入为上升沿有效,因此,在CK取样脉冲输出端与行状态寄存器403的接收脉冲输入端CLK3之间,需要增加一个非门。When row tri-state buffer 401 and column tri-state buffer 402 use the same type of tri-state buffer, for example, when tri-state buffer 74HC241 is used at the same time, the enable input of 74HC241 is active high, so the CK sampling pulse Between the output end and the enable input end EN1 of the row tri-state buffer 401 , a NOT gate needs to be added. Similarly, when row status register 403 and column status register 404 use the same type of data register, for example, when row status register 403 and column status register 404 both use double D flip-flops 74HC74 to form data registers, the trigger input of 74HC74 is valid on the rising edge , therefore, a NOT gate needs to be added between the CK sampling pulse output terminal and the receiving pulse input terminal CLK3 of the row status register 403 .
图1中的缓冲寄存器100、状态码寄存器200、编码器300组成扫描定位电路,其实施例电路图如图3所示。矩阵式键盘电路有4个按键,矩阵式键盘输出的键盘状态信号为4位二进制码,因此,缓冲寄存器100要求寄存4位二进制数据,状态码寄存器200要求寄存8位二进制数据。缓冲寄存器100的4个数据输入端连接至I1、I2、I3、I4;状态码寄存器200的8个数据输入端中,4个数据输入端连接至I1、I2、I3、I4,另外4个数据输入端连接至缓冲寄存器100的4个输出端;编码器300的8个输入端连接至状态码寄存器200的8个输出端。编码器300输出经过扫描定位确定的4位二进制键号。The buffer register 100, the status code register 200, and the encoder 300 in FIG. 1 form a scanning positioning circuit, and its embodiment circuit diagram is shown in FIG. 3 . The matrix keyboard circuit has 4 keys, and the keyboard state signal output by the matrix keyboard is a 4-bit binary code. Therefore, the buffer register 100 is required to store 4-bit binary data, and the status code register 200 is required to store 8-bit binary data. The 4 data input terminals of buffer register 100 are connected to I1, I2, I3, I4; Among the 8 data input terminals of status code register 200, 4 data input terminals are connected to I1, I2, I3, I4, and the other 4 data input terminals The input terminals are connected to the 4 output terminals of the buffer register 100 ; the 8 input terminals of the encoder 300 are connected to the 8 output terminals of the status code register 200 . The encoder 300 outputs the 4-digit binary key number determined through scanning and positioning.
图3中,触发器101组成缓冲寄存器100、触发器201组成状态码寄存器200。触发器101由4个边沿触发器组成,4个边沿触发器的触发输入端为缓冲寄存器100的接收脉冲输入端,均连接至振荡器500的CP时钟脉冲输出端;触发器201由8个边沿触发器组成,8个边沿触发器的触发输入端为状态码寄存器200的接收脉冲输入端,均连接至振荡器500的CP时钟脉冲输出端。触发器101、触发器201优选由边沿触发的D触发器组成,例如,由双D触发器74HC74、4D触发器74HC175组成。图3实施例中,触发器101、触发器201均选择上升沿触发的8D触发器74HC273,此时,要将图3中未画出的清零输入端连接至高电平,使74HC273的清零功能处于无效状态,只具有触发功能;触发器101只需要4D触发器,任意使用所选8D触发器74HC273中的4个D触发器即可。两个8D触发器74HC273的触发输入端CLK1、CLK2均连接至CP。In FIG. 3 , the flip-flop 101 forms the buffer register 100 , and the flip-flop 201 forms the status code register 200 . Flip-flop 101 is made up of 4 edge triggers, and the trigger input end of 4 edge triggers is the receiving pulse input end of buffer register 100, is connected to the CP clock pulse output end of oscillator 500; Flip-flop 201 is made up of 8 edge triggers The trigger input terminals of the eight edge triggers are the receiving pulse input terminals of the status code register 200 , and are all connected to the CP clock pulse output terminals of the oscillator 500 . Flip-flop 101 and flip-flop 201 are preferably composed of edge-triggered D flip-flops, for example, composed of double D flip-flop 74HC74 and 4D flip-flop 74HC175. In the embodiment of Fig. 3, flip-flop 101 and flip-flop 201 both select the 8D flip-flop 74HC273 triggered by the rising edge. At this time, the clear input terminal not shown in Fig. The function is in an invalid state and only has a trigger function; the flip-flop 101 only needs 4D flip-flops, and the 4 D flip-flops in the selected 8D flip-flop 74HC273 can be used arbitrarily. The trigger input terminals CLK1 and CLK2 of the two 8D flip-flops 74HC273 are connected to the CP.
图3中,只读存储器组成编码器300。只读存储器的地址输入端A7~A0为编码器300的输入端,只读存储器的数据输出端D3~D0为编码器300的编码输出端C3~C0。In FIG. 3 , the read-only memory constitutes the encoder 300 . Address input terminals A7 - A0 of the ROM are input terminals of the encoder 300 , and data output terminals D3 - D0 of the ROM are encoding output terminals C3 - C0 of the encoder 300 .
矩阵式键盘扫描定位电路的工作原理如下:The working principle of the matrix keyboard scanning positioning circuit is as follows:
图2中,矩阵式键盘的4个按键以2×2的矩阵形式排列,所有的行线与列线都通过上拉电阻接至电源+VCC。矩阵式键盘由CK取样脉冲控制,采用反转法获取键盘状态信号I4、I3、I2、I1。例如,没有键按下的键盘状态信号是1111,S1按下的键盘状态信号是1010,S1、S2同时按下的键盘状态信号是0010。键盘状态信号的4位二进制码称为键值。In Figure 2, the 4 keys of the matrix keyboard are arranged in a 2×2 matrix, and all row lines and column lines are connected to the power supply +VCC through pull-up resistors. The matrix keyboard is controlled by CK sampling pulse, and the keyboard status signals I4, I3, I2, and I1 are obtained by the inversion method. For example, the keyboard status signal of no key pressed is 1111, the keyboard status signal of S1 pressed is 1010, and the keyboard status signal of S1 and S2 pressed simultaneously is 0010. The 4-bit binary code of the keyboard status signal is called the key value.
CK取样脉冲控制对矩阵式键盘进行采样读取键值的方法是:在CK取样脉冲的低电平,通过行三态缓冲器401控制所有行线输出低电平,列三态缓冲器402输出高阻态开放列线;在CK取样脉冲的上升沿由列状态寄存器404采样读取列线状态作为键值的高2位;在CK取样脉冲的高电平,通过列三态缓冲器402控制所有列线输出低电平,行三态缓冲器401输出高阻态开放行线;在CK取样脉冲的下降沿由行状态寄存器403采样读取行线状态作为键值的低2位;上述过程周而复始,列状态寄存器404、行状态寄存器403输出的4位键值始终为矩阵式键盘的最新状态。CK sampling pulse control The method of sampling and reading the key value of the matrix keyboard is: at the low level of the CK sampling pulse, control all row lines to output low level through the row tri-state buffer 401, and the column tri-state buffer 402 outputs High-impedance state opens the column line; at the rising edge of the CK sampling pulse, the column state register 404 samples and reads the column line state as the upper 2 bits of the key value; at the high level of the CK sampling pulse, it is controlled by the column tri-state buffer 402 All column lines output low level, and the row tri-state buffer 401 outputs a high-impedance open row line; at the falling edge of the CK sampling pulse, the state of the row line is sampled and read by the row state register 403 as the lower 2 bits of the key value; the above process Repeatedly, the 4-bit key value output by the column state register 404 and the row state register 403 is always the latest state of the matrix keyboard.
从CK取样脉冲控制对矩阵式键盘进行采样读取键值的方法可知,行三态缓冲器401在CK取样脉冲的低电平使能有效时,同时要求列状态寄存器404在CK取样脉冲的上升沿进行数据锁存、列三态缓冲器402在CK取样脉冲的高电平使能有效、行状态寄存器403在CK取样脉冲的下降沿进行数据锁存。反过来,如果行三态缓冲器401在CK取样脉冲的高电平使能有效时,同时要求列状态寄存器404在CK取样脉冲的下降沿进行数据锁存、列三态缓冲器402在CK取样脉冲的低电平使能有效、行状态寄存器403在CK取样脉冲的上升沿进行数据锁存。From the method of sampling and reading the key value of the matrix keyboard by controlling the CK sampling pulse, it can be seen that the row tri-state buffer 401 requires the column state register 404 to be activated when the CK sampling pulse rises when the row tri-state buffer 401 is active. Data latching is performed on the edge, the column tri-state buffer 402 is enabled and valid at the high level of the CK sampling pulse, and the row status register 403 is data latched on the falling edge of the CK sampling pulse. Conversely, if the row tri-state buffer 401 is valid when the high level of the CK sampling pulse is enabled, the column status register 404 is required to perform data latching on the falling edge of the CK sampling pulse, and the column tri-state buffer 402 is required to perform data latching at the falling edge of the CK sampling pulse. The low level of the pulse is effective, and the row status register 403 performs data latching on the rising edge of the CK sampling pulse.
在上述CK取样脉冲控制采样读取键值的过程中,行状态寄存器403、列状态寄存器404进行采样的时刻恰好是列三态缓冲器402与行三态缓冲器401进行状态反转的时刻,正常工作下的行状态寄存器403或列状态寄存器404能够正确采样。如果要求有一定时序上的裕量,则可以对连接至列三态缓冲器402与行三态缓冲器401的CK取样脉冲进行延迟,方法是令CK取样脉冲经过RC延迟电路再连接至行三态缓冲器401与列三态缓冲器402的EN1、EN2,延迟时间由RC延迟电路决定,确定RC延迟电路的延迟时间的原则是,延迟的CK取样脉冲相位不超过90°;或者是CK取样脉冲经过几个门电路的缓冲后再连接至行三态缓冲器401与列三态缓冲器402的EN1、EN2,此时的延迟时间为所述几个门电路的总时延时间。In the above-mentioned CK sampling pulse control sampling and reading key value process, the moment when the row state register 403 and the column state register 404 are sampled is exactly the moment when the state of the column tri-state buffer 402 and the row tri-state buffer 401 are reversed, The row status register 403 or the column status register 404 under normal operation can be correctly sampled. If a certain timing margin is required, the CK sampling pulse connected to the column tri-state buffer 402 and the row tri-state buffer 401 can be delayed by making the CK sampling pulse pass through an RC delay circuit and then connected to the row three The delay time of EN1 and EN2 of state buffer 401 and column tri-state buffer 402 is determined by the RC delay circuit. The principle of determining the delay time of the RC delay circuit is that the delayed CK sampling pulse phase does not exceed 90°; or CK sampling The pulse is buffered by several gate circuits and then connected to EN1 and EN2 of the row tri-state buffer 401 and column tri-state buffer 402 , and the delay time at this time is the total delay time of the several gate circuits.
缓冲寄存器100、状态码寄存器200在CP时钟脉冲控制下,在CP的每一个周期的有效触发沿进行数据锁存。图3中,74HC273为上升沿触发有效,因此,CP时钟脉冲的有效触发沿为上升沿。Under the control of the CP clock pulse, the buffer register 100 and the status code register 200 perform data latching on the effective trigger edge of each cycle of the CP. In Fig. 3, 74HC273 is effective for the rising edge trigger, therefore, the effective trigger edge of the CP clock pulse is the rising edge.
状态码寄存器200的8个数据输入端中的4个数据输入端D20~D23直接连接至矩阵式键盘输出的状态信号I1、I2、I3、I4,另外4个数据输入端D24~D27连接至缓冲寄存器100的数据输出端Q10~Q13,缓冲寄存器100的4个数据输入端D10~D13直接连接至矩阵式键盘输出的状态信号I1、I2、I3、I4,因此,在CP时钟脉冲的有效触发沿,状态码寄存器200的8个数据输出端中,与直接连接至矩阵式键盘输出的状态信号I1、I2、I3、I4相对应的4个数据输出端Q20~Q23锁存的数据为矩阵式键盘的当前状态,其4位数据称为现态键值;与连接至缓冲寄存器100的数据输出端相对应的4个数据输出端Q24~Q27锁存的数据为矩阵式键盘的前一状态,其4位数据称为前态键值。状态码寄存器200数据输出端输出的4位现态键值和4位前态键值共同组成8位状态码。Among the 8 data input terminals of the status code register 200, 4 data input terminals D20-D23 are directly connected to the status signals I1, I2, I3, and I4 output by the matrix keyboard, and the other 4 data input terminals D24-D27 are connected to the buffer The data output terminals Q10~Q13 of the register 100, and the 4 data input terminals D10~D13 of the buffer register 100 are directly connected to the status signals I1, I2, I3, and I4 output by the matrix keyboard. Therefore, at the effective trigger edge of the CP clock pulse , among the 8 data output terminals of the state code register 200, the data latched by the 4 data output terminals Q20-Q23 corresponding to the state signals I1, I2, I3, and I4 directly connected to the matrix keyboard output are matrix keyboard Its 4-bit data is called the current state key value; the data latched by the 4 data output terminals Q24-Q27 corresponding to the data output terminals connected to the buffer register 100 is the previous state of the matrix keyboard, and its The 4-bit data is called the pre-state key. The 4-bit current state key value and the 4-bit previous state key value output by the data output terminal of the status code register 200 together form an 8-bit status code.
所述的8位状态码用于识别矩阵式键盘的当前状态和操作状态。例如,本实施例中,无键按下的状态码是11111111;S1键单键按下操作的状态码是11111010;S1键单键按下且维持的状态码是10101010;S1键单键释放操作的状态码是10101111;S2键单键按下操作的状态码是11110110;S4键单键按下操作的状态码是11110101;S2+S1组合操作的S1按下操作,表示先按下S2后,在S2维持按下的状态再按下S1的操作,该操作的状态码是01100010。The 8-bit status code is used to identify the current status and operating status of the matrix keyboard. For example, in this embodiment, the state code of pressing no key is 11111111; the state code of S1 key single key press operation is 11111010; the state code of S1 key single key press and maintenance is 10101010; S1 key single key release operation The status code of the S2 button is 10101111; the status code of the S2 key single-key press operation is 11110110; the S4 key single-key press operation status code is 11110101; the S1 press operation of the S2+S1 combination operation means that after pressing S2 first, When S2 is kept pressed and then S1 is pressed, the status code of this operation is 01100010.
编码器300用于将状态码转换为键号。实施例中,设有6个有效的键盘操作与状态,包括:The encoder 300 is used to convert the status code into a key number. In the embodiment, there are 6 effective keyboard operations and states, including:
操作0:按键S1的单键按下操作,键号为0000;Operation 0: Single key press operation of key S1, key number is 0000;
操作1:按键S2的单键按下操作,键号为0001;Operation 1: Single key press operation of key S2, the key number is 0001;
操作2:按键S3的单键按下操作,键号为0010;Operation 2: Single key press operation of key S3, key number is 0010;
操作3:按键S3单键按下后的维持状态,键号为0011;Operation 3: The key number is 0011 after the key S3 is pressed to maintain the state;
操作4:按键S4单键按下后,再按下按键S2的组合键操作,键号为0100;Operation 4: After pressing the single key of the key S4, then press the key combination of the key S2 to operate, the key number is 0100;
操作5:按键S1的单键释放操作,键号为0101。Operation 5: Single-key release operation of key S1, the key number is 0101.
根据上述规定得到的状态码和键号见编码表1:See code table 1 for the status code and key number obtained according to the above regulations:
表1编码表Table 1 Coding table
编码器300为组合逻辑电路,设计电路,满足表1的逻辑关系即可。The encoder 300 is a combinational logic circuit, and it is only necessary to design the circuit to satisfy the logical relationship in Table 1.
实施例的编码器300优选由只读存储器组成。只读存储器有8位地址,共28个4位二进制存储单元。6个有效的键盘操作与状态有6个有效状态码,对应6个有效的键号;将状态码作为只读存储器的地址A7~A0,在与6个有效状态码相对应的存储单元中,将相应的键号作为存储数据写入。6个有效的键盘操作与状态之外产生的状态码为无效状态码,即表1中的其他操作或状态所产生的为无效状态码;在其他存储单元中,全部写入无效键号,无效键号为6个有效键号之外的一个值,实施例中,无效键号为1111。The encoder 300 of an embodiment preferably consists of a read-only memory. The read-only memory has an 8-bit address, a total of 28 4-bit binary storage units. 6 valid keyboard operations and states have 6 valid status codes, corresponding to 6 valid key numbers; use the status codes as the addresses A7-A0 of the read-only memory, in the storage unit corresponding to the 6 valid status codes, Write the corresponding key number as stored data. The status codes other than the 6 valid keyboard operations and statuses are invalid status codes, that is, the status codes generated by other operations or statuses in Table 1 are invalid status codes; in other storage units, all invalid key numbers are written, invalid The key number is a value other than 6 valid key numbers. In the embodiment, the invalid key number is 1111.
只读存储器一直工作在数据输出状态。当只读存储器具有片选控制、数据输出缓冲控制功能时,应使其片选控制、数据输出缓冲控制处于有效状态。The read-only memory has been working in the data output state. When the read-only memory has chip selection control and data output buffer control functions, the chip selection control and data output buffer control should be in an effective state.
实施例中的键号为4位二进制码。键号的二进制位数可以根据需要增加,或者减少,此时,只需选择与此相匹配的只读存储器即可。设键号的二进制位数为M,M值的选择应满足2M大于等于有效键号与无效键号的数量之和。当矩阵式键盘有N位键盘状态信号输出时,只读存储器需要有2×N位地址输入,M位数据输出。The key number in the embodiment is a 4-bit binary code. The binary digits of the key number can be increased or decreased as required. At this time, it is only necessary to select the matching ROM. Assuming that the binary digits of the key number is M, the selection of the M value should meet the requirement that 2 M be greater than or equal to the sum of the number of valid key numbers and invalid key numbers. When the matrix keyboard has N-bit keyboard status signal output, the ROM needs to have 2×N-bit address input and M-bit data output.
如果需要增减按键操作功能或者是调整按键操作功能,只需根据需要修改表1,将修改后的内容重新写入只读存储器的存储内容即可。If it is necessary to increase or decrease the key operation function or to adjust the key operation function, it is only necessary to modify Table 1 as required, and rewrite the modified content to the storage content of the read-only memory.
实施例中,当矩阵式键盘S1单键按下时,编码器300在S1单键按下后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,编码输出端C3~C0输出键号0000;当矩阵式键盘S2单键按下时,编码器300在S2单键按下后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出键号0001;当矩阵式键盘先按下S4后,再按下S2,编码器300在S2组合键按下后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出键号0100;当矩阵式键盘S1单键释放时,编码器300在S1单键释放后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出键号0101;因此可以看出,当识别的是矩阵式键盘的有效按键操作时,编码器300在该有效按键操作后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出持续时间为一个CP时钟脉冲周期宽度的有效键号。In the embodiment, when the matrix keyboard S1 single key is pressed, the encoder 300 starts from the effective trigger edge of the CP clock pulse after the S1 single key is pressed, and until the effective trigger edge of the next CP clock pulse, the encoding output terminal C3~C0 output key number 0000; when matrix keyboard S2 single key is pressed, encoder 300 starts from the effective trigger edge of CP clock pulse after S2 single key is pressed, and ends at the effective trigger edge of next CP clock pulse , the output key number is 0001; when the matrix keyboard first presses S4 and then presses S2, the encoder 300 starts at the effective triggering edge of the CP clock pulse after the S2 combination key is pressed, and ends at the effective triggering of the next CP clock pulse When the matrix keyboard S1 single key is released, the encoder 300 starts from the effective trigger edge of the CP clock pulse after the S1 single key is released, and outputs until the effective trigger edge of the next CP clock pulse. Key number 0101; therefore, it can be seen that when the effective key operation of the matrix keyboard is identified, the encoder 300 starts at the effective trigger edge of the CP clock pulse after the effective key operation, until the effective trigger of the next CP clock pulse Output the valid key number whose duration is the width of one CP clock pulse period.
实施例中,当矩阵式键盘S3单键按下时,编码器300在S3单键按下后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出键号0010;在接下来的CP时钟脉冲的有效触发沿开始,至S3单键按下维持状态结束后的下一个CP时钟脉冲的有效触发沿为止,编码器300输出键号0011;因此可以看出,当识别的是矩阵式键盘的维持状态时,编码器300输出有效键号的持续时间与该维持状态的持续时间相适应。In the embodiment, when the matrix keyboard S3 single key is pressed, the encoder 300 starts from the effective trigger edge of the CP clock pulse after the S3 single key is pressed, and outputs the key number until the effective trigger edge of the next CP clock pulse 0010; at the beginning of the effective trigger edge of the next CP clock pulse, until the effective trigger edge of the next CP clock pulse after the end of the S3 single key press maintenance state, the encoder 300 outputs the key number 0011; therefore it can be seen that, When the recognized state of the matrix keyboard is maintained, the duration for which the encoder 300 outputs valid key numbers is adapted to the duration of the maintained state.
当键盘的状态或操作为表1中所述的6个有效的键盘操作与状态之外时,编码器300输出无效键号1111。无论是输出有效键号,还是输出无效键号,编码器300改变输出内容的时刻为CP时钟脉冲的有效触发沿;实施例中,编码器300改变输出内容的时刻为CP时钟脉冲的上升沿。When the state or operation of the keyboard is out of the six valid keyboard operations and states described in Table 1, the encoder 300 outputs an invalid key number 1111 . Whether outputting a valid key number or an invalid key number, the moment when the encoder 300 changes the output content is the valid trigger edge of the CP clock pulse; in the embodiment, the moment when the encoder 300 changes the output content is the rising edge of the CP clock pulse.
CP时钟脉冲的周期为矩阵式键盘的扫描周期。键盘扫描周期在20ms以上时,能够有效地避开了键盘按键抖动的影响;键盘扫描周期在100ms以下时,不至于遗漏键盘操作;因此,CP时钟脉冲的周期应该控制在20~100ms。The period of the CP clock pulse is the scanning period of the matrix keyboard. When the keyboard scanning period is above 20ms, it can effectively avoid the influence of keyboard key shake; when the keyboard scanning period is below 100ms, the keyboard operation will not be missed; therefore, the period of the CP clock pulse should be controlled at 20-100ms.
CK取样脉冲的周期要求不大于CP时钟脉冲的周期,这样,在CP时钟脉冲每个有效触发沿获取状态码时,能够保证列状态寄存器404、行状态寄存器403输出的4位键值始终为矩阵式键盘的最新状态。CK取样脉冲的特例是直接使用CP时钟脉冲作为CK取样脉冲。The period of the CK sampling pulse is required to be no greater than the period of the CP clock pulse. In this way, when the status code is obtained at each effective trigger edge of the CP clock pulse, it can be guaranteed that the 4-bit key value output by the column status register 404 and the row status register 403 is always a matrix The latest status of keyboards. A special case of the CK sampling pulse is to directly use the CP clock pulse as the CK sampling pulse.
实施例中,CP时钟脉冲、CK取样脉冲均由振荡器500产生并输出。CP时钟脉冲和CK取样脉冲也可以由矩阵式键盘扫描定位电路之外的电路或者装置提供。In the embodiment, both the CP clock pulse and the CK sampling pulse are generated and output by the oscillator 500 . The CP clock pulse and CK sampling pulse can also be provided by circuits or devices other than the matrix keyboard scanning and positioning circuit.
图4是本发明实施例的键盘状态变化脉冲产生单元的电路图。当识别的是矩阵式键盘的有效按键操作时,编码器300在该有效按键操作后的CP时钟脉冲的有效触发沿开始,至下一个CP时钟脉冲的有效触发沿为止,输出持续时间为一个CP时钟脉冲周期宽度的有效键号。接收所述矩阵式键盘输出的装置,需要时刻查询矩阵式键盘的输出,获取键号。查询的周期间隔必须小于CP时钟脉冲的周期。FIG. 4 is a circuit diagram of a keyboard state change pulse generating unit according to an embodiment of the present invention. When identifying an effective key operation of the matrix keyboard, the encoder 300 starts at the effective trigger edge of the CP clock pulse after the effective key operation, and until the effective trigger edge of the next CP clock pulse, the output duration is one CP Valid key numbers for clock pulse period width. The device receiving the output of the matrix keyboard needs to query the output of the matrix keyboard at all times to obtain the key numbers. The cycle interval of the query must be smaller than the cycle of the CP clock pulse.
图4所示电路用于判断矩阵式键盘输出的键号是否发生改变,当矩阵式键盘输出的键号发生改变时,输出键盘状态变化脉冲,用于辅助矩阵式键盘的接收装置接收矩阵式键盘输出的键号,例如,将键盘状态变化脉冲作为接收装置的中断请求信号。The circuit shown in Figure 4 is used to judge whether the key number output by the matrix keyboard changes. When the key number output by the matrix keyboard changes, the keyboard state change pulse is output, and the receiving device for assisting the matrix keyboard receives the matrix keyboard. The output key number, for example, takes the keyboard state change pulse as an interrupt request signal of the receiving device.
图4所示电路由延迟缓冲器601、异或门602、异或门603、异或门604、异或门605、或门606组成。延迟缓冲器601由只具有触发功能的4个边沿触发器组成,4个边沿触发器的触发输入端为延迟缓冲器601的接收脉冲输入端,均连接至振荡器500的CP时钟脉冲输出端;延迟缓冲器601在CP时钟脉冲的有效触发沿进行数据锁存。The circuit shown in FIG. 4 is composed of a delay buffer 601 , an exclusive OR gate 602 , an exclusive OR gate 603 , an exclusive OR gate 604 , an exclusive OR gate 605 , and an OR gate 606 . The delay buffer 601 is composed of 4 edge triggers with only trigger functions, and the trigger input terminals of the 4 edge triggers are the receiving pulse input terminals of the delay buffer 601, which are all connected to the CP clock pulse output terminal of the oscillator 500; The delay buffer 601 performs data latching on the valid trigger edge of the CP clock pulse.
延迟缓冲器601用于对编码器300的编码输出端的4位数据C3~C0分别进行延迟处理。延迟缓冲器601的4个数据输入端D63~D60连接至编码器300的编码输出端C3~C0,延迟缓冲器601的4个数据输出端Q63~Q60相应输出的数据是C31~C01;C31~C01经过延迟缓冲器601的一级缓冲后,其信号比C3~C0延迟一个CP时钟脉冲周期,图5所示为本发明实施例的键盘有效操作的相关波形示意图。设在CP时钟脉冲的T1区间,矩阵式键盘存在一次有效操作,实施例的有效操作包括:S1单键按下、S2单键按下、S3单键按下、S4+S2组合操作的S2按下、S1单键释放。在一次有效操作的下一个有效触发沿,即图5中CP时钟脉冲T1区间之后的上升沿,编码器300输出的编码C3~C0发生改变;在T2区间,编码器300输出一个周期的有效编码C3~C0;在T3、T4及之后区间,编码器300输出的编码C3~C0再一次改变且进入维持状态,该维持状态可能是例如S1单键按下后面的维持状态,输出无效键号,也可能是S3单键按下后面的维持状态,输出有效键号,直到下一次有效操作。The delay buffer 601 is used to respectively perform delay processing on the 4-bit data C3 - C0 at the encoded output end of the encoder 300 . The four data input terminals D63~D60 of the delay buffer 601 are connected to the encoding output terminals C3~C0 of the encoder 300, and the corresponding output data of the four data output terminals Q63~Q60 of the delay buffer 601 are C31~C01; C31~C01; After C01 is first buffered by the delay buffer 601, its signal is delayed by one CP clock pulse cycle than C3-C0. FIG. 5 is a schematic diagram of relevant waveforms of the effective operation of the keyboard according to the embodiment of the present invention. Set in the T1 interval of the CP clock pulse, there is an effective operation of the matrix keyboard, and the effective operations of the embodiment include: S1 single key press, S2 single key press, S3 single key press, S2 key press of S4+S2 combined operation Down, S1 single key release. On the next valid trigger edge of a valid operation, that is, the rising edge after the CP clock pulse T1 interval in Figure 5, the codes C3-C0 output by the encoder 300 change; in the T2 interval, the encoder 300 outputs a valid code of one cycle C3~C0; in T3, T4 and subsequent intervals, the codes C3~C0 output by the encoder 300 change again and enter the maintenance state. This maintenance state may be, for example, the maintenance state after the S1 single key is pressed, and an invalid key number is output. It may also be the maintenance state after the S3 single key is pressed, and the effective key number is output until the next effective operation.
图5中的D6脉冲示意表示编码器300输出的编码C3~C0是处于维持状态,没有变化,还是发生改变,实际电路中不存在所述的D6脉冲。如图5所示,D6脉冲为低电平,示意表示编码器300输出的编码C3~C0是处于维持状态,没有变化;D6脉冲为高电平,示意表示编码器300输出一个周期的有效编码C3~C0。图5中的Q6反映的是C31~C01的变化情况,显然,Q6比D6延迟一个CP时钟脉冲周期。同样,实际电路中不存在所述的Q6脉冲。The D6 pulse in FIG. 5 schematically indicates whether the codes C3-C0 output by the encoder 300 are in a maintained state, unchanged, or changed. The D6 pulse does not exist in the actual circuit. As shown in Figure 5, the D6 pulse is at a low level, which schematically indicates that the codes C3-C0 output by the encoder 300 are in a maintained state and does not change; the D6 pulse is at a high level, which schematically indicates that the encoder 300 outputs a valid code for one cycle C3~C0. What Q6 in Fig. 5 reflects is the change situation of C31~C01, obviously, Q6 delays one CP clock pulse period than D6. Likewise, the Q6 pulse does not exist in the actual circuit.
图5中,编码器300输出的编码C3~C0是处于维持状态,没有变化,还是发生改变,实际是由4位延迟缓冲器601、异或门602、异或门603、异或门604、异或门605、或门606所组成的逻辑电路完成。4个异或门分别与编码器300编码输出端C3~C0中的1位相对应,输入分别为4位延迟缓冲器601的输入、输出信号。例如,异或门602的两个输入信号分别为C0和C01,C01比C0延迟一个CP时钟脉冲周期,因此,当C0发生变化时,异或门602输出1个CP时钟脉冲周期宽度的正脉冲;当C0为一个CP时钟脉冲周期宽度变化信号时,异或门602输出2个CP时钟脉冲周期宽度的正脉冲。异或门603、异或门604、异或门605分别判断C1~C3是否发生变化,原理与判断C0是否发生变化相同。异或门602、异或门603、异或门604、异或门605的输出端分别连接至或门606的输入端,或门606用于综合判断C0~C3是否发生变化,只要C0~C3发生变化,或门606即输出键盘状态变化脉冲F,该脉冲为正脉冲。In FIG. 5 , whether the codes C3-C0 output by the encoder 300 are in a maintained state, unchanged, or changed, is actually determined by the 4-bit delay buffer 601, the exclusive OR gate 602, the exclusive OR gate 603, the exclusive OR gate 604, The logic circuit formed by the XOR gate 605 and the OR gate 606 is completed. The 4 XOR gates correspond to 1 bit of the encoding output terminals C3 - C0 of the encoder 300 respectively, and the inputs are the input and output signals of the 4-bit delay buffer 601 . For example, the two input signals of the exclusive OR gate 602 are C0 and C01 respectively, and C01 is delayed by one CP clock pulse cycle than C0, so when C0 changes, the exclusive OR gate 602 outputs a positive pulse with a width of one CP clock pulse cycle ; When C0 is a CP clock pulse cycle width change signal, the XOR gate 602 outputs a positive pulse with a CP clock pulse cycle width of 2. The XOR gate 603 , the XOR gate 604 , and the XOR gate 605 respectively judge whether C1 - C3 change, and the principle is the same as judging whether C0 changes. The output terminals of the exclusive OR gate 602, the exclusive OR gate 603, the exclusive OR gate 604, and the exclusive OR gate 605 are respectively connected to the input terminals of the OR gate 606, and the OR gate 606 is used for comprehensively judging whether C0~C3 changes, as long as C0~C3 change, the OR gate 606 outputs the keyboard state change pulse F, which is a positive pulse.
实施例中,延迟缓冲器601选择上升沿触发的8D触发器74HC273。实施例中,编码器300输出的是4位二进制键号,因此,延迟缓冲器601只需要4个D触发器。由于延迟缓冲器601中的4个D触发器和触发器101中的4个D触发器的触发输入端均连接至振荡器500的CP时钟脉冲输出端,因此,延迟缓冲器601与触发器101可共用一个8D触发器74HC273。In an embodiment, the delay buffer 601 selects a rising edge triggered 8D flip-flop 74HC273. In the embodiment, the output of the encoder 300 is a 4-bit binary key number, therefore, the delay buffer 601 only needs 4 D flip-flops. Since the trigger inputs of the four D flip-flops in the delay buffer 601 and the four D flip-flops in the flip-flop 101 are connected to the CP clock pulse output of the oscillator 500, the delay buffer 601 and the flip-flop 101 Can share an 8D flip-flop 74HC273.
延迟缓冲器601还可以采用其他方案,例如,采用RC电路,利用4个RC电路分别对C0~C3进行延迟;如果RC电路的延迟时间小于一个CP时钟脉冲周期,则编码器300输出一个周期的有效编码C3~C0时,在输出有效编码C3~C0开始和输出有效编码C3~C0结束都产生一个键盘状态变化脉冲,键盘状态变化脉冲的宽度等于RC电路延迟时间;如果RC电路的延迟时间大于等于一个CP时钟脉冲周期,则编码器300输出一个周期的有效编码C3~C0时,在输出有效编码C3~C0开始时产生一个键盘状态变化脉冲,脉冲宽度大于等于2个CP时钟脉冲周期。要求RC电路的延迟时间不超过2个CP时钟脉冲周期,以免产生漏报。Delay buffer 601 can also adopt other schemes, for example, adopt RC circuit, use 4 RC circuits to delay C0~C3 respectively; When the effective codes are C3~C0, a keyboard state change pulse is generated at the beginning of outputting effective codes C3~C0 and at the end of outputting effective codes C3~C0, and the width of the keyboard state changing pulse is equal to the delay time of the RC circuit; if the delay time of the RC circuit is greater than Equal to one CP clock pulse period, when the encoder 300 outputs one period of valid codes C3-C0, a keyboard state change pulse is generated at the beginning of outputting valid codes C3-C0, and the pulse width is greater than or equal to 2 CP clock pulse periods. It is required that the delay time of the RC circuit does not exceed 2 CP clock pulse cycles to avoid false positives.
所述的发明电路中,将对单键操作、组合键操作、键盘维持状态操作的定位,由CP脉冲扫描转换成同一二进制长度的状态码,采用统一编码的方式进行处理,单键操作、组合键操作、键盘维持状态操作仅体现在状态码的不同上;如果需要增减按键操作功能或者是调整按键操作功能,不需要修改键盘扫描电路结构,只需根据增减后的状态码表更新编码器300、即重新写入更新只读存储器的存储内容即可。所述发明电路没有使用单片机、ARM等微控制器,不用运行程序,工作可靠。In the described invention circuit, the positioning of single-key operation, combination key operation, and keyboard maintenance state operation is converted into a state code of the same binary length by CP pulse scanning, and is processed in a unified coding manner. Single-key operation, combination Key operation and keyboard maintenance state operation are only reflected in the different status codes; if you need to increase or decrease the key operation function or adjust the key operation function, you do not need to modify the structure of the keyboard scanning circuit, you only need to update the code according to the state code table after the increase or decrease device 300, that is, rewrite and update the storage content of the read-only memory. The circuit of the invention does not use microcontrollers such as single-chip microcomputers and ARMs, does not need to run programs, and works reliably.
Claims (6)
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810660969.XA CN108880561B (en) | 2016-01-05 | 2016-01-05 | Matrix type keyboard scanning and positioning method |
CN201610003614.4A CN105703780B (en) | 2016-01-05 | 2016-01-05 | Matrix keyboard Scan orientation circuit |
CN201810660631.4A CN108874167B (en) | 2016-01-05 | 2016-01-05 | Keyboard state change pulse generating circuit |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610003614.4A CN105703780B (en) | 2016-01-05 | 2016-01-05 | Matrix keyboard Scan orientation circuit |
Related Child Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810660969.XA Division CN108880561B (en) | 2016-01-05 | 2016-01-05 | Matrix type keyboard scanning and positioning method |
CN201810660631.4A Division CN108874167B (en) | 2016-01-05 | 2016-01-05 | Keyboard state change pulse generating circuit |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105703780A CN105703780A (en) | 2016-06-22 |
CN105703780B true CN105703780B (en) | 2018-09-11 |
Family
ID=56226963
Family Applications (3)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810660969.XA Expired - Fee Related CN108880561B (en) | 2016-01-05 | 2016-01-05 | Matrix type keyboard scanning and positioning method |
CN201610003614.4A Active CN105703780B (en) | 2016-01-05 | 2016-01-05 | Matrix keyboard Scan orientation circuit |
CN201810660631.4A Expired - Fee Related CN108874167B (en) | 2016-01-05 | 2016-01-05 | Keyboard state change pulse generating circuit |
Family Applications Before (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810660969.XA Expired - Fee Related CN108880561B (en) | 2016-01-05 | 2016-01-05 | Matrix type keyboard scanning and positioning method |
Family Applications After (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810660631.4A Expired - Fee Related CN108874167B (en) | 2016-01-05 | 2016-01-05 | Keyboard state change pulse generating circuit |
Country Status (1)
Country | Link |
---|---|
CN (3) | CN108880561B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1815416A (en) * | 2005-02-01 | 2006-08-09 | 艾默生网络能源系统有限公司 | Keyboard circuit |
CN1949288A (en) * | 2006-11-24 | 2007-04-18 | 苏州市华芯微电子有限公司 | Variable length coding method and circuit thereof |
CN101840268A (en) * | 2010-04-23 | 2010-09-22 | 中国电子科技集团公司第五十四研究所 | Method for fast scanning and positioning of matrix keyboard |
Family Cites Families (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
SU1005011A1 (en) * | 1981-06-09 | 1983-03-15 | Уфимский Ордена Ленина Авиационный Институт Им.Орджоникидзе | Data input device |
JPS6062259A (en) * | 1983-09-16 | 1985-04-10 | Hitachi Ltd | data transmission equipment |
JPS61161836A (en) * | 1985-01-11 | 1986-07-22 | Nec Corp | Switch signal coding device |
CN1049415A (en) * | 1989-08-09 | 1991-02-20 | 东少青 | Abacus interface arrangement of general computer |
US5274371A (en) * | 1991-01-29 | 1993-12-28 | Industrial Technology Research Institute | Extended time-shared scanning keyboard interface |
JP2950458B2 (en) * | 1993-12-28 | 1999-09-20 | 株式会社河合楽器製作所 | Electronic musical instrument |
US7177775B2 (en) * | 2005-04-29 | 2007-02-13 | International Business Machines Corporation | Testable digital delay line |
CN101789793A (en) * | 2010-01-15 | 2010-07-28 | 电子科技大学中山学院 | Determinant linear array coordinate scanning circuit |
CN106342405B (en) * | 2010-09-14 | 2014-05-14 | 中国航空工业集团公司雷华电子技术研究所 | Digital radar frequency synthesizer controls pulse-generating circuit |
CN202059394U (en) * | 2011-05-09 | 2011-11-30 | 广州励丰声光科技有限公司 | Matrix keyboard scanning device based on programmable element |
CN103279197B (en) * | 2013-06-08 | 2015-12-09 | 湖南工业大学 | A kind of Scan orientation method of keyboard |
-
2016
- 2016-01-05 CN CN201810660969.XA patent/CN108880561B/en not_active Expired - Fee Related
- 2016-01-05 CN CN201610003614.4A patent/CN105703780B/en active Active
- 2016-01-05 CN CN201810660631.4A patent/CN108874167B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1815416A (en) * | 2005-02-01 | 2006-08-09 | 艾默生网络能源系统有限公司 | Keyboard circuit |
CN1949288A (en) * | 2006-11-24 | 2007-04-18 | 苏州市华芯微电子有限公司 | Variable length coding method and circuit thereof |
CN101840268A (en) * | 2010-04-23 | 2010-09-22 | 中国电子科技集团公司第五十四研究所 | Method for fast scanning and positioning of matrix keyboard |
Also Published As
Publication number | Publication date |
---|---|
CN108874167A (en) | 2018-11-23 |
CN105703780A (en) | 2016-06-22 |
CN108880561A (en) | 2018-11-23 |
CN108880561B (en) | 2022-03-18 |
CN108874167B (en) | 2021-02-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105468164B (en) | Matrix keyboard scanner uni coding circuit | |
CN105677055B (en) | matrix keyboard scanning circuit and method | |
CN105703780B (en) | Matrix keyboard Scan orientation circuit | |
CN205490496U (en) | A Matrix Keyboard Operation Recognition and Encoding Circuit | |
CN205318331U (en) | Matrix type keyboard scanning and coding circuit | |
CN105677054B (en) | Independent keyboard Scan orientation circuit | |
CN205485933U (en) | Matrix type keyboard scans positioning circuit | |
CN105700698B (en) | Matrix keyboard state recognition and coding circuit | |
CN205320063U (en) | Matrix type keyboard state recognition and coding circuit | |
CN105677052B (en) | Independent keyboard state identification and coding circuit | |
CN105680875B (en) | Matrix keyboard operation identification and coding circuit | |
CN105700696B (en) | Matrix keyboard scanning encoding circuit | |
CN105677053B (en) | Independent keyboard operation identification and coding circuit | |
CN105700695B (en) | Matrix keyboard scanning circuit and coding circuit | |
CN105680874B (en) | Matrix keyboard scanning circuit and scanning encoding method | |
CN105680873B (en) | Independent keyboard scanning encoding circuit | |
CN205384582U (en) | Matrix type keyboard scanning circuit and coding circuit | |
CN205490497U (en) | Stand alone type keyboard scan positioning circuit | |
CN205334379U (en) | Stand alone type keyboard state recognition and coding circuit | |
CN205318332U (en) | Discernment of stand alone type key board operation and coding circuit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20191029 Address after: 221300, Fumin Road, Pizhou hi tech Industrial Development Zone, Xuzhou, Jiangsu, 22 Patentee after: Pizhou hi tech Zone New Energy Technology Research Institute Co., Ltd. Address before: 412007 School of industry, research and production, Hunan University of Technology, 88 West Taishan Road, Zhuzhou, Hunan Patentee before: Hunan University of Technology |
|
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20210304 Address after: 221300 No.56, paoche street, Pizhou City, Xuzhou City, Jiangsu Province Patentee after: Pizhou Jingpeng Venture Capital Co., Ltd Address before: 221300 22 Fu Min Road, hi tech Industrial Development Zone, Pizhou, Xuzhou, Jiangsu Patentee before: PIZHOU HIGH-TECH ZONE NEW ENERGY TECHNOLOGY RESEARCH INSTITUTE Co.,Ltd. |
|
TR01 | Transfer of patent right |