Resistive material touchpad idea (math & materials?)

I've been trying to build a touchpad that appears to be different than those I see online. I have a piece of resistive material, I'm toggling voltage at the corners with arduino data pins, and reading voltage of a probe placed on the surface with an analog pin. It "works", but I have some physical and mathematical problems...

My setup:

My code flips the X and Y pins shown above high and low to measure X and Y coordinates:

Here's a pic of the values I get when I trace the grid drawn on the board, graphed with a Processing program:

So it "works", sort of, but I have two problems:

  1. Messed up coordinates: I get 2D values that correlate to where the probe is, but they aren't nice rectangular coordinates -- I need help on the math to turn these readings into real XY coordinates. I know the basics (resistors in parallel, voltage divider basics), but the solution involves solving a system of equations, and I get stuck. Help?

  2. My "resisitive surface" sucks. My first prototype was a damn tortilla, and it only worked until it dried out. Now I'm using wet particleboard, which is very inconsistent (~30kOhm on the bottom X axis, ~50kOhm on the top X axis, etc.). It also constantly needs to be rewatered to stay conductive. What's a good, cheap resistive surface I can get? I need it to be between 500?-1M? end-to-end.

I'm excited to get this working, because it's incredibly cheap and made of just one simple material instead of layers. If I can find a resistive paint, I could make whole walls into touch pads.

The distortion is caused by the non-infinite size of the board. If the board were ten times as large as a central working grid, the distortion would be less. Mathematically, we can compensate for the distortion. Please show the Sketch.

The relevant portion of code:

int get_a() {
  digitalWrite(x_pin,HIGH);
  digitalWrite(y_pin,LOW);
  delay(1);
  return analogReadAvg(sensor_pin,samples);
}

int get_b() {
  digitalWrite(x_pin,LOW);
  digitalWrite(y_pin,HIGH);
  delay(1);
  return analogReadAvg(sensor_pin,samples);
}

void loop() {
  int a = get_a();
  int b = get_b();

  int x,y; // TODO: math to convert (a,b) to rectangular coordinates (x,y)
  
  Serial.print(a);
  Serial.print(",");
  Serial.print(b);
  Serial.println("");
}

In the code I refer to the measurements as (a,b) to distinguish them from the rectangular coordinates I want (x,y). The analogReadAvg function just smooths the reading.

I read your partial Sketch. You should have two types of adjustments:
Calibration adjustments will correct for the distortion due to current crowding at the sides and for knot holes.
Theory adjustments based on math.
Please show your equation that plotted that impressive graphical display. (Processing code?)

why not have an array of connectors on all four sides
left 0v right 5v
then
bottom 0v top 5v

means more nails, but not more pins

Here's the stripped down Processing code, but it doesn't do anything interesting -- just draw the coordinates hit gets from the analog sensors (and I think flip the Y-axis to match the board).

import processing.serial.*;

Serial myPort;  // Create object from Serial class
int a,b;      // Data received from the serial port

void setup() 
{
  size(1024,1024);
  println(Serial.list());
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}

int a0 = 0;
int b0 = 0;

int a1 = 1024;
int b1 = 1024;

float x=0,y=0;
float x0=-1,y0=-1;
String last_line = "--";
boolean was_in_field = false;
boolean in_field = false;

void draw() {
  boolean got_values=false;
  if ( myPort.available() > 0) {
    got_values = true;
    String line = myPort.readStringUntil('\n');
    if (line != null) {
      line = line.trim();
      last_line = line;
      println(line);
      String[] m = split(line,",");
      println(m);
      try {
        a = Integer.parseInt(m[0]);
        b = Integer.parseInt(m[1]);
      } catch (NumberFormatException e) {
        println(e);
        return;
      }
      
      in_field = true; //(a>200 && b>250);
      
      x = map(constrain(a,a0,a1),a0,a1,0,1024);
      y = map(constrain(b,b0,b1),b0,b1,1024,0); // flip vertical
    }
  }
  
  //background(255);
  fill(255);
  rect(0,0,200,50);
  fill(0);
  
  textFont(createFont("SansSerif",12));
  textAlign(LEFT, TOP);
  text(String.format("%d,%d",a,b),0,0);
  text(String.format("%.0f,%.0f",x,y),0,15);
  text(last_line,0,30);
  
  if (in_field) {
    rect(x-1,y-1,3,3);
    if (x0!=-1 && was_in_field) {
      line(x0,y0,x,y);
    }
  }
  
  if (got_values) {
    x0=x;
    y0=y;
    was_in_field = in_field;
  }
}

mmcp42:
why not have an array of connectors on all four sides
left 0v right 5v
then
bottom 0v top 5v

means more nails, but not more pins

I tried that -- it produces a different (but still complicated) distortion, this time with the sides curving out instead of in. The reason is that the conductors along the side act as a "shortcut" for the electrons. Even if you're measuring the X axis and leaving the Y-axis rods set as INPUTs in the code, they're still conductors, so near the border, electrons can hop on the metal highway instead of plodding through the wood to get to ground, giving you distorted measures at the edges different from the center.

Basically, either model will take math to "correct" to XY coordinates -- I just figured the 4-point system would be easier to model than the 4-rail system (and also easier to build at larger scales).

If anyone wants to dig deeper, here's measurements of the grid in CSV and Excel format. XY position (0,0) is lower left, (1,1) is upper right, and (0.5,0.5) is the midpoint.

In my spoonduino project

I used the plastic from anti static bags, the black plastic type as the surface. It has a resupistance of about 10K per square.
To prevent distortion of the coordnats do not use points of contact but strips down each side. I used self adhesive copper foi to contact the plastic wrapped round some thin plastic sheet.

Grumpy_Mike:
In my spoonduino project

I used the plastic from anti static bags, the black plastic type as the surface. It has a resupistance of about 10K per square.
To prevent distortion of the coordnats do not use points of contact but strips down each side. I used self adhesive copper foi to contact the plastic wrapped round some thin plastic sheet.

Wow, very cool.

I tried antistatic bags, but I tested a bunch of them and all of them showed resistance above my meter's range (>50MOhm I think). I'll check some more, I guess, because that would be perfect.

Also, I tried using voltage strips instead of points, but like I posted above, I got opposite distortion -- sides bowed out instead of in. I didn't screencap it, but it looked something like this:

It looks like your project emits sound based on the spoon position, so precise XY coordinates weren't necessary -- is it possible that your coordinate response was similar to mine?

You need to find the bags that are very black, completely opaque, and with a flat/satin finish.

The metallic shiny bags that you can see through probably have too high a resistance for this.

It looks like your project emits sound based on the spoon position, so precise XY coordinates weren't necessary -- is it possible that your coordinate response was similar to mine?

Yes it is possible. This is known as pin cushion distortion and it affects all xy pads. Normally it is compensated for by some form of calabration. That is taking readings at known points, normally in the corners and deriving a transformation matrix. Then your readings are multiplied by this matrix to get the true position.

The catenary is the shape you should consider to adjust for the distortion. Please transform the x y coordinates using this equation :

y = (a/2)*(e^(x/a) + e^(-x/a))

The equation is described here:

For a chain drooping under gravity, the catenary shape is easy to see in the world. See wires hanging from telephone poles. And it looks like your Processing picture!

a is related to the tension of the chain, the mass of the chain per inch, the acceleration of gravity, and the length of the chain. See the link.

Since you use electricity instead of gravity, a is just a parameter for the calibration. Match your photograph distortion to catenaries to select a parameter "a" that gives tolerable results. This equation is a calibration guess and shortcut instead of mapping the compensation manually, you approximate the compensation using the equation.

Current crowding and catenary shapes of chains might be related by a transformation to be described later.

tortilla.... Until it dried...

XD

I spewed my coffee on this line.

OK, funny aside, many years ago when cathode ray tubes were the mainstay of TV, there was a stray coating called "aquadag" (spelling may be a weebit off). A Google search indicated that GC Electronics produced a spray for refurbishing old CRT tubes, but I could not find a link.

There is a paintable product called Wire Glue which is not terribly expensive made of nano carbon and a binder which leaves a non-slick surface, but somewhat fragile.

http://www.stewmac.com/shop/Electronics,_pickups/Supplies:_Shielding/Conductive_Shielding_Paint.html lists a conductive two-part kit.

I just Googled for "antistatic bag black" and found this image of what I'm talking about:

Black conductive bags.

http://www.bagbarn.com/all_purpose_poly_bags/antistatic_black_conductive.php

But of course you'll still get the distortion and have to compensate for it. Everyone does...

Thanks for all the info. I wanted to dig into this stuff by now, but I'm heading out of town -- be back in a week, at which time I'll try the math & materials posted. Thanks, all!