CN107872230A - A kind of scanning detecting circuit and method of detectable multiple any combination buttons - Google Patents
A kind of scanning detecting circuit and method of detectable multiple any combination buttons Download PDFInfo
- Publication number
- CN107872230A CN107872230A CN201710744604.0A CN201710744604A CN107872230A CN 107872230 A CN107872230 A CN 107872230A CN 201710744604 A CN201710744604 A CN 201710744604A CN 107872230 A CN107872230 A CN 107872230A
- Authority
- CN
- China
- Prior art keywords
- button
- data
- key
- mcu
- scanning
- 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
-
- 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)
- Input From Keyboards Or The Like (AREA)
Abstract
A kind of scanning detecting circuits and method of detectable multiple any combination buttons, on software, in Scanning Detction link, the mode for taking double of recurrence packet carries out detection scanning;If wherein button corresponding to half is not pressed, the key scan of this half is directly exited;Therefore, which has preferably adapted to button in the time of the overwhelming majority mostly in the practical application upspring, so as to improve MCU operating efficiency.On hardware, diode or logic circuit are taken in all row ports corresponding to matrix press-key, its logic output terminal mouth is given to MCU interruption pin as external interrupt signal source, with reference to Data Analysis Services link mode in software, it can be achieved in the case of being pressed without any button, MCU can handle other tasks, until responding new external interrupt signal;Therefore, the processing mode also greatly improves MCU operating efficiency.
Description
Technical field
The present invention relates to combination button detection, especially a kind of scanning detecting circuit of detectable multiple any combination buttons
And method.
Background technology
Keyboard is the necessary input equipment of many electronic products.Generally, extensive keyboard has three kinds of design methods, and first
Kind is to use keyboard special coding chip, and button is inputted according to row and column, and the data after coding are exported with USB interface.The method
Need keyboard special coding chip and design USB interface, add design complexity.Second is that button is respectively connected into CPLD
IO pin, using CPLD I/O pin more than advantage each key-press status is judged respectively and result is output to processing
Unit, the method need to increase CPLD chips, add hardware cost.The third is the universal matrix keyboard designed using MCU,
Button is allowed to be linked into the corresponding row and column of matrix, the method has the advantages that cost is cheap, it is few to take hardware resource.Using MCU
The matrix keyboard of design can realize the function of single button and simple combination button, but be difficult to some complex combination buttons
Function, thus significantly limit using MCU design matrix keyboard needing the application of combinational logic button occasion.For existing
There is the function of being difficult to complex combination button in technology in matrix keyboard, not yet propose effective solution at present.
The content of the invention
The technical problems to be solved by the invention are to provide a kind of Scanning Detction electricity of detectable multiple any combination buttons
Road and method, circuit structure is simple, the reliable and stable detection of achievable larger matrix press-key, achievable any amount,
The combination function of any button, solves key mapping collision problem.
In order to solve the above technical problems, the technical scheme is that:A kind of detectable multiple any combination buttons are swept
Detection circuit is retouched, including:
MCU, the MCU are provided with altogether M+N+1 I/O pin, one of I/O pin band external interrupt function;
Matrix press-key circuit, the matrix press-key circuit include M bars transverse legs and N bars longitudinal direction branch road.Transverse legs with
Longitudinal branch road infall forms a key mapping, and M bars transverse legs are crossed to form the key of M × N number of matrix distribution with N bars longitudinal direction branch road
Position;Each key mapping corresponds to a diode, an electric capacity and a contact-making switch, the anode of diode and is connected with transverse legs,
The negative electrode of diode is connected by ceramic condenser with longitudinal branch road, and contact-making switch is in parallel with electric capacity;Each button represents unique one
Individual key;M transversal I O port is formed in the first end of transverse legs, N number of longitudinal IO ends are formed in the first end of longitudinal branch road
Mouthful, the transversal I O port and longitudinal I/O port are connected with MCU I/O pin;Second end of longitudinal branch road passes through pull-up resistor
It is connected afterwards with power supply VCC, when no any button is pressed, all transversal I O ports are pulled upward to high level by power supply VCC;Laterally
By being connected after first resistor with power supply VCC, first resistor plays level transmission and prevented when button is pressed at second end of branch road
Only corresponding transversal I O port and the short circuit of longitudinal I/O port;
Or logic circuit, including M diode, power supply VCC and resistance R113, each diode pair answer a transversal I O end
Mouthful, the diode, power supply VCC and resistance R113 form all transversal I O ports, and power supply VCC passes through resistance R113 and diode
Anode connects, and the I/O pin that power supply VCC is exported to port INT, port INT and MCU external interrupt function by resistance R113 connects
Connect.
As an improvement, the resistance of the pull-up resistor is 10K Ω.
As an improvement, the resistance of the first resistor is 100 Ω.
The scanning detection method of the detectable multiple any combination buttons of the present invention, comprises the following steps:
(1) after the upper electricity of MCU, all I/O port states are initialized at once;
(2) if MCU response externals are interrupted, into the Scanning Detction process of button;It is described to sweep
Retouching detection process includes two links:
(2.1) Scanning Detction link:Detection to all matrix press-keys is, it is necessary to by a multiple scanning for taking turns another wheel
Journey;
(2.2) Data Analysis Services link, Data Analysis Services link need following steps:
1. after Current Scan terminates, all key-press status data are stored in Buf core buffers;Pressed all
Button all find out, this kind of button value is one by one matched with dead key set, if matching find have what is pressed
Button is dead key, then exits when previous wheel scan, waits next round, meanwhile, MCU upper layer applications function returns to the number that reports an error
Value;
2. it will be contrasted when the key scan result of previous round and previous round, the first two wheel;If the scanning knot of continuous 3 wheel
Fruit is consistent, then once will also meet continuous 3 wheel testing result before the data in the Buf of previous round and previous preservation
Consistent BufPrev buffer datas are contrasted, if it is inconsistent, terminating to work as previous wheel scan, wait next round;
3. if the result of Buf and BufPrev contrasts is consistent, illustrate that no any button is pressed or upspring, directly
Connect and enter the following 5. individual step;, whereas if inconsistent, then contrast and to find Buf different from each in BufPrev
The data of bit;The location of data by the different bits, can position unique 1 has the button and its key to change
Code;And by the change of bit, learn that the button is upspring or pressed;
4. on the basis of 3., tentatively judge whether some button pressed is just to have pressed one by one, if preliminary true
Button is recognized to upspring, then the release time of corresponding button is arranged to 0;, whereas if tentatively confirm that button, will be preliminary to press
Data corresponding to the button for confirming as pressing are added in Buf2;
5. using the function of timer internal Interruption, pressing the time and releasing for all buttons in Buf2 is updated one by one
Put the time;
6. judging whether single button is finally confirmed as upspringing one by one, that is, judge following 3 conditions:
A this button data in Buf2) be present;
B)ReleaseTime>=T discharges threshold value;
C) KeyStatus is to upspring;
If 3 conditions more than meeting, the data of the release button are removed in Buf2, and layer functions are sent upwards
The message of single-button release;Otherwise, step is jumped to 7.;
7. judging whether single button is finally confirmed as pressing one by one, that is, judge following 3 conditions:
A this button data in Buf2) be present;
B)ReleaseTime>=T presses lower threshold value;
C) KeyStatus is to press;
If 3 conditions more than meeting, and layer functions send the message that single-button is pressed upwards;Otherwise, step is jumped to
Suddenly 8.;
8. judging whether combination button is finally confirmed as pressing one by one, the button while satisfaction following 3 of all compositions are judged
Individual condition:
A) there are all required button datas in Buf2 simultaneously;
B)ReleaseTime>=T presses lower threshold value;
C) KeyStatus is to press;
If 3 conditions more than meeting, the related data of the Macintosh is put into Buf3;By the Macintosh in Buf3
Flag bit flag be masked as 1, it was demonstrated that the combination button set up;And upward layer functions send Macintosh and press message;Otherwise,
Jump to step 9.;
9. judging whether combination button is finally confirmed as discharging one by one, that is, judge that all composition buttons meet following 3 bars
Part:
A) there are the data of the Macintosh in Buf3;
B) the flag positions in the Buf3 combination key datas are establishment;
C) no longer while meet (i.e. any one condition is invalid) in 3 conditions that 8. step is mentioned;
If 3 conditions more than meeting, upward layer functions send Macintosh release message, and by the combination in Buf3
The data of key are deleted;Otherwise, step is jumped to 10.;
10. Buf data are replaced to BufPrev data;
Using the function of timer internal Interruption, TimerBuf2 timers are updated;
Judge whether the button data in Buf2 is empty and TimerBuf2 time-out, is appointed if it is, exiting key scan
Business, until responding external interrupt next time;Otherwise, directly exit, wait next round key scan.
As an improvement, in the step (1), specific initialization task includes:1) longitudinal I/O port is arranged to export,
And output low level;2) transversal I O port is arranged to input;3) interrupt pin INT is arranged to trailing edge external interrupt, and
Enabled external interrupt;4) (timer is used to record some button duration t) being pressed opening timing device.
As an improvement, in the Scanning Detction link, the overall process scanning of each round, log2 (N) individual stage, nothing are segmented again
By which time Scanning Detction in which stage, MCU has carried out Scanning Detction process same as below:1) MUC according to work as
Preceding residing stage, the level for setting certain specified longitudinal I/O port are low, and remaining is height;2) MCU reads all transversal I O ports
Low and high level, and recording level state;3) state that will 2) obtain, carried out one by one with extra buffer BufTmp data
Contrast, if the state is existing, the number for corresponding to same state adds up to add 1;Conversely, increase the state in BufTmp
Data, and the number of the state is initialized as 1;4) it is delayed some nanoseconds;5) repeatedly 2)~4) identical operation totally 10 times,
And detect those most data of cumulative number in BufTmp, if only unique 1, if it is not, then continue to repeat 2)~
4) operation, until the most data of number are unique;6) the most data of number in BufTmp are taken out, by the data
Cumulative number with setting threshold comparison;If cumulative number meets to be more than or equal under conditions of the threshold value, MCU is returned
The data, so far, this Scanning Detction process terminate;The operation if condition can not be met, repeatedly 2)~5), until meeting
Condition.
Brief description of the drawings
Fig. 1 is matrix press-key circuit diagram.
Fig. 2 is logical circuitry.
Fig. 3 is double of partitioning algorithm flow chart of row port recursion of matrix press-key.
Fig. 4 is the Scanning Detction algorithm flow chart of matrix press-key.
Fig. 5 is the algorithm flow chart of the analyzing and processing link of button data.
Embodiment
With reference to Figure of description, the invention will be further described.
A kind of scanning detecting circuit of detectable multiple any combination buttons, including:MCU, 16 × 16 matrix press-key circuits
And or logic circuit.
The MCU is provided with altogether 16+16+1 I/O pin, one of I/O pin band external interrupt function.
As shown in figure 1, the matrix press-key circuit includes 16 transverse legs ROW0~ROW15 and 16 longitudinal branch roads
COL0~COL15, transverse legs form a key mapping, 16 transverse legs and 16 longitudinal branch road phases with longitudinal branch road infall
Hand over the key mapping for forming 16 × 16 matrix distributions.Each key mapping corresponding a diode, an electric capacity and a contact-making switch, two
The anode of pole pipe is connected with transverse legs, and the negative electrode of diode is connected by ceramic condenser with longitudinal branch road, contact-making switch and electricity
Hold in parallel;Each button represents only one key;Electric capacity on each node is to button landing low jitter to a certain extent
Effect, makes MCU testing results more reliable, and the diode of node plays a part of to prevent key mapping conflict.The first of transverse legs
End forms 16 transversal I O ports, and 16 longitudinal I/O ports are formed in the first end of longitudinal branch road, the transversal I O port and vertical
It is connected to I/O port with MCU I/O pin.Connect after the pull-up resistor that second end of longitudinal branch road passes through 10K Ω with power supply VCC
Connect, when no any button is pressed, all transversal I O ports are pulled upward to high level by power supply VCC.Second end of transverse legs
By being connected after 100 Ω first resistor with power supply VCC, first resistor plays level transmission and prevented correspondingly when button is pressed
Transversal I O port and longitudinal I/O port short circuit.
As shown in Fig. 2 or logic circuit includes M diode, power supply VCC and resistance R113, each diode pair answer one
Individual transversal I O port, the diode, power supply VCC and resistance R113 form all transversal I O ports, and power supply VCC passes through resistance
R113 is connected with diode anode, and power supply VCC is exported to port INT by resistance R113.Port INT and MCU external interrupt work(
The I/O pin connection of energy.In practical application, most of the time button is all in the state upspring, all transversal I O ports
It is high level to be pulled up as high level, port INT.MCU does not receive the signal of external interrupt, and in this case, MCU can locate
Manage other tasks;If conversely, be pressed when at least one button, according to or logic circuit, port INT is by some diode
Clamper is to low level, and the interrupt signal for producing a trailing edge is given to MCU, and MCU responses can deploy whole matrix immediately after interrupting
The Scanning Detction work of button.
The scanning detection method of the detectable multiple any combination buttons of the present invention, comprises the following steps:
(1) first, after the upper electricity of MCU, all I/O port states are initialized at once.Following initialization is specifically done to appoint
Business:
1) col0~col15 is arranged to export, and exports low level;
2) row0~row15 is arranged to input (it is preferably provided as band weak pull-up to input);
3) interrupt pin INT is arranged to trailing edge external interrupt, and enabled external interrupt;
4) opening timing device (being used to record the effect such as some button duration t being pressed).
(2) if MCU response externals are interrupted, into the Scanning Detction process of button, this process subdivision is examined for scanning
Survey, Data Analysis Services totally 2 links:
(I) Scanning Detction link
Detection to all matrix press-keys is, it is necessary to by a multiple scanning process for taking turns another wheel;The scanning of each round it
Between can be spaced a bit of free time (time can not be oversize, and than convenient within 3ms, MCU can handle it in these free times
Its task), and the overall process of each round scans, segmenting following 4 stages again, (log 2 (columns 16)=4, specific explanations are such as
Under).
1st stage, when MCU receive INT interrupt after, illustrate affirm at least one button be pressed, MCU by col0~
Col15 is divided to be half-and-half front and rear two groups:(col0~col7), (col8~col15), totally 2 groups, MCU successively distinguishes in the same manner
Handling key scan corresponding to the row port of this two halves, i.e. MCU first drags down all row ports (col0~col7) of the first half, then
Check whether all row ports have pin to be pulled low;If nothing, the key scan of this current half is directly exited;If
Have, then into second stage, continue current row port dividing half, be scanned in a similar way.
2nd stage, MCU respectively by the first stage division two groups of row ports (col0~col7), (col8~col15) according to
It is secondary to be divided into (col0~col3), (col4~col7), (col8~col11), (col12~col15), totally 4 groups, with identical
Mode, MCU are scanned respectively to this 4 groups, for example, (col0~col3) is all dragged down to (remaining row port is to high level),
Then it is low level to detect all row ports whether to have pin;If it is not, exit the scanning of the current group;Conversely, then enter
Enter next sweep phase.
3rd stage, MCU in the same way, on the basis of the division in the 2nd stage, continue half-and-half to divide, by all row ends
Mouth successively divide (col0, col1), (col2, col3), (col4, col5), (col6, col7), (col8, col9), (col10,
Col11), (col12, col13), (col14, col15), totally 8 groups, equally, MCU carries out key scan in a similar way.
4th stage, MCU in the same way, on the basis of the division in the 3rd stage, continue half-and-half to divide, now, altogether
16 groups are divided, each group is a corresponding independent row, and certain port arranged is dragged down and (put high level in remaining port) by MCU, Ran Houjian
Survey whether all row ports are pulled low;If it is not, exit the scanning currently organized;Conversely, next MCU will analyze the row
Whether corresponding button is pressed or is upspring.It is with other different places of preceding 3 stages, the group institute of the 4th divided stages
Comprising columns, be always 1 row, this explanation MCU is in this current stage, it is already possible to judges to correspond to all buttons on the row
State can be decided.Therefore, MCU needs to do a thing more in this stage, is exactly by the state preservation of all buttons
Get off, be stored in Buf core buffer, the state of each button is recorded with 1 bit, is represented to press for 1, is
0 represents to upspring, for 4*4 matrix press-keys, it is necessary to 16bit space, i.e. two bytes.
After all row all undergo the scanning in the 4th stage, the now Buf buffer records nearest shape of current all buttons
State.As shown in figure 3, on the Software for Design of reality, the scanning of double of division enumerated above is completed using recursive mode
Detection process.So far, the scanning process of a wheel terminates, and waits the same scanning process of next round.
As shown in figure 4, no matter which time Scanning Detction in which in stage, MCU carried out scanning same as below
Detection process.The process is detected using the method for " multiple repairing weld takes maximum probability ", ensures the reliability of testing result, is had
Body is as follows:
(1) MUC is according to the stage being presently in, and the level for setting the I/O port for specifying some row is low, and remaining is height;
(2) MCU reads the I/O port low and high level of all rows, and recording level state;
(3) state for obtaining (2), contrasted one by one with extra buffer BufTmp data;If the shape
State is existing, then the number for corresponding to same state adds up to add 1;Conversely, increase the data of the state in BufTmp, and should
The number of state is initialized as 1;
(4) it is delayed some nanoseconds;
(5) (2)~(4) identical operation totally 10 times is repeated, and detects those data that cumulative number is most in BufTmp,
Whether unique 1 is only had;If it is not, then continue to repeat the operation of (2)~(4), until the most data of number are unique;
(6) the most data of number in BufTmp are taken out, by the cumulative number of the data and the threshold comparison of setting.
If cumulative number meets to be more than or equal under conditions of the threshold value, MCU returns to the data;So far, this Scanning Detction process
Terminate.If the condition can not be met, the operation of (2)~(5) is repeated, until meeting condition.
(II) Data Analysis Services link
As shown in figure 5, Data Analysis Services link needs following steps:
1. after Current Scan terminates, all key-press status data are stored in Buf core buffers, are pressed all
Button all find out, one by one one by one (need not in design on i.e. some nodes with dead key set by this kind of button value
Add button, key assignments corresponding to this kind of node formed into a set, here abbreviation dead key set) matched;If matching hair
The existing button pressed is dead key, then exits when previous wheel scan, waits next round, meanwhile, MCU upper layer application functions return
Return wrong numerical value (developer can investigate and positioning circuit problem or software issue according to the method that this is detected self).
2. will be contrasted when key scan result of previous round and previous round, the first two wheel, will continuously before and after 3 wheel scans
The Buf buffer datas detected are contrasted;If the scanning result of continuous 3 wheel is consistent, by when in the Buf of previous round
Data once and meet that the consistent BufPrev buffer datas of continuous 3 wheel testing result are contrasted with before previous preservation;
If it is inconsistent, terminating to work as previous wheel scan, next round is waited.
3. if the result of Buf and BufPrev contrasts is consistent, illustrate that no any button is pressed or upspring, directly
Connect and enter the following 5. individual step;, whereas if inconsistent, then contrast and to find Buf different from each in BufPrev
The data of bit, by the location of data of the different bits, can position unique 1 has the button and its key to change
Code (key mapping);And by the change of bit, learn that the button is upspring or pressed;Specifically, the such as in BufPrev the 0th
Individual (being counted from 0) bit data is 0, becomes the 0th bit data 1 in Buf, learns that the 0th button of matrix is pressed.
4. on the basis of 3., tentatively judge whether some button pressed is just to have pressed (last round of shape one by one
State shows the button just to press to upspring, and currently to press);, will corresponding button if tentatively confirming button to upspring
Release time be arranged to 0;, whereas if tentatively confirming button to press, counted corresponding to the button that tentatively will confirm as pressing
According to (including key KeyValue, state KeyStatus, press time PressTime, release time ReleaseTime), addition
Into Buf2;
5. using the function of timer internal Interruption, pressing the time and releasing for all buttons in Buf2 is updated one by one
Put the time:
A) for tentatively confirming as the button just pressed, it is pressed time PressTime and is initialized as 0;
B) for tentatively confirming as the button just upspring, its release time, ReleaseTime was initialized as 0;
C) for other buttons, update it and press time and release time.
6. judging whether single button is finally confirmed as upspringing one by one, that is, judge following 3 conditions:
A this button data in Buf2) be present;
B)ReleaseTime>=T discharges threshold value;
C) KeyStatus is to upspring;
If 3 conditions more than meeting, the data of the release button are removed in Buf2, and layer functions are sent upwards
The message of single-button release;Otherwise, step is jumped to 7..
7. judge whether single button is finally confirmed as pressing one by one.Judge following 3 conditions:
A this button data in Buf2) be present;
B)ReleaseTime>=T presses lower threshold value;
C) KeyStatus is to press;
If 3 conditions more than meeting, and layer functions send the message that single-button is pressed upwards;Otherwise, step is jumped to
Suddenly 8..
8. judging whether combination button is finally confirmed as pressing one by one, the button while satisfaction following 3 of all compositions are judged
Individual condition:
A) there are all required button datas in Buf2 simultaneously;
B)ReleaseTime>=T presses lower threshold value;
C) KeyStatus is to press;
If 3 conditions more than meeting, the related data of the Macintosh is put into Buf3;By the Macintosh in Buf3
Flag bit flag be masked as 1, it was demonstrated that the combination button set up;And upward layer functions send Macintosh and press message;Otherwise,
Jump to step 9..
9. judging whether combination button is finally confirmed as discharging one by one, that is, judge that all composition buttons meet following 3 bars
Part:
A) there are the data of the Macintosh in Buf3;
B) the flag positions in the Buf3 combination key datas are establishment;
C) no longer while meet (i.e. any one condition is invalid) in 3 conditions that 8. step is mentioned;
If 3 conditions more than meeting, upward layer functions send Macintosh release message, and by the combination in Buf3
The data of key are deleted;Otherwise, step is jumped to 10..
10. Buf data are replaced to BufPrev data.
Using the function of timer internal Interruption, TimerBuf2 timers are updated.
Judge whether the button data in Buf2 is empty and TimerBuf2 time-out;Appoint if it is, exiting key scan
Business, until responding external interrupt next time;Otherwise, directly exit, wait next round key scan.
This matrix press-key Scanning Detction scheme, do to disappear to button in several details of the angle of following software and hardware and trembled
Processing, improve the Stability and dependability of the detection scheme.
1) in hardware design, button one 10pF of the parallel connection electric capacity on each node, on hardware to a certain degree
On reduce the degree of jitter of button;
2) on software, in key scan detection in the processing of Scanning Detction each time in each stage, adopt
Take Multiple-Scan to take the scanning result of maximum probability, and required that the scanning result of maximum probability meets certain number side's conduct
Judged result the most last;
3) in Data Analysis Services link, the processing searched with dead key set (if any) contrast is added, is realized
The self-checking function of software view;
4) in Data Analysis Services link, no matter the judgement to single-button or combination button, it is required to the more than
2. walking this committed step, that is, in the case of meeting that the result of the key scan detection of continuous 3 wheel is completely the same, ensure button
Data it is reliable and stable enough, could carry out next step button data analyzing and processing etc. operation.Therefore, button is greatly reduced
The probability of erroneous judgement;
5) in Data Analysis Services link, no matter the judgement pressed and discharge operation to single-button or combination button,
All require respectively by the 3. with after the 4. " preliminary to confirm " of step, from the 6. to the final of the 9. these key-press status
Confirmation all introduces " pressing the time " and " release time " of button, that is, can be final after being required to meet the threshold condition of time
Confirm;
6) in Data Analysis Services link, byWithThe two steps are using the mode of the similar the 5) point, i.e., super
When threshold decision, to improve the degree of accuracy of the judgement of " being pressed for a long time without button " such case, reduce False Rate.
The present invention improves MCU operating efficiency in following treatment of details:(1) on software, in Scanning Detction link
On, the mode for taking double of recurrence packet carries out detection scanning;If wherein button corresponding to half is not pressed, to this
The key scan of half directly exits;Therefore, which preferably adapted to button the overwhelming majority time in be in mostly
The practical application upspring, so as to improve MCU operating efficiency.(2) on hardware, in all rows corresponding to matrix press-key
Diode or logic circuit are taken in port, and its logic output terminal mouth is given to MCU interruption pin as external interrupt signal source, knot
Data Analysis Services link mode in software is closed, can be achieved in the case of being pressed without any button, MCU can handle other tasks,
Until responding new external interrupt signal;Therefore, the processing mode also greatly improves MCU operating efficiency.
Claims (6)
- A kind of 1. scanning detecting circuit of detectable multiple any combination buttons, it is characterised in that including:MCU, the MCU are provided with altogether M+N+1 I/O pin, one of I/O pin band external interrupt function;Matrix press-key circuit, the matrix press-key circuit include M bars transverse legs and N bars longitudinal direction branch road, transverse legs and longitudinal direction Branch road infall forms a key mapping, and M bars transverse legs are crossed to form the key mapping of M × N number of matrix distribution with N bars longitudinal direction branch road; Each key mapping corresponds to a diode, an electric capacity and a contact-making switch, the anode of diode and is connected with transverse legs, two poles The negative electrode of pipe is connected by ceramic condenser with longitudinal branch road, and contact-making switch is in parallel with electric capacity;Each button represents only one key Code;M transversal I O port is formed in the first end of transverse legs, N number of longitudinal I/O port, institute are formed in the first end of longitudinal branch road State transversal I O port and longitudinal I/O port is connected with MCU I/O pin;Second end of longitudinal branch road by after pull-up resistor with Power supply VCC connections, when no any button is pressed, all transversal I O ports are pulled upward to high level by power supply VCC;Transverse legs The second end by being connected after protective resistance with power supply VCC, protective resistance plays level transmission and prevented when button is pressed pair The transversal I O port answered and the short circuit of longitudinal I/O port;Or logic circuit, including M diode, power supply VCC and resistance R113, each diode pair answer a transversal I O port, The diode, power supply VCC and resistance R113 form all transversal I O ports, and power supply VCC passes through resistance R113 and diode sun Pole is connected, and power supply VCC is exported to port INT, port INT by resistance R113 and is connected with the I/O pin of MCU external interrupt functions.
- 2. the scanning detecting circuit of detectable multiple any combination buttons according to claim 1, it is characterised in that:It is described The resistance of pull-up resistor is 10K Ω.
- 3. the scanning detecting circuit of detectable multiple any combination buttons according to claim 1, it is characterised in that:It is described The resistance of protective resistance is 100 Ω.
- A kind of 4. method for the scanning detecting circuit that multiple any combination buttons are can detect such as claim 1, it is characterised in that bag Include following steps:(1) after the upper electricity of MCU, all I/O port states are initialized at once,(2) if MCU response externals are interrupted, into the Scanning Detction process of button;The Scanning Detction process includes two Link:(2.1) Scanning Detction link:Detection to all matrix press-keys is, it is necessary to by a multiple scanning process for taking turns another wheel;(2.2) Data Analysis Services link, Data Analysis Services link need following steps:1. after Current Scan terminates, all key-press status data are stored in Buf core buffers;By it is all press by Key is all found out, and this kind of button value is one by one matched with dead key set, if matching finds there is the button pressed For dead key, then exit when previous wheel scan, wait next round, meanwhile, MCU upper layer applications function returns to the numerical value that reports an error;2. it will be contrasted when the key scan result of previous round and previous round, the first two wheel;If the scanning result one of continuous 3 wheel Cause, then by when the data in the Buf of previous round are with being also once to meet that continuous 3 wheel testing result is consistent before previous preservation BufPrev buffer datas are contrasted, if it is inconsistent, terminating to work as previous wheel scan, wait next round;3. if the result of Buf and BufPrev contrasts is consistent, illustrates that no any button is pressed or upspring, directly enter Enter to the following 5. individual step;, whereas if it is inconsistent, then contrast and find Buf bits different from each in BufPrev Data;The location of data by the different bits, can position unique 1 has the button and its key to change; And by the change of bit, learn that the button is upspring or pressed;4. on the basis of 3., tentatively judge whether some button pressed is just to have pressed one by one, if preliminary confirm to press The release time of corresponding button is then arranged to 0 by key to upspring;, whereas if tentatively confirm that button to press, will tentatively confirm The data corresponding to the button pressed are added in Buf2;5. using the function of timer internal Interruption, when pressing time and release of all buttons in Buf2 is updated one by one Between;6. judging whether single button is finally confirmed as upspringing one by one, that is, judge following 3 conditions:A this button data in Buf2) be present;B)ReleaseTime>=T discharges threshold value;C) KeyStatus is to upspring;If 3 conditions more than meeting, the data of the release button are removed in Buf2, and layer functions send individual palpation upwards The message of key release;Otherwise, step is jumped to 7.;7. judging whether single button is finally confirmed as pressing one by one, that is, judge following 3 conditions:A this button data in Buf2) be present;B)ReleaseTime>=T presses lower threshold value;C) KeyStatus is to press;If 3 conditions more than meeting, and layer functions send the message that single-button is pressed upwards;Otherwise, step is jumped to 8.;8. judging whether combination button is finally confirmed as pressing one by one, judge the button of all compositions while meet following 3 bars Part:A) there are all required button datas in Buf2 simultaneously;B)ReleaseTime>=T presses lower threshold value;C) KeyStatus is to press;If 3 conditions more than meeting, the related data of the Macintosh is put into Buf3;By the mark of the Macintosh in Buf3 Will position flag is masked as 1, it was demonstrated that the combination button is set up;And upward layer functions send Macintosh and press message;Otherwise, jump to Step is 9.;9. judging whether combination button is finally confirmed as discharging one by one, that is, judge that all composition buttons meet following 3 conditions:A) there are the data of the Macintosh in Buf3;B) the flag positions in the Buf3 combination key datas are establishment;C) no longer while meet (i.e. any one condition is invalid) in 3 conditions that 8. step is mentioned;If 3 conditions more than meeting, upward layer functions send Macintosh release message, and by the Macintosh in Buf3 Data are deleted;Otherwise, step is jumped to 10.;10. Buf data are replaced to BufPrev data;Using the function of timer internal Interruption, TimerBuf2 timers are updated;Judge whether the button data in Buf2 is empty and TimerBuf2 time-out, if it is, exiting key scan task, directly To response external interrupt next time;Otherwise, directly exit, wait next round key scan.
- 5. the scanning detection method of detectable multiple any combination buttons according to claim 4, it is characterised in that:It is described In step (1), specific initialization task includes:1) longitudinal I/O port is arranged to export, and exports low level;2) transversal I O port is arranged to input;3) interrupt pin INT is arranged to trailing edge external interrupt, and enabled external interrupt;4) opening timing device, for recording some button duration t being pressed.
- 6. the scanning detection method of detectable multiple any combination buttons according to claim 4, it is characterised in that:It is described In Scanning Detction link, the overall process scanning of each round, log is segmented again2N number of stage, no matter which in stage which time Scanning Detction, MCU have carried out Scanning Detction process same as below:1) MUC is according to the stage being presently in, and the level for setting certain specified longitudinal I/O port is low, and remaining is height;2) MCU reads all transversal I O port low and high levels, and recording level state;3) state that will 2) obtain, contrasted one by one with extra buffer BufTmp data, if the state has been deposited The number for then corresponding to same state is accumulative plus 1;Conversely, increase the data of the state in BufTmp, and by the state Number is initialized as 1;4) it is delayed some nanoseconds;5) repeating 2)~4) identical operates 10 times totally, and detects those data that cumulative number is most in BufTmp, if only Have unique 1, if it is not, then continue repeat 2)~4) operation, until the most data of number are unique;6) the most data of number in BufTmp are taken out, by the cumulative number of the data and the threshold comparison of setting;If Cumulative number meets to be more than or equal under conditions of the threshold value, and MCU returns to the data, and so far, this Scanning Detction process terminates; The operation if condition can not be met, repeatedly 2)~5), until meeting condition.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710744604.0A CN107872230B (en) | 2017-08-25 | 2017-08-25 | Scanning detection circuit and method capable of detecting multiple keys combined arbitrarily |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710744604.0A CN107872230B (en) | 2017-08-25 | 2017-08-25 | Scanning detection circuit and method capable of detecting multiple keys combined arbitrarily |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107872230A true CN107872230A (en) | 2018-04-03 |
CN107872230B CN107872230B (en) | 2021-06-25 |
Family
ID=61761899
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710744604.0A Active CN107872230B (en) | 2017-08-25 | 2017-08-25 | Scanning detection circuit and method capable of detecting multiple keys combined arbitrarily |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107872230B (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109189435A (en) * | 2018-09-21 | 2019-01-11 | 英业达科技有限公司 | The firmware update of Complex Programmable Logic Devices |
CN109298331A (en) * | 2018-11-29 | 2019-02-01 | 郭玉森 | Low cost can detect the detection circuit and processing method of multiple any combination keys |
CN109361400A (en) * | 2018-12-03 | 2019-02-19 | 天津七二移动通信有限公司 | A kind of intelligence key module and its implementation |
CN110109788A (en) * | 2019-04-30 | 2019-08-09 | 惠州Tcl移动通信有限公司 | More key detecting methods, device, electronic equipment and storage medium |
CN110954804A (en) * | 2019-12-19 | 2020-04-03 | 上海御渡半导体科技有限公司 | Device and method for accurately diagnosing cBit array faults in batch |
CN111600591A (en) * | 2020-07-27 | 2020-08-28 | 北京维普无限智能技术有限公司 | Key identification method and system of matrix keyboard |
CN112200584A (en) * | 2020-11-05 | 2021-01-08 | 加减信息科技(深圳)有限公司 | Input circuit of payment acceptance terminal |
CN113422610A (en) * | 2021-06-18 | 2021-09-21 | 河南翔宇医疗设备股份有限公司 | Key detection method, device, equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS61267119A (en) * | 1985-05-22 | 1986-11-26 | Hitachi Ltd | Key scan controlling circuit for key inputting device |
CN2816909Y (en) * | 2004-10-14 | 2006-09-13 | 上海环达计算机科技有限公司 | Keyboard scanning device |
CN202189321U (en) * | 2011-06-30 | 2012-04-11 | 长城信息产业股份有限公司 | Key mapping conflict-free keyboard |
CN102662394A (en) * | 2012-05-08 | 2012-09-12 | 清华大学 | Fault simulation device for automobile electric power-assisted steering system |
-
2017
- 2017-08-25 CN CN201710744604.0A patent/CN107872230B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS61267119A (en) * | 1985-05-22 | 1986-11-26 | Hitachi Ltd | Key scan controlling circuit for key inputting device |
CN2816909Y (en) * | 2004-10-14 | 2006-09-13 | 上海环达计算机科技有限公司 | Keyboard scanning device |
CN202189321U (en) * | 2011-06-30 | 2012-04-11 | 长城信息产业股份有限公司 | Key mapping conflict-free keyboard |
CN102662394A (en) * | 2012-05-08 | 2012-09-12 | 清华大学 | Fault simulation device for automobile electric power-assisted steering system |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109189435A (en) * | 2018-09-21 | 2019-01-11 | 英业达科技有限公司 | The firmware update of Complex Programmable Logic Devices |
CN109298331A (en) * | 2018-11-29 | 2019-02-01 | 郭玉森 | Low cost can detect the detection circuit and processing method of multiple any combination keys |
CN109298331B (en) * | 2018-11-29 | 2021-09-24 | 郭玉森 | Low-cost detection circuit capable of detecting multiple keys combined arbitrarily and processing method |
CN109361400A (en) * | 2018-12-03 | 2019-02-19 | 天津七二移动通信有限公司 | A kind of intelligence key module and its implementation |
CN110109788A (en) * | 2019-04-30 | 2019-08-09 | 惠州Tcl移动通信有限公司 | More key detecting methods, device, electronic equipment and storage medium |
CN110109788B (en) * | 2019-04-30 | 2023-11-10 | 惠州Tcl移动通信有限公司 | Multi-key detection method and device, electronic equipment and storage medium |
CN110954804A (en) * | 2019-12-19 | 2020-04-03 | 上海御渡半导体科技有限公司 | Device and method for accurately diagnosing cBit array faults in batch |
CN111600591A (en) * | 2020-07-27 | 2020-08-28 | 北京维普无限智能技术有限公司 | Key identification method and system of matrix keyboard |
CN112200584A (en) * | 2020-11-05 | 2021-01-08 | 加减信息科技(深圳)有限公司 | Input circuit of payment acceptance terminal |
CN113422610A (en) * | 2021-06-18 | 2021-09-21 | 河南翔宇医疗设备股份有限公司 | Key detection method, device, equipment and storage medium |
CN113422610B (en) * | 2021-06-18 | 2023-09-05 | 河南翔宇医疗设备股份有限公司 | Key detection method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN107872230B (en) | 2021-06-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107872230A (en) | A kind of scanning detecting circuit and method of detectable multiple any combination buttons | |
Kautz | Testing for faults in wiring networks | |
EP0225761B1 (en) | Apparatus and method for calculating cyclical redundancy codes | |
EP0230730B1 (en) | CRC calculation machines | |
US6874107B2 (en) | Integrated testing of serializer/deserializer in FPGA | |
EP0226353B1 (en) | Crc calculation apparatus | |
CN101995956B (en) | Keyboard, keyboard scanning circuit and method | |
CN108241322B (en) | Optimized configuration generation method for FPGA interconnection resources | |
CN107016223B (en) | Hardware Trojan resistant chip design method and system | |
CN111027102A (en) | High-safety configurable RO-PUF circuit structure | |
CN115130413A (en) | Topological structure design method of field programmable gate array and electronic equipment | |
CN107239620A (en) | A kind of anti-hardware Trojan horse method of designing integrated circuit and system | |
US11444607B2 (en) | Many-bit, groupable, reconfigurable, multi-valued, electronic operator and its construction method | |
CN105874713B (en) | A kind of expansible configurable logic element and FPGA device | |
CN109884499B (en) | Method for testing artificial intelligence module on system chip and system chip | |
KR900008804B1 (en) | Look ahead terminal counter | |
JP2004531141A (en) | Digital system and error detection method for the digital system | |
CN105956178B (en) | Key node extracting method based on gate level circuit emulation | |
CN102147720B (en) | Device and method for realizing operation among multiple input logical terms by using LUT | |
Nirmalraj et al. | Automatic diagnosis of single fault in interconnect testing of SRAM‐based FPGA | |
CN105243188B (en) | A kind of intelligent substation monitoring information amount auto-screening method | |
US20050138523A1 (en) | Scalable cyclic redundancy check circuit | |
US7253657B2 (en) | Apparatus and methods for configuration of programmable logic devices | |
CN111294040A (en) | Reconfigurable combinational logic unit based on static circuit | |
CN205562741U (en) | Built -in test circuit of many function chip |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder |
Address after: 510820, Guangzhou, Guangdong province Huadu District charcoal step Feida Industrial Park Patentee after: Guangzhou Feida Audio Co.,Ltd. Patentee after: GUANGZHOU XINGGUANG AUDIO AND VIDEO CULTURAL TECHNOLOGY CO.,LTD. Address before: 510820, Guangzhou, Guangdong province Huadu District charcoal step Feida Industrial Park Patentee before: FIRST AUDIO MANUFACTURING Co.,Ltd. Patentee before: GUANGZHOU XINGGUANG AUDIO AND VIDEO CULTURAL TECHNOLOGY CO.,LTD. |
|
CP01 | Change in the name or title of a patent holder |