Touch screen Driver Control Based on C8051F020

Source: Internet
Author: User

Touch screen Driver Control Based on C8051F020
[Date: 2008-10-29] Source: foreign electronic components by Zhu PINWEI, Han xiaoxin [Font:Large Medium Small]

 

1 Introduction
Currently, touch screens and LCD screens have become common input and output devices for embedded computer systems. Touch Screens include resistors, capacitors, surface acoustic waves, infrared scans, and vector pressure sensing touch screens. The most commonly used touch screens are four-or five-wire resistive touch screens. TSC2046 is a four-wire resistive touch screen controller. It is widely used in battery-powered small handheld devices with its low power consumption and high speed.
C8000051fxxx series single-chip microcomputer is a fully integrated hybrid signal system-level device with a peak speed of 25 MI/s. Chip-integrated ADC and DAC; SMBus/I2C, UART, SPI interface: programmable counter/Timer array; 64 I/O Ports (P0 ~ Internal JTAG and debugging circuit, supporting system debugging. This article introduces the use of the series of single-chip microcomputer, TSC2046 and LCD screen to achieve human-machine interaction interface.

2 touch screen working principle
The touch screen controller is equivalent to the interface between the touch screen and the microcontroller. The touch screen is a 4-layer composite film attached to the display surface for use with the display. Figure 1 shows the external structure of the touch screen. Each conductive layer is a working face of the touch screen, and each Working Face is coated with silver gel at both ends. It is called a pair of child electrodes on the working face, which are called an X electrode pair and a Y electrode pair respectively. When the touch screen controller applies a fixed voltage to the X electrode instead of the Y electrode, the X electrode will form a uniform and Continuous Parallel Voltage Field on the face. 2 (). When the touch screen is touched by a finger or pen, the contact voltage reflects the position of the contact on the Y working face. The voltage is directed to the touch screen controller through the Y + (or Y-) electrode, after A/D conversion, you can obtain the number of contact voltage, that is, Y coordinate. Similarly, apply voltage to the Y electrode and take X + (or X-) as the measurement electrode to obtain the X coordinate. Based on the contact Coordinate Position and corresponding coordinate position, the microcontroller can know the intention of the touch.

3 TSC2046 operating mode and control word
The TSC2046 mode can be set to 8-bit or 12-bit working mode. The input mode is differential input and single-ended input. This article describes the 12-bit differential input mode. Table 1 is the control word of TSC22046.

S indicates the start flag of data transmission, which is "1 ". A2 ~ A0 is used for channel selection and determines the Pin Input of the analog voltage output from the touch screen body from TSC2046. MODE is used to select the/D conversion precision. When the value is 1, 8 bits are selected; when the value is 0, 12 bits are selected. In 12-bit operating mode, the percentile of the binary result indicates that the analog voltage is 1/4 096 of the reference voltage (TSC2046 pin + pressure difference between VCC And GND. SER/DFR can be used to select the input mode, SER selects the single-ended mode, and DFR selects the differential mode. PD1 and PD0 are used to select power-saving mode. Figure 3 is in differential input mode. Table 2 is the input configuration in differential mode. The difference mode is a ratio measurement conversion method. The voltage added to the touch screen electrode is the voltage between TSC2046 pin + VCC And GND, and the conversion result is the percentage of the distribution resistance value on the touch screen.

4 typical applications
4.1 Interface Circuit

Figure 4 shows the circuit connection between TSC2046 and C8051F020. The two-to-Child electrodes of the touch screen are connected to the Four electrodes of TSC2046 through J2. To enhance the drive capability, the connections between TSC2046 and C8051F020 are pulled to 5 V through a 10 k Ω pull-up resistor. The SPI interface is used for communication. The relationship between the related pins is as follows: TSDIN-data input, TSBUSY-busy signal, TSINT-pen interrupt signal, TSDDOUT-data output, TSDCLK-clock signal, and TSCS-selected signal. When TSC2046 is connected to C8051F020, because the TSINT pin receives the interrupt signal sent by TSC2046, The TSINT pin is configured as the External Interrupt pin through the cross switch when you configure C8051F020. Otherwise, you can only check the level status of the tsint pin to determine whether a touch event exists. To reduce interference, a bypass capacitor should be connected at the input ends of X +, X-, Y +, and Y-. The data line should be as short as possible.

4.2 Program Design
The driver of TSC2046 follows the standard SPI protocol to communicate with the microcontroller. When the touch screen is pressed (touch event occurs), TSC2046 sends the interrupt request to the microcontroller through the interrupt pin (TSINT), the microcontroller receives the request, delay 30 MS, then respond to the request to eliminate jitter and make the sampling more accurate. If one sampling is inaccurate, You can sample multiple times and obtain the last result. The process of the TSC2046 driver is shown in step 5. Figure 6 shows the/D conversion sequence (16 clock signals are required for one conversion ).

According to the time sequence diagram, the code for reading the TSC2046 sub-function is as follows:


The above is a typical sub-function in the driver, and other sub-functions are similar to this. Note that a single conversion requires 16 clock signals, but the output is 12-bit data. Therefore, four idle clock signals should be added to achieve 16 clock signals, in order to obtain the correct A/D conversion result. Otherwise, if TSC2046 and C8051F020 cannot be synchronized, no data is output. In addition, if the control word of TSC2046 is sent successfully, SPI communication must be disabled until the/D conversion is complete to avoid interference of the digital signal on the analog voltage. The Touch Screen has been applied to the input and output systems of a medical device and has a good response.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.