Electronics notes/Capacitive sensing

From Helpful
Jump to navigation Jump to search
This is for beginners and very much by a beginner / hobbyist.

It's intended to get an intuitive overview for hobbyist needs. It may get you started, but to be able to do anything remotely clever, follow a proper course or read a good book.


Some basics and reference: Volts, amps, energy, power · batteries · resistors · transistors · fuses · diodes · capacitors · inductors and transformers · ground

Slightly less basic: amplifier notes · varistors · changing voltage · baluns · frequency generation · Transmission lines · skin effect


And some more applied stuff:

IO: Input and output pins · wired local IO · wired local-ish IO · ·  Various wireless · 802.11 (WiFi) · cell phone

Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Noise stuff: Stray signals and noise · sound-related noise names · electronic non-coupled noise names · electronic coupled noise · ground loop · strategies to avoid coupled noise · Sampling, reproduction, and transmission distortions

Audio notes: See avnotes


Platform specific

Arduino and AVR notes · (Ethernet)
Microcontroller and computer platforms ··· ESP series notes · STM32 series notes


Less sorted: Ground · device voltage and impedance (+ audio-specific) · electricity and humans · power supply considerations · Common terms, useful basics, soldering · landline phones · pulse modulation · signal reflection · Project boxes · resource metering · SDR · PLL · vacuum tubes · Multimeter notes Unsorted stuff

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer ·

See also Category:Electronics.

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

Intro, basic workings, uses

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

Capactive sensing senses a change in effective capacitance of a circuit.

Usually there is a basic capacitance you can assume, or calibrate to, and something (with capacitance) that somehow adds to that.


Capacitive sensors can measure

(changes in) electric field fairly directly,
dielectric fairly directly,
motion and distance (given some controlled engineering)
and indirectly anything else you can tie to any of the above


So it gets used for displacement, force, motion, pressure, fluid level, distance, thickness, even some basic material characteristics (...with assumptions made).

And sometimes the point is that you can do this without direct contact.


One of the simplest examples is a "are you touching this, or not" sensor, as e.g. used in touch lamps.

Your finger adds enough capacitive surface area for the increased capacitance to be measurable (relative to the base capacitance without you).


The way the detection usually works, particularly in simpler systems, is to to try to charge it, and see whether that still happens at the same speed it did last time, or more slowly.

This yields an estimation of added capacitance.

A touch lamp will just threshold this, because it has to deal with a lot of uncontrolled noise from the environment, and a threshold can be made to not misbehave.


...but you can also use the result as a degree of touch, though this is usually only done when the environment is well engineered.

And if engineered well enough, this can be more precise than the "oh, a lamp can only realy do touch-or-not" example might make you think.


The actual detection is usually either

  • just charging it some amount and see how fast it charges.
To deal with varying environments, this is typically compared compare with an earlier measurement.
  • seeing at what frequency it resonates best
this is more complex, but has some upsides


Some setups work not on the local capacitive, but allow ground to play as well.

This is the 'how fast it charges' type, but because the circuit is much larger, this is more sensitive and often much noisier, so this is usually used only to distinguish between "touch" and "no touch".

On precision

Precise measurements are typically constrained to precision-engineered cases in decently controlled environments, and containing any fringing, shielding EMI, and other interactions.

  • e.g. for precision positioning sensors, for thickness sensors, or density sensors
e.g. for assembly-line precision/quality checks, some machining applications

Within ICs you can get such a controlled environment (easier to shield, and can do things on femtoFarad scale) this is how various accelerometers work internally.

At slightly larger scale you can use the fact that e.g. a movable shaped rod may have some specific relation to your fixed sensor, and get some pretty decent small-offset position sensing.


At larger scale, you have less control over the environment's parasitic capacitance and interference.

Some can be controlled (automatic recalibration goes a long way), while other cases will always imply reduced precision.


There are some use cases where pragmatic details work for you.

For example, detecting human proximity at a meter is possible but hard to make reliable, while it turns out to be much easier than that to use huge electrodes to detect the speed of passing cars - largely because they're metal.


Touch-or-not

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)


"Is there touch" designs (such as touch lamps, buttonless switches/keypads, some sliders), will often only try to distinguish between 'at rest' and 'something else'.

That is, threshold, rather than apply meaning to the actual values.

While this is probably the simplest variation to get to work stably, it still tends to have constant recalibration (to deal with changes parasitic capacitance of the environment, and in interference)

Variants on this design:

  • touch keypads have multiple probes, so that each only needs to decide there is touch or not
  • touch sliders, touch wheels, etc. add detection like "is the change in one inversely proportional to the other"


On fringing

Some setups are specifically designed to use the fact that the electrostatic field fringes out. For example, capactive sensing of liquids in containers is often done with two plates positioned for lots of fringing, (and possibly shielded from other directions), with well attached (so fixed) electrodes, so that the largest difference must be coming from change in dielectric in the setup, i.e. the liquid. If we assume/know the dielectric constants of liquid (and air) we can even make it a halfway decent level gauge.

Some setups play with how much the field can fringe out (which can combine interestingly with grounding, for better and/or worse), or intentionally make it fringe out in one direction, and create a basic motion sensor.

How local, how sensitive, how fast, and how directional are conflicting interests that make for varied designs depending on the exact purpose.


Notes:

  • Fringing out by design often means coplanar antennae. Most other designs intentionally contain it.
  • Reliable measurement of capacitance change relies on
the change being on the same order as the circuit's basic capacitance
interference not being on the same order
This ends up a tradeoff between stability and sensitivity.
  • "Is there touch at all" is fairly simple to do. Fancier goals need fancier design.
  • A circuit will always have parasitic circuit capacitance on femtofarad-ish scale,
which is why one of the first things for basic stability is to add a capacitor of an order more than this.
  • The charge and discharge can be done via an AC signal (some sort of waveform), where
higher-frequency makes for lower electrode impedance and faster reaction time (e.g. used in servo-feedback mechanisms) and may help avoid certain coupling,
lower frequencies make for less noise but slower response.


On degrees

Other cases:

  • use the measured capacitance (beyond a thresholded "is it different'), e.g. to sense how far a button is pressed, or how much of a sensor is being touched
This can work will decently in a few millimeters, and has roughly logarithmc response
  • capacitive fluid level sensing works with fixed sensors.
    • the basic design is in the liquid and effectively measures the difference in dielectric between the plates that changes, between air (no fluid) and whatever fluid
there are variations on the implementation
E.g. if you want to have no probe in the actual liquid, you would probably use parallel probes (and a shield) directly outside.
sensitive to parasitic capacitance (e.g. human). There are ways around that.
  • sense proximity
This relies on probes having largeish fringed fields, and the passerby having the same ground as the circuit (that last bit is not always easy to guarantee, which is one reason you don't see this design much outside of DIY
a few cm, a few dozen cm, depending on the tradeoff with stability


Touchscreens

touchscreens are a further refinement, adding more precise localization.

Note that since these are biased for accuracy, they tend to specifically avoid being sensitive (as in larger-distance), meaning they usually require require fingers to be touching or at least very close (a glove is often already enough to not work).


There are a large number of refinements, mostly sortable into:

  • surface capacitance screens
one-touch localization:
Put a voltage on the corners of a metal area for a uniform electrostatic field. A closeby conductor creates capacitance between it and the plate.
Successive measurement from each corner can be used to localize.
Upsides: durable, and good enough for big-button interfaces like various kiosks, ATMs
Downsides: limited resolution, sensitive to interference, prone to parasitic capacitive coupling, needs good calibration
  • projected capacitance screens are etched, and the top layer is typically purely protective (unlike resistive touch). Projected is split into:
    • self capacitance screens, a.k.a. absolute capacitance, measures capacitance from single electrode to ground. There being a conductor nearby (such as a finger) alters the capacitance
      • multi-pad style (often 1-layer)
      • row-and-column style (2-layer), but multiple touches can be detected but not resolved.
essentially a small area in a larger ground plane. The field is a local parasitic capacitance between the two, and an interaction with external capacitance (such as a finger) is measurable.
The area needs to be smallish because the field is only significantly present at the edges(verify).
We need not care about the actual capacitance, mainly about changes.
    • mutual capacitance screens
holds a small charge between rows and columns -- effectively many individual capacitors. A closeby conductor steals charge.
controller scans all row-column combinations for the charge.
Resolved separately, so makes multitouch relatively simple.
Also less sensitive to EMI


On resonance sensing

Swept Frequency Capacitive Sensing

essentially check the capacitive response at various frequencies (a capacitor is a resonator) and gives you a plot
which tells you a little more about the situation, in a raw-data sense, you'll need to feed these profiles to a learner

See also:

http://www.ivanpoupyrev.com/projects/touche/
https://www.disneyresearch.com/project/touche-touch-and-gesture-sensing-for-the-real-world/
M Sato et al. (2012) "Touché: Enhancing Touch Interaction on Humans, Screens, Liquids, and Everyday Objects[1]
https://github.com/damellis/ESP/wiki/%5BExample%5D-Touch%C3%A9-swept-frequency-capacitive-sensing

Design considerations

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

Direct effect on capacitance:

  • sensor area
  • sensor thickness (thinner can work better)
  • sensor separation (distance - e.g. plastic, paint, carpet, whatnot)
  • capacitance of the underlying electronics
  • capacitor you add to a probe (for predictability)

Effect on noise / accuracy / direction

  • parasitic capacitance
    • of objects very near to the capacitive field
    • due to shared earth
  • radio frequencies present the environment (EM interference)
  • environment humidity
  • environment temperature
  • capacitance of the underlying electronics
  • the sensitivity of the underlying electronics
  • an (active) shield can help direct the effect


A handful of those can chance over time and with location, so so constant recalibration is important to predictability. ("what values have I most seen recently" tends to work quite well for most purposes)


Note that

  • parasitic capacitance between (AC) power and chassis ground is unavoidable (comes from the transformer winding).
  • EMI filters (common to avoid interference entering digital ciruits) will add capacitance
also relates to ground loop hum and tingle (the hum intensity varying with effective capacitance(verify), though the current capacity is low for the tingle to hurt)


Unsorted

XKC-Y25

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

"non-contact liquid level" which, by description (non-contact through thin non-metal walls, few hundred ms response delay) must be capacitive.

Sensor processing draws ~5mA.


There are four models, which differ in how they output:

  • XKC-Y25-V (and XKC-Y25-T12V?(verify)) - high/low signal
  • XKC-Y25-NPN - NPN (can be used in a circuit, max 200mA draw)
  • XKC-Y25-PNP - PNP (same idea)
  • XKC-Y25-RS485 - RS485 serial out


There is also a DPRobots board


The wiring varies slightly per model:

XKC-Y25-V

Brown - Vcc
Yellow - Out (2mA max(verify))
Blue - Gnd
Black - Mode
floating: NO
tied to Gnd: NC

XKC-Y25-PNP

Brown - Vcc
Yellow - Out+
Blue - Gnd
Black - Mode
floating: NO
tied to Gnd: NC

XKC-Y25-NPN

Brown - Vcc (5-12V)
Yellow - Out-
Blue - Gnd
Black - Mode
floating: NO
tied to Gnd: NC

For RS485:

Brown - Vcc (5-24V)
Yellow - RS485-B
Blue - gnd
Black - RS485-A

See also


And perhaps:


Arduino CapSense library

  • uses digital pins
  • auto-calibrating (in intervals)
  • you need one receive pin per sensor, and a resistor to tweak the sensitivity.
  • one send pin can be shared for multiple sensors

Keep in mind that calibration can be finicky - life may be simpler with ICs made for this.


See also: