Capacitance Sensing

Thursday, August 4, 2011 by darco
Posted in ,

Update: After building out a few more boards and doing some additional testing, it seems as though things aren't quite as bad as I originally portrayed them in this post—the boards I made may still be usable as designed, albeit with a few quirks. However, I will be incorporating the design changes outlined below into the project for future devices to improve the consistency and performance.

After building out a few of the soil moisture sensor boards, I'm starting to think I may have been a bit hasty in ordering forty of them. The biggest problem I'm running into is noise. Lots of noise. Practically unfilterable noise, the nature of which is entirely dependent on material the sensor is embedded in. It is as if the sensing plane is acting like a large antenna, picking up all sorts of crap.

Some noise is actually a good thing, because it acts as a dither. allows me to super sample the capacitance and get a filtered result that is of a higher resolution than that of a single sample. Without any noise supersampling would not yield any better results.

But this kind of noise is on a whole different level. About the only thing these sensors (as currently designed) are good for at the moment is as a touch sensor... Which happens to be exactly what the capacitive circuit I borrowed from the QTouch guidelines was originally intended for.

qtouch-sensor

QTouch capacitive sensing channel schematic from the Atmel QTouch Library User Guide.

I am not an electrical engineer, so when the QTouch sensor design guide said on page 2-1 that the measurement circuit was capable of measuring capacitance down to a few femto-farads, I believed it—even though the circuit made no sense to me (See figure above). Initial testing seemed to indicate that the method did work to some degree, so I went with it. I now see that was a mistake; I should have trusted my instincts more.

This is not to say that my original capacitance sensing circuit (which simply discharged a capacitor thru a known resistance) was any better. Looking back at it, I think that it would likely be just as susceptible to noise as the QTouch design.

In order to keep moving forward with this project, I've come up with an entirely different circuit that should hopefully prove to be far less noisy than the previous methods:

darco-sensor

New low-noise capacitive sensing circuit.

The circuit actually works in the way that I originally imagined how the QTouch sensing circuit would work. What we do is charge up the capacitor we want to measure using a pulse, and then wait a little bit for this charge to distribute to the holding capacitor. We calculate the capacitance of the target by counting the number of pulses it takes before the sensing pin goes high.

While we end up operating this circuit in close to the same way as the QTouch method, the results are interpreted a bit differently. For example with the previous capacitance measurement fewer pulses meant less capacitance and more pulses meant more capacitance. In this circuit however the opposite is true: fewer pulses means more capacitance, and more pulses means less.

There are three things I really like about this circuit:

  1. It effectively has a built-in low-pass filter, so it should be less prone to noise.
  2. It doesn't increase the part count.
  3. There are upper and lower bounds on the capacitance reading, whereas with the previous method there was no upper bound on the number of pulses required to measure a capacitance.

Unfortunately the resulting pulse count does not have a linear relationship with the actual capacitance. This means that some sort of compensation (via a look-up table or other methods) will have to be performed to get a linear output.

New sensor orientation

Since I'm going to be re-designing the board yet again, I might as well make a few more radical changes, right?

One of the problems with this sensor is the fact that the electrodes are not only parallel, but they are also co-linear to each other. Ideally a capacitor is made like a sandwich: two electrodes with a dielectric between them.

While the "ideal" case might not be such a good idea in this case, I think I may have come up with a compromise: have two circuit boards that slide together so that the electrodes are oriented 90° from each other. I took a Dremel to two of the boards to start to put together a prototype:

another-prototype

Dual-board moisture sensor prototype. Work in progress.

As an added bonus, this sensor should be significantly more sturdy than the previous single-board design, while being more sensitive. Of course, it could just not work at all. We'll see.

References