In electronic products, keyboards are the most basic input devices. However, it is unrealistic to use general keyboard scanning devices in applications. A dedicated small keyboard needs to be designed separately. Modern EDA (electronic design automation) technology provides a good way to easily build a keyboard scanning module using VHDL hardware description language and FPGA devices. After actual operation, the module can scan and respond to each key action well and realize the pre-designed functions.
1 Overview
1.1 Universal keyboard and special keyboard
In modern personal computer systems, a universal standard keyboard (such as the standard 101/102 keyboard or the Microsoft Natural PS/2 keyboard) is generally used to implement the interface interaction between people and computers. All the required data, instructions and other information are entered into the computer through the keyboard.
However, in various embedded systems (such as mobile phones, microwave ovens, electric fans, etc.), the number of keyboard keys required is very limited, usually ranging from a few to a dozen (while standard keyboards usually have more than a hundred keys), and the functional meanings of each key are also different. Therefore, for each embedded system, the keyboard (including keyboard scanning module and related control signals, etc.) should be specially designed, and the various existing resources of the system should be fully utilized in combination with the actual engineering situation, so that the designed keyboard can be properly integrated into the embedded system and become an integral part of it.
1.2 Edit
Code keyboard and scan keyboard
In digital circuits, encoders can be used to directly encode key values. The output signal of each key is connected to each input terminal of the encoder. Through the encoding logic, the code value corresponding to each key can be obtained at the output terminal of the encoder. In the early days, this type of keyboard was called an encoding keyboard. However, when there are many keys, the cost of digital logic is high, and the direct encoding method is not flexible enough. Once the encoding logic is fixed, it is difficult to change.
On a general keyboard or when there are a large number of keys, a scanning method is generally used to generate key values. The keys are connected into a matrix, and each key is located at the intersection of a row and a column, as shown in Figure 1. The row and column of the pressed key are first determined by scanning, that is, the position code or scan code. Then the position code is converted into a key code value by looking up the table or the scan code is used directly. Some reference books call this a "non-encoded keyboard". However, this name can easily lead people to misunderstand that there is no corresponding key value, so it is also called a scanning keyboard.
[page]
1.3 Hardware Scanning Keyboard vs. Software Scanning Keyboard
If the scanning process is implemented by hardware logic, this keyboard is called a hardware scanning keyboard or an electronic scanning encoding keyboard. When performing keyboard scanning, it should be noted that there will often be some unavoidable mechanical jitters in the closing process of the key, which will cause the output signal to jitter, usually up to 10 ms to 20 ms wide. If the jitter area is not avoided, it may be mistaken for multiple key presses. Therefore, a hardware delay circuit should be set to delay the key value for tens of milliseconds before reading it. This circuit is called a de-jitter circuit. It should also be noted that when the current key value has not been sent out and another key is pressed, the subsequent key value will overwrite the previous key value, resulting in loss. Usually, a control signal can be set to allow the next key value to be generated only after the previous key value is sent out, or a group of registers can be set to save several previous key values, waiting for the system to process them one by one in sequence.
The advantage of hardware scanning keyboard is that the host does not need to bear the scanning task. Only when the key value is generated will an interrupt request be sent to the host. The CPU receives the key value in the corresponding interrupt mode, or the CPU obtains the key value from a certain address at a fixed time. This method greatly reduces the operating load of the CPU, allowing it to have more time to run other applications.
Of course, you can also execute the keyboard scanning program, and the CPU scans the keyboard through software methods. The process of the keyboard scanning program is shown in Figure 2. This kind of keyboard is called a software scanning keyboard. When a key is pressed, the keyboard makes an interrupt request to the host, and the software scans the keyboard to obtain the key value, or the CPU periodically executes the keyboard scanning program to obtain the key value. This scanning method is called row-by-row scanning. When a key is pressed, the column value of this key is first obtained, and then the row value of the key can be determined by scanning row by row, and the row and column values are converted to the key value. Of course, a certain delay can be added during the keyboard scanning process to eliminate the impact of jitter.
If the system has high requirements for the CPU's running speed, the CPU load is heavy, and the system resources are tight, you can set a single-chip microcomputer in the keyboard, which will execute the keyboard scanning program, and then request an interrupt from the CPU and send out the scan code or key value. Most common keyboards in modern computers use this keyboard scanning method. [page]
2 FPGA-based implementation method
2.1 Analysis of implementation methods
According to the actual needs of the project, the keyboard scanning module to be implemented should have the following characteristics:
The module writes the scanned key value information into the specified address of the memory in real time. The key value information includes the number of repetitions and key value of the same key. The system software reads the key value information from the address regularly to perform corresponding operations.
The method of keyboard debouncing is the multiple scanning method. When the same key value is scanned several times in succession, it is considered that the key is pressed, thus completing the debouncing operation.
Since this project does not require ASCⅡ character encoding keys, the key values are designed to be sent directly from 1 to 20.
In order to indicate the operation of pressing a key for a long time, when it is determined that a key is pressed, it will be scanned once at a certain interval thereafter. If the same key value is obtained, the number of key repetitions will be increased by one, and the number of repetitions and the key value will be combined into key value information and sent out; scan again after a certain delay.
2.2 FPGA Implementation
The design uses four modules to implement the keyboard scanning function, namely the instant scanning module, the scanning control module, the scanning pulse module and the key value transmission module, as shown in Figure 3.
2.2.1 Real-time scanning module
This module completes the keyboard instant scanning function. When a narrow pulse of the SCAN signal is detected, the module will generate a set of corresponding KB_OUT signals and output them to the keyboard matrix. Then the KB_IN input signal will be detected to determine whether any key is pressed and which key is pressed, and the corresponding instant key value VALUE will be sent out.
2.2.2 Scanning Control Module
The function of this module is to control whether scanning is allowed and whether keyboard debounce is completed. When no key is pressed, CTRL is set to a high level to allow scanning; when the same key is scanned several times in succession, it is considered that the key is pressed (the debounce operation has been completed). Then CTRL is set to a low level, scanning is prohibited and delay is started at the same time. When CNT reaches a certain value, scanning is restarted and delay is started again. At the same time, the number of key repetitions and the key value VALUE are combined into KEYVALUES and output. And so on, until no key is pressed or other key values are detected.
2.2.3 Scan pulse module
The main function of this module is to generate scan indication narrow pulse and scan delay count. When CTRL is high, a SCAN narrow pulse is sent out at each rising edge of CLK 50Hz; when CTRL is low, the delay counter starts counting, and a scan pulse signal SCAN is sent out only when a certain value is reached.
2.2.4 Key-value transmission module
This module is responsible for writing key value information into the memory for periodic query by application software.
3 Conclusion
This module is implemented with VHDL hardware description language. After function and timing simulation, it is compiled with QUARTUS Ⅱ software and downloaded to Altera's CYCLONE 1C20 development board. After actual operation test on the keyboard, it is proved that this module can normally realize keyboard scanning and de-jittering functions, and can correctly identify the action of each key. At the same time, if the module is slightly modified, it can also be transplanted to other systems, which can greatly reduce the CPU operation load, which has a strong practical significance for most embedded systems that are sensitive to system resources.
Previous article:Design of Intelligent Command Line and Its Application in SOPC System
Next article:Universal Modem Based on SoPC and CORDIC Algorithms
Recommended ReadingLatest update time:2024-11-16 16:24
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- MATLAB and FPGA implementation of wireless communication
- Intelligent computing systems (Chen Yunji, Li Ling, Li Wei, Guo Qi, Du Zidong)
- Summary of non-synthesizable statements in FPGA
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Mobile station update development board, welcome to borrow it!!
- 3. "Wanli" Raspberry Pi car - Python learning (timing task)
- This is a camera development board, but where is the camera?
- Sharing the principle of the adapter solution for charging while listening to music
- Make announces its return
- The mysterious EMC, how did it come about?
- EEWORLD University - Zero-based circuit learning
- Appointment viewing double gift: How to ensure edge computing security? Learn about an important tool
- [Sipeed LicheeRV 86 Panel Review] 6-socket to achieve communication between different processes
- Usage diagram of various Arduino basic components