Solve device, method and the keyboard scanning system of level conflict in the keyboard scan
Technical field
The present invention relates to the keyboard scan technical field, relate in particular to a kind of device, method and keyboard scanning system that solves level conflict in the keyboard scan.
Background technology
Referring to Fig. 1, Fig. 1 is the structural representation of existing 3 * 3 keyboard scanning system.Wherein, respectively corresponding three row detection lines of D1, D2 and D3; Respectively corresponding three horizontal scanning lines of S1, S2 and S3; Nine buttons of corresponding successively detection line of K11~K33 and scan line infall.Article three, the pull-up resistor of detection line correspondence is respectively: R
1, R
2And R
3In the keyboard scanning system shown in Figure 1, sweep signal on each bar scan line is produced by the assembling device with letter " X " sign, and, for detecting the button that is pressed exactly, at synchronization, from the sweep signal of three X device outputs, have only an output low level, all export high level for other two; Correspondingly, on three scan lines of synchronization, also have only one to be transfused to low level, and other two all are transfused to high level.
Among Fig. 1, the assembling device X that is used for the output scanning signal is made up of two metal-oxide semiconductor (MOS)s (MOS) pipe, wherein, and with power supply V
CcPositive pole joins is P channel MOS (PMOS) pipe, ground connection be N-channel MOS (NMOS) pipe.This assembling device has anti-phase characteristic, and the input of assembling device is the grid of above-mentioned two metal-oxide-semiconductors, and when the input input high level of assembling device, the NMOS pipe is switched on, and PMOS ends, and the output of assembling device is in the drain electrode output low level of PMOS pipe; When the input input low level of assembling device, the PMOS pipe is switched on, and the NMOS pipe ends, and the output of assembling device is at the drain electrode output high level of PMOS pipe.Circuit structure by assembling device output scanning signal among Fig. 1 is also referred to as push-pull structure, and the characteristics of this structure are exactly to export the high level of low output impedance, also can export the low level of low output impedance, therefore, has stronger load driving ability.
Fig. 2 is the key press detecting circuit schematic diagram that forms after an existing button is pressed.If the button that is pressed is K21, because after button is pressed, the time interval of the time span that detection line and scan line are switched on output scanning signal on the scan line, therefore, during this period of time, high level and low level can appear in sweep signal on the S2 in succession.Fig. 2 a is K21 when being pressed, the key press detecting circuit schematic diagram during combinations thereof device output high level.Among Fig. 2 a, under the situation that K21 is pressed, because S2 goes up the output high level, therefore, also detect high level on D1, this testing result can not determine which button is pressed.Fig. 2 b is K21 when being pressed, the key press detecting circuit schematic diagram during combinations thereof device output low level.Among Fig. 2 b, under the situation that K21 is pressed, detect low level on the D1.That is to say, K21 normally be pressed to lift during this period of time in, D1 is last can either to detect the high level shown in Fig. 2 a, also can detect the low level shown in Fig. 2 b, when on D1, detecting this low level, just can determine that a button is pressed, and can be by reading each scan line input level, with detected level on each detection line, can determine which button is pressed.Be pressed as K21, then the input level of corresponding three scan lines is respectively: 1,0,1; Corresponding three detection lines detect level: 0,1,1; Combination according to the above-mentioned two kinds of data that read: 101011, can uniquely determine that the key that is pressed promptly is K21.
For the situation of having only a button to be pressed on the same detection line, use above-mentioned system shown in Figure 1, can obtain testing result accurately.But, for the situation that has two or more buttons to be pressed on the same detection line, the phenomenon of level conflict will appear in the said system, and with the testing result that leads to errors.Reason is as follows:
Referring to Fig. 3, Fig. 3 is the key press detecting circuit figure that forms after having two buttons to be pressed on the same detection line.If the button that be pressed this moment is K21 and K31.Because assembling device A and assembling device B should be anti-phase at the level of synchronization output among Fig. 3.Therefore, can establish the grid input low level of two metal-oxide-semiconductors among the A, the output of corresponding A should be exported high level; The grid input high level of two metal-oxide-semiconductors among the B, the output of corresponding B is answered output low level.But, because K21 and K31 pressed simultaneously, the output that is equivalent to the output of A and B at the O point by short circuit, so, the phenomenon of level conflict appears at the O point.
Fig. 4 is the equivalent circuit diagram of Fig. 3.Wherein, it is all identical with the NMOS pipe to establish the PMOS pipe that A and B adopt among Fig. 3.If the internal resistance when the NMOS pipe is switched on is r
n, the internal resistance when the PMOS pipe is switched on is r
p, PMOS pipe and NMOS pipe are equivalent to resistance r among Fig. 4 among Fig. 3 so
nWith r
pCan draw D1 by Fig. 4 circuit and go up detected level, promptly the O level of ordering is:
Known resistance r
nWith r
pBe more or less the same, therefore the U that obtains
oMay be V
Cc1/2.As seen, after two buttons are pressed in same, because the short circuit of A output and B output, cause detected level on the D1 neither high level, the uncertain serious consequence of testing result appears in also non-low level.And, because resistance r
nWith r
pResistance is very little, makes A and B have stronger load driving ability, behind the output short circuit of the output of A and B, can this PMOS pipe be burnt out because of the electric current that flows through PMOS pipe among the B is excessive.
Summary of the invention
The invention provides a kind of device that solves level conflict in the keyboard scan, comprising:
Current-limiting resistance and metal-oxide semiconductor (MOS) metal-oxide-semiconductor;
Current-limiting resistance, be used to connect external power source and metal-oxide-semiconductor, the electric current of this metal-oxide-semiconductor is flow through in restriction when metal-oxide-semiconductor is switched on, and the internal resistance during the resistance value ratio metal-oxide-semiconductor conducting of current-limiting resistance exceeds several magnitude, be used for when having two or more buttons all to be pressed on the same detection line of keyboard scan array the low level of level for determining of the metal-oxide-semiconductor output of guaranteeing to be switched on;
Metal-oxide-semiconductor is used for the output scanning signal.
Preferably, described metal-oxide-semiconductor is the N-channel MOS pipe.
Preferably, the source ground of described metal-oxide-semiconductor.
Preferably, described current-limiting resistance connects the positive pole of external power source and the drain electrode of described metal-oxide-semiconductor.
Preferably, the resistance of described current-limiting resistance at 10K ohm between 100K ohm.
The invention provides a kind of keyboard scanning system, comprise N bar scan line, M bar detection line and N * M button, N 〉=2, M 〉=1, with the device that solves level conflict in the keyboard scan, the device of level conflict comprises in this solution keyboard scan: current-limiting resistance and metal-oxide semiconductor (MOS) metal-oxide-semiconductor;
Current-limiting resistance, be used to connect external power source and metal-oxide-semiconductor, the electric current of this metal-oxide-semiconductor is flow through in restriction when metal-oxide-semiconductor is switched on, and the internal resistance during the resistance value ratio metal-oxide-semiconductor conducting of current-limiting resistance exceeds several magnitude, be used for when having two or more buttons all to be pressed on the same detection line of keyboard scan array the low level of level for determining of the metal-oxide-semiconductor output of guaranteeing to be switched on;
Metal-oxide-semiconductor is used for the output scanning signal.
The invention provides a kind of method that solves level conflict in the keyboard scan, comprising:
Externally insert current-limiting resistance between power supply and the metal-oxide-semiconductor;
When utilizing current-limiting resistance restriction metal-oxide-semiconductor to be switched on, flow through the electric current of described metal-oxide-semiconductor, and the resistance of current-limiting resistance is set, internal resistance when making it than the metal-oxide-semiconductor conducting exceeds several magnitude, when having two or more buttons all to be pressed on the same detection line in the keyboard scan array, the low level of level for determining of the metal-oxide-semiconductor output of guaranteeing to be switched on.
Preferably, described metal-oxide-semiconductor is the N-channel MOS pipe.
Preferably, the source ground of described metal-oxide-semiconductor.
Preferably, the resistance of described current-limiting resistance at 10K ohm between 100K ohm.
The technical scheme that is provided by the invention described above as seen, the device and method of level conflict is by utilizing current-limiting resistance in the solution keyboard scan provided by the invention, when the metal-oxide-semiconductor conducting, the electric current of this metal-oxide-semiconductor is flow through in restriction, thereby will be from the metal-oxide-semiconductor output level limiting that is switched in low level, like this, have on the same detection line in the keyboard scan array under the situation that two or more buttons all are pressed, the low level of level for determining of the metal-oxide-semiconductor output that can guarantee to be switched on, solve the level conflict problem, guarantee to obtain correct testing result on the detection line.
Description of drawings
Fig. 1 is existing 3 * 3 keyboard scanning system;
Fig. 2 is the key press detecting circuit schematic diagram that forms after an existing button is pressed;
Fig. 3 is the key press detecting circuit figure that forms after having two buttons to be pressed on the same detection line;
Fig. 4 is the equivalent circuit diagram of Fig. 3;
Fig. 5 is the schematic representation of apparatus that solves level conflict in the keyboard scan in a preferred embodiment of the present invention;
Fig. 6 is the structural representation of keyboard scanning system in the embodiment of the invention;
Fig. 7 is the key press detecting circuit schematic diagram that forms after a button is pressed in the preferred embodiment of the present invention;
Fig. 8 is the key press detecting circuit schematic diagram that forms after two buttons are pressed in the preferred embodiment of the present invention;
Fig. 9 is the equivalent circuit diagram of Fig. 8.
Embodiment
For the purpose, technical scheme and the advantage that make the embodiment of the invention is clearer, describe in further detail below in conjunction with accompanying drawing.
The invention provides a kind of device that solves level conflict in the keyboard scan.Fig. 5 is the schematic diagram of a preferred embodiment of this device.Comprise in the device provided by the invention: current-limiting resistance and metal-oxide-semiconductor;
Current-limiting resistance is used to connect external power source and metal-oxide-semiconductor, and the electric current of this metal-oxide-semiconductor is flow through in restriction when metal-oxide-semiconductor is switched on;
Metal-oxide-semiconductor is used for the output scanning signal.Wherein, the source ground of metal-oxide-semiconductor.
Referring to Fig. 6, Fig. 6 is the structural representation of keyboard scanning system in the embodiment of the invention.This keyboard scanning system comprises N bar scan line, M bar detection line and N * M button, N 〉=2, M 〉=1, and the device of level conflict in the solution keyboard scan as shown in Figure 5.
Fig. 7 is the key press detecting circuit schematic diagram that forms after a button is pressed in the preferred embodiment of the present invention, wherein, be example with keyboard scanning system shown in Figure 6, the sweep signal of establishing on the scan line is produced by the device of level conflict in the solution keyboard scan of the present invention, and N=3, M=3.In the present embodiment, metal-oxide-semiconductor is the NMOS pipe.In Fig. 7 a, the level signal of input NMOS tube grid is a low level, correspondingly, from this NMOS pipe drain electrode output is exactly high level, after K21 is pressed, detect high level on the D1, because D1 output itself is high level, therefore, from this testing result, can not detect the incident that a button is pressed.K21 be depressed to lift during this period of time in, NMOS pipe removes can the output high level, also can output low level, accordingly, in Fig. 7 b, the level signal of input NMOS tube grid is a high level, and according to the anti-phase characteristic of NMOS pipe, drain electrode is with output low level, if the button that is pressed is K21, to detect low level so on D1, at this moment, K21 this incident that is pressed just is detected.Therefore, adopt the device of level conflict in the solution keyboard scan provided by the invention, on scan line, carry sweep signal, when a button is pressed,, can detect the incident that button is pressed from detection line according to existing testing mechanism.
The existing relatively assembling device X shown in Figure 1 of the device of level conflict in the solution keyboard scan provided by the invention, the outstanding advantage that is had is: when occurring the situation that two or more buttons all are pressed on the same detection line, when adopting the device of level conflict in the solution keyboard scan that the present invention provides, can solve the level conflict problem of mentioning in the background technology.
Fig. 8 is the key press detecting circuit schematic diagram that forms after two buttons are pressed in the preferred embodiment of the present invention.For ease of distinguishing, use R
HCurrent-limiting resistance in the expression solution keyboard scan in the device of level conflict, the pull-up resistor on the detection line D1 is still used R
1Expression.For ease of describing, represent the device of level conflict in the solution keyboard scan of scan line S2 conveying sweep signal with C; The device of representing level conflict in the solution keyboard scan of scan line S3 conveying sweep signal with D.Can establish the grid input low level of NMOS pipe among the C, the output of corresponding C should be exported high level; The grid input high level of NMOS pipe among the D, the output of corresponding D is answered output low level.After K21 and K31 all were pressed, the output of C and the output of D were connected, and the current i in the testing circuit is shown in arrow among Fig. 8.
Fig. 9 is the equivalent circuit diagram of Fig. 8, wherein, and resistance r
nInternal resistance when being the conducting of NMOS pipe.At this moment, the last detected level of D1 is the level that P is ordered among Fig. 9.In the embodiment of the invention,, calculate the P level point according to circuit diagram shown in Figure 9:
Wherein, R ' is two resistance R
HWith a R
1Resistance in parallel.The embodiment of the invention is known by inference by calculating formula (2), as long as can obtain a definite low level at the P point, and this incident that so just can detect that a button is pressed.So the embodiment of the invention is by setting R
HOne span is controlled the level that P is ordered.In the present embodiment, can be with R
HSpan be set in 10K ohm between 100K ohm.Like this, R
HOr R
1With r
nCompare, exceed several magnitude, correspondingly, guarantee that also R ' is much larger than r
nLike this, at r
nOn the voltage got, in other words, the level that P is ordered can remain on a definite low level bit, thereby guarantees can solve the level conflict problem that occurs in the background technology, and draw correct testing result when two buttons are pressed.
Device based on level conflict in the above-mentioned utilization solution keyboard scan provided by the invention, solve and mention the level conflict problem that occurs when two buttons all are pressed on the same detection line in the background technology, simple and easy derivation as can be known, adopt the device of level conflict in the solution keyboard scan provided by the invention, can solve the level conflict problem that may occur when two above buttons all are pressed on the same detection line equally, and draw correct testing result.
The present invention also provides a kind of method that solves level conflict in the keyboard scan, and the existing circuit that solves level conflict in the keyboard scan of this method improvement is by externally inserting current-limiting resistance between power supply and the metal-oxide-semiconductor; When utilizing current-limiting resistance restriction metal-oxide-semiconductor to be switched on, flow through the electric current of this metal-oxide-semiconductor.Wherein, the source ground of metal-oxide-semiconductor.After adopting said method provided by the invention to improve the circuit of existing output keyboard scanning signal, the circuit of the output keyboard scanning signal that obtains can be the above-mentioned device that the invention provides level conflict in the solution keyboard scan shown in Figure 5.
In the one embodiment of the invention, establishing above-mentioned metal-oxide-semiconductor is the NMOS pipe.In the present embodiment, the key press detecting circuit that forms after a button is pressed can be referring to shown in Figure 7.In Fig. 7 a, the level signal of input NMOS tube grid is a low level, correspondingly, from this NMOS pipe drain electrode output is exactly high level, if K21 is pressed, detect high level on the D1 this moment so, because D1 output itself is high level, therefore, from this testing result, can not detect the incident that a button is pressed.K21 be depressed to lift during this period of time in, NMOS pipe removes can the output high level, also can output low level.In Fig. 7 b, the level signal of input NMOS tube grid is a high level, according to the anti-phase characteristic of NMOS pipe, drain electrode is output low level, when K21 be depressed to lift during this period of time in, on D1, just can detect low level, like this, K21 this incident that is pressed just is detected.
If have two or more buttons to be pressed on same detection line, adopt the method for level conflict in the solution keyboard scan provided by the invention can solve the level conflict phenomenon that occurs in the above-mentioned background technology so.If there are two buttons all to be pressed on the same detection line, referring to Fig. 8, according to existing testing mechanism, when the drain electrode output low level signal of NMOS pipe among the C, the drain electrode of NMOS pipe output high level among the D.Accordingly, the grid of NMOS pipe is transfused to high level among the C, is in conducting state; And the grid of NMOS pipe is transfused to low level among the D, is in cut-off state.After K21 and K31 all were pressed, the output of C and the output of D were connected, and the electric current in the testing circuit is shown in arrow among Fig. 7.Referring to Fig. 8, after K21 and K31 all were pressed, the last detected level of D1 was the level that P is ordered among Fig. 9.According to circuit diagram shown in Figure 9, the P level point can be by aforementioned calculation formula (2) expression, and wherein, R ' is two resistance R
HWith a R
1Resistance in parallel.The embodiment of the invention is known by inference by calculating formula (2), as long as can obtain a definite low level at the P point, and this incident that so just can detect that a button is pressed.So the embodiment of the invention is by setting R
HOne span is controlled the level that P is ordered.In the present embodiment, can be with R
HSpan be set in 10K ohm between 100K ohm.Like this, R
HOr R
1With r
nCompare, exceed several magnitude, correspondingly, guarantee that also R ' is much larger than r
nLike this, at r
nOn the voltage got, in other words, the level that P is ordered can remain on a definite low level bit, thereby guarantees can solve the level conflict problem that occurs in the background technology, and draw correct testing result when two buttons are pressed.
Method based on level conflict in the above-mentioned utilization solution keyboard scan provided by the invention, solve and mention the level conflict problem that occurs when two buttons all are pressed on the same detection line in the background technology, simple and easy derivation as can be known, adopt the method for level conflict in the solution keyboard scan provided by the invention, can solve the level conflict problem that may occur when two above buttons all are pressed on the same detection line equally, and draw correct testing result.
The device or the method for level conflict are carried sweep signal in the solution keyboard scan that employing the invention described above provides on scan line, and the button that two or more all can also be pressed detects.Referring to Fig. 6, establish the output that three scan lines are keyboard scan I/O (I/O) port, three detection lines are the input of I/O port.
Introduce earlier under the situation that a button is pressed, determine the process of this button by the testing result of detection line.If button K21 is pressed, during the last output low level of S2, S1 and S3 go up the output high level; D1 last detected be exactly low level, still keep high level on D2 and the D3.Accordingly, the identification code that the I/O port reads is got is: 101011, and according to this identification code, determining the button that is pressed is K21.Among the present invention, the scheme of an above-mentioned definite button is same as the prior art.
Referring to Fig. 8, under the situation that the K21 on the D1 detection line and K31 all are pressed, adopting the device of level conflict in the solution keyboard scan provided by the invention or method can detect the level that P orders on D1 is low level, according to existing testing mechanism, can determine that a button is pressed.And, accordingly, K21 and K31 all be depressed to lift during this period of time in, the identification code that the I/O port can read is respectively: 101011 and 110011, thereby determine that the button that is pressed is K21 and K31.As seen, the present invention not only can solve the level conflict problem of mentioning in the above-mentioned background technology, under the situation that can also all be pressed at two buttons on the same detection line, identifies two buttons that are pressed.In like manner, when having two above buttons all to be pressed on the same detection line, adopt the device of level conflict in the solution keyboard scan provided by the invention or method also can identify each button that is pressed.
In sum; the device and method of level conflict is by utilizing current-limiting resistance in the solution keyboard scan provided by the invention; when the metal-oxide-semiconductor conducting; the electric current of this metal-oxide-semiconductor is flow through in restriction; thereby will be from the metal-oxide-semiconductor output level limiting that is switched in low level; like this; have on the same detection line in the keyboard scan array under the situation that two or more buttons all are pressed; the low level of level for determining of the metal-oxide-semiconductor output that can guarantee to be switched on; solve the level conflict problem; guarantee to obtain correct testing result on the detection line, also the metal-oxide-semiconductor that is switched on is played a protective role simultaneously.Said apparatus provided by the invention and method can also identify two or more buttons that are pressed on the same detection line.