Introduction to the working scheme of the LCD touch screen control system based on a single chip microcomputer

Publisher:数字梦想Latest update time:2012-07-02 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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
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
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 1 ADS7846 control word

Table 2 Relationship between ADS7846 coordinates and channel selection

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 3 SPI interface between ADS7846 and MCU.

Figure 4 ADS7846 and MCU communication timing
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 Interrupt service subroutine and ADS7846 measurement subroutine flow chart
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 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
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.

Reference address:Introduction to the working scheme of the LCD touch screen control system based on a single chip microcomputer

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号