Go Down

Topic: Servos Malfunction during connection of 8th servo in 8th assigned pin of arduino (Read 1 time) previous topic - next topic

thazze21

Good day sir/ma'am. We are currently working on a hexapod with 3 DOF(18 servos),we are using Arduino ADK MEGA and Tower Pro SG-5010. we are using a power supply of a personal computer for our servos,5V 45A. Our goal is to use atleast 10 pins of arduino mega adk for our servo motors, upon trying it, we were able to use 7 pins only. whenever we connect the 8th servo to our 8th pin in arduino, all servos connected on the board malfunctions (for example, some of the servos go to 0 or 180 degrees position, which is wrong because our loaded position of servos is 90 degrees to 120 degrees).

this is our loaded program:

#include <Servo.h>

Servo servoa; // Define a servo
Servo servob;
Servo servoc;
Servo servod;
Servo servoe;
Servo servof;
Servo servog;
Servo servoh;
int i,j,k;
int a=90;
int b=90;
int c=90;
int d=90;
int e=90;
int f=90;
int g=90;
int h=90;

void setup() {
servoa.attach(10); // RightA(4,6)
servob.attach(9); // LeftA(2)
servoc.attach(8); // RightB(4,6)
servod.attach(7); // LeftB(2)
servoe.attach(6); // LeftA(1,3)
servof.attach(5); // RightA(5)
servog.attach(4); // LeftB(1,3)
servoh.attach(3); // RightB(5)
servoa.write(a);
servob.write(b);
servoc.write(c);
servod.write(d);
servoe.write(e);
servof.write(f);
servog.write(g);
servoh.write(h);

}

void loop() { // Loop through motion tests
delay(5000);
for(i=1;i<=30;i++){
a++;
b--;
c++;
d--;
servoa.write(a);
servob.write(b);
servoc.write(c);
servod.write(d);
delay(15);
}
for(i=1;i<=30;i++){
c--;
d++;
servoc.write(c);
servod.write(d);
delay(9);
}
for(i=1;i<=30;i++){
a--;
b++;
e++;
f--;
g++;
h--;
servoa.write(a);
servob.write(b);
servoe.write(e);
servof.write(f);
servog.write(g);
servoh.write(h);
delay(20);
}
for(i=1;i<=30;i++){
g--;
h++;
servog.write(g);
servoh.write(h);
delay(9);
}
for(i=1;i<=30;i++){
e--;
f++;
servoe.write(e);
servof.write(f);
delay(9);
}
}

thank you for reading :)

zoomkat

Make sure you are not powering the arduino from the same power source as the servos. What you describe is typically a power supply issue. Also, the servos will operate much better at 6v instead of 5v.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

PeterH

I suggest you start with a single servo and connect it to each of your pins to make sure they're suitable to drive a servo.

Then define multiple servos but only connect one at a time to make sure your control logic works.

Then connect them all to confirm that your power supply is up to the job.
I only provide help via the forum - please do not contact me for private consultancy.


Go Up