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 – Steep Learning Curve

Well have the controller setup and have uploaded the demo code, all working 🙂  Now down too some serious work in getting buzzbot connected to the board. 

The Board is based on the AT91SAM7X MPU, of which I have absolutely no experience, so the learning curve begins (right at the bottom).  First thing I want to do is get the interrupts for the two wheel encoders working.  From my initial research I gather that any of the inputs on the GPIO can generate an interrupt on a state change, exactly what I want.  So now more research on how to make it happen using the ARM7 GCC tools I’ve installed, all demo code is compiling and working ok.

Looks like my starting point is some examples found here 

BuzzBot – PicAxe Frustrations


I have to make some decisions on what direction I need to go with my buzzbot project, basically I have been frustrated with some short comings of the PICAXE microcontroller.  The main being lack of any onboard timers and having only one common interrupt available.  Also I think that I’m trying to fit too much onto one of these babies. 

Don’t get me wrong I love these little guys, they are fantastic if all I need is polled I/O, which for the majority of the time is what I’m after, however everytime I want to do something time critical I hit a dead end. 

Main issues so far:

PID Motor / Differential steering Control – No timer interrupts and PICAXE not being fast enough to update PID Calculation base on each wheel velocity.  I have no real way of getting around this so I think my options are to move to an actual PIC (as opposed to PICAXE) and program the PID Differential Steering in C / Assembler.

PWM Motor Control – Limited to 2 pwm output pins on the picaxe28, (btw this in itself is not an issue, just trying to get it working on the existing H-Bridge which has 4 wires – and I didn’t really want to use any external logic), I have tried coding a PWM using picbasic, but does not have the resolution, so I may have to add some external “glue” hardware to allow my h-bridge to be driven from onboad pwm and forward/reverse direction.  I’m also cosidering replacing the existing H-Bridge that was part of the R/C buggy with a L293 Dual H-Bridge chip, this in itself will solve my issues with PWM motor control, but still need to resolve the PID issue for my differential steering. 

IR Detectors – I have moved the IR Detector Circuit offchip while playing with PWM / PID control.  This I have implemented using a picaxe08M, also having some issues here, although I think I can get around these.  The 08M only has one PWM onboard, and I’m using this to modulate one of the IR TX LEDS.  I would love to have 2 PWM onchip as the PWM/IRTX/IRRX Combo works really well in detecting objects,  I have moved to a proper IR Receiver rather than just an IR Opto Switch.  I had issues with sensitivity, and using a proper IR modulated Receiver has cut these out.  I guess it was  ambient IR causing the problems.  The only problm I have now is as there is only one PWM I need to modulate another IR TX (The right) at approx 40Khz.  I have tried it in code but no go as the picaxe is not fast enough, So I have been playing around with the “infraout” commands of the 08M,  this in conjunction with the PWM seems to be causing alot of noise on the RX, if I disable the infraout then all works aok, so some more things to look at, it may be that the same onboard timer is being used as with the PWM, or the infraout is spot on 38Khz, as I have found by detuning the PWM down I decreased my falses.  Anyway will look into this a bit more.

BuzzBot – Initial Testing

I started testing last night after finishing initial motor and wheel sensor hookups to my development board.  Couple of minor issues so far. 


I’m using a pic based board from Modtronics. These are great and reasonably priced, along with the prototyping daughterboard.  However I have since found that the onboard RS232 is not on the same pin as the PICAXE28X, so I had to wire in an additional programming circuit, no biggy.  The other issues so far were the wheel sensors.  From my initial design I had used 10K resistors to bias the output of the opto-transistor, this was not tested and when testing the logic probe was picking things up ok, but not the PICAXE, after much stuffing around and not being able to find my multimeter (it was still packed away from shifting house) I ended up prototyping the same circuit, still had some issues, so I went  hunting for my multimeter and of course it was on the bottom box lol.  Luckily thanks to my trusty multimeter I found that the sensor was just dropping down to 3.8v when interrupted, anyway the solution to the problem was a larger resistor, a 22K on the output, this tested AOK, now getting ttl levels when switched, I also noted that the distance of the sensor to the reflective object (paper in this case) was fairly critical.  I modded the breadboard and then found one side was working fine, the other was not being seen.  Checked and found that the sensor was slightly further away than the one that was working.  So out with the hot glue gun and moved the sensor.  Both side are now giving me a reading on the PICAXE.

Motor Tests 

Next I adapted some motor control routines on Hippys PICAXE site to test my motor circuit.  First I tested without my motor control board plugged in, didnt’ want any smoke to escape, and all logic tested aok, then came big crunch of running motors live.  I can gladly say that all tests worked A1 with no issues.  Motor was tested though a range of 3 speeds in FWD, REV, Turn right FWD , Turn Left FWD, Turn Right Rev, Turn Left Rev, Spin Left and finally Spin Right.  While Testing the FWD and REV, I checked the Pulses from the wheel encoders to see how much the same each drive was over 100 counts from the wheel encoders and it looks like the Right side is slightly stronger than the left, no real surprise here as no two motor/gearbox combinations are the same.  I had thought about this a few days ago and knew that with any differential drive system I will encounter this type of problem.

Motor Control Algorithm 

This then leads me onto my motor control algorithm.  Over the last few days I have been researching PID Controller and their application to motor control for robots, as I want Buzzbot to drive in a straight line, also been looking at fuzzy logic, but I think will give that a miss at the moment.  I have been thinking of using and adaptation of the PI Proportional controller from the book “Robots – Inspiration to Implementation”  however so far I’m not 100% happy with the PWM and the way it is from the code I adapted, while it is very simple and works,  I would really like to use the onboard PWMout routines, but as I mentioned in an earlier entry it is only limited to two PWM and to two physical pins on the PICAXE – Bummer!!!!   I also thought I can use the old PWM command.  This command requires it to be refreshed, much like what is happening in  my test code, except with a agreater resolution, unlike the PWMOUT that runs in the background, perfect I thought!, but when I went to test it I found it’s only available on the 08 series…double Bummer!!!!!  So now may have to look at teh PulseOut command.

While the existing configuration does give me three speeds, the lowest is time critical and I notice that when I add a debug routine the slowest speed does start pulsing, also I don’t think it will give me the fine control needed on each of the wheel speed controllers.  I’m going to have to think about this a bit deeper.


All in all everything is working as expected, with a couple of minor hicups along the way.  Biggest issue will be PWM resolution and time of my routines.  I think I’ll need to come up with another way of doing what I want simply and without too much additional hardware if I want a closed loop control system.  While I ponder on this I’ll test the IR Sensor circuits.  These I’ll prototype first before I hardwire in.  Once I finish these I can then start working on behaviour.  I would like to look at using some sort of subsumption model, but will look at it deeper as I get closer.

buzzbot -  Motor Testingbuzzbot -  Motor TestingBuzzBot - Modtronics PIC Board

Buzzbot – Circuit Design

Last night I did some brain storming asto what the I/O requirements will be.  During this requirements phase I came across a bit of a delima with the PWM requirements for the motor controller.  The motor controller requires two outputs per motor, so this rules out using the onboard PWMout command of the PICAXE, as there are only two dedicated PWM pins on the chip that I’m using.  Although I could do it with some additional glue logic in hardware, I don’t really want to do that (as I’m lazy), so now I will be doing it all within the software, this should free up the servo command within the PICAXE, so I can now use this to drive the servo for the sonar unit.

I’m going to be using the PICAXE 28X. With my I/O current configuration of the 22 available I/O on chip, I have 2 Inputs/Outputs and 4 Analogue Inputs Available for future expansion (or and additional 4 inputs if I don’t want to use the analogue inputs).  It will be interesting to see if the processor will be fast enough process everything in a timely manner, especially with the motor control and encoders.  Well I guess I’m about to find out.

I’m now going to actually get my hands dirty with the PICAXE as I still haven’t plugged the development board into my PC yet 🙂

BuzzBot – I/O Requirements

Buzzbot – PICAXE Circuit

Buzzbot – Motor Controller Tests

Ok encoders are in, although not wired up.  So I quickly re-assembled the wheels and motor controller board for a quick test.  Glad to say that everything tested aok.  Put my logic pulser on the inputs and sure enough forward and reverse is easily attained on both motors, although due to the low frequency pulses of my logic pulser the motor speed did hunt a little.  Now reassembling with cabling to go to my pic development board.

Buzzbot – Wheel Encoders

Now that the Motor Drive Controller has been worked out, (but yet untested)  I needed to make up some encoders for the Left and right Wheels.  After a bit of research I found an excellent program for creating encoders and quickly made two and have just glued them to the inside of the wheels for some rough and ready testing.  I really think I will need to make them more durable, but for the time being they should surfice.  Once I have the encoders and the sensors mounted I will start some testing on the drive system and the PicAxe.

Some quick calculations to see what I get:


 Wheel Diameter (D)=50mm
 wheel Circumference (C)= D * 3.14 = 157mm
 Encoder Resolution (Res)= 16

 Distance Travelled Per between encoder Pulses =  C/Res = 9.81mm

So per encoder output pulse width = 4.9mm (~5mm) – Remember the encoder has a resolution of 16 (50% black and 50% white) therefore I need to divide by 50% to get the per pulse distance assuming a nice neat square wave.

I’ve also placed the encoders in the top cover, filed out some slots and hotglued to suit. 

 BuzzBot Encoder Template Buzzbot Wheel encoders Buzzbot Encoder Sensor Placement

BuzzBot Motor Board Schematics

Today I reversed engineered the control board of the RC Buggy and the results are the schematic attached.  I was only interested in the Motor Drive CCT so thats all that is drawn.   It looks fairly straight forward to hook up the PICAXE to this board, although the main Driver Transistors are TO-92L type packages, so I suspect the duty cycle of the drive will not be continuous as there are no heat sinks etc. 

While I was at it I removed the RF Receiver Daughterboard and the decoder chip (U1 in the schematics), so now the board is all ready to go.

Buzzbot Motor Board (Sorry about quality)

Buzzbot Motorcontroller Schematic 



The Buzzbot idea came to me when i was trying to think what can i do to learn the picaxe uController, something practical, well rather than just flashing Leds and buzz buzzers anyway. What I wanted to do was something robotic that is cheap and easy as I don’t have much of a workshop facility available to me just yet to assemble any bases. 


We had just moved house and whilst doing the spring clean of some toy boxes and throwing alot of my childrens toys into thte “garage sale” box I came across the Buzz Lightyear Remote control buggy.  Basically a 6 wheel buggy with a psycho looking buzz with missile launchers as hands that raises and releases the missiles.  Well the missiles were long lost and what interested me was in using it as the base for my “buzzbot” is that most of the work is already done for me. i.e. I don’t have to build a base and look for motors etc.  I just want to get down to the nitty gritty of interfacing the PICAXE into something and playing around with it. Another thing that I think will work in my favour is that the Left and right wheel drives seem to be independant of each other as this thing from memory could turn on a dime, so therefore there must at least two motors, and the necessary driver circuits in place for me to use.

 BuzzBot Buzz Buggy Side

The Autopsy

Upon dissasembly it looks as though I was right, a gearbox and motor for the left and right drives (front two wheels on each side are geared , while the rear is free wheeling) also a circuit board with a simple RF Receiver and a heap of transistors, which after some initial tracing leads me to suspect are the H-Bridge Drive implementation for the motors, Left, right and the psycho buzz torso aka Missle launcher (he raises up to fire) woohoo, most of the work is already done.

Buzz Buggy InsideBuzzBot Drive Trainbuzzbot control boardbuzzbot -  inside buzz

Man he must be on crack!

buzzbuggy - psycho buzz

Next Steps…..

Ok since I have now dissected the Buzzbuggy it will now be re-assembled back into the “buzzbot”  minus the psycho buzz torso, as I just want to use the base as my test platform for the PicAxe.  I now need to trace through the circuit and see where I can tap into for the motor control, and also add some sensors. 

 Stay Tuned….


First post to christen the new site……

Personal Projects underway. 

1)  Learn the PICAXE, a fantastic little uController,  I have just got my hands on the PICAXE 18X, so in attempt to learn to use this little beast I am looking at interfacing it with a few sensors and turn my sons discarded “Buzz Buggy” into a little 6 wheeled autonomous “buzzbot”. 

2)  Also getting pissed off mowing the lawn at home every week, especially now it’s summer in Australia, so have now decided to look at some sort of mowbot.  After some research found someone who has actually implement one over the last few years with some great drawings and details, so will be using this as a starting point