Design of touch screen interface in the hottest la

  • Detail

Touch screen interface design in laser therapeutic instrument

Abstract: the application of various touch screens simplifies the process of human-computer interaction. This paper introduces the working principle of four wire resistive touch screen and its application in laser therapeutic instrument. This paper describes the data transmission process between ADS7846 and microcontroller PIC16F876

key words: touch screen ADS7846 laser therapeutic instrument PIC16F876


with the improvement of social automation, the human-computer interaction ability urgently needs a big change, and develops towards a more convenient and intuitive direction. Laser therapeutic machine mainly uses the physical characteristics of laser to act on the human body and produce body chemical reactions to achieve the purpose of treating diseases. As a kind of precision instrument, laser therapy machine needs precise control and strict requirements in dust prevention, static electricity prevention, moisture prevention and so on. The input device of laser treatment machine adopts touch screen control, which is not only based on the above requirements, but also from the perspective of user-friendly operation and intuitive interface. The application of touch screen makes data display and data input integrated, simplifying the whole device

1 touch screen principle

the touch screen is attached to the surface of the display and used together with the display. The analog electrical signal is generated by touch, which is converted into digital signal, and the coordinates of the touch point are calculated by the microprocessor, so as to obtain the intention of the operator and execute it. According to its technical principle, touch screen can be divided into five categories: vector pressure sensing type, resistance type, capacitance type, infrared type and surface acoustic wave type, of which resistance touch screen is used more in practical applications. The resistive touch screen is composed of four layers of transparent thin, the bottom is the base layer composed of glass or plexiglass, and the top is a plastic layer whose outer surface has been hardened to be smooth and scratch resistant. The two layers attached to the upper and lower inner surfaces are metal conductive layers (OTI, indium oxide), which are insulated by small transparent isolation points. When the finger touches the screen, the two conductive layers contact at the touch point

the two metal conductive layers of the touch screen are used to measure the coordinates in the x-axis and Y-axis directions respectively. The conductive layer used for X coordinate measurement leads out two electrodes from the left and right ends, which are recorded as x+ and x-. The conductive layer used for y coordinate measurement leads out two electrodes from the upper and lower ends, which are recorded as y+ and y-. This is the lead composition of the four wire resistance touch screen. When a voltage is applied to a pair of electrodes, a uniform and continuous voltage distribution will be formed on the conductive layer. If a certain voltage is applied to the electrode pair in the X direction, 2.8 the fastening device should be flexible, and when there is no voltage applied to the electrode pair in the Y direction, in the X parallel voltage field, the voltage value at the contact can be reflected on the y+ (or y-) electrode, and the X coordinate value of the contact can be obtained by measuring the voltage of the y+ electrode to the ground. Similarly, when the voltage is applied to the Y electrode pair and the operation and management of private enterprises on the X electrode pair is not standardized, the Y coordinate of the contact can be obtained by measuring the voltage of the x+ electrode. The measurement principle is shown in Figure 1

five wire touch screen is different from four wire touch screen. The main difference is that the five wire touch screen leads out the four ends of one conductive layer as four electrodes, and the other conductive layer only outputs the voltage in X direction and Y direction as the measured conductor. During measurement, the voltage should be applied alternately in X direction and Y direction

2 working principle of touch screen controller

the touch screen controller has a variety of functions. Its main function is to apply voltage to the two directions of the touch screen time-sharing under the control of the microprocessor, and transmit the corresponding voltage signal to its own a/d converter. Under the action of the synchronous clock provided by the SPI port of the microprocessor, the signal such as sticky soft rubber is taken on the surface of the digital and the sample to read into the microprocessor. The basic structure of controller ADS7846 is shown in Figure 2

the measurement results at touch point P in Figure 1 are calculated as follows:

ads7846 can internally set the resolution of the a/d converter to 8 bits or 12 bits through the setting of registers. In this system, the resolution of the a/d converter is 12 bits. Then the binary output code of point P is:

, where: is the reference voltage added to the internal a/d converter of ADS7846

the operation of the touch screen controller is controlled by inputting control commands through the serial data input port din. The basic format of the control command is as follows:

bit7 indicates the start of sending the command, and the high level is valid. A2:a0 is used to select the data input channel, 101 for X coordinate measurement, 001 for y coordinate measurement. Mode defines the resolution of the internal analog-to-digital converter as 8 bits (mode=1) or 12 bits (mode=0). Ser/dfr is the single ended/double ended reference voltage selection bit. Pd1:pd0 is selected and set according to the needs of power saving mode. The setting of these command control bits will be applied in the program code section

3 system hardware design

the input system of laser therapy machine is composed of three parts: touch screen, touch screen controller and microcontroller. The microcontroller adopts PIC16F876, a new chip of microchip company. The internal bus adopts Harvard dual bus structure. With the same internal frequency, the data transmission speed is accelerated and the bottleneck phenomenon is avoided. This chip adopts reduced instruction set (RISC), which is easy to use and accelerates the development speed. It contains 8KB program memory (paging operation), 256 byte EEPROM, 368 byte ram, 8-way analog-to-digital converter, 1 universal serial port (SCI), 1 I2C interface, 1 serial peripheral interface (SPI), 3 timers, watchdog circuit (wathcdog) and many other important resources. The reuse of many peripheral interface functions makes the whole microcontroller simple and powerful

according to the interface characteristics of data exchange between ADS7846 and microcontroller, the SPI port of PIC16F876 is selected. SPI port includes three signals: SDO (serial data output), SDI (serial data input), SCK (serial synchronous clock). The hardware connection relationship is shown in Figure 3

this paper focuses on the design of the input system of the laser therapeutic instrument, and the design of other hardware only gives the meaning of the interface. Due to the high internal integration of PIC16F876, the peripheral interface is quite simple, but the internal register must be set to complete complex control functions

4 software design

the application software is designed according to the above design idea. Fig. 4 program flow chart of main program and touch screen input detection part. Among them, the coordinate data processing usually adopts the method of looking up the table, which forms the coordinates of the user command into a data table, and uses the obtained coordinate information to transform and quickly look up the table, so as to improve the running speed of the software

the following is part of the program code of the interface between PIC16F876 and ADS7846




YDATA_ H EQ Zhang Yu, Secretary General of the power battery Utilization Branch of China chemical and physical power industry association, said frankly that u 33h

ydata_ L EQU 34H

; Initialization register

movlw 02h

movwf tricb; Define B port direction

movlw 90h

:) movwf trisc; Define the C port direction

bcf sspcon, 5

movlw 10h

movwf sspcon; Initialize sspcon

BSF sspcon, 5; Start spi

; Get x, y coordinates


bcf portb, 0; Select ads7846

movlw 0d4h; Get the X coordinate command

movwf sspbuf; Send the command


btfsc portb, 1; Judge busy


MOVF SSPBUF, W ; 12 bit data

movwf XDATA_ H ; XDATA_ H store high bytes

movf sspbuf, w

movwf XDATA_ L ; XDATA_ L stores the low byte

; Y coordinate data is also processed

retlw 0


the design of this system makes input extremely convenient, and the peripheral equipment is simplified, which improves the ability of human-computer interaction in practical application and receives good social benefits. The idea of system design can be applied not only in the medical industry, but also in industrial production automation, handheld devices and other industries


1 burr brown corporation ADS7846 TOUCH-SCREEN CONTROLLER. 1999

2 Microchip Technology Inc. PIC16F87X Data Sheet. 2001

3 Yu Guangyun, Wang Qihong, Wu Yifeng Pic Series MCU development and application technology Beijing: Electronic Industry Press, 2000 (end)

Copyright © 2011 JIN SHI