Pages: [1]   Go Down
Author Topic: Servos Malfunction during connection of 8th servo in 8th assigned pin of arduino  (Read 1075 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(smiley-cool; // 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 smiley
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Multi sweep - sweep upto 12 servos, this will tell you if its your code or something else.

http://rcarduino.blogspot.com/2012/01/can-i-control-more-than-x-servos-with.html

Duane B

rcarduino.blogspot.com
Logged


Pages: [1]   Go Up
Jump to: