L'Hexapod: What's next?

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.

I now have an easy to extend PWM servo controller and the next job on my list of things to do is extend it so that it supports the functionality that I feel I need for correct control of my hexapod’s legs. As I mentioned here, I’d like to be able to tell the servo controller to move a group of servos to a particular set of positions so that they all arrive at the same time and, the movement is incremental and the movement can be stopped at any point in case a leg sensor detects an obstruction. Configuring a group of servos in one go requires several other things to be in place before it can work and so my first changes to the serial protocol will be as follows:

  • Add the ability to send a move command with a ‘delay’ which will cause the move to take some time to complete. Sending a ‘delayed move’ of 127 to a servo that is currently in position 0 will cause it to step from 0 towards 127 at a rate determined by the delay specified. Once the servo reaches its final position the servo controller will send an asynchronous serial message back to the controlling computer to inform it that the move is complete.
  • Add the ability to report on the current location of a servo.
  • Add the ability to stop a servo in the current position, this is only really relevant to a servo that is being moved with a ‘delayed move’. The idea being that if we send a command to move to 127 and the servo starts at 0 but a leg sensor detects an obstruction we can send a stop command to the servo and it will stop where it is and report the current location. Working with servo groups then becomes a case of adding additional commands which take multiple servo number and control value pairs and which calculate the movements required so that all of the servos in the group arrive at their destinations at the same time. The additional commands will break the current SSC compatible command structure and will also make the serial protocol more complex as we’ll be dealing with commands with different byte lengths and also with the servo controller sending unsolicited responses to the controlling computer (for ‘move complete’ notifications).

I’ve already got scribbled notes on how all this will work so it’s just really a case of implementing it. Hopefully the current code is a good base to develop these changes on.