Pages: [1] 2 3 ... 5   Go Down
Author Topic: Re: CapSense Library  (Read 16820 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Paul.  I tried the other code you posted earlier for doing the same thing and it worked like a charm.  This is cool stuff!
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK it's packaged up in a library, thanks to some help from David Mellis. It really wasn't that big a deal and I'm sure I would have finished up around April of 09 on my own. jk

The library is accessible both at its old location
http://www.arduino.cc/playground/Main/CapSense
and on the reference/library page.

I think it is possible to build a scroll wheel with this function. Also I sensed through a ream of paper when testing, so it should be possible to sense through more than an inch or so of plastic, ceramic or other insulating material. I especially got a nice (somewhat linear) response to squeezing  a sensor covered in fabric and think it would work great inside a stuffed animal.

A covered (insulated) sensor seems to work best and yields a surprisingly responsive pressure sensor. Much better than a force sensing resistor in many applications, I would think.

Please post bugs, suggestions, or any amazing feats on this thread.

Enjoy,

PB
« Last Edit: November 24, 2008, 03:12:33 pm by paulb » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried this yesterday but the results were not too promising.
My dev environment is a Macbook not connected to ground. The sensor is a 3"x3" piece of aluminum foil that I stuck under the cardboard of a hardcover book, R=10MOhm. The sensing range for my hand was around 0.5" and for a single finger I could just make out a tiny increase of values upon touching the insulator. Touching the foil itself yielded a nice huge delta. Replacing the 10meg with 20meg resistors hardly changed the results. Moving my hand closer to the laptop however, DID create a large change in values.

The docs say to use a grounded connector which means that you could only build tethered projects. Kind of limiting for an embedded device such as the arduino- it would be nice if both battery operation AND power supplies would yield similar results.

Freescale has some nice application notes on their touch sensing ICs. To summarize: for single touch sensors they recommend using a spiral pattern where Gnd and Sensor wire traces run parallel to each other. Good insulator material is neoprene rubber, and to avoid stray capacitance there should be a Gnd plane behind the sensor. However, for reliable results they suggest a distance of only a few millimeters which makes me wonder how your docs can claim a sensing distance of > 10".

Most commercial capsensing ICs (Omron, Freescale, AD) seem to employ an oscillator and then measure phase/frequency shifts induced by touching the sensor. I wonder if this is any more reliable than measuring the charging rate as done in the CapSense library. This library depends on an arbitrary switching point of the atmega's CMOS inputs. Wouldn't the analog pin readouts be more robust ?
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried this yesterday but the results were not too promising.
My dev environment is a Macbook not connected to ground. The sensor is a 3"x3" piece of aluminum foil that I stuck under the cardboard of a hardcover book, R=10MOhm. The sensing range for my hand was around 0.5" and for a single finger

For 10" I was using a whole hand and somewhat larger sensor - it just depends on what you are trying to accomplish.



Quote
I could just make out a tiny increase of values upon touching the insulator. Touching the foil itself yielded a nice huge delta. Replacing the 10meg with 20meg resistors hardly changed the results. Moving my hand closer to the laptop however, DID create a large change in values.

This probably had to do with the wire connecting the sensor, which is live (sensing - unless you use shielded cable). The Theremin sensor though reported a similar effect.

Quote
The docs say to use a grounded connector which means that you could only build tethered projects. Kind of limiting for an embedded device such as the arduino- it would be nice if both battery operation AND power supplies would yield similar results.

The Qprox datasheets suggest taping a ground to the wall - The sensor doesn't need to be connected to a laptop - a power adapter works equally well (no need to be grounded). Unfortunately - the calibration is going to change a bit. As far as I can see there's no way to avoid this without adding an earth ground.

The approach I am using with subtracting the baseline should add some kind of rough calibration, but there's a lot I don't know about this yet. If you've used the Qprox linear sensors, you know how jittery and glitchy they are too.


The frequency approach isn't really that different - think of the whole thing as a big oscillator and you'll see that the frequency is changing. The period of the oscillation is being measured.

See the theremin approach in the playground (and posted on this forum too).

PaulB



« Last Edit: January 22, 2009, 11:58:43 pm by paulb » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have begun testing out the CapSense library this afternoon, and noticed that if I left the sensor on for a few minutes there would be a slow build up (higher numbers coming out of the capsense function) over time. I am using a Macbook connected to ground and the arduino is powered by  USB.
I haven't tested it with foil yet, just a 2 foot wire with a 1/2" by 2" piece of aluminum at one end. Also their seems to be a significant charge after a while because its giving me small shocks.
Is there a way to clear this build up?
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have begun testing out the CapSense library this afternoon, and noticed that if I left the sensor on for a few minutes there would be a slow build up (higher numbers coming out of the capsense function) over time.

I think what is going on is that the output of capsense is compared to the lowest reading. Over time noise (and maybe other factors) could produce a lower reading (especially true if your sensor wire is loose). Then the function is comparing with a lower number so will yield a higher output. There is an autocalibrate routine that runs every so often. You can change that in the header file for more frequent calibration. This should counter the drift (at the cost of a glitch where the sensor will fail to read a sensed hand until the hand is removed from the sensor). I'm going to implement a reset function to make this easier.

As to the charge, are you sure that it's just not plain static charge from dry air in the winter? The sensor probably is giving off lots of RF at some frequency but I don't really see that building up a charge. Then again I don't really know that much about RF.

PaulB
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks. Yeah I am not sure about the charge at all. It very well could be the dry winter weather.  I will tinker with the autocalibrate.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For testing purposes use the RawSense function instead and see if it still keeps increasing.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was going to mention another tip. If you reset your Arduino (or clone smiley)
the function autocalibrates on the way in, so you could compare the drift then reset.

Or as Cross mentioned, just use capSenseRaw - then you'll really know what's going on, and you can write your own subtraction function - maybe  better than mine too, and we can improve the library!

PaulB
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Before it was in a library I have used some of your earlier code and used it
in an application that measures fuel tank level by measuring the capacitance of the probe. The probe is basically an aluminum rod inside of an aluminum tube. Anyways while bench testing I discovered by accident
a way to use your code with one pin:

    I keep a 10meg 5V pullup on the receiving pin.
    Turn receive pin to output and drive low (overcomes pullup).
    Turn receive pin to input and count until pin reads high.

I thought this might be useful to some. Btw thanks for this code as it
is extremely useful for my purposes.
Joel
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One more thing to consider is pulling the input pin low for a longer time  in between measurements to make sure that all charge on the capacitor has dissipated.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

jrhall,

If it works with one pin that way then go for it. The new library drives the send pin both low and high (charging the cap each way) so don't know if this would work. Maybe because it's only looking for a CHANGE in values it doesn't really matter.

It might actually end up being more consistent if it only charges the capacitance one way. Someone could do some testing if interested. I'm on 16 other missions right now.

Electricity, fuel - yikes! Better have a good idea what you're doing. I've always wondered about electric fuel pumps and fuel gauges in cars and how they insure they're safe. It can't be a huge issue or there would be some literature of urban myth about  fuel pumps blowing up cars.

Paul
« Last Edit: February 06, 2009, 04:56:46 pm by paulb » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The design for the fuel probe and the the method of reading it has been in use for decades. The modernizing part I am doing with the Arduino is getting rid of the analog/555 approach for determining capacitance in the sensor box.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm interested in using Arduino along with a relay to sense water level in a small tank.  I have a tank under my window air conditioner unit to catch the water drips (for use in a flower bed and to prevent the water from soaking my porch).  I want to turn on a pump when the tank is nearly full then turn the pump back off when it's nearly empty (don't want the water to go too low allowing the pump to suck air).  I figure two capacitive sensors would be necessary.  One for the high water level and one for the lower level.  I know it's a bit overkill to use the arduino for this but I like the idea of building it myself instead of purchasing an off the shelf pump and/or float switch.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll bet the sensing part of this is fairly easy. I'd predict you'll get a really clear reading from the water in the tank and can just threshold against a hard-wired value. Maybe post something here with your results if you get a chance.

PaulB
Logged

Pages: [1] 2 3 ... 5   Go Up
Jump to: