Capacitive sensing

Status
Not open for further replies.

scswift

Well-known member
How does capacitive sensing work? I don't mean how do I read the sensor... I know about touchRead(). I mean, how does it behave?

I've seen some examples which look for a value of 2000-3000 when someone touches a wire. Makes sense. But does the value drop over time if you continue to touch it, or does it remain relatively steady?

And what if I mounted the Teensy in a box, and then attached the wire to the box? I assume that it can sense the touch if it's metal. What about plastic?

Also, how would the sensor handle differentiating between the box and a touch? When I connect the Teensy to the box is the value gonna jump to X just from that, then up to X + 2-3K when a person touches it?

And if the box is sitting on a table wouldn't that be the same as a person touching it while standing on the ground? Do I have to insulate the box from the ground with rubber feet?

Which brings me back to the question of whether this touch interface can even work if my enclosure is plastic. Perhaps I need to stick a metal plate inside the enclosure to make it work like those PCBs with the touch pads they sell for capacitive sensing? I guess those are insulated, so you're not directly touching the metal.

My end goal here is to make a box that may be either metal or plastic that the user can touch to trigger one of several actions based on how long they touch it. And it has to work consistently, like one of those touch lamps. I can't tweak the values once the end user gets the device.
 
I'm a big fan of the touchRead() function.

I've built two little boxes, one metal and the other plastic each of which has two fixed metal buttons wired directly to touchRead inputs of a Teensy 3.0. When the application starts, it assumes you are not touching the buttons and takes a bunch of reading to calibrate the sensors. During normal operation, the Teesny polls the inputs and applies a threshold to determine whether or not a finger is touching a button.

Out of curiosity, I also implemented an "analog" mode in which the Teensy plays a tone with frequency proportional to the capacitive reading. A light touch produces a low reading. A harder touch squishes more of your finger around the button and produces a higher value.

I haven't noticed any problems with lack of grounding. The metal box contains a battery and isn't wired to anything else. the plastic box is used as a voltage monitor and is wired to an external battery and a radio transmitter.

Follow the link in my sig to read all about them. :)
 
Thanks for the info. One question is whether you can sense proximity, capacitive sensing, using the touch pins or do you have to make direct physical contact with the metal? What I want to do is make a custom keypad by designing a custom PCB with pads and use some kind of overlay. The overlay would undoubtedly insulate the finger from the copper of the PCB so I guess I am looking for capacitive sensing rather than "touch". I am going to do some testing soon but do you think my idea will work using the native touch pins and touchread()?

What I want to make is a bespoke keypad using a bespoke design similar to this MPR121 Capacitive Touch Keypad but using the native Teensy 3.0 /3.1 touch pins. Therefore my PCB will be nothing more than some pads that break out to a pin header or ribbon interface.

Thanks for the info so far :0)
 
I believe your use case is exactly what the capacitive sensing feature in the Kinetis MCU was designed for. I've been able to sense proximity using touchRead(). Direct contact with a conductor is not required.

The experiment I tried was to attach some magnet wire (thin-gauge varnish-covered copper) and also some typical hookup wire (AWG 22 or AWG 24). The sensing range is at least a half a centimeter through the insulation and air.

I was interested in this as the basis of a soil moisture sensor. The nice thing about using capacitive sensing for this is that it is possible to use an insulated sensor, thereby avoiding corrosion problems associated with resistive sensors (like two nails in a gypsum block).

If you dip an insulated wire in a glass of water, you can see the touch readings go up and down.
 
I am also interested in capacitive sensing for soil moisture. Why not use a PCB as the sensor ? This seems to be the basis of the rather expensice vegetronix sensor. I have a few of these and they work wel but have poor linearity. I have to read the touchRead() documents I think I can use the touch inputs for this sort of thing ? Anybody has ideas for the best wiring configuration to put on a PCB ?
 
In my case I want to detect when a user has touched the project enclosure to change modes and/or mute the device depending on if they maintain contact for a second or touch it briefly. I foresee a problem though in that the user will be touching the device when they turn it on. If the microcontroller takes a reading when it first powers up and all future readings are based off that then the results may be off. The power switch will be on the bottom of the device though and the touch panel on the inside front, but the user may still have their hand on the front when they reach around the back to turn the device on.

I'm thinking what I may need to do is take a running average of touchRead() and if the value changes suddenly over a brief period of time, then I can assume the device has been touched. This may avoid the need to carefully calibrate the threshold.

Unfortunately I haven't had time to do any tests yet, but I did have a look at those documents. They didn't really help much though. I don't have any better of an understanding what values I could expect to see from touchRead or if this thing is going to sense when I'm touching the case anywhere, or just where I have a metal plate installed on the inside.
 
If the microcontroller takes a reading when it first powers up and all future readings are based off that then the results may be off.

Good point! Might be ok to do this only the first time the gadget is turned on and store the results in the built-in Flash memory. I bet you'd never need to re-calibrate, but it could be an option.
 
Status
Not open for further replies.
Back
Top