Introduction: DIY Hexapod
In this instructable I will give you the step by step guide to create a bluetooth, remote controlled Hexapod.
First of, this is a big hexapod, and to move it you’ll need 12 strong Servo motors (MG995) and to handle this amount of PWM signals (to control each motor) the easiest way to do it is using an Arduino Mega 2560. It must be noted that some extra equipment was used, like 3D printers and WaterFlow cutting machine. Now you will find all the materials used and the steps you will need to build one of this robots.
Step 1: What You'll Need
Soldering iron, 3D printing machine, water jet cutting machine.
- PLA 3D printing filament
- steel pedacer
- M3X20 screws
- M3X10 screws
- M3 nuts
- M3 washers
- 623zz ball bearings
- CAD Software
- (12)Servo motors MG995
- (2) 9V batteries
- (1) 6V, 7Amps battery
- GoPro camera
- Arduino MEGA
- Arduino NANO
- (2) Joysticks
- (2) HC-05 Bluetooth Module
- (1) 10K Potentiometer
Step 2: Mechanics & Designing the Parts You'll Need
The mechanical design starts from the number of servomotors to be used per leg. In this project it was decided to use 2 servos per leg, giving it a greater number of degrees of freedom and making its naturalness remarkable. It is clear to mention that in any type of mechanisms, machines or robots the more degrees of freedom you have, the greater the naturalness of your movements and actions. Within the plan for this project, requirements and limitations, there are 12 actuators to be used, 2 per leg. As mentioned, the servos motors will be the main components of the legs, let's say they are those points that represent the joints of the robot. By which different movements to the machine are triggered that, together, will simulate the movement making it walk. Based on the dimensions of the previously mentioned servomotors, a casing is designed in which this type of actuator is fitted. The dimensions of this one provide reference points to design a fastening system, for the supporting elements and connectors for what will make up the leg as a whole. One of the servo motors is positioned vertically and the other horizontally, this is mainly due to the direction in which its shaft will rotate and activate the element to which it is screwed and thus develop the movement in x or y, necessary for the walking of the hexapod. When looking at the figures and images, you can see the points where they are assembled to the main based, which are the plates, of the robot. If you take a look at the servomotor in an upright position, you will see it is between both plates. One of them being screwed in the upper part and the other in the lower one. From there, connectors and bars will facilitate the support for the second servomotor in a horizontal position, from which 4 different types of connectors work as part of the leg. These allow the mechanical movement that simulates and activates the lifting and moving of this element; which includes these two bars that hold the largest component of the leg, on which it rests and leaves almost the entire weight of the robot.
As mentioned before, there are limitations that define your design. They can be different types whether mechanical, economic, or any other essential resource for the operation of your machine. These mechanical elements; in this case the servomotors, established the dimensions of the robot. This is why the design proposed in this manual is of such dimensions, since they start mainly from the selected actuators and controller, to which a large battery was added later.
It is important to say that the mechanical design is not defined to be replicated as it is proposed. This can even be optimized through simulations of stress and fatigue of the main elements, bars and / or connectors. Taking into account the selected manufacturing method, additive manufacturing, you can make the most of designing, simulating and printing the solid that best suits your loads and application. Always considering the basic elements of support, fasteners and bearings, for what you need. This according to the role they play in the mechanism. So you should think about the specifications of these elements so that they have the appropriate place in conjunction with the other pieces of the leg.
Step 3: Designing Electronics
2 PCBs where designed for the robot.
1 is the main board that will be mounted in the robot and the second one is for the electronics in the remote controller. The PCB was designed using the Fritzing software and then machined using a CNC Router for PCB engraving.
The main PCB includes the Arduino Mega as well as the bluetooth module, all the servos are connected as well and using two lines of power that come directly from the battery to 2 screw terminals.
The remote controller PCB has more components but is more compact, starting with the mounting of the Arduino Nano, to it it is connected the two joysticks to control the direction and movements of the Hexapod, one push button with its appropriate 220Ohms resistor, a potentiometer to adjust the height of the robot and its bluetooth module HC05. All of the board is powered using a 9V battery and the elements on it are powered using the 5v Output of the Arduino board.
After the design, the PCB can be manufactured with the special CNC PCB machining tool and then you can proceed to install all the components in the boards.
Step 4: Step 4: Assembling
After having all the printed parts, screws and bearings available as well as the tools to assemble the robot, you can start with the assembly of the corresponding parts, considering that the bases of the vertical servos are assembled having an upper plate and a lower one, 6 of these pieces with a servomotor inside them. Now the coupling to the shaft of the servomotor is screwed and to this the piece is connected: "JuntaServos" that in its counterpart would have its corresponding bearing to facilitate the rotation between both parts. Then it would be connected to the second servo, the horizontal servo and its respective set of bars that link with the other 2 segments, making a direct attachment to the steel tip. Both bolted with the indicated screws. To finish with the leg, the tip printed in PLA is inserted under pressure.
This procedure must be repeated 6 times to assemble the 6 legs that support and activate the robot. Finally; position the camera on the upper plate, adjusting it as desired by the user.
Step 5: Step 5: Coding
In this section it will be described a bit of how the code works. and it is going to be divided in two parts, the code of the remote controller and the code of the hexapod.
First the controller. You want to read the analog values of the potentiometers in the joysticks, It is recommended that these values are filtered and adequate to only obtain the values when these change outside the range established in the code. When this happens, a character array type value is sent using the Arduino Serial.write function via bluetooth to indicate that one of the values has changed this to be able to do something once the other bluetooth module receives them.
Now the Hexapod code can be divided in 2 parts as well.
The first part is where the functions that will be made according to the messages received by bluetooth are designated and the other part is where the necessary is done to create the functions performed by the hexapod, such as walking forward, backward, turning, others
The first thing that you want to do in the code is to designate the necessary variables for the operation of both the bluetooth communication and the functions of the servos and their movements in each leg.
the Serial.readBytesUntil function is used to obtain the entire array of characters, which is 6, all commands have 6 characters, that is something very important to take into account. In the forums of Arduino you can find references about how to select the optimal parameters so that the message is received correctly. After obtaining the whole message, it is compared with the strcmp () function, and a set of if functions that assign values to a variable is then used to assign the function of a hexapod in a switch function.
There are extra functions, which one of them when receiving the command "POTVAL" changes the height of the robot, another function changes the relative height of each leg and its static rotation, this is achieved with the joystick, and when the button is pressed in the control, the "BOTTON" command is received in the hexapod code and changes the movement speed of the hexapod.
Step 6: Testing
In the following video it is shown how the Hexapod evolved over time and to see the testing and the end result.