Go Down

Topic: Arduino Duemilanove with two servos, chopps. (Read 648 times) previous topic - next topic

Stigern

Oct 10, 2011, 05:00 pm Last Edit: Oct 10, 2011, 05:03 pm by Stigern Reason: 1
So, I've took my Arduino Duemilanove from the shelf again, and tought I was gonna try a little half-finnished robot that was laying around.

Lets cut to the problem, I've hooked up two servos, small 9g ones. And trying to control both servos at the same time. One servo is attached to pin 2 and the other one on pin 11.

It seems to be some kind of interference runing them both, cause if I take out pin 2 or 11, the other servo runs fine. If I insert it again they both start behaving choppy and strange.

Heres my code:
Code: [Select]

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

Servo servo_turn;  
Servo servo_move;  



void setup()
{
 servo_turn.attach(2);  
 servo_move.attach(11);
}

void loop()
{

 Center();
 Forward();
 delay(1000);
 Left();
 delay(2000);
 Center();
 delay(500);
 Right();
 delay(1500);
 
 
 

}

void Forward()
{
 servo_move.write(10);
}

void Right()
{
 servo_turn.write(76);
}
void Center()
{
 servo_turn.write(87);
}
void Left()
{
 servo_turn.write(100);
}



So, why won't they run smoothly when they both are plugged in?
I'm from Norway!

Grumpy_Mike

Simply because they generate interference. So you have to do something with the power supply to each.
Like using a separate supply for the motors and the arduino (connect the grounds) or supplying some decoupling to each servo:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

zoomkat

Quote
So, why won't they run smoothly when they both are plugged in?


If you are trying to power the servos from your arduino, then that is probably your problem.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Stigern

Ah, thanks guys! So to cut it short, a easy way to solve this is to power the servos on a individual battery-bank and let the arduino use its own battery =)

Or did I miss something?
I'm from Norway!

Grumpy_Mike

Quote
Or did I miss something?

I think you missed the word easy. I would say that was the complex way of solving it.

Go Up