L'Hexapod: After the servo controller

Previously published

This article was previously published on lhexapod.com as part of my journey of discovery into robotics and embedded assembly programming. A full index of these articles can be found here.

The work on turning my excel spreadsheet into AVR assembler code which can move multiple servos to arrive at their target locations at the same time is proceeding well. I have the required code operating in a stand alone environment in the simulator and all I need to do now is merge that in with the rest of the code… Once that’s done my servo controller is complete and whilst I already know that there are at least two further versions in the pipeline I expect I’ll move onto something more before working on them.

This weekend I sketched out some ideas for the next programming phase; the servo sequencer or ‘gait controller’. This will initially be written in C++ and run on a PC but the design sketches that I did this weekend were for the microprocessor version. The plan is that the servo sequencer is a state machine which can be triggered off of servo move completions and timers. The idea being that it can be programmed to know about a sequence of moves (such as all of the moves required to move a 6 legged robot in a forward direction) and then be told to execute those moves. The sequencer would then manage this and other processors would deal with sensors and other decisions (such as exactly where the feet should land or exactly how the body should be angled, etc.). The sequencer can be isolated from these things a little by allowing the other controllers to tell it the detail (i.e. where exactly each three servos for each leg should be) but the sequencer itself would know that it moves this leg after that leg etc. Step length, step depth and body orientation can then be adjusted by tuning parameters that the overall sequence of steps uses without changing the state machine that makes the middle left leg move after the front right, or whatever.

My current ideas for the microprocessor version of the sequencer are quite ambitious; but then that’s the point really, these micro projects should be pushing me forward and shouldn’t be easy. The sequencer, since it’s essentially a programmable state machine, needs to be able to allocate manipulate and free various blocks of memory; so it seems that I’ll be building a dynamic memory allocator at some point. It will use interrupt driven serial I/O; and once that’s done that work can be used for the next version of the servo controller. It will need to speak to the PC so that a PC program can be used to controller the sequencer (until the next level of robot controller is conceived and then designed) and it needs to talk to the servo controller to actually move the legs (this may be two UARTS; potentially meaning I have to create the second without hardware support and bit-bang the comms out, or perhaps serial to the PC and TWI/I2C to the servo controller). The sequencer’s state machine is driven by the completion of delayed moves from the servo controller; so we can kick of a sequence by actioning the first state and then wait for the completion to trigger the state transition. Additionally a state transition can set a timer which can later trigger a new state transition. The programmable timer code will need to be developed…

Deliberately the sequencer will not be limited to controlling blocks of 3 servos. This wont be a hexapod sequencer but a generic servo sequencer that will work with the servo controller that I’m currently finishing. So, theoretically when I want to develop l’arachnid once l’hexapod is complete I can ‘simply’ switch to using 8 x 4 servo legs and the same firmware…

However, the fact that I’ve now got to the point where I’ve almost completed a ’non-trivial’ assembler project means that I feel I’m able to move the hardware side of the project forward. So I expect that once the servo controller is complete and whilst the sequencer is being designed I’ll try and get to a point where I actually have the required number of servos and a 6 legged robot to control…