Circuit to replace 4 wire resistive touchscreen

ChristopheFoket

Joined Dec 21, 2015
3
Hi there,

I recently came across this tutorial (https://www.sparkfun.com/tutorials/139) on how to read out the x and y coordinates of a touch on a 4 wire analog resistive touchscreen. I understand that in order to read the coordinates the touchscreen controller switches the meaning of the wires between 5V/ADC and floating/GND, and that this is not really a problem because the touch screen essentially acts as a voltage divider. However, I was wondering if it would be possible to build a circuit that acts as if it were a 4 wire analog touchscreen, and that could work with the same controller.

Given my limited knowledge of electronics, here's what I've come up with so far.

The left of the schematic shows the input pins, including variable voltages representing the X and Y coordinates, and a 5V source, separate from the one provided by the controller. The right of the schematic shows 4 pins corresponding to the wires of the touchscreen that the circuit is trying to replace. Each pin is marked A/B, where A is the function of the pin when the controller is reading the x coordinate, and B the function when the controller is reading the y coordinate.

My thought process when developing this circuit was as follows. I use pull-up resistors on the floating/ground pins to determine whether or not the PNP transistor should be open or closed to let the signals corresponding to the X and Y values through. Then, I use diodes to ensure no current flows into the transistor when pins SV2.1 and SV2.3 are in their 5V state.

Assuming the controller is reading the x coordinate the circuit works as follows (in my head). SV2.2 is floating, which means it will be pulled up to 5V, and T7 remains open, because SV2.1 = 5V. Additionally, SV2.4 = GND, which means T6 closes and SV1.3 is connected to SV3.3 (the ADC).

Now my question, is it possible for this circuit to work, or am I way off? I have not built it yet, because for now it's more of a though excercise, rather than something I intend to build (I also do not have the components). Also, I was wondering whether or not it is necessary to connect the grounds of SV1 and SV2 for it to work. However, how does one do this when the meaning of SV2's pins keep changing? My first thought would be to connect SV1.4 to FL/GND and GND/FL, because those are either always floating or ground. However, since my circuit uses the GND/FL pins to determine whether to open or close the transistors, I expect it to no longer work, if it already would have in the first place.

ErnieM

Joined Apr 24, 2011
8,362
Nope. A resistive touchscreen has 4 wires, 2 for x and 2 for y. You power the x wires + and minus and read either y (they both have the same voltage) to read the x side, and the reverse to read the y side.

So somewhere you need 6 wires going into this, + power, - power, +x, - x, +y and - y.

On a micro where you can arbitrarily assign pins to A2D inputs you need no hardware, just configure 4 lines to drive one side while reading the other. If the analog pins are somewhat fixed (as in earlier PIC devices) you need some hardware to help, a few transistors will do the trick.

ChristopheFoket

Joined Dec 21, 2015
3
Thank you for your reply. However, I don't think I fully understand your post, or maybe my post could have been clearer. Essentially, what I'd like to do is come up with a circuit that you can plug into a pre-existing controller as if it were a touchscreen, and that you can feed the x and y values (as variable voltages) that it should report to the controller when the controller powers the right wires.

I'm with you as far as reading the x and y values goes. When you wrote "You power the x wires...", that's essentially what the controller does, so that would be what the right hand side of my circuit would "listen" for, so that it can report the y value fed into it on the left hand side.

However, after that, you lost me. I'm not sure how you would go about doing the following:
just configure 4 lines to drive one side while reading the other

ErnieM

Joined Apr 24, 2011
8,362
Ok, now I see where you are going... Partially anyway.

Yes the grounds must be connected. Any voltage reading is between 2 points, not 1.

While the meaning of the drive/sense pins keeps changing you will always have one power pair when reading, and you can use that to enable some sort of switch.

The transistor just might work, tough I don't see the need for the diode. To fully work this out I'd have to make some paper copies to make notes, and since I am on an iPad I can't do that.

ErnieM

Joined Apr 24, 2011
8,362
A 3AM bathroom run lead me to think you don't really need any circuitry at all, just whatever your position voltage source is (say a potentiometer) with just a series resistor to keep the drive voltage from damaging the source. No switching required because the read end does the switching.

sailorjoe

Joined Jun 4, 2013
364
Interesting thought experiment, Christophe.
I have to disagree with EarnieM, though, about connecting the SV1 and SV2 grounds. The signals on SV2 change roles, so there is no fixed ground there. The main controller board must have one, but SV2 treats the touch screen as an adjustable resister in X, then again in Y. It does measure voltage between two points, but one of them isn't constant ground. You can't connect the two FL/GND lines together or that defeats the purpose of the floating line.
The issue is that the touch screen is like an array of floating resisters, whose voltages and currents keep getting switched, but with nothing for an external voltage source to reference against.
I think the simplest solution is EarnieM's, with series resistors from X and Y voltage sources. Connect the voltage sources grounds to the main ground on the controller board. The controller ground is probably close to the ground level on the switched controller lines, so it should work, more or less.
I also worked out a solution that uses two variable resistors and two diodes (I think).
Lastly, I had some trouble with the linked Sparkfun article. I couldn't get all the various pin descriptions to line up. The figure didn't seem to match the table, so double check that. In the end, it just has to be consistent and complete, not identical to each other, so maybe it's alright.
Einstein used a lot of thought experiments to imagine solutions to deep physics problems.

ChristopheFoket

Joined Dec 21, 2015
3
Indeed, given that you can connect to a fixed ground on the controller board, using two series resistors is probably the most effective solution.

Yet, this had me wondering about whether or not it would be possible without connecting to one of the controller's fixed ground pins. Unfortunately, it seems that this problem cannot be solved easily using transistors. However, a solution involving relays might work.

What if I were to hook up the input x (similar for y) to an adc that drives some relays, which then connect to a dac, that connects to the ADC/5V pin of the controller?

So I essentially would have something like this:

SV1.3 -> adc -> relays -> dac -> SV2.3
<----------------------> <----------------->

The idea is to use the relays to store the value of x in the circuit, or at least configure the relays on the inputs of the dac in such a way that when the controller powers the rhs of the circuit, it provides the correct inputs to the dac, and it receives the value of x on its adc pin.

I know this solution might be somewhat overkill, but I don't think it requires the grounds of the circuit and the controller to be connected.