Notifications
Clear all

Resources for Programming the Me Arm?

40 Posts
5 Users
3 Likes
14.7 K Views
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: casey

I noticed the me arm appears to keep the claw parallel to the ground thus it should be able to pick up a test tube.

That feature alone is not sufficient for the complete operation.  Even though the jaw is kept parallel to the ground, if the arm doesn't raise the claw straight up to lift the test tube out of the rack the bottom of the test tube could knock the test tube rack over as it's being lifted.

In other words, even though the jaw is always parallel to the ground, that's no guaranteed that as the arm raises the claw the claw will move straight up with no sideways motion.  The upper and lower arm of the Me Arm need to work together to insure that as they raise the claw the claw is raised straight up with no sideways motion (or front to back motion).

I'm a long way from any need to address this problem at this time.  I'm currently in the process of calibrating the servo control software to be sure I have full motion of all the Me Arm servos. I also want to make sure that none of the servos are being driven beyond their range.  Only then will I be prepared to move forward.

Everything was working as expected when I was using the servo library and just writing angles to the servos.  So mechanically the Me Arm is calibrated.   But when I switched over to using the PCA9685 board the previous calibration was lost.  So I'm back to square one on re-calibrating the thing.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Progress Report:

I wrote up a small program to find all my limiting pulse width numbers.  The program is extremely crude, but I'll post it anyway just in case someone might find it useful in some way.   It allows the control of 4 servos individually based on changing the pulse width in steps of 10 increments or decrements at a time.  That was enough for  me to find the limits of my Me Arm.

Unfortunately because of the mechanical design of the Me Arm things are not as simple as they could be.  This has to do with the way the upper and lower arms of the Me Arm interact with each other.  How they behave can depend on what position the other half of the arm is already in.   So when programming the Me Arm we need to take into consideration what the optimal positions are for the upper and lower parts of the arm.  The claw and the base rotation are independent and so they will  be easier to deal with.

First the Results: (note that these results may be unique to my Me Arm)

For the Base servo I got the following:

The numbers are pulse widths to be used in the Adafruit command.

Base:
Left maximum travel = 140
Right maximum travel = 450
Centering the arm = 290

Upper Arm:
Fully Retracted = 230
Fully extended = 470
Midpoint = 350 * can depend on the position of the lower arm

Lower Arm:
Maxium up = 460
Maxium down = 190
Midpoint = 290 * can depend on the position of the upper arm.

Claw:
Fully open = 140
Fully closed = 220

So as you can see each servo will need to have its own mapping in the Arduino program.

Hopefully this will all work out and we can move forward with trying to program the arm to do some interesting tasks.

Here's the code I used to discover the pulse width limits of the Me Arm.  It's a crude program that could use so prettying up.   I just wanted to get these numbers and move forward.

/* Me_Arm_Servo_Calibration_V1
 * by Robo Pi
 */

#include  // Include Wire Library for I2C Communications
#include  // Include Adafruit PWM Library for using the PAC9685 board
#define FREQUENCY             50 // Variables for the PCA9685 board

// The PCA9685 board I2C address is 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40); 

String str_input = ""; // Used for Serial input from monitor
int int_Char; // Used for Serial input
int base_angle; //  Base angle
int u_arm_angle; //  Upper arm angle 
int l_arm_angle; // Lower arm angle
int claw_angle; // Claw angle

// Servo PCA9685 board pins
int servo_pin;
int base = 0; 
int u_arm = 1; 
int l_arm = 2; 
int claw = 3;

void setup() 
{ 
  Serial.begin(9600); // Use Serial monitor 
  pwm.begin(); // start Adafruit object
  pwm.setPWMFreq(FREQUENCY); // set frequency
} 
 
void loop() 
{ 
  Serial.println("Enter 0, 1, 2, or 3 for Base, U_arm, L_arm or Claw"); 
  while (Serial.available() == 0){} // wait for input
  str_input = Serial.readString(); 
    //  Add input rrror checking routine here ~~~ To be done later ~~~
  servo_pin = str_input.toInt();
  move_Arm(servo_pin);       
}

void move_Arm(int motorOut)
{
  int pulse_width = 300;
  while(true)
  {
      Serial.println("Enter 1 or 2 to inc or dec angle, or 3 to end");
      while (Serial.available() == 0){} // wait for input
      str_input = Serial.readString();
      int_Char = str_input.substring(0,1).toInt();
      //Serial.println(int_Char,DEC); 

    switch (int_Char)
    {
      case 1: 
        pulse_width = pulse_width - 10;
        Serial.print("Pulse Width = ");
        Serial.println(pulse_width,DEC);
        pwm.setPWM(motorOut, 0, pulse_width);
        break;
      case 2: 
        pulse_width = pulse_width + 10;
        Serial.print("Pulse Width = ");
        Serial.println(pulse_width,DEC);
        pwm.setPWM(motorOut, 0, pulse_width);
        break;
      case 3: 
        return;    
      }
    }
  }
  

  

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Recycled Roadkill
(@recycled-roadkill)
Member
Joined: 5 years ago
Posts: 75
 

Here's a pic of the shield I was planning to use. 12v power supply and A4988 (I think) to drive the main steppers. A H bridge will drive the claw motor.

Then all I need is the code. Learning as best I can.

5

This message was approved by Recycled.Roadkill. May it find you in good health and humor.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

@recycled-roadkill

That's a nice shield for driving steppers.  I'm hoping to find the time to build an arm using the 28BYJ-48 stepper motors as I have over a dozen of them.  They come with their own driver boards.  That project most likely won't see the light of day until winter when I have more time for hobby robotics.

Keep us posted on the progress you make with your arm.  I'm interested to see what it takes to control an arm driven by stepper motors.   I'm thinking that you would need to keep track of where they are at all times.  Either that or have sensors to give you feedback on their current position.  With the servo-driven Me Arm I can always place servos in a "Home" position without any need for sensor feedback to know where the arm is.   In fact, I chose to start with a Me Arm because I think that servos are easier to control as a first project.   Steppers have more advantages, but they may require a lot more programming.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Recycled Roadkill
(@recycled-roadkill)
Member
Joined: 5 years ago
Posts: 75
 

It's not so much a problem programming the steppers and I forgot to mention that it's a 28BYJ-48 that will be rotating the gripper claw. LOL, the missing part of the pic. I want to be able to control them remotely, likely bluetooth or IR, and be able to replicate their position and movement for some important task like retrieving a marble and putting it higher for a fall.

But, I have other brain clogging stuff I'm trying to work out right now. I'll have to find code and adapt it to what I plan to do. I'm not bright enough to code it all myself.

This message was approved by Recycled.Roadkill. May it find you in good health and humor.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: Recycled Roadkill

I'll have to find code and adapt it to what I plan to do. I'm not bright enough to code it all myself.

The key to programming it all yourself is to is to just start with one axis. The base is a good axis to start with. Just learn how to control the base motor to position the base at any rotation angle  you want.   Then once you have that accomplished.  You can basically just copy and paste that code for the next axis and then just modify the code for that axis until you get that axis under control, and so on.   Break it down into easy byte-size pieces.  Before you know it you'll have the whole arm under control.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Recycled Roadkill
(@recycled-roadkill)
Member
Joined: 5 years ago
Posts: 75
 

Good advice I'm sure. Thank you

The Craw

Wondering if anyone would be interested in trading coding for 3d printing?

🙂 Everybody be safe today.

This message was approved by Recycled.Roadkill. May it find you in good health and humor.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

My my! What a big claw you have there!

As far as code is concerned someone would basically need to have an arm like yours to know how to code it.  I'm pretty lame when it comes to programming too.  If I don't have the thing I'm programming right here in front of me to do a ton of trial and error experiments with I'm basically dead in the water.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Recycled Roadkill
(@recycled-roadkill)
Member
Joined: 5 years ago
Posts: 75
 

Not Claw! Craw! (Get Smart)

Anyone? Free 3d Printing for code?

What could possibly go wrong?  🙂  CAD included it it's not to complicated.

This message was approved by Recycled.Roadkill. May it find you in good health and humor.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: Recycled Roadkill

Anyone? Free 3d Printing for code?

Start a thread with that title and you'll most likely get some offers. ? 

Aren't there resources available for the arm you have?  There's probably already code out there for it  somewhere.

By the way, make sure the code actually works before shipping out any 3D printed parts. ? 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Yippee! Hallelujah! It works PERFECTLY!

I did it!  I calibrated my Me Arm using servo pulse widths and successfully mapped them to angles from 0 to 180.   So I'm all calibrated up and ready to settle in to some serious programming. ? 

The code is extremely simple thanks to the use of a 2-dimensional array to hold the various MIN and MAX pulse widths for each servo.  The 2-D array is initialized before the setup starts.  Then each servo's MIN and MAX values are assigned to the array in the setup routine.

This allows the mapping, which is done in the move_Arm() method, to be just one line for all four servos.

I'm extremely pleased with the progress thus far.  Nice clean code (at least I think so) and now I'm prepared to move forward and get on with some actual programming.

Here's the code thus far. 

/* Me_Arm_Servo_Control_V1
 * by Robo Pi
 */

#include  // Include Wire Library for I2C Communications
#include  // Include Adafruit PWM Library for using the PAC9685 board
#define FREQ             50 // Servo FREQ for the PCA9685 board
int Servo_Map[4][2]; // 2-D array to hold min and max servo frequencies.

// The PCA9685 board I2C address is 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40); 

String str_angles = ""; // Used for Serial input from monitor
int base_angle; //  Base angle
int u_arm_angle; //  Upper arm angle 
int l_arm_angle; // Lower arm angle

// Servo PCA9685 board pins
int base = 0; 
int u_arm = 1; 
int l_arm = 2;

void setup() 
{ 
  Serial.begin(9600); // Use Serial monitor 
  pwm.begin(); // start Adafruit object
  pwm.setPWMFreq(FREQ); // set FREQ
  Servo_Map[0][0] = 140; // Base Servo MIN        - LEFT
  Servo_Map[0][1] = 450; // Base Servo MAX        - RIGHT
  Servo_Map[1][0] = 230; // Upper Arm Servo MIN   - RETRACTED
  Servo_Map[1][1] = 470; // Upper Arm Servo MAX   - EXTENDED
  Servo_Map[2][0] = 190; // Lower Arm Servo MIN   - DOWN
  Servo_Map[2][1] = 460; // Lower Arm Servo MAX   - UP
  Servo_Map[3][0] = 140; // Claw Servo MIN        - OPEN
  Servo_Map[3][1] = 220; // Claw Servo MAX        - CLOSE  
} 
 
void loop() 
{ 
Serial.println("Enter Angles as 3-digit inputs eg.  000,000,000  Base, U_arm, L_arm"); 
  while (Serial.available() == 0){} // wait for input
         
  // Take in all three angles a single string.
  str_angles = Serial.readString(); 
          //  Add input rrror checking routine here ~~~ To be done later ~~~

  // convert angels to integers
  base_angle = str_angles.substring(0,4).toInt(); 
  u_arm_angle = str_angles.substring(4,8).toInt(); 
  l_arm_angle = str_angles.substring(8).toInt(); 

  // Write the angles to the monitor screen and the to the servos
  Serial.print("Setting Base Angle = ");
  Serial.println(base_angle,DEC);   
  move_Arm(base_angle,base);      
  Serial.print("Setting Upper Arm Angle = ");
  Serial.println(u_arm_angle,DEC);
  move_Arm(u_arm_angle,u_arm);        
  Serial.print("Setting Lower Arm Angle = ");
  Serial.println(l_arm_angle,DEC);
  move_Arm(l_arm_angle,l_arm);        
}

void move_Arm(int angle, int motorOut)
{
  int pulse_width;
  // Mapping all four servos using the 2D array
  pulse_width = map(angle,0, 180, Servo_Map[motorOut][0], Servo_Map[motorOut][1]);
  // send the control value out to the correct servo motor. 
  pwm.setPWM(motorOut, 0, pulse_width);
}
 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Recycled Roadkill
(@recycled-roadkill)
Member
Joined: 5 years ago
Posts: 75
 

Congratulations

And on a date you'll never forget.

This message was approved by Recycled.Roadkill. May it find you in good health and humor.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Sadly things have taken a turn for the worse since I posted the calibration success story. ? 

I was so excited about having it calibrated that I decided to devote some time to programming the first task, but I ran into two problems.

Problem #1:

The gripper is so weak that it can't even pick up a very small glass test tube. I even tried putting some heat-shrink tubing over the jaws to give them more friction, but the test tube just slides right out of the jaw.  This is not really a major problem just for learning to program the Me Arm.  I can always used lighter weight objects to pick up like make-believe Styrofoam test tube.  In fact, I'm having some success picking up an eye dropper by it's rubber bulb.   So this problem alone isn't a biggie.   Just a little disappointing.   Although I'm not planning on using this Me Arm for anything more than learning to program it. 

Problem #2:

While the calibration seems to be fairly good, the accuracy isn't.  The Me Arm doesn't always return to precisely the same place it was when given angle commands.  It can actually be off by as much as an inch from the last time it was at that position.  So this would make it totally useless in terms of trying to record a program of movements and expect it to reproduce them accurately.

It's a bit of a bummer.

I'm going to continue on with it just to work on the part of the program that reads the data from the SD card and puts the arm through a predetermined sequence of positions.  But I don't think it's going to have the precision I was hoping for.   I wanted to have it pick up a test tube (or eyedropper) from the test tube rack, and then put it back into a different hole in the same rack.   This is a small test tube rack that only has 1/2" diameter holes.   So the Me Arm isn't going to work if it can't keep at least an accuracy of 1/4" or less.  And right now it doesn't appear that it's going to have that kind of repeatable accuracy.

So we'll see where this goes.  I might have to move up to a more accurate arm real soon.  I was hoping to build my own arm using those 28BYJ-48 stepper motors.   So that project might be on the agenda sooner than I thought.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Mandy
(@amanda)
Member
Joined: 5 years ago
Posts: 74
 

Hi Robo,

Two suggestions for problems with the servos not hitting the same position.

It looks like 9g (ish) servos, when I used then there was a lot of slop in the gears.  Will the arm move to the correct position without having to move the servos, does it wiggle?  Can you hit the same position if you always go in the same direction?

The other problem I have had is servos drawing too much power, I'm using a dedicated 5V 3A and Vcc is on a separate supply.  If Vcc and V+ are connected you may be getting a brown out.   If you put a multimeter on v+ does it keep a steady 5V with the servos driving?  A power problem may also explain the lack of grip although smooth objects are always a problem.  (try the fingers off rubber gloves or the rubber bits off pipettes)

These are the best things I can think of as the PCA9685 is very good at running servos.  I hope it helps.

 

The 600 series had rubber skin. We spotted them easy, but these are new. They look human... sweat, bad breath, everything. Very hard to spot.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Thanks for the quick reply Mandy.  I never thought about the power supply requirements.   I'm running these through a 5V breadboard power supply.  Those kind that plug right onto the end of the breadboard.  And I'm powering that with a plug-in wall transformer that has switchable DC voltage out.  I have it set for 9V out to allow the breadboard power supply room to regulate down to 5 volts.   However I just now read the power output on the transformer and it's only rated at 300 mA.  So that could be the problem right there.  Maybe I'll need to grab a heftier power supply.  I never even gave that a thought until you mentioned it.

This arm is already zipping around at warp speed.  I'm going to program in some "smooth motion" by controlling it to move only a few degrees at a time so it doesn't whip around from coordinate to coordinate so fast.

I never suspected the problem would  be with the PCA9685 board.  I'm really not even suspecting sloppy servo motors.  It might be in the mechanics of this Me Arm itself.  I tried to assemble it as tight as I dare without locking up the motion.  But even that allows for some slop. 

I'll see if I can dig up a power supply with more current capability.  That might help.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Page 2 / 3