Touche for Arduino: Advanced touch sensing.

 by madshobye
Featured
Screen Shot 2012-05-30 at 13.36.22.png
Update: New interface - look at the last step.

Credits: Arduino sensing done by DZL, Processing sketch and Instructable done by Mads Hobye

Disney Research lab designed a novel way to detect touch. You can see a video of their demo here:


I had the honor to meet them at CHI2012 in Texas and I discussed with them whether it would be possible to convert their system into the Arduino platform. Their immediate reaction was that the Arduino would not be able to generate good enough frequencies. I asked my friend DZL if he could solve this problem and this was his solution to the problem:

The Touché hardware uses a really fancy Direct Digital Synthesizer IC from Analog Devices. It generates a really pure sine wave signal with frequencies between 1kHz and 3.5MHz with high resolution. While the Arduino is capable of generating frequencies in this range the signal is a square wave with lots of harmonic frequency components and really low frequency resolution.
Simply using this signal with the circuit described in the Touché paper result in a really messy frequency graph due to the harmonics from the square wave. The solution is to use the filtering properties of the LC circuit to our advantage. By measuring the signal after the inductor (coil) rather than before we only see a nice sine wave shaped signal free of all the unwanted frequency components. As a result we now see a peak in signal at resonance rather than a notch but the signal contains the same information.


This has resulted in the following sensing capabilities:


At the conference they told me that they used 200 steps and they were able to get up to 2000. We have 150 in the above video. 

Step 1: Components neded

To make the shield for Arduino you will need the following components:
  • Arduino
  • Usb cable
  • Shield
  • pin headers
  • Resister: 10k, 1MOmh, 3,3k
  • Capacitor: 100pf, 10nf
  • Diode: 1N4148 diode
  • Coil / inductor: 10mH (cypax.dk  part no: 07.055.0510)
  • Water bottle as sensing object.

If you do not have the inductor, it is basically a coil. You should be able to roll your own. Grab an empty roll of toilet paper wind very thin wire around a couple of hundred times. You have to experiment until you get a peak on the graph.

Or be scientific:
http://www.pronine.ca/coilcal.htm
You want 10000µH

Step 3: Upload code to the Arduino board

arduino_logo.jpeg
There are lots of tutorials who have already explained how to program an Arduino and they do a much better job than we could. So we will just give you a couple of links:
  • http://arduino.cc/en/Guide/HomePage
  • http://www.youtube.com/watch?v=4HqXAmV_Ock
  • http://www.ladyada.net/learn/arduino/lesson1.html

The 3 things that usually cause trouble:
  • On windows you have to install the proper drivers (sometimes also on mac).
  • Remember to select the right serial port in the gui.
  • Remember to select the right board in the gui.

Below are the simplified steps to uploading the code to your Arduino board:

Step 4: Run the Processing sketch

256px-Processing_Logo_Clipped.png
You will need processing to visualize the graph. Here are the general steps to get it up and running:
  • Download and install Processing (http://www.processing.org)
  • Get the sketch from github (https://github.com/Illutron/AdvancedTouchSensing - same link as the Arduino sketch)
  • Open the sketch in processing and run it. You will need to choose the right serial port in setup method. It is usually the lowest number.
  • At pointed out in the comments. Arduino uno has problems with high speed serial and you need to reset the board (or unplug) it every time you run the processing sketch. If you get an error please unplug and plug it in again for it to work. 

The graphing sketch is a modified version of Bool Scotts graphing example:

http://boolscott.wordpress.com/2010/10/23/sneak-preview-of-my-open-source-project/

Congratulations - you are ready to go!

Step 5: Update: Alternative visualizer

Screen Shot 2012-10-02 at 7.28.20 PM.png
Some of you have problem with the processing sketch. This is due to a crappy graphing interface written in processing. I have made an alternative version. It is based on my new Guino interface - which has much faster graphing. You have to do the following steps:

Download the arduino code here:
https://www.dropbox.com/sh/jxkno1vgka7yisf/MZe8m3G4br

Follow the instructions here to upload it and run the guino interface:
http://www.instructables.com/id/Guino-Dashboard-for-your-Arduino/

Hope it helps.
1-40 of 83Next »
farmersride says: May 16, 2013. 12:26 PM
http://forum.arduino.cc/index.php?topic=166747.0  

I have started a new topic on the arduino forms to help push this along. You can follow/contribute here.
farmersride says: May 16, 2013. 8:34 AM
I am trying to alter this code to allow the use of a bluetooth com port. This will isolate ground from earth and provide a more customized/flexible sensor for generic use. I have gotten so far as to get the bluetooth shield up and running at 115200 baud using the hardware serial ports (0,1). I also freeze the touche program in gbegin(...) until the bluetooth connection is paired and connected. If I begin the connection using a terminal I get a single transmission of garbled characters. I'm guessing that this is the structure that Easy Transfer is sending or some dashboard configuration information. However if I try to open in Guino interface it will not connect, the bluetooth module doesn't even detect an attempt to connect. The only difference between what I'm doing and what is there originally is that the bluetooth module will occasionally send out status information about it's connection. Any help you can provide would be greatly appreciated.
madshobye (author) in reply to farmersrideMay 16, 2013. 9:10 AM
I have little experience with bluetooth, but I would love the idea of getting it to work. Please post the code and maybe make an instructable if you get it up and running.

The serial transfer is a serialised struct with a tjeck sum. E.g. it is binary. If the bluetooth module sends some characters it is going to mess up the protocol, but easytransfer should be able to regain sync.

There might be some problems on the computer side of things. I would not be surprised if the guino program expects immediate connection. You might need to tweak the timing there. Or make it try to reconnect if it does not get any useable data.
farmersride in reply to madshobyeMay 16, 2013. 10:13 AM
Thanks for the response! The code for gbegin(...) is below. This requires the seedstudio bluetooth shield with jumpers set so that hardware serial ports are used. The bluetooth device is paired and ready for a serial connection as soon as the Guino app is started - however the first characters sent out of the unit will likely be a status message from the bluetooth module saying that it is connected. The bluetooth shield flashes it's red/green lights when it is inquireable when it establishes a serial connection this changes to two green flash per second continuous. The guino application does not even establish a connection as the red and green continue flashing indicating that it has not been inquired. Any/all suggestions appreciated, I don't really know how to spy on the bluetooth or serial traffic to further debug whats going on.

void gBegin(int _eepromKey)
{

  // Sets all pointers to a temporary value just to make sure no random memory pointers.
  for(int i = 0; i < guino_maxGUIItems; i++)
  {
    guino_item_values[i] = &gTmpInt;
  }
  eepromKey = _eepromKey;

  gInit(); // this one needs to run twice only way to work without serial connection.
  internalInit = false;
  //Serial.begin(38400);
  //Serial.print("\r\n+STBD=115200\r\n");
  //Serial.flush(); //without this bluetooth shield will not switch to 115200 baud
  Serial.begin(115200);  //new baud rate is remembered after power off so do not forget what you set this too
  Serial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  Serial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  Serial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  Serial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  delay(2000); // This delay is required.
  Serial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
  //Serial.println("The slave bluetooth is inquirable!");
  delay(2000); // This delay is required.
  Serial.flush();
  int val = 0;
  while(val < 500){
    val = analogRead(A1);
    delay(1000);
  }
  ET.begin(details(guino_data), &Serial);
  gSendCommand(guino_executed, 0, 0);
  gSendCommand(guino_executed, 0, 0);
  gSendCommand(guino_executed, 0, 0);
  gSendCommand(guino_iamhere, 0, 0);

}
czaide says: Apr 22, 2013. 10:22 PM
the purpose of the diode was not mentioned in the given document. by the way, thank you for the reply earlier.
czaide says: Apr 18, 2013. 1:34 AM
what is the purpose of the diode? and can you explain why is that when we connect ourselves to the sensor, the amplitude increases? please reply asap. we need it for a presentation.
madshobye (author) in reply to czaideApr 18, 2013. 2:08 AM
You can find the paper about the original system here:

http://www.disneyresearch.com/project/touche-touch-and-gesture-sensing-for-the-real-world/

czaide says: Apr 17, 2013. 8:30 AM
(removed by author or community request)
dablondeemu says: Apr 16, 2013. 9:47 PM
I want to use this with Max. So I was trying use processing rather than guino.
I keep getting this error in processing :

portName= Serial.list()[PortSelected];
booster123 says: Apr 14, 2013. 8:31 PM
@naman123 tera rply nhi aaya be........n mads tnxx for d awesome project..:)
naman123 says: Apr 12, 2013. 1:19 PM
Hello...
Thanx for the awesome instructable. I am using the GUINO for seeing the output. I am getting one problem......the moving label is not getting updated in real time.....I have to disconnect and then connect the GUINO for the change in the Label. Can you please assist me in this problem as soon as possible.
madlabdk says: Apr 8, 2013. 8:38 AM
Hey Mads, We built the touché (thank you so much for your instructables) and interfaced it with two environments we love: PureData and Max/MSP. We have succeeded in this. Here we go the project:
http://madlabdk.wordpress.com/2013/04/08/2-touche-meets-pd-and-maxmsp/
and the github ;)
https://github.com/madlabdk/touche

keep on sharing !
dablondeemu in reply to madlabdkApr 10, 2013. 5:10 PM
Ive week working on a very similar project for a while, and wanted to check this out. Can you explain how to set it up?
I uploaded arduino graph, and ran the graph mxp and nothing happens. If I check the arduino serial port it it is just outputting nonsense (lots of numbers and symbols).
I did the same with the "peak" files and could not any results.
Any ideas?
ferrygun says: Apr 4, 2013. 7:13 AM
I have replicated this project using Raspberry Pi. It is very slow but it works. Check out this video here: http://youtu.be/cljP1Z7pc4Y
birdm4n says: Apr 4, 2013. 1:14 AM
changed the capacitors and now it work's like a charm! thanks! you might want to consider adding this to the inscructable ;) (the fact that it has to be ceramic capacitors)
birdm4n says: Apr 3, 2013. 5:43 AM
having some problems with the reply function (the captachas are not showing up) so I will just post my reply directly:

thanks, i will try that and let you know. I wasn't aware that it makes a difference. The capacitance is the same as I said.. could you perhaps point me to the data sheet of the right ones? (or a reseller page like you did for the coil) That would help allot to finde the right pieces.
birdm4n says: Apr 3, 2013. 3:03 AM
(removed by author or community request)
madshobye (author) in reply to birdm4nApr 3, 2013. 4:24 AM
Your capacitors looks wrong. I think you should use ceramic capacitors. Let me know if that worked for you.
jde bont says: Mar 28, 2013. 11:56 AM
Hello,
Thanks for the great tutorial, though I ran into some problems which I can't get solved.
The program works just fine when a use a small piece of aluminum-tape (yet if covered with a layer of paper for instance). But what happens when I enlarge the size of the sensor (which is necessary due to hardware reasons in my design) I loose the peak, the graph becomes flattened out and it is impossible to sense a difference between one finger or whole hand touch.. Is there any way to reduce the sensitivity?? Thanks in advance!
madshobye (author) in reply to jde bontApr 2, 2013. 3:49 AM
Sounds about right. This is a common challenge within capacitative sensing and beyond my expertise. One thing I can recommend though: Make sure that your installation is properly grounded.
vikaspcd says: Dec 17, 2012. 10:18 AM
Hello, in the coding file named "serial_ink.pde" for the processing graph, while writing the cases for switch command you had omitted few cases in between and directly jumped from case 6 to case 20. Why is that? should we add remaining cases ourselves or is it correct with the present code itself
madshobye (author) in reply to vikaspcdMar 18, 2013. 12:40 PM
It should work out of the box. The processing grapher was one I found online - it is really sketchy and has a quite confusing code, but it did the job :)
tknuutila says: Feb 25, 2013. 4:12 AM
I stumbled upon the Arduino CapSense Library. It seems to do the same job with minimum amount of components. Have you compared the precision of these two things? There is a tutorial how to set it up here. (Using Quartz Composer and sending messages out as midi cc, could be midi notes or osc as well).
madshobye (author) in reply to tknuutilaMar 18, 2013. 12:39 PM
Well for simple touch sensing the capsense library is fine, but the touche is way better and much more detail since it does a frequency sweep.
lasithg says: Feb 28, 2013. 4:23 AM
Hi There, Fantastic!. I'm probably a few months late, but nevertheless, I seem to get an error "PlotArray was not declared in this scope" when i try to verify the sketch (Arduino_Sensing.INO) any ideas why ?
madshobye (author) in reply to lasithgMar 18, 2013. 12:37 PM
Nope - maybe try the guino version.
dykeso says: Mar 10, 2013. 5:06 PM
Hey can someone please possibly give me a tip or pointer on what I am doing wrong here? I have set up the circuit and downloaded the code but when I try to upload it to ardunio I get this error....?

Guino_libray:62: error: 'EasyTransfer' does not name a type
Guino_libray.ino: In function 'void guino_update()':
Guino_libray:91: error: 'ET' was not declared in this scope
Guino_libray.ino: In function 'void gBegin(int)':
Guino_libray:162: error: 'ET' was not declared in this scope
Guino_libray:162: error: 'details' was not declared in this scope
Guino_libray.ino: In function 'void gSendCommand(byte, byte, int)':
Guino_libray:379: error: 'ET' was not declared in this scope

It is obviously just me and I am failing to understand what I have done wrong but any help would be much appreciated.

Thanks.
madshobye (author) in reply to dykesoMar 18, 2013. 12:37 PM
Did you install the libraries?
dablondeemu says: Feb 24, 2013. 8:47 PM
Im a total noob at this. I have installed the Guino and EasyTransfer Libraries, and am trying to run the disneyTouchGuino.ino and keep getting that things are not declared. Do you know what Im doing wrong? Thanks!

disneyTouchGuino.cpp: In function 'void setup()':
disneyTouchGuino:48: error: 'gBegin' was not declared in this scope
disneyTouchGuino.cpp: In function 'void loop()':
disneyTouchGuino:94: error: 'gUpdateValue' was not declared in this scope
disneyTouchGuino:101: error: 'guino_update' was not declared in this scope
disneyTouchGuino:102: error: 'gUpdateValue' was not declared in this scope
disneyTouchGuino.cpp: In function 'void gInit()':
disneyTouchGuino:110: error: 'gAddLabel' was not declared in this scope
disneyTouchGuino:112: error: 'gAddSpacer' was not declared in this scope
disneyTouchGuino:116: error: 'gAddFixedGraph' was not declared in this scope
disneyTouchGuino:117: error: 'gAddSlider' was not declared in this scope
dablondeemu in reply to dablondeemuFeb 28, 2013. 5:38 PM
Just realized i was making a simple mistake, the disneytouchguino.ino and guino.ino were not in the same folder.
tknuutila says: Feb 11, 2013. 1:46 AM
We built this as a class exercise, and it was quite fun. But the problem for me is that the Arduino / Processing code especially related to the way how data is read, written and transmitted from one program to another is very difficult to read and impossible to teach to 2-3 year media students. I'd like to see if there is a way to send the data bytes or convert their values to ints or whatever as normal serial.print() communication from Arduino? Would I really need more values than x and y low and high (Actually just the highest values could be enough?) - the whole graph is nice, but if I understood correctly the measuring of peaks happens by writing the highest and lowest x value during a mouseclick (the circle in the original graph). Or is it comparing the whole graphed line? With Guino it gets worse as there is no output and one can't really see what is happening. Perhaps there could be osc / Tuio communication out? This would really make this more interfaceable :)

btw, we did not have enough 10 nf capacitors at hand, but trying out smaller ones did not make too much of a difference.
madshobye (author) in reply to tknuutilaFeb 11, 2013. 2:14 AM
The next feature on guino is definitely osc.

Mean while: it should be really simple to make your own serial communication with the basic sketch.

Yes right now it compares the distance to the peak (really simple way to do it and it could be improved greatly with AI or just comparing the whole graph).

Anant M Nambiar says: Dec 28, 2012. 12:16 AM
@aravind
what door knob.....
aravindskumar10 says: Dec 24, 2012. 11:48 AM
@anant we'll do the door knob thing.
@madshobye wonderful work mate
Anant M Nambiar says: Dec 15, 2012. 2:15 AM
i want to use it on a model wheel chair with a proximity sensor. can you pls help me with the coding
robocopatrick says: Nov 6, 2012. 8:34 AM
Brilliant! I'm about to order the parts but i'm not sure about the capacitors. Should I worry about their voltage? Also, is a 10mH, 37.4Ω, 63mA inductor ok?
Cheers!
madshobye (author) in reply to robocopatrickDec 13, 2012. 10:15 AM
Try it and let me know :)
mandrade says: Dec 1, 2012. 3:25 PM
Hello, I'm Marcelo from Brazil! First of all congratulations for your Amazing project!
I tried to do the same here but I got a problem... When I run the program on Procesing, it open a window and... nothing! Its a blank window. I've changed he port number to 0 (becuse my arduino is on COM1), after the problem I've tried change the port number, but it don't run with other numbers..

Can you help me, please?
madshobye (author) in reply to mandradeDec 13, 2012. 10:15 AM
Try the new grapher - look at the last step.
adityakodkany says: Dec 11, 2012. 6:49 PM
Hey! This is a great project, but I have the same problem as mandrade. Processing just opens a blank window and does nothing. Could you please help out?
1-40 of 83Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!