Abstract: With STC12C5A60S2 single-chip microcomputer processor of Hongjing Company as controller, matrix keyboard as input device, RS485 communication interface chip as data update mode, LCD3202401 produced by Beijing Qingyun Company as display output device, the corresponding hardware circuit and display driver are studied and designed, and the design of human-computer interaction system is completed on this basis. Make full use of low-cost and low-resource single-chip microcomputer system to realize perfect human-computer interaction function.
Keywords: human-computer interaction; LCD; single-chip microcomputer
1 System design scheme
The following situations are encountered when designing buttons of this system: (1) There are many peripherals of the product, and the I/O ports of the single-chip microcomputer are relatively few. It is necessary to consider saving I/O ports during design. (2) Due to the limitation of the on-site situation, there should be a distance between the keyboard and the motherboard. (3) The keyboard needs 15 buttons, and a reset button is extended at the same time, for a total of 16 buttons. According to the above situation, the A/D keyboard is the most suitable.
Considering that the system display requires both graphic display and character display function, the single-chip microcomputer is used to control the LCD to maximize the use of LCD drawing, character display and other functions.
The effect of this system design is shown in Figure 1.
2 System structure and principle
The human-computer interaction system is responsible for data display and input, exchanges information with the main control module through the RS485 interface, displays the power parameter information transmitted by the main control module through the industrial LCD, and sets the system working mode, parameter threshold, and communication protocol through keyboard input. Correct the various electrical parameters of the analog channel and use graphics to intuitively represent the working status of the primary diagram and voltage parameters, and sound an alarm when overcurrent and overvoltage alarm information occurs. The system can complete these multiple functions well under limited cost conditions.
The display system consists of hardware and software, as shown in Figures 2 and 3.
The hardware part is based on the STC12C5A60S2 microcontroller. The crystal oscillator and reset circuit are necessary devices for the system to work. It receives input commands from the 3×5 matrix keyboard and communicates with the main control module in real time through RS485. The keyboard directly collects voltage judgment through the A/D function of the microcontroller.
The software part can be divided into two parts: the bottom driver and the upper control. The bottom driver includes setting the system clock and system mode, configuring the I/O port, initializing the serial port to turn on the ADC conversion function, initializing the LCD controller, interrupt controller, etc. The upper control program constantly queries whether there is a key pressed. If a key is pressed, the corresponding task is executed and the LCD displays the corresponding content; at the same time, if necessary, it sends control or request data and other information to the main control module through RS485.
3 System Hardware Circuit Design
3.1 Keyboard Circuit
In the human-computer interaction system, the keyboard must be used to input control commands, set values, query electrical parameters, historical data, alarm information, etc. The system is designed to use a 3×5 keyboard, plus a reset button to form a 4×4 format installation. In addition to the 10 numbers 0 to 9, there are also the confirmation key "Enter", the menu key "Menu", the up key "Up", the down key "Down", the "Mute" key and the reset key. Pull-up resistors are connected to the output lines of ports KEY0, KEY1, and KEY2 so that the ports can be accurately set high or low. The other end of the pull-up resistor is connected together to a 5 V power supply. The circuit diagram is shown in Figure 4.
The figure shows the circuit design of 3x5 keyboard. KEY0, KEY1, and KEY2 are connected to the I/O port with A/D function of the microcontroller. At this time, the A/D scan can be used to read, and the A/D value can be used to determine whether a key is pressed or which key is pressed. According to the resistance value in the figure above, it can be calculated that if no key is pressed, the A/D value is 5 V; SW1 is pressed, and the A/D value is VCC×R1/(R1+R20)=0.16 V by calculation; SW4 is pressed, and the A/D value is VCC×R1/(R1+R20+R24)=0.733 V; similarly, SW7=1.559 V; SW10=2.287 V; S5=2.875 V; according to the comparison of A/D acquisition values, the key value range closest to it is the key.
When using this method, it is necessary to pay attention to the selection of keys with good contact. After a long time of use, the key difference is easy to generate contact resistance, and more keys are prone to misdetection.
3.2 LCD display
circuit The system uses the LCD3202401 liquid crystal controller produced by Beijing Qingyun Company. The LCD3202401 uses the powerful RA8835 as the controller. This LCD has 4 display data lines and transmits data quickly; it has powerful drawing functions; it supports text display, graphic display, and mixed display of graphics and text; it has a simple MPU interface and a full-featured control instruction set. The interface circuit between the microcontroller and the LCD is shown in Figure 5.
In the figure, a 1 kΩ current limiting resistor is added at the connection between the LCD and the microcontroller pins to effectively prevent the microcontroller pins from being damaged by excessive current. Since the frequency of the microcontroller is 22 MHz, the data cannot be seen to be transmitted one bit at a time by the naked eye. From the perspective of human vision, it is as if all characters or pictures are displayed at the same time.
4 Software Design
In this system, there are more than 30 main menus and submenus, and they need to be displayed synchronously in real time, which increases the difficulty of application layer design. Therefore, the program adopts a modular structure, which mainly includes the main menu page switching module, key scanning module, option management control module and data input module.
4.1 Main menu page switching module
In order to switch the operation interface according to user requirements, a page_index image register is defined, and its value varies between 1 and P, where P is the number of operation interfaces. The value of P in this system is 9. The main menu interface is shown in Figure 6.
If page_index=1, the LCD displays page 1; the primary image page is shown in Figure 7. To maximize the use of the system's Flash, the lines and boxes are directly implemented using its drawing function.
If page_index=2, the second page will be displayed on the LCD display. The user can press the numeric keys to control the value of page_index to select the corresponding page to achieve human-computer interaction. The electrical parameter page is shown in Figure 8.
4.2 Key Scan Module
Scan the 15 operation keys and save the results in the key image register. This register has a status flag keyState. If its value is True, it means that the corresponding key is pressed; otherwise, it is released. When the program is running, the key is read and the flag is cleared. Figure 9 is the program flow chart of the keyboard module.
4.3 Option Management Control Module
If the current operation interface belongs to the "option interface", due to the large number of setting parameters, the option page is divided into several pages. Press the "Up" and "Down" keys or directly press the number keys to select the corresponding page. Figure 10 is the flow chart of the option management control module.
For the convenience of analysis, the setting page is taken as an example. The setting page is divided into 5 pages, including the system parameter setting page, the threshold parameter setting page, the Modbus setting page, the Ethernet setting page and the CAN setting page. After selecting the setting from the main menu to enter the setting page, you can press the numeric keys or the up and down keys to select the page. For example, press the 2 key to enter the threshold setting in the setting page, as shown in Figure 11.
At this time, press Enter to enter the input setting for the value. 2/5 in the figure is the current page prompt, 2 is the second page, and 5 is the total number of pages.
4.4 Data input module
If the current operation page belongs to the "setting interface", use the numeric keys to enter any value that meets the user's requirements, such as the value input in the threshold setting in Figure 11. The program flow chart of the data input module is shown in Figure 12.
By using the above modules, only a small amount of program code is needed to flexibly realize functions such as options, data modification and switching operation interfaces.
5 Conclusion
This design uses C language programming, and the selected microcontroller is STC12CSA60S2. Although its program memory is only 60kB, it realizes the display and switching of more than 30 pages of operation interfaces, as well as human-computer interaction functions such as data setting and query, and also realizes monitoring, control and communication functions.
Previous article:Design of strong magnetic water treatment instrument
Next article:Single chip microcomputer and embedded system application
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- [Live broadcast on May 9] Discussing solutions to reduce downtime in the new manufacturing era, ADI live broadcast expert Zhao Yanhui is here again
- MOS tube isolation drive circuit, if we drive high voltage MOS tube, we need to use transformer drive and integrated...
- Watch NXP LPC55S69 live broadcast and get the book "Embedded Security Processor Application and Practice" for free
- EEWORLD University ---- SimpleLink Academy: Develop your Bluetooth? Low Energy project
- dsPIC33EP32MC204PWM current limiting function problem
- Do you have any recommendations for low-power encryption products? I am using this on a smart device and have strict requirements on power consumption.
- Microcontroller port input problem?
- Operation of EEPROM inside PIC microcontroller
- Will the voice signal remain the original sound after being processed in this way?
- STMicroelectronics' STM32MP1 is coming. What do you think of this chip?