Short recap of introduction blog
The idea: Power tool safety glasses that will not allow the tool to be switched on unless the operator is actually wearing them.
The problem: What type of sensing should be used by the glasses to achieve a reliable reading?
How to go about it? I thought I had a couple of ideas but this is where suggestions from the community began to flow. Starting from force sensors, through vision based recognition and all the way to brain activity sensing. Those are all very interesting ideas which, hopefully, I'll have time to investigate. But I thought I'll start with the good ol' capacitive sensing, which will be the subject of this blog post.
I'll keep the theoretical part short as there are loads of high quality information out there (for example, here and here).
What is capacitive sensing?
Capacitive sensing is a technology in which a sensor can detect touch (or close proximity) based on the principals of capacitive coupling.
In the simplest form, a capacitive sensor has three main components:
- Base capacitance
- Capacitance measurement circuit.
- A human finger
Base capacitance is the capacitance of the sensor element itself. In its simplest form, the sensor element is a parallel plate capacitor, consisting of two conductive plates, separated by an insulating material (a.k.a dielectric). When voltage is applied across the conducting plates, an electric field is created. The capacitance is a measure of the field's strength, or the ability of the capacitor to store charge. The higher the capacitance,the stronger the electric field (for the same applied voltage). The capacitance is determined by the geometrical properties of the capacitor.
So what happens when a human touches the capacitor? Since the human body has conductive and dielectric properties it interferes with the electric field lines and thus creates a capacitance that can effectively can be seen as connected in parallel with the original base capacitance. Of course, this is a very simplistic explanation for a very complicated subject, but for our purposes, the bottom line is that human finger introduces a capacitance change that can be detected by the capacitance measurement circuit.
How to measure capacitance?
To summarize the previous paragraph: The human body introduces a change in capacitance on some sensing element. In order to make use of this physical phenomena we need to be able to measure capacitance (or more importantly, capacitance change). Two of the more common methods are time constant based and oscillator based, both of which can be implement using the MSP432 micro-controller.
(This is just a brief description, more info can be found in this and this TI application notes from which the pictures below are taken)
- Time constant based: In this method the sensing element and an external resistor form an RC circuit. As you know, the time it takes to charge and discharge the capacitor depends on the size of the capacitor. The larger the capacitor, the longer it takes for it to charge and discharge. The micro-controller quickly charges the capacitor and measures the time it takes for it do discharge through a large resistor. This time will increase when the load capacitance is increased (as a result of a finger touching the sensor, for example). If the time is longer than a certain threshold, we know that the sensor has been touched.
- Oscillator based: In this method the sensing element is used as the tuning capacitor in an RC oscillator circuit. Any change in capacitance will cause a change in the oscillating frequency that can be picked up by the micro-controller.
My experiments:
OK, that's it for the theoretical part, let's move on to some actual measurements.
1. Make a parallel plate capacitor: I used two strips of conductive tape, glued on a piece of thin piece of cardboard. This construction makes it flexible and easy to place on the inside of the safety glasses.
2. Build the circuit: The circuit used to test the capacitor is simply an RC circuit driven by a square wave signal generator. The resistor was chosen to be 100KOhm. In addition a scope was used to probe the driving signal and th capacitor voltage.
3. Probe the waveform and derive the capacitance (using the time constant,as described above) for three different cases:
a. Capacitor disconnected. This is a reference measurement to see what is the influence of the parasitic capacitance (those could be due to the oscilloscope probe itself, wires, component's leads, etc.).
b. Capacitor connected.
c. Finger touching the top plate of the capacitor. This is what we came for. In this measurement we actually see and measure the effect of the human body on the capacitance.
4. Analyzing the results:
a. For each of the above cases the time constant (tau) was measured. Tau is defined as the time it takes the signal to reach 63% of its final value. In our case, the source is 1V step signal, so tau is the time it takes the
capacitor voltage to reach 630mV. Using tau, the capacitance is easily derived through the relationship: tau=R×C
b. Here are the numbers:
| Case | tau | C (tau/R) | Comments |
|---|---|---|---|
| A. Capacitor disconnected | 1us | 10pF | This included the probe capacitance and other parasitic sources. |
| B. Capacitor connected (no finger) | 9.55us | 95pF | By subtracting the parasitic capacitance, we get : C = 95pF - 10pF = 85pF. |
| C. Capacitor connected and finger touching | 23.3us | 233pF |
c. We see that the capacitance of our "cardboard" capacitor equals to 85pF. Let's see if this value has any correlation with the theoretical value.
The equation for the capacitance of a parallel plate capacitor is: C=k×8.85×10−12×AD
Where:
A - plate area = 13.5 mm x 240 mm = 3240 mm^2
D - plate distance = 0.7 mm
k - dielectric constant = 2.3 (this is the dielectric constant of paper Relative Permittivity - the Dielectric Constant )
Inserting the above numbers into the formula results in: C = 94.3 pF. This means that we were off by about 10pF (not too bad, looks like the theory actually works).
Practical example
Well, this is all fine and dandy, but how can this be used in practice? Luckily, thanks to the Arduino and the CapSense library, it is quite simple to get a qualitative measure of an amount of capacitive loading.
The example code ,that comes with the library, generates a low-to-high transition on an output pin. The voltage is applied to an RC circuit and the capacitor voltage is sampled back using a different input pin. The library effectively measures the time it takes for the voltage in the receiving pin to reach a logic '1' state. The higher the load capacitance, the longer it will take.
Let's examine how touching the capacitor effects the output of this example code:
Again, the numbers marked in a red rectangle are a measure of the time it took the signal to reach a certain logic level in the receiving pin. When a person touches the capacitor's plate it increases the load capacitance on the receiving pin, thus increasing the measured time which results in the higher number seen above.
Summary
- A short description of the principals behind capacitive sensing was presented.
- Two potential methods for capacitance measurement were described: time constant based and oscillator based. Hopefully, I'll be able to test both methods once the kit arrives.
- We've seen that it is possible to implement a touch sensor using a simple parallel plate capacitor.
What's next ?
- Start integrating the sensor into the safety glasses.
- Perhaps start investigating one of the other suggested methods for sensing.















Top Comments