1. Technical Field
The present disclosure relates to scanning circuits and scanning methods for keyboards, and particularly, to a scanning circuit and a scanning method employed in a matrix keyboard.
2. Description of the Related Art
Keyboards are widely used as input means for various electronic devices, such as computers and personal digital assistants (PDAs). Usually, each keyboard includes a plurality of keys capable of being pressed, and a scanning circuit with a row-column type wiring structure aligned with the keys. The keys are set above the intersections where the row wires cross the column wires. A plurality of switches is deposited at the intersections, with two contacts of each switch being electrically connected to one row wire and one column wire respectively. Therefore, when a key is pressed, the corresponding switch is closed by the key. The row wire and the column wire corresponding to this switch are then electrically connected together. When the scanning circuit works, the column wires are connected to output ports of a single-chip microprocessor and are set by the single-chip microprocessor to be either high or low, and the row wires are connected to input ports of the single-chip microprocessor. During scanning, each output port is sequentially set low by the single-chip microprocessor. When one of the output ports is set low, the rest of the output ports are set high. The input ports are checked to find out if any switches are closed, so as to check whether any key is pressed down.
However, such a scanning circuit occupies too many ports of a microprocessor.
Therefore, a scanning circuit and a scanning method using fewer ports are needed in the industry.
The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of scanning circuit and method for keyboard. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
Referring to
The column wires P1˜Pn+1 are each electrically connected to a power supply VCC via a resistor. The column wire Pn+1 is also grounded.
The row wires L1˜Ln are electrically connected to n ports K1˜Kn, correspondingly. The ports K1˜Kn are I/O ports of a control unit 11 such as a single-chip microprocessor (not shown). The n*n keys S1(n+1)˜Sn(n+1) are located at the intersections except those where the diodes D1˜Dn are located, the n*n keys S1(n+1)˜Sn(n+1) are connected across the column wires P1˜Pn+1 and the row wires L1˜Ln correspondingly. Taking the column wire Pn+1 and the row wire Ln as an example, the column wire Pn+1 is connected to the power supply VCC via a resistor Rn+1. The row wire Ln is connected to a port Kn. The key Sn(n+1) is connected across the row wire Ln and the column wire Pn+1.
The ports K1˜Kn are normally high by connecting to the power supply VCC via the diodes D1˜Dn. The ports K1˜Kn are sequentially set low one at time by the control unit 11 during scanning. When any of the ports K1˜Kn is set low, the corresponding column wire P1˜Pn is changed from high to low.
Referring also to
During each scan when one of the ports K1˜Kn is set low and the corresponding row and column wires are pulled low it may happen that a user pressed the corresponding key at the same moment. To avoid missing recognition of the key press, the control unit 11 is programmed to determine which key is pressed only after a whole scanning period T1 to Tn+1 expires. In other words, after each scan if one of the other pots is found to be low that information is stored, and once all scans are done, the information checked and a determination of which key was pressed if any is made. For example, during the scanning sequence T1, the port K2 is found to be low that the information is stored, when the scanning sequence counts Tn+1, if the port K2 is found to be low, then the key S2(n+1) is determined to be pressed. If the port K2 is found to be high, the key S21 is determined to be pressed.
Therefore, only n ports are used and checked to find out which one of the n*n keys is pressed.
Referring also to
Therefore, just 4 ports K1, K2, K3, and K4 are needed for a scanning circuit with 16 keys, which occupies fewer ports of a control unit 11 as compared to previous scanning circuit.
Referring to
In step S401, during the scanning sequence Tm, setting the port Km to be low, and maintaining the other ports K1˜K(m−1) and K(m+1)˜Kn to be high. Both n and m are natural numbers and m is variable from 1 to n. The row wire Lm connected to the low port Km and the column wire Pm are also pulled to be low.
In step S402, checking whether any one of the other ports K1˜K(m−1) and K(m+1)˜Kn is low. If any one of the other ports K1˜K(m−1) and K(m+1)˜Kn is low, then the procedure goes to step S403, otherwise, the procedure goes to step S404.
In step S403, determining a key crossing the column wire Pm and the row wire corresponding to the low one of the other ports K1˜K(m−1) and K(m+1)˜Kn.
In step S404, increasing the value of m by 1, and determining whether the value of m is equal to that of n. If yes, then the procedure goes to step S405, otherwise, the procedure returns to step S401.
In step S405, maintaining all the ports K1˜Kn to be high, during the scanning sequence Tn+1.
In step S406, scanning the ports K1˜Kn to find out whether any one of the ports K1˜Kn is low. If one of the ports K1˜Kn is found to be low, the procedure goes to step S407; otherwise, the procedure goes to step S408.
In step S407, determining one of the keys S1(n+1)˜Sn(n+1) connecting to the grounded column wire Pn+1 corresponding to the low one of the ports K1˜Kn is pressed, then the procedure goes to step S408.
In step S408, determining the key determined in step S403 is pressed, the procedure ends.
It is understood that the present disclosure may be embodied in other forms without departing from the spirit thereof. Thus, the present examples and embodiments are to be considered in all respects as illustrative and not restrictive, and the disclosure is not to be limited to the details given herein.
Number | Date | Country | Kind |
---|---|---|---|
201010208971.7 | Jun 2010 | CN | national |