Hogwarts Wand Software

The wand software was developed by Acorn over the 9 months preceding the Hogearts game. The software was developed on a prototype circuit which is very similar to the final circuit.

The first piece of software developed was a bootloader for the wand. Once the bootloader is programmed into the wand the wand can be reprogrammed using a serial port. This makes development much easier. The bootloader also maintains the date and time while the wand is running its main software. Finally the bootloader has some debugging features that allow the wand to be debugged over the serial port from my GNU/Linux laptop. In addition to allowing updates to the wand software, the bootloader is capable of loading a new version of the bootloader and replacing itself.

The second piece of software developed was the 'ww' (w for wand) server program. It runs on the laptop and communicates with the bootloader via serial port. It allows uploading new versions of the wand and bootloader software onto the wand, and downloading accelerometer data for offline analysis.

The biggest challenge in the wand was recognizing motions (mwaneme spells). This is done in 2 phases for each spell that is cast. Phase 1 records motions, and phase 2 analyzes the motion and compares it to the description of motion for each spell. (After casting a spell the wand LEDs blink up and down during phase 2.)

Phase 1 was implemented first. It uses the PIC's A/D converter to alternately read the x and y channels of the accelerometer. It then converts these to polar coordinates and stores them in a delta compressed way (see the sourcecode for how this works).

The software for analyzing the motion data and comparing it to the stored spell data was first developed in C on a GNU/Linux laptop. Data was obtained by waving the wand and then downloading the result over the serial port. Several fuiltering steps are performed to remove noise from the data before comparing it to the stored spells.

Once the analysis software was working in C it had to be ported to PIC assembly. This was done in several steps. First the code was rewritten in C in such a way that it would run just like the code would run on the real wand. Second a PIC simulator was written so PIC assembly code could be run on the laptop. Third the code was ported to PIC assembly and run in the simulator. At each of these steps a regression test was run comparing the result of the analysis on each of the different versions of the software. Finally, once the PIC assembly version (running in simulation) agreed with the original C code, the assembly was programmed into the wand and the wand was able to do the analysis.

Tuning the wand analysis software took the most time. Many spells were cast by Sean Gugler and others and the data collected. A graphical tool (see Makefile) was developed to visualize the data and resulting analysis.

Finally the results of casting spells were programmed into the wand. Each spell has a different message depending on what date and time it is cast. This allowed GC to skip slower teams over one or two clues, or redirect faster teams to extra "slowdown" clues, so that the teams stayed closer together in the game.

All the software files are:


This file Copyright (C) 2006 by Nathan (Acorn) Pooley
Go to TOP Wand page
Go to Acorn's personal webpage
Go to Hogwarts website: www.gotohogwarts.com
Snout: www.snout.org/game
Gadgets of Justice Unlimited
File created by Acorn on Sat Sep 16, 2006