Mechanics and Construction > Mechanics and Construction

Robotic Arm run by Arduino

(1/2) > >>

jsaginaw14:
Hello,
My name is Joe and my friends and I are building a robotic arm for a competition.

We have constructed an arm that utilizes 6 servos for 5 joints, and a dc motor is used to turn the whole set up left and right. We are using an Arduino Mega 2560 and potentiometers to control each individual servo. The wiring is done through a breadboard. We have a 9 volt battery working the DC motor, a 6 volt battery giving power to the arduino board, and another 6 volt battery running the potentiometers.  There are two servos at the base joint, and one servo at all the other joints.  The servos are Standard servos from BP Hobbies and the baterris are 6 V, 1600maH, NiMH Tenergy batteries.  The potentiometers are 25-ohm potentiometers from RadioShack.  There is a knife switch controlling the direction of the DC motor and a 5K-ohm potentiometer controlling its speed. 

Everything is wired properly, we have checked numerous times and used an ohm meter.  Concerning the power sources, there are different ones.  The board and the servos are running off their own 6V battery, which is inputted into the board with a spliced DC jack plug going into the DC  jack on the arduino board.  The other ends are attached to the battery leads.  The servos are getting power through the 5V pin and grounded to the GND pin.  They get their signal from the PWM outputs on the board.     

The potentiometers have a very low ohm-rating, so we put them on a separate circuit because they use alot of current.  Their positive and ground ends are attached to another 6V battery, and the output wires from the center of the potentiometer go into the analog input pins of the arduino board. 

Here is an example of the code:
#include <Servo.h>
 
Servo myservo;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
 
int potpin = 0;
int potpin1 = 1;
int potpin2 = 2;
int potpin3 = 3;
int potpin4 = 4;

int val;
int val1;
int val2;
int val3;
int val4;
void setup()
{
  myservo.attach(9);
  myservo1.attach(8);
  myservo2.attach(7);
  myservo3.attach(6);
  myservo4.attach(5);
}
 
void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(30);                           // waits for the servo to get there
 
  val1 = analogRead(potpin1);           
  val1 = map(val1, 0, 1023, 0, 179);     
  myservo1.write(val1);                 
  delay(30);                         

  val2 = analogRead(potpin2);           
  val2 = map(val2, 0, 1023, 0, 179);     
  myservo2.write(val2);                   
  delay(30);                           

  val3 = analogRead(potpin3);           
  val3 = map(val3, 0, 1023, 0, 179);     
  myservo3.write(val3);                 
  delay(30);                           

  val4 = analogRead(potpin4);           
  val4 = map(val4, 0, 1023, 0, 179);     
  myservo4.write(val4);                 
  delay(30);                           
}

When we have everything hooked up, the arm start going nuts and moves like it has a mind of its own. We do have some control over it, but the arm is still jerking left and right at almost every joint, the most at the servo controlling the gripper.  We have ruled out noise interference because we have had complete-non jerky control over it at previous points in time. 

The competition is next weekend so please help.   :)
If you need pictures, I will zip them and attach them but they are too large to attach at the moment

jwatte:
Some things:

1) Get new potentiometers. A 5k or 10k potentiometer will be plenty for the Arduino input, and will not burn off all your power.

2) Make sure that the "-" contacts for ALL THE BATTERIES are connected together. This creates a common ground. Else you'll have who-knows-what kind of problems.

3) What powers the servos? Each servo may need 1A of current. If you're trying to power the servos using the same battery as the Arduino, that would cause problems when the voltage drops and the Arduino resets.

4) You are calling delay() after each servo write. You do not need to do this. The servo library will generate the right pulses at the right times; your control of the servo library just tells it what those pulses should be when the time comes around. (It keeps doing this forever)

5) You should put something like "flash a LED for 5 seconds" in the setup() function. This will let you know when the Arduino resets.


--- Code: ---void setup() {
  pinMode(13, OUTPUT); // the built-in LED on Arduino UNO
  for (int i = 0; i < 25; ++i) {
    digitalWrite(13, HIGH);
    delay(50);
    digitalWrite(13, LOW);
    delay(50);
  }
  ... do other setup
}

--- End code ---


6) You should also reduce everything to the simplest possible setup. Start with only a single servo, nothing else hooked up. Make sure that works. Then expand to two servos. Repeat...

Azraels:
I remember having the same jerky movements in my servos on the first arm I built. It was more than likely caused by not having everything running to the same ground including the arduino ground on the digital I/O pin line. But before I had figured that out I had put it down to the pots not keeping a constant value at a certain position causing the map to be constantly changing the servo's position. I rewrote the code to increment write values to the servos when the pot was greater than or less than a certain middle stop value.

jsaginaw14:
Thank you guys so much.  I will definitely try these potential solutions out. I have also heard that twisting the signla wires can reduce noise interference, but I believe there is too much jittering to be just noise.  Currently, I have the potentiometers and the board on the same 6V battery and the motors on their separate battery.  Would it be possible to run everything through the board with 2-3 6V batteries in parallel to provide 6V but 3200-4800maH through the board to power everything so they are all grounded to GND?

Thanks so much again.
Joe   

Azraels:
Well you could, but remember the recommended voltage for the Mega is 7 to 12 volts and you are at the minimum of 6v. Any sudden loss of voltage can cause the Arduino to reset, which could happen when your motors kick on. You might want to try a higher voltage battery. And you can still use different voltage batteries like you were before just link there negatives.

Navigation

[0] Message Index

[#] Next page

Go to full version