Buzzbot – Odometry Task

Now that I have my Interrupts working on the the PIO Port, I have successfully adapted some code to provide Odometry for Buzzbot, based on reading the wheel encoders.    

This odometry task provides me with the following data:

  • Buzzbots Location in 2D Space (X and Y cooridinates).
  • Current Heading in Degees.
  • Average distance travelled in centimeters.
  • Angle of rotation about the axis.

I would like now to get the motor contol going, so at least I can get some basic movement, then the next step will then get some behaviour happening.    The PID combined with the odometry will allow me to command Buzzbot to drive to a specific X, Y Location, so I can do some calibration on the odometry to see how accurate it is.

All these tasks run under the FreeRTOS (

Interrupts on makecontroller now working

Finally worked out how to use the GPIO interrupts on the AT91SAM7X, which is the brain of the makecontroller.  A couple of “gotchas” along the way, especially for a newby to these beasts like me, which as usual, after I’ve finally worked it out I look back see how simple it was lol.

 The three main “gotchas” were:

  1. The ISR needs to be in its own .c file and the filename appended to the ARM_SRC section in the makefile.  Reason: All IRQ need to be compiled in ARM mode
  2. In the ISR I needed to Read the Interrupt Status register, PIOB_ISR, I was not dodin gthis and so it would process  the IRQ once and never again.  By reading the ISR it clears it and allows interrupts on the PIO to re-occur.
  3. The very last thing in the ISR is to renable the AIC so that interrupts will be processed upon exit

Here is the code: