Some explanation is in order for the programming approach used in this project. By this time I had spent some time playing around with PICs, and a program intended only to achieve the required behaviour - bump, reverse, turn, drive off - would have been very simple.

This program was never intended to be that. A structure of low-level interrupt-driven routines was to provide services to a high-level control program which would be concerned only with the logic of the task. The overall structure was inspired to some extent by the heavily interrupt driven operating system of the BBC microcomputer, and was to be a foundation on which future versions of the program would build.

Motor control was to use pwm from the outset. The top-level control program would write its requirements in terms of speed and direction for each motor into named locations, and the interrupt-driven lower-level code would make it happen. In phase one, the interrupt driven code would also provide tone generation for the sounder and general purpose timers for use by the control program. Later there would be additional functions to generate ultrasonic signals, modulate infra-red sensors, etc.

Surprisingly it all worked. There must have been some head banging over the details from time to time, but I don't remember them. I do remember the buggy, interrupts, pwm and all, doing everything it was supposed to do - driving around, bumping, beeping and avoiding. I counted this a considerable success. As I suggested at the outset, a buggy with the same basic behaviour could be put together and programmed using Lego Mindstorms in an hour or so, but that is not the point. I gained a lot of satisfaction from this project. I also learned a lot, some of which found its way into my teaching.

Unfortunately, I have lost all the programs written for this buggy apart from the very first one, dated August 1998. The reason I still have this one is that it was done on my desktop PC, and like everything else on the PC, has been copied from machine to machine over successive upgrades. The later programs were done on a bench PC which was retired some years ago. Between that and subsequent clearouts of floppy discs, which I no longer use, I have managed to lose all the work done on that machine.

Program Listing

In this program the structure is there, the interrupt-driven pwm and a timer are implemented and the control program uses them to make the buggy carry out a few simple manoeuvres. The final phase one program will have been very similar, with additional low-level code to generate tones for the beeper and a control program to implement the bump-beep-go algorithm.