Sunday, 19 February 2012

Multiple capacitive sensing inputs

Using our switch-from-output-to-input method of testing for a piece works fine to date. But there's a problem brewing that needs tackling early on:

Each sensing pad currently uses one digital i/o pin.
One of the larger pin-count PIC microcontrollers, an 18F4550 (or 16F877A if we're not worried about the USB stack) has only 40 pins, of which about 34 can be used for digital i/o. If we consider even a simple chess board, we'll need at least 64 digital i/o pins for an 8x8 grid.

For anything larger or more interesting than a chess board, we'll need LOTS more pins! It's possible that we could use lots of shift registers and daisy chain them to increase our pin count, but we're going to try our earlier design, using "rows" and "columns".

We'll hook up 8 pads onto a single input PORT (each port is 8-bits/one byte wide) and monitor it for input from the board. Then we'll use the left over digital pins (and perhaps a shift register if necessary to increase the pin count here) to activate specific "rows" on the board. By knowing which row is activated, and by reading which input pins are high after the row has been switched off (using residual capacitance to keep the input pin high if a pad is touched or a player touches a piece standing on top of the pad) we can calculate exactly which pad has triggered the "high" input signal.

To achieve a full-sized Blood Bowl board, we're going to construct each row from two "modules" of 8 pads. Each module can connect to its own input port (e.g. PORTB and PORTD) on a 40-pin PIC so we'll be able to monitor up to 16 pads at any one time.

Here's a module we've come up with.
For testing we're going to etch this onto single-sided copper board. For the final version, we're going to use double-sided board (so that the traces are on the bottom and can't pick up any stray capacitance from the pieces on the top).


Capacitive sensing 1x8 board module

The first 8 pins connect via a wire to the input port(s) on a microcontroller. The final pin (connected to the 8 "row" pads through a 1mm wide trace) goes to a "row control" pin (either directly to an i/o pin, or to a shift register used to increase the number of available pins).

A few people have already said that when they printed the earlier (portrait) version of this board, their printer resized it ever so slightly to get it to fit onto the page - we managed to get this effect too, so here's a landscape version of the same board:

Capacitive sensing 1x8 module (landscape)