1. Introduction
With the rapid development of modern computer technology and Internet technology, embedded systems have begun to occupy the mainstream of the market. Due to the high performance and low power consumption of 32-bit ARM embedded processors, it has been widely used in scientific research, engineering design, military technology, commercial culture and art, and consumer products. As the latest computer input device, the touch screen has the advantages of being durable, fast in response, space-saving, and easy to communicate. It is mainly used in places such as public information query, industrial control, military command, tourism, electronic games, ordering songs and dishes, multimedia teaching, and real estate pre-sales. Therefore, this article focuses on the interface design based on the embedded microprocessor HMS30C720 and the touch screen controller, and the programming design method combining the underlying serial port driver with the upper microwindows graphical interface to realize the control of the touch screen over the embedded devices.
2. Overall structure of the system
The overall structure of the system is shown in Figure 1: This system consists of an ARM unit and a touch screen control unit. The ARM unit mainly receives the location data information of the touch screen control unit and calls the ARM control and application program according to the location information. We selected Hynix 's ARM CPU HMS30C7202 as the main chip of the ARM system unit. It is a cost-effective 16/32-bit RISC microcontroller based on the Ethernet application system, which contains a 16/32-bit ARM7TDMI RISC processor core designed by ARM [1, 4] . The touch screen control unit mainly completes signal amplification and processing, A/D. According to the digital signal, the position of the icon on the touch screen clicked by the user is identified. And the icon should be called to execute the corresponding instruction. We selected a touch screen controller from a company in Shenzhen. The touch screen controller has the characteristics of serial communication interface and high resolution.
Figure 1 Overall structure of the system
3. Hardware circuit design
3.1 LCD interface circuit
HMS30C7202 has a built-in LCD display controller, and has a dedicated video DMA controller and video bus connected to the SDRAM controller. The separate bus makes the LCD refresh no longer require ARM control, and the data transfer is completely controlled by the DMA controller, which improves the performance of the entire system. HMS30C7202 supports color, monochrome STN LCD displays and TFT color LCD displays, with a display resolution of up to 640×480. This system platform uses 16-bit true color and a 565 color scheme, 5 bits of red, 6 bits of green, and 5 bits of blue. TFT displays all use 18 data lines, so the lowest bits of the red and blue data lines are grounded. In addition to the data lines, the LCD interface also has line and field synchronization signals, LCD clock signals, and LCD control signals, which can be connected to the CPU's LCD control outputs LLP, LFP, and LAC respectively.
3.2 Touch screen hardware circuit
3.2.1 Four-wire resistive touch screen
As shown in Figure 2, it is a schematic diagram of the principle of a four-wire resistive touch screen. The four-wire touch screen contains two resistive layers. One layer has a vertical bus at the left and right edges of the screen, and the other layer has a horizontal bus at the bottom and top of the screen. To measure in the X-axis direction, bias the left bus to 0V and the right bus to V REF . Connect the top or bottom bus to the ADC, and a measurement can be made when the top and bottom layers touch. To measure in the Y-axis direction, bias the top bus to V REF and the bottom bus to 0V. Connect the ADC input to the left or right bus, and the voltage can be measured when the top and bottom layers touch. For a four-wire touch screen, the ideal connection method is to connect the bus biased to V REF to the positive reference input of the ADC, and connect the bus set to 0V to the negative reference input of the ADC.
3.2.2 Touch screen serial port controller interface definition
The relationship between the touch screen interface pins and the RS232 serial port pin functions is shown in Table 1. The RS232 serial port pins are 9 pins, only 5 pins are used, and the touch screen power supply is provided by the 4th pin of the PS/2 interface.
Table 1 Relationship between touch screen interface pins and RS232 serial port pin functions
Pinout |
1 |
2 |
3 |
4 |
5 |
RS232 serial port pin functions |
Data Detection |
Receiving Characters |
Transmit Character |
Data terminal preparation |
land |
Touch screen serial port pin function |
send |
take over |
|
|
land |
PS/2 Pin Functions |
|
|
|
+5v |
land |
[page]
4. Determination of communication protocol and software design
4.1 Detailed analysis of the communication protocol of the touch screen serial port controller
Due to the company's commercial reasons, the source code and communication protocol are not provided, and there is no driver for HMS30C7202. With the help of the serial port debugging assistant and storage oscilloscope analysis, we have obtained the communication protocol of the serial port touch screen controller. Its transmission rate is 9600, one frame of data is 10 bits, the start bit is 1, 8 data bits, the stop bit is 0, and there is no check bit. The low bit is sent first and then the high bit. Each data packet transmits 5 bytes of data. The first byte is the control bit, the second and third bytes are the X-axis coordinate values obtained by the touch screen, and the fourth and fifth bytes are the Y-axis coordinates obtained. In this way, we have obtained the communication protocol of the touch screen controller, which provides a basis for writing the corresponding touch screen program under the Linux system.
4.2 Design of touch screen serial communication program
First, write a serial communication program corresponding to the touch screen under the Linux system, compile it with a cross compiler, download it to the target board ARM, and after running it, click the touch screen to get the touch screen output data. In this program, our goal is to establish communication between the touch screen serial port controller and ARM7 serial port 1, so that the read data can be displayed on the corresponding LCD display screen. After setting the corresponding baud rate, data bit, parity bit and stop bit, the data sent by the touch screen serial port controller can be read. The main program flow chart is shown in Figure 3 [3] .
Figure 3 Main program flow chart
4.3 Touch screen and LCD display coordinate conversion and Microwindows programming implementation
This design uses the microwindows 0.90 version. When writing a program, you do not need to care about the underlying driver and directly call the upper-level API. There is no need to write the underlying driver. The method used here is to write a serial port receiving program corresponding to the touch screen in microwindows, and then compare the coordinates of the microwindows window with the coordinate values in the serial port data. If they are within a certain range, a corresponding event is generated [2] . Use an array to receive the data sent from the serial port, and then take out the position information of the touch screen from the array. The coordinate origin and resolution of the touch screen are different, which also needs to be converted. The specific conversion formula is:
We assume the touch screen is as follows: the lower right corner is the origin coordinate (x 1 ,y 1 ), the horizontal axis is the x-axis, the vertical axis is the y-axis, the upper right corner coordinates are (x 1 ,y 2 ), the upper left corner coordinates are (x 2 ,y 2 ), the upper right corner coordinates are (x 2 ,y 1 ), and the resolution is 4096×4096; the coordinate origin of the LCD connected to ARM7 is in the upper left corner, the horizontal axis is the x-axis, the vertical axis is the y-axis, and the resolution is 640×480, then our coordinate conversion formula is:
x LCD =640-[640×(xx 1 )/(x 2 -x 1 )] (4-1)
y LCD =480-[480×(yy 1 )/(y 2 -y 1 )] (4-2)
Since the resolution of the touch screen is 4096×4096, the values of x 2 -x 1 and y 2 -y 1 are both 4096; the coordinate conversion formula is:
X LCD =640-640×z 1 /4096; (4-3)
Y LCD =480-480×z 2 /4096; (4-4)
The coordinates z1 and z2 in the formula are the coordinates of the touch screen. The method of obtaining them is as follows: the array buffer[ ] receives the data sent from the serial port, and we need to extract the useful coordinate information from the array.
x1=buffer[6]; x2=buffer[7]; x3=buffer[3]; x4=buffer[4];
Here we use four 8-bit elements to obtain two 16-bit coordinate information. Then we need to convert the two 8-bit coordinate data into one 16-bit data. The specific conversion is as follows:
y1=x1<<8; y1 |=x2; /*Two 8-bit data shifted to 16-bit data*/
y2=x3<<8; y2 |=x4;
Then y1 and y2 are the coordinate signals of our touch screen. After the conversion, the coordinates of the display and the touch screen correspond to each other. Create a window under microwindows, set its coordinate value and size, and then use the message processing function of microwindows. If the touch range (the corresponding coordinates of the touch screen on the screen) is within the coordinate range of the window, a corresponding event is generated. I am printing a Touched message on the window. When the touch screen is touched outside the window range, the Nottouched message is printed. Write a program to touch the corresponding position on the touch screen, and a new window will be output at the corresponding position on the screen, and the position is relatively accurate. Figure 4-9 shows the touch point response position displayed on the LCD display when the touch screen is touched.
Figure 7 The position of the LCD display when the touch screen is touched
in conclusion
Through debugging and testing, the design requirements are fully met. The innovation of this design is: the touch screen controller of a Shenzhen company is successfully applied to the HMS32C7202 embedded control system. When the other party does not provide the communication protocol and driver, the communication protocol of the controller is analyzed and the driver of ARM is written. The physical conversion relationship between LCD and touch screen is analyzed, and then the upper-level program is written. The relevant calls are made through the API of microwindows to establish a connection between the underlying data and the upper-level graphical interface. Finally, the corresponding event processing and response program is written to complete the operation of ARM by touching the graphical interface of the touch screen. This interface has been applied to the embedded system platform based on Internet network communication developed by me.
References
[1] Hynix Semiconductor Inc.
HMS30C7202
·www.hynix.com
[2] Wu Minghui et al. Development and application of embedded systems based on ARM. People's Posts and Telecommunications Press. 2004.6
[3] Li Zhongqi. Research and implementation of touch screen control in embedded Linux system. Modern Display. 2005.2.19-22 [4] Yang Guangyou et al. Design of touch screen interface for embedded microprocessor ARM7202. Microcomputer Information. 2004.4, 2004.4.75-76
About the author: Wang Hong, male, born in April 1963, senior engineer, Hunan Provincial Education Department Scientific Research Funded Project (03C211), mainly engaged in digital television and embedded system research and development
Previous article:Design and implementation of DC motor speed control system based on ARM
Next article:Design of interface circuit between ARM HMS30C7202 and touch screen
Recommended ReadingLatest update time:2024-11-16 16:46
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
- Xianyu low-cost wireless digital microphone disassembly (Jerry solution)
- [Perf-V Review] + Solidification of Hummingbird Soft Core
- Read the good book "Electronic Engineer Self-study Handbook" + my impression
- Three-port network
- RSL10 drives ink screen
- GoKit Case Study: Gizwits IoT Development Platform’s Pet House Transformed into an Air Quality Detector
- Embedded licensing: why not and why not?
- I found a 1963 "Electron Tube Handbook"
- How to extract the effective value of fundamental wave and each harmonic in MATLAB?
- Analysts predict Bluetooth location services will grow at a CAGR of 32% by 2025