1 Introduction
Touch screens are increasingly being used in embedded systems. The design methods for touch screens vary in different application fields. Generally, there are three types: (1) Using a touch screen module. The touch screen module provides a standard hardware interface to connect to the application system (usually a PC or an industrial computer with an X86 architecture). It can work after installing the driver, and basically no development is required; (2) Expanding the touch screen controller. This is a common method for designing touch screens in embedded systems. Commonly used touch screen control chips include ADS7843, ADS7846, etc. These chips integrate A/D converters and touch screen drive circuits, and certain software must be designed; (3) Similar to the previous method (2), some processors integrate A/D converters, and the touch screen control can also be achieved by simulating the touch screen drive signal through the IO port.
With the development of chip technology, the resources integrated inside the processor are becoming more and more abundant. Some chips have integrated touch screen controllers. For example, the 32-bit ARM processor ARM7202 (HMS30C7202) chip of Hyundai Semiconductor Co., Ltd. in South Korea has integrated a resistive touch screen controller. ARM7202 integrates the ARM7TDMI CPU core, memory management unit (MMU), 8KB high-speed cache memory (Cache), and has a main frequency of 70MHz. It is a high-performance embedded processor. In addition to the touch screen controller, it also contains other rich resources, such as LCD controller, SDRAM controller, interrupt controller, DMA controller, etc. [1]. The interface between ARM7202 and the touch screen is somewhat different from the previous three in terms of software/hardware design.
2 Hardware Design
2.1 Principle of resistive touch screen
The resistive touch screen is a multi-layer composite film, with a layer of glass or organic glass as the base layer, a transparent conductive layer coated on the surface, and a plastic layer on top. Its inner surface is also coated with a transparent conductive layer. There are many tiny transparent isolation points between the two conductive layers to separate and insulate them, as shown in Figure 1. When a finger touches the screen, the two normally insulated conductive layers have a contact at the touch point. After the controller detects this contact, one of the conductive layers is connected to the 5V uniform voltage field in the Y-axis direction, and the other conductive layer leads the voltage of the contact point to the controller for A/D conversion. After obtaining the voltage value, it is compared with 5V to obtain the Y-axis coordinate of the touch point, as shown in Figure 2. Similarly, the X-axis coordinate is obtained. This is the common basic principle of all resistive touch screens.
2.2 Interface between ARM7202 and touch screen
The on-chip resources of ARM7202 include a touch screen controller for controlling a 4-wire resistive touch screen. Among the 5 A/D conversion channels, A0 and A1 are used for touch screen coordinate acquisition. At the same time, the chip provides four scan lines, ATSXP, ATSXN, ATSYP and ATSYN, to scan the X and Y directions respectively. When ATSXP and ATSXN apply a positive voltage in the X direction, the corresponding value of the X coordinate is detected in the Y direction; similarly, when ATSYP and ATSYN apply a positive voltage in the Y direction, the corresponding value of the Y coordinate is detected in the X direction, which is collected by A0 and A1 respectively. In order to reduce system power consumption and the CPU resources occupied by the touch screen, the touch screen controller starts scanning only when a pen is placed, and the corresponding value of the coordinate is obtained through A/D conversion. Therefore, a pen-place detection circuit needs to be designed externally, as shown in Figure 3. In the figure, IRLML6302 and IRLML2402 are PMOSFET and NMOSFET respectively, which are used as switch tubes to control the scan output in the X and Y directions. PB7 is connected to a pull-up resistor to detect the pen-down interrupt. When the pen is down, PB7 detects a low level and triggers an interrupt. PB6 is the enable signal of the interrupt detection circuit. When PB6 is high, the interrupt is valid and the touch screen scan is invalid; otherwise, the interrupt is invalid and the touch screen scan is valid. [page]
3 Touch screen control program mechanism
The application of touch screens under different operating systems is different, but they all include basic modules such as device initialization, device reading and writing, and interrupt response. The driver of the touch screen involves two interrupts: pen down interrupt and touch screen A/D conversion interrupt. The program modules included are: touch screen initialization, pen down interrupt service program, A/D interrupt service program, filter program, and coordinate conversion program. Here we focus on the two interrupts of the touch screen.
The touch screen initialization program completes the interrupt setting of the external circuit and the setting of the sampling rate, and turns off the A/D interrupt and A/D converter power of the touch screen to make the external circuit interrupt effective.
When a pen is dropped, the external interrupt is triggered and the pen drop interrupt service routine is entered. In the pen drop interrupt service routine, the interrupt source is cleared, the external interrupt is turned off, the external interrupt circuit is invalidated, and the touch screen interrupt and the AD converter power supply are turned on. At this time, the touch screen circuit starts to scan the touch screen. After the touch screen A/D conversion is completed, an A/D interrupt is generated and the A/D interrupt service routine is entered. In the touch screen A/D interrupt service routine, the A/D interrupt is cleared, the touch screen A/D interrupt is turned off, and the A/D conversion value is read. At this time, it is also necessary to determine whether the pen continues to drop. If there is no pen drop, the external circuit interrupt is turned on, the external interrupt circuit is enabled, the A/D interrupt and the A/D converter power supply are turned off, and the energy saving mode is entered, as shown in Figure 4(a); if there is still a pen drop, the touch screen A/D interrupt must continue to be turned on, the external interrupt circuit is invalidated, and the touch screen A/D conversion continues, as shown in Figure 4(b).
Figure 4 Touch screen program flow chart [page]
The values obtained by A/D conversion are the X and Y coordinates of the touch point on the touch screen, which need to be converted into coordinates on the display screen through a certain method. Due to space limitations, this is omitted here. The principle and implementation method can be found in reference [2]. During A/D conversion, 4 sets of conversion values are obtained from the A/D conversion register each time. A filtering program can be designed to improve detection accuracy.
4 Programming
The application modules of the touch screen include: touch screen initialization, pen down interrupt service program, A/D interrupt service program, filter program and coordinate conversion program. The initialization program, filter program and coordinate conversion program are general routine programs. The core of the touch screen driver is the pen down interrupt and A/D conversion interrupt service programs. The following are two interrupt service programs of the touch screen driver under the uc/OS operating system. For detailed description, see the notes.
5 Conclusion
Based on the above analysis of the working mechanism of the touch screen, the touch screen driver written by the author under the real-time embedded operating system uc/OS is applied to the intelligent controller based on ARM7202. Practice has proved that the system is stable and reliable, and meets the requirements of fast response of the touch screen in a complex real-time multi-tasking environment.
References
[1]Hynix Semiconductor, HMS30C7202_datasheet_ver1.3_A13, 2003.
[2]Carlos E. Vidales, An algorithm for calibrating the point-to-point correspondence between touch screens and displays.
Previous article:Long-distance portable wireless transmission system based on ARM
Next article:Design and implementation of remote wireless monitoring system based on ARM
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
- How to deal with severe overheating of the adjustable DCDC circuit?
- DSP6678 NDK network configuration (UDP) points
- TUSB9261 -- USB3.0 to SATA interface bridge chip programming guide
- About the input stage of multi-channel acquisition cards
- Help! Why can't my TMS320F28379D launchpad even light up the LED?
- MSP430 Main Memory Bootloader Introduction
- ADS software simulation post summary
- Filter function judgment
- Bluetooth Module Hardware Design Guide
- 【Beetle ESP32-C3】Download CircuitPython