Controlling 4DOF Robotic Arm Claw Kit with 16 channel PWM/Servo Shield using analog input.

Overview

This Robotic Arm Claw kit is an Arduino based system which comes with 4 degrees of freedom. This project aims to interface an Arduino Uno with a 16 channel PWM/Servo shield and using potentiometer to control the Robotic arm movements. The shield uses I2C Communication.

Hardware Used

  • Arduino

  • 4DOF Robotic Arm Claw Kit
  • 
    
  • 5V Power Supply
  • Breadboard
  • 
    
  • Jumper Wires
  • 
    
  • 16 x 12-bit PWM/Servo shield
  • 
    
  • 4-pcs Potentiometers 
  • 
    
    

    Software Used

    Library used

    Hardware Set-up

    We are using the 16 channel 12-bits PWM servo shield.

    The 16-Channel 12-bit PWM/Servo Driver Shield will drive up to 16 servos over I2C with only 2 pins. The on-board PWM controller will drive all 16 channels simultaneously with no additional Arduino processing overhead.

    Up to 16 servos can be attached to one board. If you need to control more than 16 servos, additional boards can be stacked.

    What is PWM?

    Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal is in the ON state versus the time that the signal is in the OFF state. The duration of “ON time” is called the pulse width. To get varying analog values, you change, or modulate, the pulse width.

     

    Here are the steps on how to assemble your Robotic arm kit:

    Remove the components protection paper and Arrange according to its uses.

    In preparing the base use

    4 x M3 nuts

    4 x M3 * 30 mm screws

    Fasten the 4 pieces M3*30mm screws and nuts to secure the base

    Attach the 4 pieces M3*10mm screws and nuts to secure your Arduino uno board.

    This is now your Base must look like

    Use the ff:
    2 pieces M3*8mm screw
    Black servo rack
    Black servo holder

    Mount the servo through the holder and carefully pull the wires so that the servo will fit.

    Now attach the servo rack to the servo and screw both side from the servo holder.

    This is now how it looks like.

    Now mount your servo as this serves as your base.

    Prepare these items to build Forearm of the Robot use the M3*8mm screws.

    Mount the base and the bracket then screw both side to secure the servo.

     

    Attach the horn in the main acrylic arm using the M2.5 taping screw.

     

    Attach the arm to the servo and secure it with self- tapping screw that is included in the servo package.

    Note: Make sure to calibrate the arm properly or else a problem may occur later as you continue.

     

    Using the M2.5 tapping screw Attach the servo horn to the acrylic arm joint.

     

    Use the 2 M3*8mm screw to build the other forearm of the robot and use M3*6 attach the long Acrylic arm to the arm joint as shown in the image.

    NOTE: Make sure to calibrate properly the arm to avoid problems later on.

     

    Use 2 tapping screw and attach the servo horn into the servo rack base.

     

    Connect the two joints using the M3*8mm screw. Do not over tighten the screw so that it can rotate freely.

     

    Now attach the two Acrylic clapboard in the corresponding wing slot.

     

    attach the two active joints in the corresponding slot as well as the rack base and secure both side using the 4 M3*10mm screw

     

    Attach the backbone between the forearm and the main arm of the robot using 2 M3*10mm screw and secure it on both side.

     

    Use the long acrylic arm as well as the M3*6mm screw and screw it on the bottom right side

    It should look like this.

    Then use the another long acrylic arm with three active joints using M3*8mm screw and connect it to the two forearm joints.

    use the ff:
    2 M3*8mm screw
    1 Black Circular spacer
    1 Black Support arm
    1 Black Triangle support connector

    Fix the screw as shown in the first image where the spacer is also attached in between.


    Then fix the other end of the support arm. as you can see there is still has three free dangling ends which are eventually connected to secure the claw part.

    To assemble the claw use ff:
    2 square brackets
    4 M3*8mm screw
    2 connector accessories

    Place the square bracket in the bottom and pull the cables out as required to connect to Robot Extension Board.

    Now place the rectangle bracket on the top of the Servo and secure the Servo with four M3*8mm screws.

    Fix the two claws on the rectangle servo bracket with two M3*6mm screws.

    Use the ff:
    4 M3*8mm screw
    1 short connector
    1 circular spacer

    Secure it on the left-hand side of the claw as shown on the left.

    Remember to put the spacer in between

    Prepare the following to connect Claw and Triangle support connector:
          Two M3*8mm screws
          One spacer
          One support arm

    Then secure the Support arm into the Triangle connector.

    Then the entire Claw part can be secured with the three free dangling Forearm ends

    Prepare the tapping screw in the Servo package and servo horn.

    Secure the horn with tapping screw as shown on image.

    Pull the claws widely open and then insert the short arm we created in the last step and screw it firmly.

    This now the final output of our Robotic arm .

    NOTE:
    Make sure that the screws are not over tightened so that the joints can move freely and the holes of the joints will not worn out.

    Schematic Diagram

    The battery represents the external power supply. You can use any external 5-6V power supply: (1) adjustable power supply, (2) switched mode power supply, or (3) 4- AA battery.
    This is the actual circuit.
    NOTE : An External power of 5V is required for the servo shield.

    Code

    #include <Adafruit_PWMServoDriver.h>
    #include <Wire.h>
    #define SERVOMIN 150 // this is the 'minimum' pulse length count (out of 4096)
    #define SERVOMAX 600 // this is the 'maximum' pulse length count (out of 4096)
    
    // called this way, it uses the default address 0x40
    Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
    // you can also call it with a different address you want
    //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
    // you can also call it with a different address and I2C interface
    //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(&Wire, 0x40);
    
    // Depending on your servo make, the pulse width min and max may vary, you 
    // want these to be as small/large as possible without hitting the hard stop
    // for max range. You'll have to tweak them as necessary to match the servos you
    
    uint8_t servo1 = 0, servo2 = 1, servo3 = 2, servo4 = 3; // Servo pin number
    int potpin1 = A0,potpin2 = A1,potpin3 = A2,potpin4 = A3; // analog pin used to connect the potentiometer
    int val1,val2,val3,val4; // variable to read the value from the analog pin
    
    void setup() {
       Serial.begin(9600);
    
      pwm.begin();
      
      pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
    
      delay(10);
      
    
    }
    
    void loop() {
    
     val1 = analogRead(potpin1);
     val1 = map(val1,0,1023,SERVOMIN,SERVOMAX);
     pwm.setPWM(servo1,0,val1);
     Serial.println(val1);
     delay(15);
     
     val2 = analogRead(potpin2);
     val2 = map(val2,0,1023,SERVOMIN,SERVOMAX);
     pwm.setPWM(servo2,0,val2);
     Serial.println(val2);
     delay(15);
     
     val3 = analogRead(potpin3);
     val3 = map(val3,0,1023,SERVOMIN,SERVOMAX);
     pwm.setPWM(servo3,0,val3);
     Serial.println(val3);
     delay(15);
     
     val4 = analogRead(potpin4);
     val4 = map(val4,0,1023,SERVOMIN,SERVOMAX);
     pwm.setPWM(servo4,0,val4);
     Serial.println(val4);
     delay(15);
     
    }

    This is the code for the entire system.

    #include <Wire.h>
    #include <Adafruit_PWMServoDriver.h>
    
    // called this way, it uses the default address 0x40
    Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

    This calls the library for I2C which is the Wire.h and for the PWM servo driver which is  Adafruit_PWMServoDriver.h.

    void setup() {
       Serial.begin(9600);
    
      pwm.begin(); //this is to begin pwm
      
      pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
    
      delay(10);

    This function can be used to adjust the PWM frequency, which determines how many full ‘pulses’ per second are generated by the IC.

     

    val1 = analogRead(potpin1);  // reads the value of the potentiometer (value between 0 and 1023)
    
     val1 = map(val1,0,1023,SERVOMIN,SERVOMAX); // scale it to use it with the servo (value between 0 and 180)
     pwm.setPWM(servo1,0,val1);
     Serial.println(val1);
     delay(15);

    The setPWM function sets the start (transition from OFF to ON) and end (transition from ON to OFF) of the HIGH state of the PWM pulse on a specific channel.  You specify the ‘tick’ value between 0 to 4095 when the signal will turn on, and when it will turn off.  servo1 indicates which of the 16 PWM outputs should be updated with the new values.

    The video shows the robotic arm lifting and moving around small objects.

    Conclusion

    The system is not limited to what is described above as it only illustrates basic functionality using analog input. You can always change and improve with your desired output. You can even add additional sensors or wireless/remote control to make the robotic arm kit even more interesting.

    References

    The post Controlling 4DOF Robotic Arm Claw Kit with 16 channel PWM/Servo Shield using analog input. appeared first on CreateLabz.

    16 channel 12-bit pwm servo shieldArduinoArduino unoI2cKnowledgebasePwmRobot armRobotic arm claw kit 4dofRoboticsServo

    Leave a comment

    All comments are moderated before being published