# Touch Screen 101

When looking at the mikromedia for PIC32 development board, the most striking feature is the QVGA display. Programming the display will be the topic of many posts I’m sure. The second most prominent thing is the fact that it’s a touch screen display. The touch screen is the sole user input device provided, so getting it working is vital.

I had originally intended to go directly to the subject of touch screen calibration, but I figured it would be wise to take a look at the basics of the touch screen we’ll be working with. The provided touch screen is one of the simpler types. It’s known as a four wire resistive touch sensor. This sensor overlays the display with two clear conductive films separated by an air gap. When the screen is touched, the two layers are brought together and a position can be determined. The general hookup is as follows:

In typical operation, the sensor toggles between two states: measure Y and measure X. These are shown below:

In measure Y mode, the PIC port pins are used to generate a voltage gradient across one surface while the analog to digital converter is used to read the voltage present on the other surface. In measure X mode, the roles of the surfaces are reversed. Now assume for now that the sensor is currently in measure Y mode and it is being touched. What sort of voltage are we going to measure? Let’s take a look at the equivalent circuit for a moment:

Under ideal circumstances, Y1 and Y2 form a voltage divider and the output can be computed simply as :

$V_O = 3.3_V \frac{Y_2}{Y_1+Y_2}$

Alas, things are not ideal. Parasitic resistances and leakage currents all conspire to make it very difficult to predict the output voltage ahead of time. Consider the following more complete equation but still highly simplified:

$V_O = 3.3_V \frac{Y_2+P_2}{Y_1+P_1+Y_2+P_2}+I_L(X_1+P_3)$

Most of the values (eg: $P_n, I_L$) in the equation are unknown, uncontrolled, or parasitic values. Without some way for taking these terms into account, there is simply no way to make the touch sensor accurate enough to be useful. That is why it is so important that resistive touch screens be calibrated. The calibration process is used to determine the macro system behavior of all the unknown, manufacturing, and batch sensitive parameters. And that is our next topic!

Peter Camilleri (aka Squidly Jones)