loading

Use the "Force" to drive a Remote Controlled Device with a DIY 3D capacitor!

Featured
Picture of Use the
For our electronics class project, we made our own version of the 3D capacitive controller described here:

http://www.instructables.com/id/DIY-3D-Controller/?ALLSTEPS

and here:
http://blog.makezine.com/2012/08/10/build-a-touchless-3d-tracking-interface-with-everyday-materials/


The controller is made up of a cardboard support, 3 "plates" of aluminum foil, shielded wire, resistors, an arduino, and a computer with a charger and the proper software.

By putting your fist in the space between the plates, you are creating a capacitor between your fist and the plates, with the plates at some voltage and your body at ground (don't worry - this is safe!) 

By changing the distance between your fist and the plates, you are changing the capacitance.  The Arduino can measure this by grounding the plates, then letting them recharge from a constant 5V source, and measuring how long it takes to recharge to a certain threshold.  This time is determined by the RC constant (equivalent resistance of the circuit times the capacitance), and since the resistance is constant, it's a measure of the capacitance.

The Arduino can measure the changes in this recharging time relative to an initial calibration, and through the Processing code, it figures out the location of your hand.


A quick overview of the steps:

1. Build the cardboard support structure pictured with 3 (non-touching) pieces of aluminum foil

2. Construct the circuit that we will discuss later using shielded wire, alligator clip heads, and resistors.

3. Plug the circuit into the Arduino (download Processing 1.5 if you don't already have it) and run the code found here: https://github.com/Make-Magazine/3DInterface

4. Run the Processing sketch and make sure that the capacitor can sense the location of your hand as shown in the videos from the guides we linked above

5. Modify the code in the Processing sketch so that it sends information about the location of your hand to the Arduino through the serial port

6. Modify the Arduino code to use that information to drive a device of your choice!  You'll need to take apart the device and wire some inputs from the Arduino into its circuitry.  We chose to drive the throttle of a remote controlled helicopter, varying rotor speeds (and thus the height that the helicopter flies at) depending on the position of your hand.

This project could still use some improvements and fun add ons!  Because of this, we'll try to describe some of the major problems we encountered during the making of the project, how we debugged them, and managed to fix them (or not.)
 
Remove these adsRemove these ads by Signing Up

Step 1: Things you will need

You will need:
Cardboard
Aluminum foil
Shielded wire (Your results could be much worse if you use non shielded wire for the alligator clip cables due to an antenna effect )
Three 10k resistors and Three 270k resistors
An Arduino Uno with a Serial cable
A computer with a charger
Arduino software
Processing 1.5
Wire cutters or a knife to strip shielded wire

Step 2: Make the 3D Capacitor

Picture of Make the 3D Capacitor
Cut out three pieces of cardboard to support the aluminum foil and connect them so that they can stand on their own as shown in the picture. For this job, we used every DIYer's best friend: duct tape.  

Originally, we used large aluminum plates, which is why (if you look carefully) we have these little cardboard ridges on the inside edges that will hold the plates in place and prevent them from touching.  There was originally one in the vertical edge too.  

We experimented with different sizes of aluminum foil and our results were best when we used 8" x 8"  pieces.

Cut out three pieces of 8" x 8" aluminum foil and tape them to the cardboard as shown in the picture.   If you want to organize your wires better, you can cut a hole in the back corner of the cardboard, and thread the 3 cables through there.  Just make sure not to allow electrical contact between the plates or cables.

Step 3: Make the wires (capacitor end)

Picture of Make the wires (capacitor end)
IMG_1301.jpg
IMG_1378.jpg
You'll need three pieces of shielded cable for best results. You can use non-shielded wire as a cheaper alternative but the electromagnetic fields from the current will mess with your data and make your position inside the capacitor less accurate. We used BNC cables to make everything look nice. (Pictured).

First, cut off about an inch of the outermost layer of the cable to reveal the shielding. (Pictured)

Cut off the shielding. We don't need to worry about what we do with it on this end of the wire because with shielded wire, you only set the voltage on ONE end. The BNC cables make this easy on the other end of the cable, which we will set at 5V. This means the shielding can just get cut off on this end.

Strip the wire coating to reveal about half an inch of the wire at the end.

Strip the wire connecting to the alligator clip to reveal about half an inch of wire. 

Solder the two together. (Pictured)

Step 4: Make the wires (arduino end)

Picture of Make the wires (arduino end)
IMG_1332.jpg
IMG_1381.jpg
IMG_1334.jpg
IMG_1373.jpg
Solder a 10k resistor and a 270k resistor to the yellow part of the BNC connector that juts out.  This part connects to the shielded wire that goes to the alligator clips. (Pictured).

Connect the three ends of the 270k resistors. We will call this "Connection A" for clarity. Solder wires from the tab that sticks out of the BNC connector (this connects to the shield and is labeled as "tab" on the second photo in this step) to Connection A.  The shielding acts as a Faraday Cage, blocking stray electric fields from outside and keeping the wire from becoming part of the capacitor and reducing the sensitivity of your circuit.

Finally, solder a wire to Connection A, leaving the other end available to be plugged into "5V" on the arduino. The 10k resistors will be plugged into digital pins 8, 9, and 10.

Note: It's very important to keep these wires and resistors from touching each other lest the signals from different plates interfere with each other.  You might want to look into separating them with electrical tape or shrink wrap tubing or something of the sort.

Step 5: Arduino code and Processing sketch

Picture of Arduino code and Processing sketch
The code for the Arduino and the Processing sketch can be found here: https://github.com/Make-Magazine/3DInterface
It's best to download it as a zip file (click the arrow button) so that the directory structure is preserved.

If you haven't already, download Processing here: http://www.processing.org/download/

To be safe, make sure to download Processing 1.5.1, NOT 2.0!  We encountered some bugs running the code possibly due to incompatibilities with Processing 2.0.  

If you live in North America or Japan, change the line "#define mains 50"  to "#define mains 60" in the Arduino code
This reflects the 60Hz AC frequency coming out of your wall socket.

Here's a rough outline of how the Arduino code works to the best of our understanding:

Setup:

1. It sets up the Serial communication port to communicate at 115200 baud

(Serial communication works by sending one byte at a time between the computer and the Arduino at a certain number of symbols per second, or baud.  115200 baud is currently the fastest possible communication rate between the computer and the Arduino.)

2. The Arduino then sets every pin to ground (LOW).  This is to prevent fields from other pins from potentially affecting the wires going into the Arduino in some sort of an antenna effect.  It then initializes pins 8,9 and 10 to INPUT (remember pin 8 is connected to the left plate, pin 9 is connected to the bottom plate and pin 10 is connected to the right plate).  At this time, all of the plates will be charged to 5 volts through the 270 kOhm resistors.

Loop:
3.  The code calls the function "time" for pin 8 (left plate), which first sets pin 8 to OUTPUT and sets the voltage on the pin to a (digital) low (which is close but not necessarily equal to 0V).  This will very quickly discharge the plates through the 10k resistors.  

Sometime during or after this discharge process, the Arduino will set pin 8 to INPUT.  At this point, it will start counting upwards, once every clock cycle, until the plate has charged up enough through the 270 kOhm resistors that the Arduino sees the voltage at pin 8 has gone back to (digital) high (which is close but not necessarily equal to 5V).

Then the Arduino will stop counting, and report the number over the Serial cable to the computer.  Then the computer, using the Processing sketch, figures out based on this number where your fist is located relative to the left plate.

This same process now repeats for the bottom and right plates.  All of this happens in a fraction of a second, repeated over and over.

In this way, the Arduino constantly reads the position of your hand!













Step 6: Using the controller and Hacking the code

Picture of Using the controller and Hacking the code
project2.jpg
IMG_1370.jpg
When running the Arduino code, make sure to have your computer plugged into the wall and the Serial cable attached to the Arduino.  This is to ensure that the Arduino's ground is the Earth's ground rather than a "floating" ground.

Open the Arduino code in its environment, and load it on to the Arduino.  Then open the Processing sketch in its environment and click the play button.  A screen that looks like the first image should pop up, with the ball moving to the top corner, closest to you.

Now place your fist in the top corner, with your arm pointing towards the far bottom corner (where the 3 pieces of cardboard intersect.)

Click the left mouse button, and hold it down.  Slowly move your fist towards the far bottom corner.  When you have reached there, let go of the button.

Now the Processing sketch knows what your range of motion is, and the range of charging times it can expect for each plate.  You can now play around and see the ball follow your hand!  

This tracking will not be perfect, especially towards the edges of the cube (probably due to fringe fields from the capacitor.)  However, by working with shielded wire, making sure that nothing is in electrical contact, and selecting a good value for the size of the plates and for the resistors, you should be able to improve the response of the sensor.  Experiment with this!  We tried a few plate sizes and settled on 8 inches square, but the way we did it was far from quantitative.  We also didn't have time to try other resistor values.  Remember, the higher the value of the resistor, the slower the charge or discharge time.  We are not sure how this will affect the accuracy of the readings, although my first guess would be that longer discharge times would lead to a more accurate but slower to respond measurement.

Hacking the code:

The real fun of having this 3D sensor is how you can adapt it to control all sorts of devices.  The most straightforward applications would be to control something that simply involved switching various circuits on when your hand is in a certain position, and off when your hand is in another.

In the Processing sketch, the variables that tell you the coordinates of your hand are called axyz[0].avg, axyz[1].avg and axyz[2].avg (sd is just a scaling factor.)

You can print out the values of these variables by adding print statements right after where the variables are first seen, such as:  print(axyz[0]);

By printing out the values of these variables, you can figure out which numbers correspond to which locations in the cube.  

Then you can use these coordinates to your advantage!  For example, you can write an if statement in the Processing Sketch that tells the Arduino where your fist is such as:

if (axyz[0] < 0.1 && axyz[1] > 0.9 && axyz[2] < 0.1) {
  serial.write(1)
// this code snippet should tell the Arduino over Serial that your fist is in the back corner
// note that the code has already initialized the Serial port to be called "serial" on line 4
}

Then in the Arduino code, you can write an if statement that says "if my fist is in this location, set digital pin 5 to HIGH"
Above
void setup()  
write the statement:  
int incomingByte = 0;   // declares a variable to store the incoming Serial byte

Then in the loop, write

// send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();
        if (incomingByte == 1){
        digitalWrite(5, HIGH);
        }

Now play around with the device you want to control!  Take it apart and see what you need to do, circuit wise, to drive it.  You now have the flexibility to use the location of your hand to tell your Arduino what to do with if statements.  Use it for good or for evil.

Step 7: Helicopter

Picture of Helicopter
IMG_1387.jpg
IMG_1385.jpg
IMG_1390.jpg
We decided to try and hack a relatively cheap remote controlled helicopter.

The helicopter keeps in the air by spinning its rotors at a certain frequency, which you can adjust to make it go higher or lower by pushing on a joystick.  But who wants to push on a joystick when you can use the Force?

So we took apart the remote control (picture 3) and found that the joystick that controls the up - down motion is really just sliding a metal circuit connector over these pads.  The higher up the circuit you complete, the faster the rotors go.  

The long metal strip that looks like a backwards L is ground.  We covered it up with electrical tape in order to avoid spilling solder on it (probably not the best practice, but it worked in a pinch.)

We then saw that the default for the helicopter was to spin its rotors at a low frequency (not enough to keep it up in the air).  The part that the green wire is connected to is the pad that makes the rotors stop spinning completely.  

We experimented with grounding various pads until we could figure out which ones would make the helicopter behave in various ways.  We found that the pads on the right, going up seem to be the essential ones to ground to make the rotors spin faster and faster.  So we soldered some wires to those pads (not pictured - they were later unsoldered.)  

The black wire is connected to the ground of the batteries in the remote control.  We were going to connect this to the Arduino ground so that there was a common ground between the remote control and the Arduino.  This way, the Arduino would be able to write LOW to a digital pin, which would be connected to a pad through a soldered wire, and complete various circuits depending on the location of a fist in the sensor.  

Unfortunately, in the course of our experimentation, just as we figured out how to use Serial to send the location of a hand to the Arduino, we think that we short circuited something or burned something out in the circuitboard.  Since it's printed and not very accessible, we were not able to figure out what went wrong (first the board thought that the helicopter was charging when it was not, and then it refused to turn on.)  Even though we weren't ultimately successful in completing our project, we're pretty sure that if we had another remote controlled helicopter to play with, we would be able to make it work in this way (with a little more debugging and a little more careful soldering of course).  

In hindsight, a better first start would probably have been a remote controlled car.  The simplest ones just involve on - off switches to determine whether the car goes forward (yes or no - on or off), backward, left and right.  This seems easily programmable using a 3D capacitive controller, even with not the best spacial resolution!  

Have fun coming up with your own ideas about what to do with this controller, and happy hacking!




digipup12 years ago
My jumper wire connecting to 5v is acting up and the ball that shows where my hand is gets stuck at the top of the invisible corner what do I need to do?
lenniad2 years ago
May i shield the wires with some foil revestiment? One pal said once that he isolates the electronic of his guitar putting alunimium sheets around. ¿would it work for wire?
scci2 years ago
(guess) You probably connected the pad straight to ground when before it was first influenced by a resistor. The ardunio might not have offered enough internal resistance to stop the curcuit from overloading. Therefore frying it. Next time id put a few ohms of resistence in
ku5e2 years ago
The Theremin Remote Control. I love IT!
tcase62 years ago
here's one for you,,, I have a friend from back in ohio that made a head band, connected to a keyboard port, and was able to put text into notepad with this headband,,,,,the power of thinking.....lol... he came to my wife and I to see if we could help with finances to get it off the ground, and patented.... had the lawyer and everything,,,, unfortunately, we couldnt, so he found someone that could, but before he knew it, the other guy he went with, went behind his back, and had everything written up in his own name, no co-inventor, and sold it to IBM, who now has it just sitting on a shelf... kind of,,, i did see it again though,,, they had this game on a tv commercial, I think it was like basketball... using air to push the ball into the hoop.... but, yet, was the same headband, using your mind to power how much air pushes the ball into the hoop...... such a powerful invention being placed into a game... guess at least they used it,,, many things just sit, and dont even get that... but, the other guy took 1 million dollars for it, and bought a restaurant with it,,, which also went under in 1 year......good luck and keep up the good work....
jimgrace632 years ago
looks like a good project. I think I will work on it with my 10 year old grandson. He's a bright kid and this project will introduce him to a multitude of ideas and possibilities. Thanks for sharing and I hope you received high marks for your effort.
lnorooz2 years ago
oh wow! we did the same exact thing (using a kinect) and also called it "the force" in our class as well! check it out :) (skip to 1:40 to see the actual demo) )http://www.youtube.com/watch?feature=player_embedded&v=p9AV_Ws96Aw
evileddead2 years ago
Pretty neat!
A video of the project in action would be nice.
gschoppe2 years ago
really simple change, but I suggest covering each plate with a piece of paper... That way, you don't get strange readings if your hand brushes the foil, and you can get a clean zero-distance calibration... as for cleanly calibrating the other dimensions, I'd add a distance scale to each sheet of paper, so you can effectively gauge distance. from each plate

As for a more complicated edit, the plates don't have to be at 90 degree angles to each other. at the cost of "resolution", you could theoretically get a much wider "field of view" for the sensor, by making triangular plates with an angle of 110 degrees where they meet (110|35|35), and joining them to form a shallow dish shape that sits below the hand.
SarahandDillon (author)  gschoppe2 years ago
Huh interesting. I'll have to try the paper out.

Varying the degrees seems like it would mess with the cube visualization in the processing sketch, but you could probably get used to it. For now though, the field of view isn't the problem - we have plenty of space to move a hand around. Accurate "resolution" is the main problem so far.
SarahandDillon (author)  SarahandDillon2 years ago
If we were to really improve this, it would also be nice to get a rough but quantitative measurement of how the recharging times read by the Arduino vary with hand distance, and whether or not different hands / arms create different capacitances (maybe due to some dielectric effect?) Making marks on the paper would be a good start to getting a handle on that.
straight2 years ago
veeeeery nice
SarahandDillon (author)  straight2 years ago
:)
naw29832 years ago
could I use 220k resistor instead of a 270k
SarahandDillon (author)  naw29832 years ago
Yep, that would work too. It would make the charging of the plates faster, which could possibly make tracking a little bit smoother, but might make it marginally less accurate.
That's awesome!
SarahandDillon (author)  simplebotics2 years ago
Thanks!

A TON of credit should go to http://www.instructables.com/member/kylemcdonald/
who as far as I know came up with the original implementation of this controller!
GraphixS62 years ago
Is it possible to use something else as the medium for the capacitor? If so, this could have great potential as an accurate 3d or 2d pen computer controller.
SarahandDillon (author)  GraphixS62 years ago
I'm not 100% sure what you mean by medium for the capacitor - use some other material besides foil, or something else? We did experiment with 1/4 inch aluminum plates, but they seemed to not work as well as the foil (although it may have been due to the size of the plates rather than their thickness.)

I think the Arduino program should work as long as you

1) Have 3 perpendicular plates
2) Have a movable conductor connected to ground in the space between the plates to act as the other part of the capacitor.

We also tried using a styrofoam ball wrapped in aluminum foil with a metal skewer connected to the foil that we'd hold on to. This, we thought might minimize the effect of our arms (which we think might be the cause of some of the imperfect sensitivity we were getting - because our arm angles were changing depending on where our fists were.) The results were similar to what we had with just our fists, though.