Source: TouchScreen Article - mikroElektronika
What is a touch panel?
A touchpad is a fine panel adhesive placed on the screen a graphic LCD. It is very sensitive to pressure so that a soft touch causes some changes in the output signal.
There are different types touch panels. The simplest of them is the resistive touch panel which will discuss here.
Working principle
A resistive touch panel is composed of two transparent rigid foils, forming a structure "sandwich" having a layer Resistive on their inner faces. Resistance these layers usually does not exceed 1Kohm.
Opposite sides of the sheets have contacts to access a ribbon cable. The procedure to determine the coordinates the position of the panel has been pressed can be divided into two steps. The first is the determining the X coordinate and the second the Y coordinate of the point. To determine the X coordinate, it is necessary to connect Pin superfi left surface of the X contact to ground and right to the power supply. This allows obtaining a voltage divider pressing the touch panel. The voltage value obtained in divider can be read on the bottom contact of the superfi Y. surface tension will vary in the range of 0 V to the voltage supplied by the power supply and X coordinate depends If the point is near the left contact superfi surface X, the voltage will be close to 0 V.
For determining the Y coordinate, it is necessary connecting the lower contact surface Y superfi to ground, while the upper contact will connect to the power supply. In this case, the voltage reading will be in contact superfi left the surface X.
Connecting to a microcontroller
To connect a touch panel to the microcontroller, it is necessary to create a circuit for touch panel control. Through this circuit, the microcontroller connects the right contacts the touch panel to ground and the supply voltage (as described above) to determine the X and Y coordinates (see Scheme). The lower contact surface superfi Y and left contact the surface superfi X are connected to A / D converter of the microcontroller. the Ones X and Y coordinates are determined by measuring the voltage at the respective contacts.
In software is to display a menu in a graphical LCD, switch on and off the touch panel (touch control panel) and reading the values of A / D converter which actually represent the X and Y coordinates of the position. After determining the coordinates, it is possible to decide what we want to do to the microcontroller.
dim x_coord, y_coord, x_coord128, y_coord64 as longint ‘ scaled x-y position
sub function GetX() as word
‘reading X
DRIVE_A = 1 ‘ DRIVEA = 1 (LEFT drive on, RIGHT drive on, TOP drive off )
DRIVE_B = 0 ‘ DRIVEB = 0 (BOTTOM drive off )
Delay_ms(5)
result = ADC_Read(0) ‘ READ-X (BOTTOM)
end sub
sub function GetY() as word
‘reading Y
DRIVE_A = 0 ‘ DRIVEA = 0 (LEFT drive off , RIGHT drive off , TOP drive on)
DRIVE_B = 1 ‘ DRIVEB = 1 (BOTTOM drive on)
Delay_ms(5)
result = ADC_Read(1) ‘ READ-X (LEFT)
end sub
Image Gallery
Video:
Top Comments