1 Structure of resistive touch screen
The detection component of the resistive touch screen is a multi-layer composite film that fits closely with the display surface. It is composed of a layer of glass or organic glass as the base layer, a resistive conductor layer (such as indium tin oxide ITO) coated on the surface, and a hardened, smooth and scratch-resistant plastic layer on the top. The inner surface of the plastic layer is also coated with a resistive conductor layer. There is an isolation layer with many tiny isolation points between the two conductor layers, which separates and insulates the two conductor layers, as shown in Figure 1. When a finger touches the screen, the two conductor layers come into contact at the touch point. The controller detects this connection point and calculates the X and Y coordinates. This is the detection principle of the resistive touch screen.
Resistive touch screens are divided into various structures such as 4 to 8 lines according to the number of lead lines. The 4-wire resistive touch screen is the most representative, and its detection principle is shown in Figure 2. A narrow electrode is placed on the upper and lower sides of the outer ITO layer, with the lead ends being Y+ and Y-, and a narrow electrode is placed on the left and right sides of the inner IT0 layer, with the lead ends being X+ and X-. In order to obtain the position signal of the touch point in the X direction, VREF and 0 V voltages are applied to the two electrodes X+ and X- of the inner ITO layer, respectively, so that a voltage gradient from 0 to VREF is formed on the inner IT0 layer. The voltage from the touch point to the X- end is the voltage divided by the two-terminal resistors to VR-EF. The voltage divided value represents the position of the touch point in the X direction. Then, one electrode (such as Y-) of the outer ITO layer is suspended, and the voltage divided can be taken from the other electrode (Y+). The voltage divided is converted by A/D and compared with VREF to obtain the X coordinate of the touch point.
In order to obtain the position signal of the touch point in the Y direction, it is necessary to apply VREF and OV voltages to the two electrodes Y+ and Y- of the outer ITO layer respectively, and leave one electrode (X-) of the inner ITO layer suspended, and take the divided voltage of the touch point in the Y direction from the other electrode (X+).
2 Features of ADS7846
2.1 Basic Features
ADS7846 is a new generation of 4-wire touch screen controller launched by BB Company in the United States. It consists of low on-resistance analog switches, successive approximation ADC with sampling/holding function, asynchronous serial data interface, temperature sensor, etc. ADC is the core of ADS7846, with a conversion rate of up to 125 kHz and a programmable resolution of 8 or 12 bits. The device not only has the function of measuring X and Y coordinates, but also has four measurement functions: battery voltage, chip temperature, touch pressure and external analog quantity. Its working mode can be determined by the control word. The 6-to-1 analog multiplexer in the chip can select one of the 6 voltage quantities (X+, Y+, Y-, VBAT, TEMP, AUX-IN) according to the command word sent by the microcontroller, and send it to the A/D converter for conversion, and then send the conversion value to the microcontroller through the SPI interface. ADS7846 also integrates a touch recognition circuit. When a touch is detected, the circuit will output a low-level signal at the pin to make an interrupt request to the microcontroller to measure the coordinates of the touch point. The chip is powered by a single power supply with an operating voltage of 2.2 to 5.25 V and an internal +2.5 V reference voltage.
2.2 Pin Function
The pin arrangement of ADS7846 is shown in Figure 3, and the pin functions are shown in Table 1.
2.3 Control Word
The control function of ADS7846 is mainly to realize the switching of touch screen electrode voltage and A/D conversion of touch point position signal. The control word of ADS7846 is as follows:
S: Data transmission start flag. If it is 1, it means a new control byte has arrived; if it is 0, the data on the DIN pin is ignored.
A2A1A0: Channel selection bit. Used to control the input of the channel selector, the touch signal drive switch and the reference input voltage of the ADC. When A2A1A0=001, the Y coordinate signal is collected; when A2A1A0=101, the X coordinate signal is collected.
MODE: Used to select the precision of A/D conversion. 1 selects 8-bit precision; 0 selects 12-bit precision.
Used to select the reference voltage input mode. 1 is the reference voltage non-differential input mode; O is the reference voltage differential input mode.
PD1, PD0: Low power mode selection bits. If it is 11, the device is always in the power supply state; if it is 00, the device is in low power mode between two conversions.
2.4 Conversion Timing
The conversion timing of ADS7846 is shown in Figure 4. A complete electrode voltage switching and A/D conversion requires three serial data transmissions between ADS7846 and the microprocessor, and each transmission requires eight clock cycles.
The first transmission is from the microprocessor to send the control word to ADS7846, and the next two transmissions are the microprocessor reading the conversion results from ADS7846 (the last 4 bits are automatically filled with 0). Since the serial port supports bidirectional transmission at the same time, and the reading and the next control word can overlap, the conversion rate can be increased to 16 clock cycles each time.
2.5 Touch Coordinate Calculation
Since the Y-direction voltage increases gradually from bottom to top and the X-direction voltage increases gradually from right to left in a four-wire resistive touch screen, the coordinate origin corresponding to the Y and X-direction voltages is in the lower right corner of the touch screen. In order to obtain the X and Y coordinate values used in engineering (i.e., move the coordinate origin to the lower left corner), the X-position voltage conversion value should be complemented. In addition, the X and Y position voltage conversion values must also correspond to the dot matrix of the display screen (the liquid crystal used is a 240×160 dot matrix). Therefore, the calculation formula for the corrected X and Y coordinates is:
Where: Xmax, Xmin are the maximum and minimum values of the voltage conversion result at the X position; Ymax, Ymin are the maximum and minimum values of the voltage conversion result at the Y position; Y, X are the conversion values of the voltage at the touch point; x, y are the corrected coordinates of the touch point.
3 Interface between touch screen and microcomputer
3.1 Interface Circuit
The interface circuit between the touch screen and the 80C55 microcontroller using ADS7846 is shown in Figure 5. The X+, X-, Y+, and Y- of the touch screen are connected to the corresponding terminals of the ADS7846. When A2A1-A0=001 in the control word, X+ is connected to the power supply VCC and X- is grounded by switching the on-chip analog switch. The Y+ and Y- terminals are connected to the input terminals of the A/D converter in a differential form. The result of the A/D converter is the Y position voltage. Similarly, when A2A1A0=101 in the control word, the result of the A/D converter is the X position voltage. When the data transmission between the microcontroller and ADS7846 adopts serial communication mode, the microcontroller serial port modes 1 to 3 are different communication modes, which do not match the timing of ADS7846; serial port mode 0 is a register mode, although it can match the timing of ADS7846, the serial port data input/output uses the same terminal RXD (TXD) as the synchronous pulse output terminal), and the ADS7846 data input/output uses different terminals DIN and DOUT. In order to achieve correct bidirectional data transmission, a bidirectional data chip GAL is designed. The function of this chip is that when E=O, the data transmission direction is Y to A; when E=1, the transmission direction is B to Y. The pen interrupt signal of ADS7846 is connected to P2.4. When the signal is valid, the microcontroller sends the control word. The busy signal BUSY of ADS7846 is connected to P2.6. At the falling edge of the BUSY signal, the microcontroller receives the A/D conversion result.
3.2 Interface Program
When the touch screen is touched, the ADS7846 interrupt signal is valid. After the MCU detects this valid signal, it first sends the X coordinate measurement control word and detects whether the BUSY signal has a falling edge. After the falling edge arrives, it reads the X position voltage; then sends the Y coordinate measurement control word to obtain the Y position voltage. The obtained X and Y position voltages are calculated using formulas (1) and (2) to obtain the X and Y coordinates of the touch point. The software flow is shown in Figure 6.
4 Conclusion
The designed touch screen interface circuit has the following advantages: by adding a two-way transmission GAL chip, the serial communication problem between the 51 series microcontroller and the touch screen controller ADS7846 is solved; by correcting the voltage at the touch point position, the correct touch coordinates are obtained; the interface circuit is easy to implement and has strong practicality.
Previous article:Design of Stable Operation of 51 Single Chip Microcomputer in Microcomputer Automatic Switching System
Next article:Using MCS51 single chip microcomputer to drive stepper motor circuit and program
- 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
- Duty cycle setting problem
- Detailed explanation of Zigbee networking principle
- Ask a question about operating ESP8266 with STM32
- How to write pointer array in stm32
- [Evaluation of domestic FPGA Gaoyun GW1N-4 series development board]——12. Two tips (multi-function pins and board silk screen)
- Questions about the CAN bus ID part
- [Classic C language knowledge] Summary of C/C++ programming difficulties
- Is this a series voltage regulator circuit?
- Shenzhen Yezhan Electronics is looking for talents||Looking forward to your joining
- 【Atria AT32WB415 Series Bluetooth BLE 5.0 MCU】Serial port test