While I was thinking about the next project, lots of things came to my mind. But this time, I thought of doing something new. Going through the scraps, I found 11 servo motors that I purchased for a project 4 years ago. Let's see, Arduino, servo motor, servo motor driver, regulator. Hmm... Why not something that could walk? So, I decided to get rid of all the wheels and make a 3 legged walking robot. In this post, I will show you how to build a three legged robot (a tripod) using Arduino and servo motors.
Materials NeededArduino Nano
Or any Arduino board which will be the controlling center of our project
Voltage Regulator Module
For providing controlled and stable DC source for the working of servo motors as well as internal chips.
PCA9685 16 Channel 12 Bit PWM I2C-bus controlled Servo motor Driver
Now we need some thing to drive all the 9 servos. I am using Adafruits PCA9685 16 Channel PWM Module. The PCA9685 is a 16 Channel 12 Bit PWM I2C-bus controlled Servo motor driver. The Driver can very easily connected to your Arduino, Raspberry Pi and easily programmed to control single or multiple servo motors and make your own RC plane, car, ship, quadrapod, hexapod or anything you want.
To know how to control a servo motor using this driver, watch the video below.
Servo Motor
These are servo motors. They are widely used in the field of robotics due to its precise control of position, velocity and acceleration.
These servo motors can be combined together to provide multiples degrees of freedom. In this project, we are using 3 servo motors in each leg which gives us 3 degrees of freedom. So we need a total of 9 servo motors.
Design your own PCBs for your Project!I used Altium designer to draw the circuit and design the PCB. It is a powerful tool that can be used to design and create our own PCBs for our project as well as complex and multi-layer PCBs for industrial use.
If you are a DIY Electronic enthusiast, I bet this is gonna be really useful for you guys. I have been using it for the past 3-4 years and let me tell you guys, this is amazing! You can download the Free Trial of Altium PCB Designer from here.
PCB Design Tutorial using AltiumCheck out the below video to start designing your own PCBs in Minutes!
Arduino and servo motor that I am using needs a voltage between 5v and 6v. Since I am using a lithium polymer battery of 11v, I will have to use regulator. The regulator I am using is LM 2596S 20083 adjustable voltage regulator. It is really easy to setup 1 yourself but If you don't know how to use, watch the below video tutorial in which I explained the usage of this regulator.
In the current project, I set the operating voltage to 5.5 V. Servo motors take too much current from the power source. If we are using a single regulator, it may overheat when multiple servo motors are running. So it is always a better idea to use multiple regulators in parallel in these cases.
The Body Parts and DesignsThe material for the leg is acrylic sheet and the body is made of foam board. I designed these body parts in coral draw and got it laser cut from a nearby workshop. I will upload the layout here. Feel free to use it.
These are the different parts. For the base of the tripod, you can use any lightweight material. Here I had some foam board so I used it. You have to cut 3 holes to mount the base servo motors. Clean the edges otherwise it be difficult for the servo motor to fit in.
Let's StartLogon to www.greenterminal.in for more fun projects and tutorials. It would be better if you can watch the video just below for clearly understanding what is going on. Watch this:
Start by fixing all the servo motors in the body parts as shown in the video. Just fix it with some nuts and bolts and tighten all the connection so that it wont fall off or shake while the tripod is moving.
Use some strong glue and join 2 servo motors as shown in the video. Combining two servo motors like this will give us 2 degrees of freedom. Connect the elbow part with the other joints. Connecting the elbow part with these 2 servo motor will give each arm of the tripod, a total of 3 degrees of freedom, which is more than enough to make it walk the way we want.
Now fix all the legs to the foam base as shown in the video. Fix the two regulators somewhere it wont be disturbed. I fixed these at the bottom of the foam board base. Attach it with screws and use hot glue gun so that all the connections will be secure. Fix the servo driver module in another piece of foam board and secure it with screws. Use double sided tape to fix the battery and foam board piece with the base of our tripod. At last, fix our Arduino on the top foam board near the servo driver board.
All the connections in this project are very easy. Just connect the battery to our regulator input and servo driver and Arduino to the regulator output. I will share the schematics and circuit diagrams soon.
This is our tripod after all the connections.
It is a little bit messy. So lets clean it up. Use some zip-ties to organize all the wires.
Make sure that Arduino and servo driver are near to each other. Otherwise, the connections will be little bit hard.
Now its time to program our tripod. Connect the Arduino to our PC. Just go to device manager and check the device port. Now open Arduino IDE. Below is a sample sketch just to check all the motors functionality.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define MIN_PULSE_WIDTH 650
#define MAX_PULSE_WIDTH 2350
#define DEFAULT_PULSE_WIDTH 1500
#define FREQUENCY 50
uint8_t servonum = 0;
void setup()
{
Serial.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(FREQUENCY);
pwm.setPWM(0, 0, pulseWidth(100));
delay(500);
pwm.setPWM(4, 0, pulseWidth(60));
delay(500);
pwm.setPWM(12, 0, pulseWidth(60));
delay(500);
pwm.setPWM(1, 0, pulseWidth(10));
delay(500);
pwm.setPWM(5, 0, pulseWidth(170));
delay(500);
pwm.setPWM(13, 0, pulseWidth(170));
delay(500);
pwm.setPWM(2, 0, pulseWidth(120));
delay(500);
pwm.setPWM(6,0 , pulseWidth(85));
delay(500);
pwm.setPWM(14, 0, pulseWidth(110));
delay(500);
}
int pulseWidth(int angle)
{
int pulse_wide, analog_value;
pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
Serial.println(analog_value);
return analog_value;
}
void loop()
{
pwm.setPWM(0, 0, pulseWidth(150));
pwm.setPWM(13, 0, pulseWidth(180));
delay(500);
pwm.setPWM(14, 0, pulseWidth(180));
delay(500);
pwm.setPWM(1, 0, pulseWidth(0));
delay(500);
pwm.setPWM(5, 0, pulseWidth(180));
delay(500);
pwm.setPWM(2, 0, pulseWidth(120));
delay(50);
delay(50);
pwm.setPWM(14, 0, pulseWidth(110));
delay(1000);
pwm.setPWM(0, 0, pulseWidth(50));
delay(1000);
pwm.setPWM(4, 0, pulseWidth(120));
delay(1000);
pwm.setPWM(1, 0, pulseWidth(20));
delay(500);
pwm.setPWM(5, 0, pulseWidth(160));
delay(500);
pwm.setPWM(0, 0, pulseWidth(100));
delay(500);
pwm.setPWM(4,0, pulseWidth(60));
delay(500);
}
This is just a simple code just to move the servo motors. Paste the code to Arduino IDE go to boards, select correct COM port and board and upload the sketch.
If the code is uploaded successfully, with in 15 seconds, all the servo motor will start to move. Congrats, you have done it!
Now I am working on writing the codes for the tripod to walk, run, duck and some other complex movements and integrate various sensors into this tripod to fully automate it. Once I complete that, I will upload it in my blog.
Comments