1. A brief introduction to the working principle of the hardware
This experiment uses the 8-bit digital tube display circuit and 4×4 matrix keyboard circuit on ME300B. The working principles of these two parts are briefly introduced below:
1. Working principle of 4×4 matrix keyboard
The matrix keyboard is also called a determinant keyboard. It is a keyboard composed of 4 I/O lines as row lines and 4 I/O lines as column lines. A key is set at each intersection of the row and column lines. In this way, the number of keys in the keyboard is 4×4. This determinant keyboard structure can effectively improve the utilization rate of the I/O port in the single-chip microcomputer system.
Figure 1 is the circuit diagram of the ME300B matrix keyboard, with row lines connected to P1.4-P1.7 and column lines connected to P1.0-P1.3.
Figure 1
Figure 2
2. Digital tube dynamic scanning display circuit
In the ME300B development system, an 8-bit digital tube dynamic scanning display is used. The 8 segment lines of all digital tubes are connected together accordingly and connected to the P0 port of AT89S51, and the field output is controlled by the P0 port. The common anode of each digital tube is controlled by the P2 port of AT89S51 to control Q20-Q27 to realize the bit output control of the 8-bit digital tube.
In this way, the dynamic scanning display of a group of digital tubes needs to be controlled by two groups of signals: one group is the glyph code output by the field output port, which is used to control the displayed glyph, called the segment code; the other group is the control signal output by the bit output port, which is used to select which number of digital tubes to work, called the bit code.
Since the segment lines of each digital tube are connected in parallel, the output of the segment code is the same for each digital tube. Therefore, if the bit selection lines of each digital tube are in the strobe state at the same time, the 8-bit digital tube will display the same character. If each digital tube is to display the character corresponding to the current position, a scanning display method must be used. That is, at a certain moment, only the bit selection line of a certain position is in the on state, while the bit selection lines of other positions are in the off state. At the same time, the font code of the character to be displayed in the corresponding position is output on the segment line. In this way, at the same time, only the selected position displays the character, while the other positions are off. In this way, each digital tube can display the character to be displayed.
Although these characters appear at different times, and at the same time, only one digit is displayed while the others are off, due to the afterglow characteristics of the digital tube and the persistence of vision of the human eye, as long as the display interval of each digital tube is short enough, the visual impression given to the human eye will be a continuous and stable display.
Figure 3
The time interval of different digits of the digital tube can be achieved by adjusting the delay length of the delay program. The time interval of the digital tube display can also determine the brightness of the digital tube display. If the display time interval is long, the brightness of the digital tube will be brighter when displayed. If the display time interval is short, the brightness of the digital tube will be darker when displayed. If the display time interval is too long, the digital tube will flicker when displayed. Therefore, when adjusting the display time interval, it is necessary to consider the brightness of the digital tube during display and to prevent the digital tube from flickering when displayed.
When using digital tube to display information in ME300B MCU development system, short-circuit the 2nd and 3rd terminals of JP2. See Figure 3
2. Programming method of demonstration program
1. Programming method of 4×4 matrix keyboard:
1.1. First read the status of the keyboard and get the key feature code.
First, output low level from the upper four bits of P1 port, and output high level from the lower four bits, and read the keyboard status from the lower four bits of P1 port. Then output low level from the lower four bits of P1 port, and output high level from the upper four bits, and read the keyboard status from the upper four bits of P1 port. Combining the results of the two reads can get the characteristic code of the current key. Using the above method, we get the characteristic codes of 16 keys.
Here is an example of how to get the key feature code:
Assume that the "1" key is pressed, find the key's characteristic code.
The high four bits of P1 output low level, that is, P1.4-P1.7 are output ports. The low four bits output high level, that is, P1.0-P1.3 are input ports. The state of the low four bits of P1 is "1101", and its value is "0DH".
Then the high four bits of P1 port output high level, that is, P1.4-P1.7 are input ports. The low four bits output low level, that is, P10-P13 are output ports. The state of the high four bits of P1 port is "1110", and its value is "E0H".
The characteristic code of the key is obtained by performing a logical OR operation on the P0 port status values read twice, which is "EDH".
The same method can be used to obtain the characteristic codes of the other 15 keys.
1.2. According to the characteristic code of the key, look up the table to get the sequence code of the key.
The feature codes of the 16 keys obtained by the above method are arranged in the order of the keys in Figure 2 to form a correspondence table between feature codes and sequence codes, and then the currently read feature code is used to look up the table. When the feature code appears in the table, its position is the corresponding sequence code.
1.3. Specific programming of matrix keyboard key value search program
1. Identify whether any key is pressed on the keyboard. If no key is pressed, return.
2. If a key is pressed, find out the specific key value (sequence code).
[page]
=====================================================
Matrix keyboard key value lookup program
The key value is stored in unit 30H
=====================================================
KEY_SCAN:
KEY_IN1:
KEY_IN2:
KEY_IN3:
;Correspondence table between feature coding and sequence coding
KEY_TABLE:
2. Programming method of 8-bit digital tube display program
Determine the scanning initial value and scanning direction according to the specific position of the digital tube to be used.
The number of scanned digits is determined by the number of digital tubes used.
Prepare the data to be displayed and put it into the corresponding display unit.
===========================================================
; Light up 8 digital tubes from right to left
===========================================================
DISPLAY:
DISP1:
Since only one digital tube is needed for key value display, the above display program can be optimized to obtain the following display program.
====================================================
Key value display subroutine
====================================================
KEY_PLAER:
TABLE:
3. Demonstration Program Functions
When you press any key on the matrix keyboard, the buzzer sounds and the corresponding key value is displayed on the digital tube. Figure 4 is a practical demonstration picture of the ME300B development system.
Figure 4
Previous article:Simulation of Ultrasonic Distance Measurement Using Single Chip Microcomputer
Next article:A Brief Analysis of KEIL C51 Reentrant Functions and Simulated Stacks
Recommended ReadingLatest update time:2024-11-16 15:55
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
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
- 104 capacitors are the most widely used, whether it is power supply filtering or ADC filtering, can any forum friends tell me? Why not 102...
- [Silicon Labs BG22-EK4108A Bluetooth Development Evaluation] 3. Bluetooth protocol test APP lighting and button detection
- [Goodbye 2021, hello 2022] Stop looking at refrigeration units and start clean air conditioning
- What is the difference between quick format and normal format?
- Wake-up function of pedometer bracelet based on F103 and X-NUCLEO-IKS01A3
- Recruiting MBSE part-time training instructors
- [Qinheng Trial] CH559 Development Environment Construction
- Detailed explanation of analog ground and digital ground
- Recently, when I logged into MYTI, I needed to verify my email address, but I didn’t receive any email from Ti in my mailbox. Has anyone encountered this before?
- Principles of MCU Hardware System Design