Brandon's hardware is fairly simple. The main bits are:
Brandon's software consists of a multitasking operating system written in assembly language, some libraries written in both assembly language and C, and the maze solving and motion systems which are written in C.
Well, an operating system is a bit too grand a term for what Brandon runs, but it does support all the basics required for multitasking. And it was written in just a few weeks so we didn't do too badly. There is obviously no protection available with the 68HC11, so which bits make up the kernel and which are libraries is a bit fuzzy. The basic set of system functions provided by the kernel are:
void idle(void)
int fork(int stacksize)
void PM_SetTimeSlice(int slicelen)
void *malloc(int len)
void free(void *p)
int FreeMemory(void)
void SIO_lock(void)
void SIO_unlock(void)
void SIO_putchar(char c)
int SIO_getchar(char *cp)
int OPT_X_Pos(void)
int OPT_Y_Pos(void)
int OPT_Angle(void)
void OPT_Reset(void)
void OPT_Correct(int dx,int dy,int dtheta)
void SetMotorSpeed(int Motor1, int Motor2)
void IR_on(void)
void IR_off(void)
int Analog(int input)
Brandon's code runs in three processes:
The maze solver process is the highest control level. It knows the maze
only as a 16 by 16 grid of cells, and the robot's position in cell coordinates.
The main control loop of this process consists of asking which of the north,
east, south and west directions are blocked by walls, deciding where to go,
and telling the navigation system which direction to move next.
Top-level Solver C code
The navigation process is concerned with moving the robot from one maze
cell to the next. It receives commands from the maze solver and then uses
sensor feedback loops to move in the correct direction. When it has moved
to the destination cell, it tells the maze solver process which of the
directions contain walls. Note that there is no code for turning
corners; if when starting to move, the robot is facing the wrong direction,
then this is simply detected and corrected by the feedback loops.
Navigation C code, including feedback loops
The clever bit is how the above two processes interact. With the simple layout described, you would expect the robot to move to the next cell and then stop to wait for the maze solver to tell it what to do next. This would result in very jerky and inefficient movement. What actually happens is that the navigation system can return the list of valid exits long before the robot reaches the centre of its destination cell. As soon as the front 2 side sensors are in the cell, all 4 exits can be checked. When running, this allows the maze solver more than enough time to calculate the next move before the robot even begins to slow down.
The diagnostics system provides regular status indications on the LCD screen, and polls the keypad.
Sample runtime debug output