Arduino with Sensors and Actuators

DIY 6 DOF Robotic Arm: A Step-by-Step Guide to Design, Print, and Program

by Omar Draidrya

Building a 6-DOF robotic arm: From CAD design to interactive control
The construction of a 6-DOF robotic arm is an exemplary project that demonstrates the synergy between mechanical design, electronic control and precise user interaction. This blog will guide you through the entire process of creating a fully functional robotic arm controlled by six servos, each of which is directly manipulated by a dedicated potentiometer for real-time movement adjustments. Using Autodesk Inventor for 3D modelling, followed by 3D printing, and wired through an Arduino Uno with a PCA9685 servo driver board, this project is perfect for enthusiasts looking to get into advanced DIY robotics.

Design with Autodesk Inventor

The first stage is to design each component of the robot arm using Autodesk Inventor. This CAD software allows precise 3D modelling, ensuring that the components are perfectly tailored to accommodate SG90 Micro Servos and MG996R servos – chosen for their balance of weight, size and torque capabilities: SG90 Micro Servos are ideal for smaller arm joints due to their compact size and sufficient precision. MG996R Servos are used for the base and other high load areas due to their robust torque capabilities.

3D printing the arm components

Once the models are complete, the next step is 3D printing. Each part is printed using a filament such as PLA for its ease of use and good detail accuracy. Print settings should be optimised for strength, especially for joints that will experience higher mechanical loads. Post-processing may include assembly adjustments and aesthetic enhancements.

Assembling the Robotic Arm

 Once all the parts have been printed, assembly involves carefully placing the servos in their designated mounts and accurately connecting the arm segments. Joints should be tested for smooth operation to ensure they can handle the expected range of motion without stressing the servos.

Step 1: Assembling the Base

  • Securing the Servo Motor
    Start by installing the first servo motor onto the base of your robotic arm. Utilize the screws that come with the servo package to ensure it is firmly attached. This servo acts as the pivotal rotation point for the entire structure of the arm, allowing for the foundational movement.
  • Adding a Ball Bearing
    Install a ball bearing to facilitate smooth rotational movement between the base and the arm’s upper rotating part. Carefully place the ball bearing into the designated slot on the base. This component is critical for reducing friction and wear during the arm’s operations, enhancing both the precision and longevity of the movement.
  • Connecting the Servo Horn
    Attach the servo horn to the rotating upper part of the arm. Use the screws provided in the servo package to secure the horn directly to the rotating part that sits atop the ball bearing. Ensure that the connection is snug and secure, as this will transmit the rotational forces from the servo motor through to the upper parts of the arm.

Step 2: Mounting the Servo Horns to Robot Arm Links

To assemble the servo horns to the robot arm links, align the servo horns with the arm’s attachment points, ensuring the holes line up correctly. Secure each horn with two screws, firmly tightening them to ensure stability and prevent slippage during operation. Double-check each connection to confirm the horns are attached securely, as this will be crucial for the precise and reliable functioning of your robotic arm. 

Step 3: Mounting Servo Motors to Robot Arm Links

To mount the servo motors to the robot arm links, align each motor with the designated mounting points on the arm links, ensuring correct orientation. Secure each motor using two screws, threading through the arm into the motor’s mounting holes for a tight fit. After securing, test each connection for stability by applying gentle pressure to ensure the servo is firmly attached without any movement. This step is vital for the durability and functionality of the robotic arm during operation.

Step 4: Connecting Robot Arm Links

After securing the servo motors and horns to the robot arm links, align and connect the links. Position the links so the holes on one link’s horn match the next link’s attachment points. Secure them using screws to ensure a firm connection crucial for seamless joint movement. Tighten the screws properly to maintain stability and functionality during the robotic arm’s operation. This step ensures structural continuity and effective motion across the robotic arm’s joints.

Step 5: Assembling the Gripper

In the final assembly step, attach the gripper to the robot arm’s end link. Ensure it aligns properly and secure it with screws, checking that the gripper operates smoothly and without hindrance. This integration completes the physical construction of the robotic arm, setting the stage for functional testing and adjustments to ensure precise operation of the articulated movements.

Step 6: Mounting the Robotic Arm on a Wooden Base

Secure the fully assembled robotic arm to a wooden base to ensure stability during operation. Use screws to fasten the arm’s base securely to the wood, allowing for a solid foundation that prevents any movement during its use.

Electronic configuration and wiring

The electronics for this project revolve around integrating the PCA9685 servo driver with the Arduino Uno to control the six servos:

Arduino Mega: Acts as the main controller.
PCA9685 servo driver board: This I2C controlled PWM driver efficiently manages up to 16 servos, perfect for expanding beyond six if required in future iterations of the project.
Wiring Guide:
Powering the PCA9685 and servos: It’s important to use an independent power source (such as a 5V 10A power supply) to handle the current demands without overloading the Arduino’s power regulator.
Connect each servo to the PCA9685: The servos are connected to individual channels on the PCA9685, matching the correct orientation for power, ground and control signals.
Connect each potentiometer to the Arduino: Connect the middle pin of each potentiometer to one of the Arduino’s analogue inputs, configuring each to control a servo.

more about PCA9685 servo driver card

Controlling servos directly from an Arduino is easy, but you may run into limitations, especially if your project involves multiple servos or other PWM-dependent components. Using all available PWM pins or potential library conflicts over timer resources are common challenges that can hinder the scalability of your designs.

To efficiently manage multiple servos without overloading the Arduino, integrating a dedicated servo driver board, such as one equipped with the PCA9685 chip, is an excellent strategy. This board uses I2C communication, which simplifies connections to just two wires – CL (clock) and SDA (data) – regardless of the number of servos being controlled. It supports control of up to 16 servos per board, and can be daisy-chained with other PCA9685 boards. This setup allows up to 992 servos to be controlled by cascading multiple boards, ideal for large projects.

Each board has simple connections:

GND: Ground connection.
OE: Output enable, usually left unconnected to keep all outputs enabled.
SCL: Clock line for I2C communication.
SDA: Data signal for I2C communication.
VCC: Logic supply at +5 volts.
V+: Power for the servomotors, which can also be supplied via a protected connector on the top of the board for greater protection against reverse polarity.
The board features sets of 3-pin connectors for each servo motor, greatly simplifying the wiring process and providing a robust solution for projects requiring extensive servo control without taxing the resources of the primary controller. This approach not only increases the reliability of the project, but also streamlines the development process, allowing you to focus on higher-level programming and design tasks.

To effectively manage and control 16 servo motors using a PCA9685-based driver with your Arduino, follow these detailed steps to correctly set up and wire the components:

Connecting to the Arduino
The PCA9685 servo driver uses I2C communication and requires only four connections to your Arduino. Here’s how to connect it depending on your Arduino model:

Classic Arduino (Uno, etc.)
+5V -> VCC (powers the PCA9685 chip, not the servos)
GND -> GND
Analog 4 -> SDA
Analog 5 -> SCL

Powering the servos:

VCC on the PCA9685 board only powers the chip itself. To power the servos you must also connect the V+ pin, which can handle up to 6V even if VCC is at 3.3V.
A polarised terminal block is recommended for connecting the servo power.
As servos can draw considerable current, especially under load, you should consider these power sources:
5V 2A switching power supply for smaller or fewer servos.
4xAA battery holder – Provides 6V from alkaline cells or 4.8V from NiMH cells.

Connecting the servos:

Connect each servo to the PCA9685 board using its standard 3-pin socket. Ensure that the ground wire (usually black or brown) matches the bottom row of pin headers on the board and that the signal wire (usually yellow or white) matches the top row.

Programming for interactive control

Programming involves setting up the Arduino to read from the potentiometers and command the servos via the PCA9685. This interaction allows dynamic control, with each potentiometer controlling one of the arm’s six servos.

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); // Default address 0x40

void setup() {
  Serial.begin(9600);           // Start serial communication for debugging purposes.
  pwm.begin();                  // Initialize the PCA9685 module.
  pwm.setPWMFreq(60);           // Set the PWM frequency suitable for servos.
}

void loop() {
  // Servo 0
  int potValue0 = analogRead(A0);          
  int servoPos0 = map(potValue0, 0, 1023, 125, 575);
  pwm.setPWM(0, 0, servoPos0);

  // Servo 1
  int potValue1 = analogRead(A1);          
  int servoPos1 = map(potValue1, 0, 1023, 125, 575);
  pwm.setPWM(1, 0, servoPos1);

  // Servo 2
  int potValue2 = analogRead(A2);          
  int servoPos2 = map(potValue2, 0, 1023, 125, 575);
  pwm.setPWM(2, 0, servoPos2);

  // Servo 3
  int potValue3 = analogRead(A3);          
  int servoPos3 = map(potValue3, 0, 1023, 125, 575);
  pwm.setPWM(3, 0, servoPos3);

  // Servo 4
  int potValue4 = analogRead(A4);          
  int servoPos4 = map(potValue4, 0, 1023, 125, 575);
  pwm.setPWM(4, 0, servoPos4);

  // Servo 5
  int potValue5 = analogRead(A5);          
  int servoPos5 = map(potValue5, 0, 1023, 125, 575);
  pwm.setPWM(5, 0, servoPos5);

  delay(20);   // Short delay for stability
}

Calibration and testing

After programming, extensive testing is carried out to ensure that each joint operates smoothly and responds accurately to the potentiometer inputs. Calibration may be required to fine-tune the range and response of the servos to achieve the desired precision and fluidity of movement.

Conclusion


Building a 6-DOF robotic arm is a complex but highly rewarding project that combines several engineering disciplines, from mechanical design to electronics and programming. This project will not only broaden your engineering skills, but also provide a platform for further exploration into more sophisticated robotics applications.