0 Preface
In the design of single-chip microcomputer system, the design of LCM (liquid crystal display module) human-computer interaction interface is often a very important link. LCM can be used to display setting parameters, status prompts, test results and parameters to be input on intelligent instruments. In combination with the design requirements of electrolyte analyzer, this paper adopts YXD-12864A2LCM produced by Shenzhen Yexinda Industrial Co., Ltd., studies and implements the interface circuit and program design of LCD based on C8051F020, and adds a key system to achieve the purpose of user convenience.
1 Introduction to Electrolyte Analyzer
The electrolyte analyzer designed in this system is an instrument with high resolution and high precision. It can be used with a variety of ion selective electrodes and can automatically determine the concentration and pH value of potassium, sodium, chloride, and calcium ions in samples. Its structural block diagram is shown in Figure 1. The instrument is designed with the single-chip microcomputer C8051F020 as the core chip. In the measurement room, the chemical sensor collects the potential signal of the electrolyte and transmits it to the signal conditioning circuit. After signal conditioning, it is sent to the main circuit board for A/D conversion, and then output and displayed on the LCM. The display of LCM parameters and measurement results can be operated by the keyboard. In terms of communication with the host computer, RS 232 communication is used to transmit data. The characteristics of this instrument are that it can be used alone or connected to the host computer. After connecting to the host computer, the interface operation can help users complete the query and storage of patient information and the real-time detection of the working status of the instrument.
The system display part uses a graphic LCD module YXD-12864A2LCM, which is installed on the surface of the instrument to display parameter settings, measurement results, calibration, quality control, etc. The interface display, parameter setting, page turning and other functions are realized through key control.
2 YXD-12864A2LCM
2.1 Module Introduction
YXD-12864A2LCM is produced by Shenzhen Yexinda Industrial Co., Ltd. It is a graphic dot matrix LCD display module, which mainly consists of row driver, column driver and 128×64 full dot matrix LCD display.
It can display graphics and 4×8 (16×16 dot matrix) Chinese characters. The YXD-12864A2 module has 20 pins. Among them, the 1st pin VSS is connected to the system ground; the 2nd pin VDD is connected to the power supply voltage; the 3rd pin V0 is connected to the LCD display drive power supply; the 4th pin D/I is connected to the data instruction selection signal; the 5th pin R/W is connected to the read-write selection signal; the 6th pin is connected to the read-write enable signal. When E is high, the data is read out, and when the falling edge of E arrives, the data is latched into DB0~DB7; the 7th to 14th pins are connected to the three-state data bus; the 15th and 16th pins are connected to the chip selection signal; the 17th pin RST- is connected to the reset signal; the 18th pin Vout is connected to the output voltage terminal of the internal negative voltage generator; the 19th pin is connected to the positive electrode of the LED backlight power supply; the 20th pin is connected to the negative electrode of the LED backlight power supply.
2.2 Interface Circuit
The interface circuit diagram and schematic diagram are shown in Figure 2 and Figure 3. The P3 port of C8051F020 is connected to the DB port of the LCD module as the data port; P2.0 is the reset pin RST-control terminal; P2.1, P2.4, and P2.5 are used as ordinary I/O ports, respectively connected to the enable terminal E, register selection pin D/I, and read/write pin R/W of the LCD module; P2.2 and P2.3 are respectively connected to the chip select signal left or right to position the display.
In the circuit diagram of Figure 2, R28 and R41 are pull-up resistors, because each port is connected to the microcontroller. For the display, the operating voltage is 5 V, while the operating voltage of C8051F020 is 3.3 V. In order to make the output of C8051F020 better drive the LCM with 5 V input, each port should be connected to the 5 V power supply through a pull-up resistor, so that the logic "1" output of C8051F020 can be increased to 5 V.
2.3 Software Design
Display characters: Display the specified string from the specified position on the screen. This LCM is a 128×64-bit LCD screen, and each character occupies an 8×8 dot matrix. The display position is determined by two coordinate parameters. The horizontal coordinate x represents the "row" and the value range is 0~7; the 0th row corresponds to the top row of the screen, and the 7th row corresponds to the bottom row. The vertical coordinate y represents the "column" and the value range is 0~15. The 0th column corresponds to the leftmost column of the screen, and the 15th column corresponds to the rightmost column of the screen.
Assuming that the character "K" is to be displayed from the 4th row and 8th column, the display of Chinese characters is similar to that of characters, except that the dot matrix occupied by Chinese characters is in the form of 16×16. Therefore, in this LCM, Chinese characters can only be displayed in 4 rows and 8 columns. The coordinates of the first row of Chinese characters are 00H~07H, and the coordinates of the second, third, and fourth rows are 10H~17H, 20H~27H, and 30H~37H respectively. To display Chinese characters, the coordinate starting position of the Chinese characters must be written as a command, and the Chinese character font must be written as data. To continuously write multiple Chinese characters, the table lookup method can be used.
3-button system
The hardware design of the key system can be done in two ways: independent and matrix.
(1) In the independent type, each key occupies an I/O port line separately. The working status of the key on each I/O port line will not affect the status of other I/O port lines. It is generally used in occasions with a small number of keys; (2) The keys of the matrix type are arranged in a row-column matrix structure, with 4 rows and 4 columns, a total of 16 keys, occupying only 8 I/O port lines. Therefore, when the number of keys is large, this method can be used to save I/O port lines.
This instrument defines 8 buttons in total. Considering that the I/O interface on C8051F020 is very rich, an independent type is adopted. A total of 8 buttons are designed on the instrument, namely "Yes", "No", "↑(up)", "↓(down)", "←(left)", "→(right)", "Reset" and "Print". Except for the "Reset" button (which is directly reset after being pressed), which is not processed by the keyboard information processing program, the pressing processing of the remaining 7 keys is completed by the keyboard information processing program in the main loop program. For independent buttons, the CPU can obtain the direct state code value of the button by directly reading the state of the I/O port, and the button can be directly identified based on this value. The code value of each key is shown in Table 1.
The specific definition of the buttons is as follows:
(1) “↑(up)”, “↓(down)”, “←(left)”, “→(right)”: move the cursor or switch screens with different contents, modify data, complete password input, etc.;
(2) "Yes": confirm the operation, including confirming the selected menu item or data, confirming the entered password, confirming the modified data, etc.;
(3) “No”: You can cancel the entered password value or modified data;
(4) "Reset": soft reset system;
(5) “Print”: Control the printer to print output.
The working modes of keys are divided into two types: programming control mode and interrupt control mode. This instrument adopts interrupt control mode, and the flow chart is shown in Figure 4. This mode can improve the efficiency of the CPU. When a key is pressed, an interrupt is requested from the CPU. After the CPU responds to the interrupt, the keyboard scan, key value check and processing are performed in the interrupt service program. The programming control mode means that within a working cycle, the key scanning subroutine is called using the spare time of completing other tasks. After the program query, if there is no key operation, it returns; if there is a key operation, it further determines which key it is and executes the corresponding key processing program. This affects the efficiency of the CPU. Therefore, the interrupt control mode is selected.
The key switch used in this instrument is a mechanical elastic switch. It takes several milliseconds of jitter time from the key being pressed to the contact being stable, and there is also such a problem when releasing it. The length of the jitter time is determined by the mechanical characteristics of the key, which is generally 5~10 ms. This will cause multiple readings of a key. For the jitter problem, a software method can be used. It can be avoided by delaying the jitter method, that is, after detecting that the key is closed, a delay program is executed to generate a 20 ms delay, and the state of the key is detected again after the front edge jitter disappears. If the closed state level is still maintained, it is confirmed that the key is really pressed. When the key is released, a 20 ms delay is also given, and the key processing program can only be transferred after the back edge jitter disappears.
4 Conclusion
The display interface of the electrode quality analyzer is designed using the YXD-12864A2 graphic LCD display module. The 8-bit parallel mode is used to transmit data. The main reason is that although it occupies more I/O pins, it is much simpler to program than the serial mode. In addition, the C8051F020 has 8 8-bit I/O ports and 64 digital I/O pins, which are very rich, so there is no need to consider the problem of insufficient pins. By adding a key system, the displayed content can be operated by the user, which is very convenient.
Previous article:8051 MCU Data Description
Next article:Design of electric vehicle seesaw using 51 single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 12:25
- Popular Resources
- Popular amplifiers
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
- Q&A on Connectivity: Why Wi-Fi 6 Could Be Your Competitive Advantage
- Why do we need to learn transistor circuits when we already have integrated circuits?
- 2. Hardware Introduction and Development Environment Installation
- 【New Year's Festival Competition】+ Watching Lanterns on the Lantern Festival (multiple photos)
- 5G small base stations are under the spotlight: now is the eve of the outbreak
- 【CH579M-R1】+ PWM breathing light
- [Experience] [Free trial of Letuo USB oscilloscope] Comparison test of Letuo USB oscilloscope
- Wi-Fi 6E scarcity causes enterprises to delay upgrades until Wi-Fi 7 devices ship
- [RISC-V MCU CH32V103 Evaluation] W25Q16 Reading, Writing and Application
- 【GD32E231 DIY Contest】1. USART0