1. Technical Field
The present disclosure relates to an electronic device with a bounce protection circuit.
2. Description of Related Art
Keys which must be physically operated generate a pressing signal for executing a corresponding function when pressed. However, the pressed mechanical key may rebound several times, thus the same corresponding pressing signal is generated repeatedly.
Therefore, there is room for improvement in the art.
Many aspects of the embodiments can be better understood with reference to the following drawings. The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the embodiments. Moreover, in the drawings, like reference numerals designate corresponding parts throughout two views.
The disclosure is illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at “least one.”
The electronic device 100 includes a first voltage module 10, a second voltage module 20, a key module 30, a processor 40, and a bounce protection circuit 50.
The first voltage module 10 provides a first voltage. In the embodiment, the first voltage is a high level voltage signal.
The second voltage module 20 connects to the first voltage module 10 through the key module 30, and provides a second voltage. In the embodiment, the second voltage is a low level voltage signal.
The key module 30 connects to the second voltage module 20 and the bounce protection module 50. The key module 30 includes a number of keys 32, 34, and 36, and generates a signal when any of the keys 32, 34, and 36 is pressed. In the embodiment, the signal is a logic low level voltage signal.
The processor 40 includes a first port P1 and a second port P2. The processor 40 sets the voltage of the first port P1 and a second port P2 according to a predetermined rule, and then detects whether the voltages of the first port P1 and the second port P2 are changed by a signal from a pressed key. When either one of the voltages of the first port P1 and the second port P2 is changed, the processor 40 recognizes the key which has been pressed and executes a corresponding function. In the embodiment, in the predetermined rule, the processor 40 firstly sets the first port P1 and the second port P2 in a logic high voltage level, and then sets the second port P2 into a logic low voltage level when neither of the voltages of the first port P1 and the second port P2 are changed. In other embodiments, the processor 40 can include more than two ports.
The bounce protection circuit 50 connects to the first voltage 10, the key module 30, and the processor 40. The bounce protection circuit 50 counts a time when any of the keys 32, 34, and 36 is pressed, and transmits the signal from the pressed key to the processor 40 when the period of accumulated time is more than a predetermined period. The bounce protection circuit 50 includes a first protection module 51 and a second protection module 52. The first protection module 51 is connected to the first port P1, and the second protection module 52 is connected to the second port P2. The keys 32, 34, and 36 correspond to different predetermined periods of time in a one-to-one relationship, and the predetermined periods of time can be set by operations of users. In other embodiments, the bounce protection circuit 50 can include more than two protection modules corresponding to the ports of the processor 40 in a one-to-one relationship.
The second voltage module 20 includes a ground port 21. In another embodiment, the second voltage module 20 further includes a pull-up resistor R5 (see
The key 32 and the key 34 are connected between the first voltage module 10 and the second voltage module 20 in parallel, opposite terminals of the key 36 are respectively connected to the bounce protection circuit 50.
The processor 40 includes a first port P1 and a second port P2. The first port P1 and the second port P2 are connected to the bounce protection circuit 50 in parallel, and are respectively connected to the first resistor R1 and the second resistor R2.
The bounce protection module 50 includes a first protection module 51 and a second protection module 52. The first protection module 51 includes a first protecting resistor R3 and a first capacitor C1. A terminal of the first protecting resistor R3 is connected to the first port P1, and the opposite terminal of the first protecting resistor R3 is connected to the key 32. A terminal of the first capacitor C1 is connected to the first port P1, and the opposite terminal of the first capacitor C1 is grounded. The second protection module 52 includes a second protecting resistor R4 and a second capacitor C2. A terminal of the second protecting resistor R4 is connected to the second port P2, and the opposite terminal of the second protecting resistor R4 is connected to the key 32. A terminal of the second capacitor C1 is connected to the second port P2, and the opposite terminal of the second capacitor C1 is grounded. In the embodiment, the resistances of the first protecting resistor R3 and the second protecting resistor R4 are adjustable, and the capacitances of the first capacitor C1 and the second capacitor C2 are adjustable.
The principle of the electronic device 100 is described as follows, the first capacitor C1 and the second capacitor C2 are charged by the voltage of the power source Vcc. When the key 32 is pressed, the processor 40 sets the first port P1 and the second port P2 at the logic high level. The first capacitor C1 is discharged for a first predetermined time through the first protecting resistor R3. After the first predetermined time, the voltage of the first port P1 changes to 0V. Thus, the processor 40 recognizes the key 32 is pressed. The first predetermined time T1 is calculated according to the formula T1=C1*R3.
When the key 34 is pressed, the processor 40 sets the first port P1 and the second port P2 at the logic high level. The second capacitor C2 is discharged for a second predetermined time through the second protecting resistor R4. After the second predetermined time, the voltage of the second port P2 changes to 0V. Thus, the processor 40 recognizes the key 34 is pressed. The second predetermined time T2 is calculated according to the formula T2=C2*R4.
When the key 36 is pressed, the processor 40 sets the first port P1 and the second port P2 at the logic high level. The voltages of the first port P1 and the second port P2 are not changed, the processor 40 further sets the second port P2 in a logic low voltage level. The first capacitor C1 and the second capacitor C2 are discharged together for a third predetermined time through the first protecting resistor R3 and the second protecting resistor R4. After the third predetermined time, the voltage of the first port P1 changes to 0V. Thus, the processor 40 recognizes the key 36 is pressed. The third predetermined time T3 is calculated according to the formula T3=(C1+C2)*(R3+R4).
In use, when the keys are bouncing, the signal from a pressed key cannot be transmitted by the processor. Therefore, misoperation of keys of the electronic device 100 when the keys are bouncing is reduced.
It is to be understood, however, that even though information and advantages of the present embodiments have been set forth in the foregoing description, together with details of the structures and functions of the present embodiments, the disclosure is illustrative only; and changes may be made in detail, especially in the matters of shape, size, and arrangement of parts within the principles of the present embodiments to the full extent indicated by the broad general meaning of the terms in which the appended claims are expressed.
Number | Date | Country | Kind |
---|---|---|---|
2013100778390 | Mar 2013 | CN | national |