Go Down

Topic: SERVO+ARDUINO HELP (Read 547 times) previous topic - next topic

Blaec

I don't understand why my robotic arm is not working. If anyone can tell me why, based on the description below, before three o'clock pm, I would appreciate it.
I have:
-four servos (3 are HS422s, one is the "medium servo" from Sparkfun) connected to an Arduino; one with signal to pin 6, one to pin 9, one to pin 10, and one to 11
-each of the servo's are in parallel to the power source (which is the 5 volt breadboard power supply from Sparkfun)
-four 10K pots (2 are in a joystick config, however) connected to Arduino; one on analog pin 0, one on 1, one on 2 and one on 3
-the grounds are connected
-the Arduino is powered via USB, the rest via the power supply

Arduino is running this code:
   
Code: [Select]
#include <Servo.h>

Servo sm1; 
Servo sm2; 
Servo sm3; 
Servo sm4; 

int pot1 = 0; 
int pot2 = 1;
int pot3 = 2;
int pot4 = 3;

int val1;
int val2;
int val3;
int val4;

void setup() {
  sm1.attach(6); 
  sm2.attach(9);
  sm3.attach(10);
  sm4.attach(11);
 
}

void loop() {
  val1 = analogRead(pot1);
  val2 = analogRead(pot2);
  val3 = analogRead(pot3);
  val4 = analogRead(pot4);
 
  val1 = map(val1, 0, 1023, 0, 179);   
  val2 = map(val2, 0, 1023, 0, 179);
  val3 = map(val3, 0, 1023, 0, 179);
  val4 = map(val4, 0, 1023, 0, 179);
  sm1.write(val1);   
  sm2.write(val2);
  sm3.write(val3);
  sm4.write(val4);
  delay(15);                           
}



The motors dont respond at all until I unplug one or two, and then they jerk around and go crazy. Please help me!

johnwasser

The software looks fine so it must be hardware.

Are you sure you have the power and signals wires identified correctly?

Can you put a meter on the power supply to make sure the power supply is up to the task?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Aeturnalus

The SparkFun power supply is rated at a MAX of 1.5A - a good rule of thumb is that each servo will require between 0.5A and 1A, so you're definitely either exceeding the limit or cutting it real close.  This is quite possibly the cause of your problem.  Are you able to get each servo to work individually?  (as in, running with the sweep code example with the other servos disconnected)

vinceherman

I second the thought to run the sweep tutorial on each individual servo.
Preferably with it removed/disconnected from the arm to remove load.

AWOL

Don't give the bugs dark corners to hide in.
Code: [Select]
#include <Servo.h>
const int SERVOS = 4;
const int servoPin [SERVOS] = {6, 9, 10, 11};
const int potPin [SERVOS] = {0, 1, 2, 3};
Servo sm [SERVOS]; 

void setup()
{
  for (int i = 0; i < SERVOS; ++i) {
    sm [i].attach(servoPin [i]); 
  }
}

void loop()
{
  for (int i = 0; i < SERVOS; ++i) {
   int val = analogRead(potPin [i]);
 
   val = map(val, 0, 1023, 0, 179);   
   sm[i].write(val);   
  }
  delay(15);                           
}
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up