making sense of Capsense
Monday, February 11 2013
Last night I was experimenting with the Arduino Capsense library, which is used to detect the proximity of a grounded conductor to a digital pin. In most applications, the grounded conductor is a human finger and the digital pin serves an input button. But I wanted to use Capsense to accurately measure the very low capacitance of my capacitive fuel probe. For whatever reason, I couldn't get Capsense to work at all last night, but I'd been using my custom-made Arduino programming and prototyping board, which is actually an Olimex board with a ZIF socket and a bunch of other features, all of which I assembled by hand over the years. Today when I tried the Capsense libary on a stock Arduino NG (the second Arduino generation, circa 2006), it seemed to work okay, though I wouldn't exactly call it reliable. The stream of numbers coming out of the serial port were more like something you'd see coming from mad scientist's tesla coil than from a piece of reliable measuring equipment (which is, after all, what I wanted this to be). Still, it had enough promise that I began preparing the fuel tank to receive the new probe.
The probe, which I actually made years ago and have never deployed, is just over four feet long, which made it just a little too tall to fit in the tank. That wasn't a problem; I'd mount a PVC stack on top of the tank to contain whatever didn't fit inside. More problematic were the constraints on the physical space above the tank, which made maneuvering such a long probe into position difficult. For starters, I had to use a hole saw to cut a hole in a shelf directly above the plug in the tank where the probe will go. Then I had to slightly shorten the probe so it wouldn't run into the ceiling as I went through the necessary gymnastics to get it through the hole I'd drilled in the shelf.
This evening, I worked on integrating the Capsense code with the existing code on the Serial Slave that had been (very inaccurately) measuring fuel level using an infrared rangefinder. I ran into a couple problems along the way that produced the sorts of side effects that are difficult to debug when developing on the Arduino platform. The first of these came when I accidentally told the Arduino IDE that I was programming to a Lilypad Arduino, which (it turns out) runs at a different clock speed. The only effect this had as far as I could tell was to alter the baud rate by some factor, but I found myself looking in vain through the code in hopes of finding where I was inaccurately setting the baud rate, only to find, after much head scratching, that I'd set the IDE on the wrong board. The other problem was even harder to debug. Basically, whenever I tried to do anything useful after making a CapSense call (such as printing to the serial port), the Atmega168 hung, causing the watch dog to reboot it. Eventually I determined that this must be a memory exhaustion problem, a theory that I confirmed when I switched to using an Atmega328 (which has twice the memory) and the problem went away. I'm finding it harder and harder to get my projects to fit inside even an Atmega168, which seemed like a huge advance over the Atmega8 in the early days of my Arduino tinkering.
This evening Ray and Nancy showed up almost without warning and wanted to take us to dinner at the Garden Café in Woodstock. Gretchen did some research and found the soup of the day would be split pea, something that didn't excite me very much (all I normally care about at the Garden is the soup). So I tried to beg out, but Ray and Nancy were insistent that I come. It turned out that they were treating us both to dinner as their way to celebrate our birthdays (which happen a month apart at this time of year).
That split pea soup was actually pretty good once I dumped a bunch of hot sauce and salt into it. But there was nothing much to be done to salvage the pasta with meatballs entrée I ordered. (It's relatively new to the menu.) For starters, it came out of the kitchen uncomfortably close to room temperature. But then it had the problem of almost no flavor aside from a bit of cloying (and completely foolish) sweetness. Somehow it managed to cling to this blandness despite enormous amounts of salt, as well as both hot and black pepper. The takeaway from this experience: the Garden Café does some things well, but they have yet to master the simple art of making a plate of pasta with red sauce. (As for the vegan meatballs, Gretchen thought they were good, but Ray and I agreed they were mediocre at best.)
For linking purposes this article's URL is:feedback
previous | next