-
The switches used for the usual keys are mechanical elastomeric switches. Due to the elastic effect of mechanical shock, the keys are accompanied by a series of jitters at the moment of closing and disconnecting. Key jitter can cause a key to be misread multiple times.
In order to ensure that the CPU closes the key only once, the jitter must be removed.
There are two ways to eliminate jitter: hardware and software. Hardware methods commonly use RS flip-flop circuits. The software method is to execute a 10ms 20ms delay program when the key is closed, and then check the state of the key again, and if it is still closed, it will confirm that the key is really pressed.
-
Add capacitors to the keys to remove interference, and string a resistor on the keys can also solve the interference caused by static electricity or other interference to the keys.
Software debounce is also a very common method of dejitting, that is, the key is detected many times, and each time the key is pressed, it is considered that the key is pressed. Software debounce should adopt the method of multiple acquisitions, and the interval in the middle can be dejitted by using a delay or using the idea of time-sharing, and the general software debounce is de-jitter with time-sharing thinking.
-
I know there is a software delay.
Trigger the inverter.
There is also a small circuit made up of capacitors, check it yourself.
-
Software latency.
Hardware plus a slightly larger capacitor.
-
Deferred reconfirmation is not necessarily the best method, but it is certainly the most commonly used.
-
In the hardware, the debounce circuit can be composed of an RS flip-flop (bistable flip-flop) or a monostable flip-flop at the key output, and the debounce circuit can be added to the key output.
The measures taken on the software are: when a key is detected, a delay program of about 10ms (the specific time should be adjusted according to the key used) is executed, and then confirm whether the key is still closed, if it is still closed, the key is closed, and similarly, after detecting the release of the key, the same steps should be used to confirm, so that the effect of jitter can be eliminated.
-
There are two methods, one is hardware dejitter, adding resistance and capacitance resistance, and filtering out interference waves.
The second is the software method, which adds a delay to eliminate jitter.
-
For example, button 1 is connected to a port with an external interrupt to control the opening of the switch S1 to SN, when you need to turn on S1, you only need to press S1, if there is mechanical jitter, it will turn S2 on, or even open S3 (the program runs too fast). When writing the interrupt service program (how to turn on and off the interrupt service program, I ignored it), you need to use a statement to control the shutdown of the interrupt at the end, and add a delay in front of the interrupt statement, that is, when the interrupt is opened, it must be delayed for a certain amount of time to end the interrupt program, and this delay is generally about 500 milliseconds. The advantage of this is that when key 1 is pressed, it is necessary to press and hold for 500 milliseconds to interrupt the program before it can be executed and S1 can be opened, so that unnecessary actions caused by mechanical jitter can be avoided.
-
Because the key jitter can cause a key to be misread multiple times.
In order to ensure that the CPU only processes the closure of a key once, the key jitter must be removed.
When the bond closure is stable, the state of the key is read, and it must be discerned; After the key release is stable, it will be processed again. The jitter of the keys can be eliminated by either hardware or software.
If there are many keys, the common software method is to de-jitter, that is, to detect the key closure and execute a delay program, resulting in a delay of 12 to 20 ms, so that after the leading edge jitter disappears, the state of the key is detected again, and if the level of the closed state is still maintained, it is confirmed that the key is really pressed.
When a key is confirmed to be pressed or a key release is detected, the handler for that key can be transferred.
-
Debounce is to avoid the effects of violent level shakes when keys are pressed or raised. The debounce of keys can be done in either hardware or software. If there are many keys, the common software method is debiting, that is, after detecting the key closure, a delay program is executed, with a delay of 5ms and 10ms, so that the leading edge jitter disappears and the state of the key is detected again, and if the level of the closed state is still maintained, it is confirmed that the key is really pressed.
When the key release is detected, a delay of 5ms and 10ms is also given, and the handler for the key can only be transferred to after the trailing edge jitter disappears.
In general, software debounce is done by constantly detecting key values until they are stable. Implementation: Suppose that 1 is entered when the key is not pressed, and 0 is entered after the key is pressed, and the jitter is uncertain.
The following tests can be done: after detecting that the key input is 0, the delay is 5ms 10ms, and the detection is again, if the key is still 0, then it is considered that there is a key input. The 5ms and 10ms latency just avoid the jitter period.
-
Hello dear, I have helped you query the result: the result is: the result of the key dejitter based on the state machine is that when the user presses the key, the key will only be triggered once, not multiple times.
The result of the non-jitter based on the state machine keys is that when the user presses the key, the key is triggered multiple times, depending on the duration of the user keystroke. The difference is Jane's: state machine button dejitter:
After the key is pressed, the key action will be triggered only when the key remains pressed for a certain period of time (jitter time), otherwise it will not be triggered. The state machine button does not shake: after the button is pressed, it is blocked, and the key action is triggered immediately, no matter how long the button remains pressed.
-
Hello, sorry for keeping you waiting, sorry <>
The difference between key dejitter and non-jitter based on a state machine lies in the stability of the keys. Key dejitter means that the input signal of the key is processed to eliminate the mountainous balance of contacts caused by mechanical vibration and elastic relaxation of the key. In a state machine-based dejitter program, a delay is added to eliminate this transient trigger signal.
In contrast, a program that does not perform dejitter may cause misoperation due to physical jitter or too fast finger movements. Therefore, the stability of the keys can be improved through the debounce program based on the state of the machine, and misoperation can be avoided. In conclusion, using a state machine-based debounce program can effectively improve the stability of the keys, thereby improving the ease of use of the device.
Ignoring dejitter may cause the device to be unreliable and misoperated.
First, exercise can be open-minded, the mind will become positive, optimistic, your attention will be shifted to sports, there will be no time to worry! >>>More
Yes, the pattern of interaction between childhood and parents affects the present. To recognize this, you have to change this interactive model and change your personality.
Swollen eye bubbles are a phenomenon of moisture imbalance that is caused by excessive fluid storage in the blood vessels that smashes up the eyelid tissue. Swollen eye bubbles may be caused by kidney diseases, or sinusitis, allergies, colds, etc., which may cause water metabolism disorders in local tissues, and stay in the loose tissues of the eyelids; It can also be caused by using eye creams that are too strong and moisturizers that prevent water loss and do not allow the delicate eyes around the eyes to lose moisture. Puffy eyes that occur when you wake up in the morning can also be caused by drinking a lot of water before going to bed. >>>More
Vacuum liposuction is actually a small incision in the conjunctiva of the eye (inside the lower eyelid) using a special electrosurgical knife or laser from an electrocoagulator to remove the fat in the eye socket and eliminate the eye bags, but the outer eyelids are not scarred, to be precise, it should be scarless eye bag removal.
You can use flat fruit slices to put on the eyes.