Single key means that each key occupies one pin of the microcontroller. The characteristics of this connection method are that the circuit and program are very simple, but the disadvantage is that it occupies many pins of the microcontroller and consumes a lot of hardware resources. This connection method is generally suitable for 6 or no more than 6 keys.
The circuit diagram of the single-key circuit is shown in Figure 1. It can be seen from the figure that one end of each key is directly connected to a pin of the PC port of 8255 as an input pin, and this port pin is only connected to one key. This connection method is the single-key connection method. The single-key connection method requires that one end of the key is connected to a pull-up resistor, and the other end of the key is directly grounded, so that the input pin can always be kept at a high level when the key is not closed. If the program detects that this pin is at a high level, it will be considered that the key of the pin is not pressed, and after the key is closed, the level of the input pin will become a low level. In this way, when the program detects that the input pin is at a low level, it will be considered that the key is pressed.
Figure 1 Single-key circuit
When a key, especially a mechanical key, is pressed, there will be a certain amount of jitter, which will last for a short time. This jitter will cause the program to be abnormal, because the program is likely to think that the key has been pressed many times in such a short time. Many materials specifically mention the anti-shake circuit. Practice has proved that this circuit can be completely ignored and can be completely replaced by a program.
Some materials also use programs instead of anti-shake circuits, but they use delay circuits of tens of milliseconds. Such programs will undoubtedly increase the time overhead of the program and are not conducive to the rapid response of the program.
We can use program processing to turn the keys into so-called differential keys. The so-called differential actually means that we only process the changes in the keys, and we do not process the key information that has not changed. Since the differential key only processes the information of the first change, short-term key jitter will not cause misoperation.
The corresponding key program and analysis are given below.
In this program, the so-called single-key input is actually reading the information of the PC port of 8255.
The program first checks whether a key is pressed. If not, the key characteristic variable ktz is set to 0 and the function is exited, which reduces the running time of useless programs. If a key is pressed and ktz is equal to 0 (indicating that it is the first time it is pressed), it will enter the key processing part. Key processing mainly defines the key coding, because the key values read from the input port usually need to be processed in order to filter out unnecessary information or interference, and at the same time, the input values are regularized into key codes that are easy for us to process. The key codes here are 1, 2, 3, 4, 5, 6, 7, and 8. These 8 numbers correspond to 8 keys. The flowchart of the single-key input function is shown in Figure 2, and the corresponding program is as follows:
Figure 2 Flowchart of the single-key input function
Previous article:Secondary Active Clamp Circuit of DC-DC Forward Converter
Next article:Stepper Motor Control Based on 8XC196MC Waveform Generator
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- After cashing out 1.5 billion yuan, Mobike's post-80s founder left behind two unspoken rules for life
- RISC-V cross-compilation tool chain and the process of building a simulation environment
- 【New Year's Festival Competition】+ Characteristics of Southern Small Cities
- A flyback adapter reference design with a maximum output of 9V 5A
- Download Gift|ADI Flow Cytometer Solution
- EEWORLD University Hall----Application of TI DLP? Technology in 3D Machine Vision and Automated Optical Inspection
- DSP/BIOS Thread
- EEWORLD University Hall ---- Introduction to Microelectronics Technology
- EEWORLD University ---- Balance Car Tutorial Qianfeng Internet of Things
- [Serial] [Starlight Lightning STM32F407 Development Board] Chapter 14 Low Power Consumption Experiment