Touch screen coordinate algorithm in 51 single chip microcomputer system

Publisher:剑戟辉煌Latest update time:2012-03-16 Source: 单片机与嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction:
There are many types of interfaces for human-computer dialogue, such as display, LED, LCD and LCD with touch screen. The latter is a new technology that has just developed in recent years. It processes sound, image, video, text, animation and other information through computer technology, and establishes certain logical relationships between these information, making it an integrated system that can interactively access and output information. In other words, it can collect, process, integrate and transmit information in a two-way manner based on the wishes of the information publisher and the needs and acceptance habits of the recipient. The touch screen system conforms to the principles of simplicity, economy and efficiency, and has the characteristics of good human-computer interaction, simple and flexible operation and fast input speed. It is combined with the rapidly developing computer network and multimedia technology. Users can retrieve information and analyze data by just touching the screen with their fingers, and can even make immersive and lifelike effects; it is simpler, more intuitive and faster than keyboard input, and has rich and colorful expression capabilities, which is more affinity than any previous media. The

touch screen and 51 single-chip microcomputer interface can make the operation of some small systems more convenient and faster. The most important issue when using a touch screen is to determine the coordinate position, that is, to determine whether the contact position is within the effective area of ​​the key. Since the assembly language of the 51 series microcontroller does not have the rich library functions and logical operation capabilities of other high-level languages, how to use the 51 microcontroller to simply and accurately complete this task has become an urgent problem to be solved in the application.

In actual applications, we use ADS7843 as the controller of the touch screen. There have been many articles published on the principle and working mode of ADS7843, but how to confirm the coordinate position is rarely mentioned. This article only analyzes the problem of coordinate determination as follows.

1 Conversion mode

The conversion accuracy of ADS7843 is 8 bits and 12 bits, which can be accurate to 1/256 and 1/4096 in the X or Y direction. We use the PDA240160 touch display screen of Tsinghua Pengyuan Company, with an outer size of 61.6mm×42.4mm, so there is no need to use 12-bit A/D conversion, and only 8-bit A/D conversion is enough to achieve the required accuracy, that is, the minimum division is 1/256 in the X and Y length directions.

2 Coordinate Determination

The coordinates of the PDA240160 touch screen display are shown in Figure 1.


Among them, (X,Y) is the center coordinate of a chart key, (X',Y') is the coordinate of the lower right corner, and (X",Y") is the coordinate of its upper left corner. When touching the screen, as long as the touch point is within the rectangular area of ​​(X',Y') and (X",Y"), it is considered that the touch is valid. Assuming that the center coordinate (X,Y) of a 32×32 dot matrix icon key is (50,50), then (X',Y') is (35,40), and (X",Y") is (65,60). When touching, as long as the key coordinates obtained are between (X',Y') and (X",Y"), it is considered that the key is touched. However, there are so many values ​​within the key coordinate range. How to process the obtained coordinates? Initially, we adopted the scattered transfer method, but the result was that the program was too lengthy, poorly readable, and poorly portable, and could not be called as a subroutine. After discussion and analysis, we finally adopted the table lookup method.

First, make a coordinate table as shown below (including the two corner coordinates of all keys on the current screen):
Each row in the table represents the two corner coordinates of a key value (it is necessary to call the relevant program to determine the coordinate values ​​of the two corners after placing the icon key), and the last characters 001~n are the signs of each key value (abbreviated as A). This sign is very useful and will be seen in future programs.
3 Program flow chart and program list

The program flow chart is shown in Figure 2:


The subroutine list can be found in the online supplementary version of this journal (www.dpj.com.cn). Among them, XA and YA store the coordinate values ​​after A/D conversion. The program has been debugged and passed. Please verify it.

Conclusion

After repeated tests, it is concluded that each touch key is very sensitive and can respond within the effective area of ​​each icon key. It proves that this idea is simple, easy to understand, and has good portability. It is very valuable in practical application when determining the coordinates of the touch key position.

References
1 Burr-Brown Company. ADS7843 Data Book. 1998
2 He Limin. Single-Chip Microcomputer Application Technology Selection (5). Beijing: Beijing University of Aeronautics and Astronautics Press, 1997
3 Wan Fujun, Pan Songfeng, et al. Single-Chip Microcomputer Principle System Design and Application. Hefei: University of Science and Technology of China Press, 2001
4 Hu Bing, Wu Shengyan, et al. ADS7843 Touch Screen Interface. Foreign Electronic Components. 2002(7): 27~29

Reference address:Touch screen coordinate algorithm in 51 single chip microcomputer system

Previous article:Intelligent power cabinet based on single chip microcomputer C8051F060
Next article:Realizing Remote Temperature Display Using Single Chip Microcomputer

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号