Back in 2015 I spent a couple of months building a hexapod robot after seeing several models on the web with prices totally out of my reach, whose purchase would also have deprived me of the adventure of getting involved in the design and construction process.
To be honest, these commercial models such as “Phoenix” from Lynxmotion or the “PhantomX” from Trossenrobotics are high-quality machines with robust aluminum structures and state-of-the-art digital servo motors, components that surely worth their price.
Broadly speaking a hexapod robot is a robot that uses servo motors to articulate its legs and thus be able to move like an insect. The complexity of the robot and also the naturalness of its movements increase with the number of joints that have its legs, which is known as degrees of freedom. At least they usually have two per leg and, thus, a hexapod (6 legs) would have a total of 12 degrees of freedom. There are also quadrupeds (4 legs) and we would have 8 degrees of freedom, something relatively easy to handle with an arduino.
However, excited about the commercial models mentioned above, I decided to opt for a 18 degrees of freedom hexapod, that is, 6 legs with 3 joints each.
Without a doubt the structure had to be able to be manufactured with 3D printing technology if possible without excessive requirements, that is, simple pieces to print. This forces me to inspect thingiverse.com, since many times I have found things that fit my original idea very well and this is one of those cases. The legs proposed by trev502000 in its “asmanylegsasyoucancontrolapod” are PhantomX style, they meet my requirements and I have only slightly modified the original design using Blender, great 3D modeling and animation software offered for free on the blender.org website.
After many hours of printing the legs were formed but the body seemed to me that it would give more than one problem in case of printing due to its size and the required resistance. I bought a kitchen table, probably nylon, and cut the base of the robot, leaving the whole set very robust.
The amount of servos used conditions several parts of the design, on one hand 18 independent control PWM signals are required and with an arduino no more than 15 would be controlled using an atmega2560. I have opted for the use of a Lynxmotion product, the SSC-32U servo controller, capable of handling 32 servos from orders received through a serial port. It is a board based on the atmega328p MCU and solves the problem of handling that amount of signals but it is not a cheap product (50 Eur approx.). It would be interesting therefore to design something similar for future projects that require so many signals handling.
It should also be noted that with this board and without the need for any external circuit we would be able to control the movement of a 12 degrees of freedom (12 DOF) hexapod since it has the code for it in its firmware. However, my robot has 18 DOF, so, as I will explain later, it will have to be MCU controlled, in this case by an Arduino Nano board.
Also from the manufacturer’s website we can download a utility called ssc-32 servo sequencer that is very useful for calibrating the central position of the servos and it has been indispensable for me.
On the other hand, I had to choose cheap servos if I did not want the cost to skyrocket and, of course, the cheap and in addition to Chinese manufacturing does not give great results. I have mostly used MG-995 servos with metal gear train and ball bearings. They provide a pair of 13 – 14 kg * cm, necessary for this project due to the weight of the set and consume around 1A @ 6V. The electronics and motor they use are not very robust and some of them failed right away, overheating in a way that proved fatal. Later I used the MG-946R that seem a bit more robust and the price is similar, on ebay about 5-6 Eur.
In my case the servos are the weakest point of the robot. I have even tried to replace the MOSFET transistors in soic8 format that they carry with a higher current capacity with similar results. The gears and the motor sometimes get stuck, maybe due to temperature changes and the dilations that occur. This causes a very high current consumption constantly and the mosfets end up damaged, leaving the servo unusable. All this due to poor design, low quality components, etc. The obvious solution is to replace them with others of higher quality but this would greatly increase the cost.
Changing the subject, we must consider how to feed 18 servos that consume around 1A each, that is, we must provide 18A with a voltage of 6V (the servos run smoothly at 5V but at 6V they offer more torque and here is a need). As the power supply is going to be using 2 or 3 cells Lithium-polymer battery (7.4V / 11.1V), a voltage regulator of at least 20A must be used and this is a critical component that must operate at full capacity. One option would be to connect several linear regulators, 7806 for example, in parallel. This, although it would be functional, would not be efficient at all, since the linear regulators dissipate the energy “left over” ( speaking roughly: what is 7.4V to 5V is lost). The obvious option, then, is to use a switched regulator that, although it has a slight curly tension, in this case it is irrelevant and the efficiency of these can be 90% or more. After much searching I found one very suitable in hobbyking, then problem solved and, in fact, this component perfectly fulfills its function.
Once the electromechanical part is completed, it is time to think about how the robot will be controlled, taking into account its 18 degrees of freedom. There are commercial products for this but, thanks to the open source culture and, especially to its author KurtE we have excellent software (which can be implemented in an Arduino Nano) known as “Phoenix code” in this github repository.
The software must solve a reverse kinematics problem. With a reference system origin at the beginning of each leg (where it joins the body) the position of the end (foot) is given by its XYZ coordinates. If we want it to go to that position we will have to know what are the angles that the servos should rotate, which mathematically is more complex to solve than the direct problem (if I move the servos some specific angles using trigonometry I easily get the position of the end … ). The problem of reverse kinematics applied to a hexapod of 18 degrees of freedom, for those who want to deepen, is very well explained in the following link.