More than just a delay, it seems...

Back in 2010 I thought that the birth of my first son, Scott, would be just a small blip in my journey into robotics but, looking back, it seems to have been the end of that chapter. Of course, raising children takes time, and Scott was just the first; he was followed shortly after by Max and if I thought assembly and robotics was complex to learn it’s nothing compared to raising kids!


I’ve been very busy with other things just recently and so I haven’t been able to spend much time on this project. Work has been busy as I’m working towards a new release of my code and my son Scott was born on 25th January. Right now I have very little spare time for my robotics but I’m sure that will change as things settle into a new routine.

Bug in v7.0 of the servo controller firmware

The simple servo sequencer that I’ve been working on has exposed a bug in the servo controller firmware. The bug is due to stack corruption during movement completion notifications, so it only happens if you use the ‘multi-move’ commands or the delay move command. The problem is that at the end of SerialSendMoveCompletionNotification we jump back to the serial data accumulation loop rather than using a ret to return… Since we enter SerialSendMoveCompletionNotification via a call rather than a jump we are failing to balance the stack and so eating two bytes each time we call the function.

Where are we?

Once the servo controller code was feature complete I switched to looking at the hardware side of things and thinking about the next stage, the servo sequencing. From a hardware point of view I had several things to work on. Firstly I needed to get the servo controller and I/O multiplexor chips off of a breadboard and onto something a little more permanent. Since I still find building things with perfboard a little hard I decided to build the controller itself on one board and build separate daughter boards for the I/O multiplexing.

Sensing servo torque

Whilst playing around with my servo controller I realised that the power used by a servo goes up considerably when it’s under heavy load (such as when it’s pressing against the table and still trying to move). I can, potentially, get an idea of this load by measuring the current that each servo is using and using this feedback somehow. I’ve yet to work out how, but at the very least it could be used to protect the servos against overloading; if the load gets above a certain threshold then stop moving!

New soldering iron...

I decided to treat myself to an early christmas present and bought a 60W temperature controlled soldering station (a ZD-916 which I got from Maplin). All I can say is WOW. Suddenly I can solder neatly rather than making a smeary mess. The difference between this and my cheapo 12W soldering iron is just unbelievable. It just makes the whole process SO much easier. Where in the past when soldering something with a large heat sink or onto a large pad would be painful as both items would never seem to get up to temperature now I hear the iron click on as I touch the items to be soldered and the heat stays constant and it just works… Highly recommended.

ATMega168 64 channel servo controller with 'advanced' servo commands

This is the AVR Studio project and assembly language source code files for the latest version (v7.0) of my 64 channel serial servo controller. This is the latest version of the ATMega168 version of the code which includes all of the new servo commands that I wrote about here including the multi-move command and the unit tests that I spoke of here. The controller allows you to set minimum, maximum and startup servo positions for each servo which can be saved into eeprom and used every time the controller is powered up.

Back to JIT testing

The latest version of the serial servo controller is now fully operational (I’ll upload the source code shortly). There are still some bugs that I’m finding but the work I put in to getting the unit tests in place makes fixing these bugs pretty straight forward. Whilst I have pretty much 100% coverage for the simpler serial commands I’ve stopped writing tests for the ‘multi-move’ command now and I’ve switched to “Just in time” testing; that is I write a test in response to finding a bug.

Testing backwards

It’s taken me almost a month but I’m finally back to working on integrating the multiple servo move command into the rest of the code. Well, the integration was done long ago, unfortunately the debugging was the bit that was taking up my time. I decided that putting ‘printf’ style debug output into the routine to attempt to debug it from my PC based control software was just the wrong way to go about finding the problems and so I set off on a mission to finally get some unit testing into my code.

For those of you interested in the kind of thing that this blog is about you might also find useful. It’s a ‘stackoverflow’ for embedded programming and electronics people. Hopefully it will become a useful resource!