Pages: [1]   Go Down
Author Topic: Arduino Duemilanove with two servos, chopps.  (Read 621 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
<3 Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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?
« Last Edit: October 10, 2011, 10:03:28 am by Stigern » Logged

I'm from Norway!

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Norway
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
<3 Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I'm from Norway!

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Or did I miss something?
I think you missed the word easy. I would say that was the complex way of solving it.
Logged

Pages: [1]   Go Up
Jump to: