porcupine

Porcupines!

This page describes building instructions for a sensing module, the porcupine, that can be taught to recognize motion and pose patterns. It has been designed to be as power-conserving as possible, so it should be ideal for a large variety of wearable and mobile applications.  

picture of the porcupine close-up of the porcupine real-close-up of the porcupine

  

Bill of Materials (Ingredients)

The items in the green rows are for the battery board, those in blue are for the main porcupine board. Remember that the total cost at the bottom of the table does not include the time spent assembling it, nor the cost of the tools (like soldering stations, solder paste, etc.). Availability of all items was last checked at 15/07/2005.

No Order at Order Code Part No, Manufacturer Description Price (£) Pack details
1 Farnell 908654 3003, KEYSTON RETAINER COIN CELL 20MM PK5; Diameter, cell max:20mm 0.5 5 for £2.5
1 PCBPool X PCBPool Batttery Printed Circuit Board 5 110.63€ for 14
1 RS 468-1805 53748-0208, Molex 20 way SMT stacking plug connector,3mm 2.16 1
9 Active Switch and Sensor AT407 AT407, Active Switch and Sensor Tilt & Tip-Over Switch, Ball Contact 0.39 1
1 Analog Devices ADXL202JE Analog Devices ADXL202 - ±2 g Dual Axis Accelerometer 7 $8.50
1 Farnell 4243407 MICROCHIP PIC16F628A-I/ML 1.52 1
1 RS 468-1855 52991-0208, Molex 20 way SMT stacking receptacle conn,3mm 1.68 1
9 RS 345-1827 VISHAY D11CRCW0603 minireel resistor,1M 1% 0.01 £8.27 for 1000
3 RS 220-7966 GRM Series SMT Y5V ceramic capacitor,100nF 50V 0.02 1
1 RS 345-1704 VISHAY Resistor,1000 unit, Minireel, chip, SMT, 0603,1%, 300k 0.01 £8.27 for 1000
1 PCBPool X PCBPool Porcupine Printed Circuit Board 5 110.63€ for 14
29



23.29

Note that you can click some of the descriptions for the datasheet links.

Board Designs

It should be obvious from the schematics that this board is fairly simple: the microcontroller in the middle has an accelerometer sensor (dual-axis) and a set of 9 tilt-switches attached to it. The 9 tilt switches are pulled up to VCC by 9 resistors, so their readings are 1 when open, and 0 when switched. The accelerometer has a few capacitors and a resistor to set its output to the right mode. The big 20-pin connectors in the bottom is for attaching the Porcupine to the battery and BSN boards, and the 5 pin connector is for reprogramming the PIC microcontroller.
schema
topbottom

The battery board is just a PCB with drill holes and pads for three connectors: one to connect to the Porcupine, one to the battery holder, and two holes that can be used for attaching the board to a serial rs232 bus.
 
schema battery

Click on the schematics and board lay-out pictures to download the .sch and .brd files.

Note: these files were made using Eagle, a CAM software package that has a freely downloadable lite version that is limited to small, 2-layer boards (so the free version works perfectly for this board!), if you continue to use it you might want to order the full version. You obviously need Eagle to view these files. You can also just submit the brd file to a PCB manufacturer (such as PCBPool), for which you don't need Eagle of course.

Main Elements

Tilt Switches / Ball Switches

There is a good reason for those 9 big cylindrical objects on top of the Porcupine: they cover a very crude sense of tilt for the board in three planes. The easiest way to visualise how this works is in one plane; the other two planes that are positioned orthogonally on this plane work the same, but only 9 instead of 12 switches are required since we have common tilt switches between the three planes.

animation of tilt switches

There are two reasons for incorporating these switches, related to resources:

  • Energy: They require less power: with the heavy pull-up resistors, they draw only a few microAmp, compared to a few hundred microAmp for the accelerometer.
  • Processing: Their output is binary, and thus easier and faster to process, especially when combining multiple switches. The microcontroller also doesn't need to run at a fast speed for reading the switches' states or doing analysis. 

Accelerometers

The problem with the tilt switches is that they don't give a very accurate output, and also give no information on acceleration on top of that. For things like basic gesture recognition, it is quite important therefore to have an accelerometer present for the fine-grained acceleration readings.

To keep everything efficient though, the accelerometers can be switched on and off by the microcontroller to keep power consumption down at times when only a vague notion of tilt is enough. When the tilt switches notice that more movement is going on, the accelerometer can be switched back on for heavier, more accurate, processing.

The accelerometer used for the Porcupine is the ADXL202JE: it is fairly sensitive (+- 2g) and outputs its information in Pulse Width Modulation (PWM), which is extremely nice since we don't need any ADC conversion.

Microcontroller

The Microcontroller has specifically been chosen because of its build in circuits that determine it's processing speed. For the tilt switches, it runs at a low 32kHz, while for the accelerometers it will switch to 4 Mhz. If nothing is happening at all with the switches or accelerometers, the microcontroller can even go into an extremely low-power sleep mode. The speed at which any microcontroller runs affects its power consumption heavily (measured with a 3V coin cell battery attached):

There are a few microcontrollers that have the same functionality and are pin-compatible: the Microchip PIC16F628A was used in the design of both hardware and software, but others with more features and memory like the PIC16F648A also work (and have been tested).

Building Instructions

The Porcupine Board

board1 board2

It is best to order the PCBs with protective layers and silk screen, which helps in soldering the components in the right orientation and place.

board4 board3

The hardest components to solder to the PCB are the PIC (left) and the molex connector (right) - use solder paste. The three 100 nF capacitors and the 300kOhm resistor (left, top-right) as well as the 9 1MOhm resistors (right, bottom) should be easier.

final top picture]

Then finally add the accelerometer, the 9 tilt switches, and the programming connector, and you'll have a finished porcupine, ready to program. The 5-pin programming connector's layout is shown below:
1: MCLR Master Clear (active low Reset)
2: PGC Program Clock (using pin B6)
3: GND Ground
4: PGD Program Data (using pin B7)
5: PWR Power, Vdd


The Battery Board

battery board battery board 2

The battery board has connectors for the coin cell battery holder and the 20-way molex connector. There are two holes to connect an rs232 bus if required for serial communication.

Software and Algorithms

The PIC microcontroller is programmed by erasing and uploading a hex file onto its flash program memory. There are many PIC programming devices available to do this, a cheap and pretty good one is the ICD-40 from CCS, which also produces an easy C compiler for PICs.

Forwarding the sensed data and basic features

This first program collects data from all sensors (tilt switches and accelerometers), and sends their pre-processed information over rs232 to any attached board (or bus), at a rate of approximately 10 Hz. The output is in a fixed 15-byte format, and sent at 2400 baud:

Pre-amble 0xFF 0XXXXXXX 0XX0[hamming] [average x] [average y]
[minimum x]* [minimum y]* [maximum x]* [maximum y]* [peak height x]*
[peak height y] [peak length x]** [peak length y]** [peak size x]  [peak size y]

where the 9 Xes are the (binary) states of the 9 switches, and [hamming] is a cumulative hamming distance between all readings taken since the last output (taking 4 bits).

*over a sliding window of size W

**the peak length can be positive or negative, according to whether the peak is poiting upward or downward

By changing the values of N and W in the source code, one can modify the features to be more (or less) responsive to high-frequent patterns in the acceleration signals.

[click here to download the c file]

[click here to download the hex file]

Applications

The stack connector layout has been adopted from the BSN nodes, designed by Benny Lo at Imperial College, London. The porcupine can therefore be used as an add-on board for a BSN node, giving it access to a wireless sensing network, as well as additional processing and memory. The battery board can for the exact same reasons be used to power both BSN node and porcupine. Below are a few pictures of the whole setup, plus the features of the BSN node. 

with bsn node hand
BSN Node features:
  • 8MIPS TI MSP430 ultra low power processor (16 bits RISC processor, 64KB +256B Flash memory, 12-bit ADC)
  • a Zigbee ready RF link (Chipcon CC242, 2.4GHz, 250kbps, with hardware MAC encryption, range 50m)
  • 512K EEPROM
  • 6 analog channels
  • stackable design
  • running TinyOS
side view

In this configuration it is used as a self-organising sensor network of porcupines that can be attached on the body (preferably arms and legs).

habitat

Some of the porcupines getting ready for action, with the first prototypes in the foreground.

To interface the Porcupine with the BSN nodes (or any Mote), you'll need to install TinyOS first. A guide on how to do this can be found  here.

Page updated on 23/07/2005  by kristof