CN104461035A - MCU keyboard circuit capable of enabling multiple keys to be pressed simultaneously and implementation method thereof - Google Patents
MCU keyboard circuit capable of enabling multiple keys to be pressed simultaneously and implementation method thereof Download PDFInfo
- Publication number
- CN104461035A CN104461035A CN201410626425.3A CN201410626425A CN104461035A CN 104461035 A CN104461035 A CN 104461035A CN 201410626425 A CN201410626425 A CN 201410626425A CN 104461035 A CN104461035 A CN 104461035A
- Authority
- CN
- China
- Prior art keywords
- mcu
- button
- pwm value
- keyboard circuit
- pressed
- 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.)
- Granted
Links
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
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Input From Keyboards Or The Like (AREA)
Abstract
The invention provides an MCU keyboard circuit capable of enabling multiple keys to be pressed simultaneously and an implementation method thereof. The keyboard circuit comprises an MCU, M keys from S1 to SM, M resistors from R1 to RM, a common resistor, a voltage/frequency converter, a Schmitt trigger and a NOR gate. One end of the Ri is connected to a VCC power source, the other end of the Ri is connected to one end of the key Si (1<=i<=M), and the other ends of all the keys are connected to a point A and are connected with the ground through the common resistor. The point A is connected with the input end of the voltage/frequency converter and the input end of the Schmitt trigger. The output end of the voltage/frequency converter is connected to one input end of the NOR gate, and the output end of the Schmitt trigger is connected to the other input end of the NOR gate, or the output end of the NOR gate is connected to a pin INT1 of the MCU. By means of the MCU keyboard circuit, hardware resources of the MCU are greatly saved, the processing time for pressing the multiple keys simultaneously is greatly shortened, and therefore the MCU keyboard circuit has the advantages of being simple, effective, reliable and the like.
Description
Technical field
The present invention relates to keyboard technique field, particularly relate to a kind of simple, efficient, special save MCU hardware resource process the MCU keyboard circuit and its implementation that many buttons press simultaneously.
Background technology
The implementation method of the keyboard circuit of usual MCU is as follows:
(1) stand-alone keypad method
Usually, when key number is not more than 8, can adopt in this way, each button connects the I/O line of a MCU, like this, has several button just to need to take the I/O line of several MCU, it is more that this method takies MCU hardware resource, when multikey is pressed simultaneously, need to process multikey value with software, the CPU more time can be taken.
(2) matrix keyboard method
Usually, when key number is greater than 8, this method of many employings, becomes matrix form by key arrangement, the ranks of matrix is connected to the I/O line of MCU, the I/O line number of shared MCU is line number and the columns sum of this matrix, now, when there being multiple key to press simultaneously, also need the key assignments be concurrently depressed by software Treatment Analysis, program is more complicated, takies CPU time more.
The implementation method of above-mentioned two kinds of keyboard circuits, the I/O line of shared MCU is more, so just to the trouble needing the MCU system connecting more peripheral hardware to bring I/O inadequate resource, simultaneously in said method when processing multiple button and being concurrently depressed, all adopt the method for software to realize, the CPU more time can be taken like this, reduce system effectiveness.
Summary of the invention
The object of the present invention is to provide and a kind ofly process the MCU keyboard circuit and its implementation that many buttons press simultaneously, solve the problem of the I/O inadequate resource of MCU system in prior art;
Another object of the present invention is to provide a kind of and process the MCU keyboard circuit and its implementation that many buttons press simultaneously, overcome the defect taking the excess CPU time in prior art when multiple button that Treatment Analysis is concurrently depressed.
The object of the invention is to be achieved through the following technical solutions.
Process the MCU keyboard circuit that many buttons are pressed simultaneously, comprise MCU and M button S1 ~ SM, also comprise: with button M resistance R1 ~ RM, common resistance, electric voltage/frequency converter one to one, Schmidt trigger, rejection gate;
Wherein, one end (1≤i≤M) that one end of Ri is connected to VCC power supply, the other end is connected to button Si, the other end of button S1 ~ SM is all by common resistance ground connection;
The link be connected with common resistance of described button S1 ~ SM is all connected to A point, and A point is connected respectively with the input end of electric voltage/frequency converter and the input end of Schmidt trigger;
The output terminal of electric voltage/frequency converter is connected to an input end of rejection gate, and the output terminal of Schmidt trigger is connected to another input end of rejection gate, the output terminal of rejection gate be connected to MCU /INT1 pin;
When pressing without button, A point voltage is low, and Schmidt trigger exports as high level, and rejection gate exports as low level, and signal/INT1 is invalid for MCU interruption; When a button is pressed, A point produces certain magnitude of voltage, the input end of Schmidt trigger produces by no-voltage to the change on positive voltage, MCU interruption signal/INT1 is effective, current one or more button be pressed of pwm value identification that MCU outputs signal according to electric voltage/frequency converter.
Wherein, include counter in described MCU, this counter starts counting at described/INT1 pin, stops counting when described/INT1 pin is low level when being high level, for measuring the pwm value of described electric voltage/frequency converter output signal.
Wherein, described A point is also by electric capacity C1 ground connection.
An implementation method for the MCU keyboard circuit that many buttons are pressed simultaneously can be processed as above, comprising: initialization step, and the recognition by pressing keys method when there being one or more button to be concurrently depressed;
Described initialization step comprises: definition push key zone bit juxtaposition initial value zero; Pulsewidth buffer zone is set and resets; Open MCU external interrupt and to be set to negative edge effective; The mapping relations table of the pwm value that various key information when different key or multiple button being simultaneously pressed and V/F output signal is stored in appointed buffer;
Described recognition by pressing keys method comprises:
When key flag bit is set, the pwm value of measuring voltage/frequency converter output signal, and read pwm value, stored in pulsewidth buffer zone by MCU external interrupt;
In the keystroke handling function of master routine, according to described pwm value and current one or more button be pressed of described mapping relations table identification.
Wherein, measure by the counter in MCU the pwm value that V/F exports pulse, described counter starts counting at described/INT1 pin, stops counting when described/INT1 pin is low level when being high level.
Wherein, when according to described pwm value and described mapping relations table identification current key information, first pwm value data corresponding to current key information and last pwm value data are removed, as basis of characterization after averaging to other pwm value data.
Wherein, also comprise: go forward side by side after row relax identifying current key information, described key flag bit is reset.
Compared with prior art, beneficial effect of the present invention is:
(1) adopt resistor network and electric voltage/frequency converter combined techniques to realize keyboard circuit, save MCU resource simple, efficient, especially, multikey can be processed press simultaneously;
(2) adopt the I/O line of a MCU to start MCU counter records pwm value, and read pwm value by interruption method, finally by the method for pwm value identification key assignments, special hardware resource and the time saving CPU;
(3) coordinating by electric capacity and Schmidt trigger, the validity of system, reliability is improved.
Accompanying drawing explanation
Fig. 1 is MCU keyboard circuit schematic diagram in the embodiment of the present invention;
Fig. 2 is the implementation method process flow diagram of MCU keyboard circuit in the embodiment of the present invention.
Fig. 3 is the fundamental diagram of MCU Counter in the embodiment of the present invention;
Fig. 4 is the waveform schematic diagram of B, C, D 3 in Fig. 1.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
Refer to Fig. 1, the MCU keyboard circuit that the present invention proposes comprises: M button S1, S2 ..., SM, and with button M resistance R1, R2 ..., RM one to one, common resistance, electric capacity, electric voltage/frequency converter (V/F), Schmidt trigger, rejection gate, MCU.In the present embodiment, the value of M is 8, namely includes 8 buttons and 8 resistance R.
Wherein, one end (1≤i≤M) that one end of Ri is connected to VCC power supply, the other end is connected to button Si, the other end of all button S is simultaneously by common resistance R9 ground connection.In addition, the link be connected with common resistance R9 of whole button S is connected to a bit (being set to A point in the present embodiment), and A point is connected respectively with the input end of V/F and the input end of Schmidt trigger.The output terminal of V/F is connected to an input end of rejection gate, and the output terminal of Schmidt trigger is connected to another input end of rejection gate, the output terminal of rejection gate be connected to MCU /INT1 pin.In addition, A point is also by electric capacity C1 ground connection, and its object is: one is the input of stable V/F; Two is when there being little burr to come, and it filters the interference of burr together with Schmidt trigger, ensures the validity of interrupting.
In above-mentioned MCU keyboard circuit, when pressing without button, A point voltage is low, and Schmidt trigger exports as high level, and rejection gate exports as low level, and signal/INT1 is invalid for MCU interruption; When a button is pressed, A point produces certain magnitude of voltage, the input end of Schmidt trigger produces by no-voltage to the change on positive voltage, MCU interruption signal/INT1 is effective, current one or more button be pressed of pwm value identification that MCU outputs signal according to electric voltage/frequency converter.
Refer to shown in Fig. 2, in the present embodiment, the implementation method of MCU keyboard circuit comprises:
201, initialization step.
Specifically comprise: definition push key zone bit juxtaposition initial value zero; Pulsewidth buffer zone is set and resets; Initialization is carried out to MCU counter; Open MCU external interrupt and to be set to negative edge effective; When different key or multiple button are pressed simultaneously and the corresponding relation data of pwm value that output signal of V/F stored in appointed buffer.
Wherein, as shown in Figure 3, its initial method is specially counter: by the C/T position 0 i.e. timing mode of counter, TR1 puts 1, GATE sets to 0, add 1 counter initial value TH1, TL1 and be all set to 0, visible, only have/INT1 pin is high level, counter is just started working, when/INT1 pin becomes low level, add 1 counter and just stop counting, the value now adding 1 counter (TH1 with TL1) is multiplied with the machine cycle (the crystal oscillator cycles of 12 times) just corresponding to the width (as T) of D point pulse in Fig. 1.When/INT1 pin becomes low level from high level, produce external interrupt, in interrupt function, read the value adding 1 counter, i.e. pwm value, and stored in pulsewidth buffer zone, and TH1 and TL1 is reset.
Step 202, find a button is pressed time, set key flag bit.
Step 203, the pwm value outputed signal by the counter measures electric voltage/frequency converter of MCU, and read pwm value, stored in pulsewidth buffer zone by MCU external interrupt.
The output waveform of V/F is as the waveform of B point in Fig. 4, when different buttons is pressed or multiple button is concurrently depressed, A point all will produce different voltage, then V/F also correspondingly can export the pulse signal of different frequency, that is, all corresponding to the pwm value that B point is different when different single buttons is pressed or multiple different button is concurrently depressed, thus the present embodiment reads the basis for estimation of pwm value as subsequent keys identification.
In the present embodiment, in Fig. 1, the waveform schematic diagram of B, C, D each point as shown in Figure 4, and the pulsewidth of B point pulse signal is different along with the difference of button; When not having key to be pressed, C point is high level, and when there being key to be pressed, C point becomes low level; B, C produce D point after rejection gate, D point connect MCU /INT1, it has two effects: one starts counter when being high level, makes counter start counting, and two make MCU generation external interrupt when being its negative edges, and stop counter works.As seen from Figure 4, when there being button to press, when D point is high level, start counter, during D point negative edge, generation/INT1 interrupts, and stops counter works simultaneously, and in interrupt routine, read the value of TH1 and TL1 of counter, i.e. pwm value, stored in pulsewidth buffer zone.
Step 204, in the keystroke handling function of master routine, according to described pwm value and current one or more key information be pressed of mapping relations table identification of prestoring.
In this step, keystroke handling function read the pwm value relevant to current button go forward side by side row relax time, preferably remove first pwm value data corresponding to current button and last pwm value data, other data are averaged.
205, key flag bit is reset.Owing to identifying the current key value be pressed, so now need, by button flag clear, to return step 201, when a button is pressed next time, again produce and interrupt and carry out follow-up recognition by pressing keys.
In sum, (1) the present invention adopts resistor network and voltage/frequency transformation approach, different single button is pressed or multiple key presses simultaneously time, its pulse width corresponding to the output signal of V/F is different, by obtaining the pwm value of the output signal of V/F, identify that the button be pressed is which or which.
(2) method of this reading key assignments, taking the hardware resource few (only need use a counter and an external interrupt of MCU, an I/O line) of MCU, taking the time of CPU also seldom (mainly through having interrupted).
(3) can identify that certain single button or certain several button are pressed simultaneously, different and identify according to the pwm value of V/F corresponding under different situations output signal.
(4) method adopting electric capacity and Schmidt trigger to combine, make keyboard when not having key to be pressed or being subject to environmental interference, counter is failure to actuate, and does not record the pulsewidth of V/F output signal, does not also produce MCU interruption; When the button is pressed, counter 1 just starts the pulsewidth recording V/F output signal, and after the time of a pulsewidth terminates, external interrupt 1 will be triggered.
(5) after entering external interrupt 1 interrupt routine, put button mark, read the value adding 1 counter in counter 1, i.e. pwm value, and stored in pulse-width data buffer zone.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.
Claims (7)
1. can process the MCU keyboard circuit that many buttons are pressed simultaneously, comprise MCU and M button S1 ~ SM, it is characterized in that, also comprise: with button M resistance R1 ~ RM one to one, common resistance, electric voltage/frequency converter, Schmidt trigger, rejection gate;
Wherein, one end (1≤i≤M) that one end of Ri is connected to VCC power supply, the other end is connected to button Si, the other end of button S1 ~ SM is all by common resistance ground connection;
The link be connected with common resistance of described button S1 ~ SM is all connected to A point, and A point is connected respectively with the input end of electric voltage/frequency converter and the input end of Schmidt trigger;
The output terminal of electric voltage/frequency converter is connected to an input end of rejection gate, and the output terminal of Schmidt trigger is connected to another input end of rejection gate, the output terminal of rejection gate be connected to MCU /INT1 pin;
When pressing without button, A point voltage is low, and Schmidt trigger exports as high level, and rejection gate exports as low level, and signal/INT1 is invalid for MCU interruption; When a button is pressed, A point produces certain magnitude of voltage, the input end of Schmidt trigger produces by no-voltage to the change on positive voltage, MCU interruption signal/INT1 is effective, current one or more button be pressed of pwm value identification that MCU outputs signal according to electric voltage/frequency converter.
2. can process the MCU keyboard circuit that many buttons are pressed simultaneously as claimed in claim 1, it is characterized in that, counter is included in described MCU, this counter starts counting at described/INT1 pin, stops counting when described/INT1 pin is low level when being high level, for measuring the pwm value of described electric voltage/frequency converter output signal.
3. can process the MCU keyboard circuit that many buttons are pressed simultaneously as claimed in claim 2, it is characterized in that, described A point is also by electric capacity C1 ground connection.
4. the implementation method processing the MCU keyboard circuit that many buttons are pressed simultaneously as described in as arbitrary in claims 1 to 3, is characterized in that, comprising: initialization step, and the recognition by pressing keys method when there being one or more button to be concurrently depressed;
Described initialization step comprises: definition push key zone bit juxtaposition initial value zero; Pulsewidth buffer zone is set and resets; Open MCU external interrupt and to be set to negative edge effective; The mapping relations table of the pwm value that various key information when different key or multiple button being simultaneously pressed and V/F output signal is stored in appointed buffer;
Described recognition by pressing keys method comprises:
When key flag bit is set, the pwm value of measuring voltage/frequency converter output signal, and read pwm value, stored in pulsewidth buffer zone by MCU external interrupt;
In the keystroke handling function of master routine, according to described pwm value and current one or more button be pressed of described mapping relations table identification.
5. can process the implementation method of the MCU keyboard circuit that many buttons are pressed simultaneously as claimed in claim 4, it is characterized in that, in the method, measure by the counter in MCU the pwm value that V/F exports pulse, described counter starts counting at described/INT1 pin, stops counting when described/INT1 pin is low level when being high level.
6. can process the implementation method of the MCU keyboard circuit that many buttons are pressed simultaneously as claimed in claim 4, it is characterized in that, in the method, when according to described pwm value and described mapping relations table identification current key information, remove first pwm value data corresponding to current key information and last pwm value data, as basis of characterization after averaging to other pwm value data.
7. can process the implementation method of the MCU keyboard circuit that many buttons are pressed simultaneously as claimed in claim 4, it is characterized in that, the method also comprises: go forward side by side after row relax identifying current key information, described key flag bit reset.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410626425.3A CN104461035B (en) | 2014-11-10 | 2014-11-10 | Many buttons can be processed while the MCU keyboard circuits pressed and its implementation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410626425.3A CN104461035B (en) | 2014-11-10 | 2014-11-10 | Many buttons can be processed while the MCU keyboard circuits pressed and its implementation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104461035A true CN104461035A (en) | 2015-03-25 |
CN104461035B CN104461035B (en) | 2017-06-20 |
Family
ID=52907226
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410626425.3A Active CN104461035B (en) | 2014-11-10 | 2014-11-10 | Many buttons can be processed while the MCU keyboard circuits pressed and its implementation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104461035B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105227188A (en) * | 2015-09-29 | 2016-01-06 | 深圳市新国都支付技术有限公司 | A kind of many key press detecting circuits |
CN107332568A (en) * | 2017-06-06 | 2017-11-07 | 京信通信系统(中国)有限公司 | Key encoding circuit and keyboard scanning circuit |
CN111238150A (en) * | 2020-01-16 | 2020-06-05 | 长虹美菱股份有限公司 | Refrigerator control method based on composite keys |
CN111399412A (en) * | 2020-03-25 | 2020-07-10 | 佛山科学技术学院 | Function generator based on single chip microcomputer and frequency-voltage conversion chip |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010050883A1 (en) * | 2000-06-07 | 2001-12-13 | Pierre-Andre Farine | Portable object with a wristband including a keyboard |
CN201859203U (en) * | 2010-11-03 | 2011-06-08 | 中航华东光电有限公司 | Key detection circuit of a singlechip or microprocessor with an analog-digital converter |
CN102594362A (en) * | 2011-12-06 | 2012-07-18 | 广东九联科技股份有限公司 | Key circuit based on analog-digital conversion |
CN102857231A (en) * | 2012-06-26 | 2013-01-02 | 惠州市德赛西威汽车电子有限公司 | Key testing circuit |
CN102868392A (en) * | 2011-07-06 | 2013-01-09 | 广东万和新电气股份有限公司 | Portability key circuit |
-
2014
- 2014-11-10 CN CN201410626425.3A patent/CN104461035B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010050883A1 (en) * | 2000-06-07 | 2001-12-13 | Pierre-Andre Farine | Portable object with a wristband including a keyboard |
CN201859203U (en) * | 2010-11-03 | 2011-06-08 | 中航华东光电有限公司 | Key detection circuit of a singlechip or microprocessor with an analog-digital converter |
CN102868392A (en) * | 2011-07-06 | 2013-01-09 | 广东万和新电气股份有限公司 | Portability key circuit |
CN102594362A (en) * | 2011-12-06 | 2012-07-18 | 广东九联科技股份有限公司 | Key circuit based on analog-digital conversion |
CN102857231A (en) * | 2012-06-26 | 2013-01-02 | 惠州市德赛西威汽车电子有限公司 | Key testing circuit |
Non-Patent Citations (1)
Title |
---|
高培先: "《一种独立式键盘电路及其中断程序设计》", 《设计与应用》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105227188A (en) * | 2015-09-29 | 2016-01-06 | 深圳市新国都支付技术有限公司 | A kind of many key press detecting circuits |
CN105227188B (en) * | 2015-09-29 | 2018-07-31 | 深圳市新国都支付技术有限公司 | A kind of more key press detecting circuits |
CN107332568A (en) * | 2017-06-06 | 2017-11-07 | 京信通信系统(中国)有限公司 | Key encoding circuit and keyboard scanning circuit |
CN107332568B (en) * | 2017-06-06 | 2020-07-07 | 京信通信系统(中国)有限公司 | Key coding circuit and keyboard scanning circuit |
CN111238150A (en) * | 2020-01-16 | 2020-06-05 | 长虹美菱股份有限公司 | Refrigerator control method based on composite keys |
CN111399412A (en) * | 2020-03-25 | 2020-07-10 | 佛山科学技术学院 | Function generator based on single chip microcomputer and frequency-voltage conversion chip |
Also Published As
Publication number | Publication date |
---|---|
CN104461035B (en) | 2017-06-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104461035A (en) | MCU keyboard circuit capable of enabling multiple keys to be pressed simultaneously and implementation method thereof | |
CN106292981B (en) | A kind of server master board application method and system | |
US10409936B2 (en) | Method and apparatus for modelling power consumption of integrated circuit | |
CN103576816B (en) | Switching on and shutting down control circuit | |
CN107305526B (en) | Debugger for microcontroller | |
CN208140901U (en) | A kind of server power supply real time monitoring apparatus | |
TWI521220B (en) | Timing analysis method for integrated circuit and computer program product thereof | |
CN103576576B (en) | A kind of multiplexing method of automobile body controller MCU port | |
CN110826112B (en) | Method and system for identifying hardware version number | |
CN104898853A (en) | Novel three-terminal tact switch | |
CN105202987A (en) | Automatic part scoring equipment for digital caliper and working method of automatic part scoring equipment | |
CN104049143A (en) | Commercial power detection device and detection method | |
CN104484305B (en) | Server debugging analysis interface device | |
CN204808309U (en) | Watchdog module IP kernel based on APB interface | |
CN105227188B (en) | A kind of more key press detecting circuits | |
CN210351233U (en) | Circuit breaker, cabinet and system | |
CN205787055U (en) | A kind of electric voltage exception fluctuation monitoring and recording instrument | |
CN104360752A (en) | MCU (micro control unit) keyboard circuit and implementation method for same | |
CN204631788U (en) | A kind of novel three end touch-switchs | |
CN203338347U (en) | Interface circuit for computer main board failure detection device | |
CN110474533B (en) | Circuit for identifying equivalent resistance in direct current converter | |
CN207799608U (en) | A kind of circuit for realizing the clear CMOS of case that exempts to be switched on by reset key | |
CN201820100U (en) | Power measurement and control system | |
CN201527648U (en) | System-on-chip data writing device | |
CN105074827A (en) | Power management for a memory device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |