Go Down

Topic: Capacitive sensing and grounding (Read 4643 times) previous topic - next topic

Hoximor

Hi

In my current project, I need to detect when someone touches a piece of metal (which I already have).
To do that, I use the CapacitiveSensor library with my Arduino. It works well while I'm using the USB power supply, but as soon as I switch to my real power supply (a 5V AC DC adapter), the feature is completely broken.

I came to the conclusion that this happens because the ground I have (which is the "real" Earth) is not the same as the Arduino's one, so the whole mechanism is broken.

First of all, is there any workaround for that ? I tried switching resistors (from 1 MOhm to 330kOhm, but also by randomly adding a 100pF ceramic capacitor in series with the resistor and it kind of works, but I don't know why and I don't like it).

Carrying on in my searches, I found this, which I already had (https://www.dfrobot.com/product-78.html). It's a touch sensor, and it's also working when I'm using my AC DC adapter.

Does anyone know how such a thing works? Could I adapt the circuit (schematic here : http://www.dfrobot.com.cn/images/upload/File/DFR0030/20140825132741ztc9n2.pdf) to my project to bypass my grounding issue?

Thanks for any help

DrDiettrich

A proper capacitive sensor consists of 2 plates, one connected to Gnd. That's how touch pads and screens are built, with many distinct sensors. A single plate is nothing but an antenna, catching whatever ambient noise.

wvmarle

Can't you simply connect the ground of the Arduino to the ground plate of your sensor?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

INTP

How big is the piece of metal?

You are right that the ground of the circuit as a whole affects sensitivity of the capsense, but it should still work if you use a good resistor value as well as capacitor value for stability.

In case you haven't read the guide.
http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

Hoximor

A proper capacitive sensor consists of 2 plates, one connected to Gnd. That's how touch pads and screens are built, with many distinct sensors. A single plate is nothing but an antenna, catching whatever ambient noise.
Stupid question: since the ground for the phone's battery is obviously not the earth, how can it possibly have the expected effect. Also, to what extent does this use the same technique as CapacitiveSensor library does (measuring RC circuit constant)?

How big is the piece of metal?

You are right that the ground of the circuit as a whole affects sensitivity of the capsense, but it should still work if you use a good resistor value as well as capacitor value for stability.

In case you haven't read the guide.
http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense
It's a kind of cylinder, I'd say 4cm height for 10cm diameter. I got it from a "touch lamp" (that included a capacitive sensing circuit or something that did what I'm trying to do, but for a 220V AC power, so not applicable to my setup).

Also, do you have any kind of idea of what resistance I should use? As I said, I already tried different values, every time it works over USB but not on the power supply.

Finally, I indeed read the documentation, but this line wasn't really clear:

Quote
Also experiment with small capacitors (100 pF - .01 uF) to ground, on the sense pin. They improve stability of the sensor.
What I understand from it is this (sorry for ugliness):



Thanks

INTP

By GND in the pic, do you mean the Arduino's GND pin?
Because it should be.

Hoximor

Yes sorry about that I did mean the Arduino pin. I think I already tried that setup but I'll give it another go just to be sure.

Smajdalf

A proper capacitive sensor consists of 2 plates, one connected to Gnd. That's how touch pads and screens are built, with many distinct sensors. A single plate is nothing but an antenna, catching whatever ambient noise.
Are you sure about this? I was looking at touch sensing some time ago and tried to understand this. After some research I came to conclusion that proper capacitive sensor is only one "electrode" - conductive metal plate or similar. In fact in one app note there was warning the power planes (neither ground nor Vcc) should NOT be under the electrode because it would reduce sensitivity greatly.
Can you show how the two electrodes should be arranged? I tried to understand how the touch sensing works but I am still unsure. I know touch increases capacitance. But how? Does part of the current go through me when sensing electrode is being charged? A bit mystery. Picture of real sensing electrode may help me understand?
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

DrDiettrich


INTP

The capacitive tech Diettrich is talking about is completely different from what this thread is about.

DrDiettrich

Well, a capacitor consists of two electrically isolated plates, everything else is not a capacitor. In the CapSense tutorial everything connected to the Arduino Gnd counts as the second plate, mostly at a high distance from the other (sehsitive) plate and consequently forming a very low capacity. A person between those "plates" becomes part of the circuit, i.e. current flows through it. But that's not a big deal, because the total voltage is only Vcc (typically 5V). Other electric fields, from mains lines, power planes, motors or switching power supplies, also influence that "capacitor" and can cause random readings.

That's why two electrodes (plates) should be used for reliable capacitive sensing. One electrode is connected to the I/O pin, and the other one to Gnd. When the user moves a hand or finger, or some other conductive material, near these plates, the electric field between these plates concentrates in that "conductor", increasing the capacitance between the plates. This change of capacity can be measured by the usual libraries.

The shape of the plates is not important, but the extent of their surfaces is. The bigger the surface, the higher the achievable capacity. Also the orientation and distance between the plates is important. For highest capacity the plates should be oriented face to face and very close to each other. But there is a limit with capacitive sensing, where it must be possible to bring some conductive material (finger...) into the electric field between the plates. If the plates are arranged side by side, their electric field approximately forms a sphere around the plates. The more of a finger can penetrate that sphere, the higher the change of capacity.

It's also possible to use a common metallic ground plane, and cut holes into it, which then are filled with insulated metallic plates for the other (sensitive) electrodes. On a copper coated PCB one can erase a ring of copper around each electrode. Or you glue aluminium foil, with holes in it, onto some non-conductive surface, and fill the holes with pieces of foil.  Without the surrounding ground electrode all other electrodes will react in the same way, when the user approaches the surface. With the surrounding ground plane that electrode will react most sensible, over which the finger resides, while all others show almost no difference.

Smajdalf

Thanks for nice explanation. It seems very reasonable. But during my experiments with touch sensing I was using just one electrode and it worked fine. It was made out of wire and a piece of aluminium foil at end. When I touched the (insulated) wire the capacitance also increased a bit. I did not focus at this but I don't remember capacitance change increase the closer the touch to Arduino was. Also I would expect placing hand anywhere between the wire and Arduino should make capacitance increase if it worked as you said. But it did not happen. Only close proximity to the wire made measurable difference. When I get home and have enough time I will surely test this again.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

DrDiettrich

With a single plate you can get all sorts of effects. Connect the plate to the microphone input of some amplifier or PC, and listen to the effect caused by your hand or finger.

Did your Arduino have a ground plane at all, and did it face the sensor? Or was your Arduino connected to a PC, then the area between the plate and the PC may be more sensitive than the area between the plate and the Arduino.

Did your lamp have a metal case or stand, that acted as the ground plate with the original circuit?

Repeat your experiments with two plates, then you can figure out the really capacitive effects. Every different behaviour, with a single plate, is based on different obscure and mostly unreproducible effects.

Smajdalf

Every different behaviour, with a single plate, is based on different obscure and mostly unreproducible effects.
I got impression software compensates for it - it measures "background" capacitance and sharp increase is considered touch. But as I said before - I know too little about this topic to argue. I will definitely do some experiments and revisit my "knowledge".
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

Smajdalf

With a single plate you can get all sorts of effects.
Interesting. I tried TTP223 chip (not breakout board). When powered from Arduino powered from laptop powered from mains it behaved exactly as I expected: getting close to the sensing electrode it signalized touch. Touching anything else including laptop, its power source, anything on Arduino was not sensed as touch. The electrode did not seem to be more sensitive from one particular direction.

On the other side powering the TTP223 from 2 (or 3) AA batteries led to "strange behavior". The sensing electrode is still most sensitive part of the circuit but touching any other part of the circuit (batteries are second most sensitive) is also sensed as touch. I added lots of caps as "decoupling" of power lines but it made no difference. Interesting...
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

Go Up