1 Introduction
Embedded touch screen device is a human-computer interaction device. Generally, the touch screen is installed on the LCD screen. The microprocessor is used to control the touch screen and the LCD screen, so that the touch screen can control the LCD screen. It is convenient and intuitive, replacing the traditional keyboard input and becoming the input device of the embedded computer system. It is widely used in electronic products and industrial control. Due to the uneven edge resistance of the touch screen, it is difficult to find the change law, and it is difficult to achieve the correspondence between the touch screen coordinates and the dot matrix LCD screen. There will be a misalignment between the touch point and the LCD display information, resulting in insensitive touch control information. Based on the AT89C51 microcontroller and ADS7846 chip, supplemented by a dot matrix LCD screen, this paper designs the hardware and software of the embedded touch screen input and display system, realizes the correspondence between the touch point measurement and the pixels on the LCD screen, realizes the expected control function, and improves the sensitivity of touch control.
2 Hardware Design of LCD Touch Screen
The LCD touch screen consists of a graphic LCD display module and a touch screen attached to the display screen. The software and hardware interface is realized with the help of the touch screen controller ADS7846 and the microprocessor AT89S51. The display and control functions are realized by detecting the user's touch position on the touch screen.
2.1 Working principle of touch screen
Touch screens can be divided into various types based on their working principles, such as resistive, capacitive, infrared, surface acoustic wave, vector pressure sensor, etc. This article uses the most commonly used four-wire resistive touch screen.
The resistive touch screen is composed of 4 layers of transparent composite film. The bottom layer is a base layer made of glass or organic glass, and the top layer is a hardened smooth anti-scratch plastic layer. There are two layers of indium tin oxide (ITO) transparent conductive layers between the inner surfaces of the bottom and top layers, forming two working surfaces of the touch screen. A silver glue is coated at both ends of each working surface, which is called a pair of electrodes of the working surface. If a voltage is applied to the electrode pair of a working surface, a uniform and continuous parallel voltage distribution will be formed on the working surface. When a certain voltage is applied to the electrode pair in the X direction, and no voltage is applied to the electrode pair in the Y direction, in the X parallel voltage field, the voltage value at the contact point can be reflected on the Y+ (or Y-) electrode. By measuring the voltage of the Y+ electrode to the ground, the X coordinate value of the contact point can be obtained through A/D conversion. Similarly, when a voltage is applied to the Y electrode pair and no voltage is applied to the X electrode pair, the Y coordinate of the contact point can be obtained through A/D conversion by measuring the voltage of the X+ electrode. There are two types of resistive touch screens: four-wire and five-wire. The working principle of the measurement process of the four-wire touch screen is shown in Figure 1.
Figure 1 Four-wire resistive touch screen measurement principle
The measurement result at the touch point P is calculated as follows:
2.2 ADS7846 Controller
ADS7846 is a touch screen dedicated controller from Burr2Brown. Its internal structure is shown in Figure 2.
Figure 2 ADS7846 internal structure diagram.
ADS7846 is composed of a multiplexer and a 12-bit A/D converter. The working state of the multiplexer is controlled according to the control word of the serial control port, the working voltage of the working surface is controlled, and the working voltage corresponding to the coordinate position of the contact on the corresponding electrode is sent to the A/D converter, which is converted into a digital quantity and then transmitted to the CPU through the serial port. The coordinates of the X and Y directions of the contact are obtained through calculation, and the contact position is determined. The program executes the corresponding function according to the information displayed on the contact coordinate position.
Then the binary output code of point P is:
Where: V ref_full is the reference voltage applied to the A/D converter inside the ADS7846. [page]
The control word of ADS7846 is shown in Table 1. S is the start flag of data transmission, which must be "1"; A2, A1, and A0 are used for channel selection control. The relationship between coordinates and channel selection is shown in Table 2. MODE is used to control the accuracy of A/D conversion. "1" selects 8 bits and "0" selects 12 bits. SER/DFR selects the input reference voltage mode. "1" is single-ended mode and "0" is differential mode. PD1 and PD0 select power saving mode: "00" allows power saving mode, power is turned off between two A/D conversions, and interrupts are allowed; "01" is similar to "00", but interrupts are not allowed; "10" is reserved; "11" prohibits power saving mode.
Table 1 ADS7846 control word
Table 2 Relationship between ADS7846 coordinates and channel selection
ADS7846 and MCU are connected through a standard SPI interface, as shown in Figure 3. When a touch action is detected, the pen interrupt request terminal (PENIRQ) of ADS7846 outputs a low-level signal to send an interrupt request to MCU to measure the coordinates of the touch point. MCU selects ADS7846 through the SPI interface, sends a coordinate measurement control word, and then reads the ADS7846 A/D conversion result data. After two controls, the X and Y coordinates of the touch point position can be obtained respectively. The working sequence of ADS7846 is shown in Figure 4.
Figure 3 SPI interface between ADS7846 and MCU.
Figure 4 ADS7846 and MCU communication timing.
[page]
3. Determination of the corresponding positioning of the touch point coordinates and the LCD screen control function
In this example, ADS7846 uses a differential reference voltage method to reduce measurement errors. Due to individual differences in touch screens, the measured values of different touch screen edges are different, and the measured values cannot reach 0 or full scale (4096). The LCD screen has a relatively accurate positioning value, and it is difficult to achieve a one-to-one correspondence between the touch screen and the LCD screen, which brings great trouble to programming and debugging. Only the regional correspondence between the touch screen and the LCD screen can be achieved, which does not affect the display function of the LCD screen and the control function of the touch screen.
The touch screen controller ADS7846 is connected to the microcontroller AT89S51 through the SPI interface. When a touch occurs, the ADS7846 makes an interrupt request to the AT89S51, and then the AT89S51 responds to the interrupt request and reads the conversion result of the ADS7846 through the SPI to obtain the coordinates of the touch point. Figure 5 is a flowchart of the interrupt service subroutine and the ADS7846 measurement subroutine.
Figure 5. Flowchart of the interrupt service subroutine and the ADS7846 measurement subroutine.
In order to effectively find the coordinate range of the touch point of the touch screen and the corresponding area of the dot matrix LCD screen, according to the dot matrix coordinates of the display function area of the LCD screen, according to the character format of the control information displayed on the LCD screen, reasonably select the horizontal and vertical lines, and measure the touch point values according to the LCD display and touch screen control function areas to find the touch point value range of the touch screen control area corresponding to the LCD screen. According to the measured data analysis of the touch point coordinates of the touch screen, the corresponding pixel coordinates on the LCD screen can be obtained.
The relationship between the coordinates of the LCD screen pixel point and the measured value of the touch screen touch point can be expressed as:
Where: X and Y are the touch point measurement values; (Xmin, Ymin) and (Xmax, Xmax) are the maximum and minimum coordinate touch point measurements on the touch screen respectively; (X1, Y1) is the pixel coordinate of the touch point on the LCD screen. The data in Table 3 and Table 4 are measured data.
[page]
Table 3 Coordinate values of equidistant measurements on the measured vertical line
Table 4 Coordinate values of equal distance measurements on the measured horizontal straight line
It is worth noting that the measured conversion value of the touch screen in the X direction is from large to small, and the conversion value in the Y direction is from small to large. The coordinate value is basically linear in a certain range. However, the output resistance in the X direction and the output resistance in the Y direction change greatly at the edge of the touch screen, which is a nonlinear relationship. Therefore, in order to accurately calibrate the coordinates of the touch screen, the linear change law is used in a large range, and the table lookup method is required in the edge.
4 Conclusion
Using ADS7846 to realize touch screen control can conveniently use the SPI interface to realize the interface with the microcontroller. When used in conjunction with a dot matrix LCD screen, industrial control can be easily realized through coordinate transformation between the LCD screen and the touch screen, while improving the response speed of the LCD screen.
Previous article:Realizing Low-cost and High-precision A/D and D/A Conversion Using Single-chip Microcomputer
Next article:Design of USB2.0 Interface for Digital Synthesized Frequency Sweeper
- 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
- Programming with MicroPython:Embedded Programming with Microcontrollers and ...
- Is the forum exchange activity suspended?
- Video of Glowing Bubble Clock
- EEWORLD University ---- Computer Networks (Harbin Institute of Technology)
- Four-axis source code
- [Help] Hardware IIC slave problem of stm8s103f3p6
- Is it necessary to add a π-type filter circuit for serial communication? If the board is small and the space is limited, this must be considered.
- The conducted spurious signals of the RF with shielding cover are 5-6dB worse than those without shielding cover.
- What should we pay attention to when launching new products? In particular, is there any good advice on how to prevent plagiarism?
- Design of Chinese Human-Machine Interface Based on MSP430 Microcontroller with Low Power Consumption