ah. How to connect a 4-wire resistance touchscreen to a PIC microcontroller?

Use 4 resistors (one on each pin). The resistance is determined by the power supply voltage (most microcontrollers work on 3.3 V or 5 V) and the touchscreen design. The resistors must be connected in series with the touchscreen pins. I used four 180 ohm resistors on my touchscreen.

NOTE: How to protect the microcontroller and the touchscreen against overcurrent?

Z2 pressure is measured on Y- pin, while strong logical "1" is applied to Y+ and strong logical "0" is applied to X-.

Z1 pressure is measured on X+ pin, while strong logical "1" is applied to Y+ and strong logical "0" is applied to X-.

Y position is measured the same way on X- pin, while strong logical "1" is applied to Y+ and strong logical "0" is applied to Y-.

To measure X position, you have to apply strong logical "1" (power supply voltage) to X+ pin and strong logical "0" (GND) to X- pin. Then X position is measured on Y+ pin with A/D converter (ADC). Set the microcontroller's ADC multiplexer to measure voltage in Y+ pin. You now have the relative X position.

Touchscreen can measure three parameters:

- X position

- Y position

- Z1 and Z2 pressure

Touchscreen is a relatively simple device. It operates either on resistance or capacity principle. A 4-wire resistance touch screen connects to a microcontroller through 4 pins (X+, X-, Y+, Y-). The microcontroller must be capable of measuring voltage level on three of the four pins and must also be able to apply power supply voltage or GND on all four pins.

ANSWER

How to connect a 4-wire resistance touchscreen to a PIC microcontroller?

QUESTION

PROGRAMMING EXAMPLE

' Touchscreen

' pin 0 = X+ (RA0 on PIC18)

' pin 1 = Y- (RA1 on PIC18)

' pin 2 = X- (RA2 on PIC18)

' pin 3 = Y+ (RA3 on PIC18)

'Pressure

PIC.DataMemWrite(TRISA, &H3)

PIC.SetDataMemBit(PORTA, 3) ' pin 3

PIC.ClearDataMemBit(PORTA, 2) ' pin 2

X_pres = CInt(PIC.ReadAnalogInput(0)) ' pin 0

Y_pres = CInt(PIC.ReadAnalogInput(1)) ' pin 1

Lb_XPres.Text = CStr(X_pres)

'Position X

PIC.DataMemWrite(TRISA, &H5)

PIC.SetDataMemBit(PORTA, 3) ' pin 3

PIC.ClearDataMemBit(PORTA, 1) ' pin 2

X_pos = CInt(PIC.ReadAnalogInput(0)) - 280 ' pin 0

If X_pres > 100 Then

LbAD0.Text = CStr(X_pos)

Else

LbAD0.Text = "---"

End If

Position Y

PIC.DataMemWrite(TRISA, &HA)

PIC.SetDataMemBit(PORTA, 2) ' pin 2

PIC.ClearDataMemBit(PORTA, 0) ' pin 0

Y_pos = CInt(PIC.ReadAnalogInput(3)) - 290 ' pin 3

If X_pres > 100 Then

LbAD1.Text = CStr(Y_pos)

Else

LbAD1.Text = "---"

End If

ALSO READ:

- PROGRAMMING GUIDE

- Graphics LCD with touchscreen