Pages: [1]   Go Down
Author Topic: Trouble when attaching 3rd servo (Duemilanove 328)  (Read 1920 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I am trying to build a small robot using an Arduino Duemilanove ATmega328 and Arduino 0017. Everything works fine until I try to attach a third servo (I would like to use at least 5 servos). With just two servos attached a simple program like the one below works without any noticeable problems. However, once the third servo is attached (servo3 in code below), the two other servos behave seemingly random, not following the instructions at all.

This problem also occurs if i use the MegaServo library or when I tried an alternative pin setting.

In the following example servo1 and servo2 are continous servos. This code produces the strange behavior, once line 18 ("servo3.attach(PINS3);") is commented out it runs fine.

Code:
#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;

const int PINS1 = 3;
const int PINS2 = 11;
const int PINS3 = 6;

void setup()
{
  pinMode(PINS1, OUTPUT);
  pinMode(PINS2, OUTPUT);
  pinMode(PINS3, OUTPUT);
  servo1.attach(PINS1);
  servo2.attach(PINS2);
  servo3.attach(PINS3); // this line causes trouble
}


void loop()
{
  // turn one way for 4s
  servo2.write(0);
  servo1.write(0);
  delay(4000);
  // stop for 4s
  servo2.write(90);
  servo1.write(90);
  delay(4000);
  // turn the other way
  servo2.write(180);
  servo1.write(180);
  delay(4000);
  // stop again
  servo2.write(90);
  servo1.write(90);
  delay(4000);
}

Any help is appreciated! Happy holidays!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a separate supply for the servos?
You should do.

If you already do, it could be you need some decoupling.
« Last Edit: December 24, 2009, 07:51:19 am by AWOL » Logged

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a problem similar with your, It seems resumes when I use more the 2 servos, because the servos's values rollback to the initial possition post in setup method.
This problem dos not appear at the arduino mega, then it's not a servo problem.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have problem when attaching 2nd servo...

Shouldn't this Arduino Duemilanove 328 setting work with two servo motors? As servos we have two "Microservos"

As power source we use 12V 3,4Ah Pb battery.

Battery + is connected to 9V regulator and 5V regulator. 9V regulator GND goes to battery - and 9V goes to Arduino DC-connection. DC-connection ground goes also to battery -.

5V voltage goes to two servo motors. Servo GND goes to same point that 5V regulator GND is. After that we have transistor (between Arduino GND pin and regulator / motor ground) as switch so regulator won't eat energy all the time. Transistor emitter goes to Arduino ground pin.

If we connect only one motor PWM (we use same code all the time), motor works fine. No matter which motor we connect. Though every random time servo jumps to some position and then back.

If we connect two PWM signals both servos go wild and jump back and forward.

We have also tried to turn off the other servo with .detach() and move only one servo at time but it doesn't seem to work. Servos seem to attach and detach slowly because they won't work right away.

Can anyone say what is the problem here?

BR. Adre
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the rating of the regulator supplying the servos?
Logged

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

What does regulator rating mean?

And sorry... In previous mail I said we have different regulator that we really have.

Our regulator is REGULATOR TO220 1,5A +6V 7806.

And servo is "Operating Voltage: 4.8V~6.0V".

BR. Adre
« Last Edit: August 06, 2010, 05:34:15 am by jpuustel » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why are you using PWM to move the servos?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How else should servos be moved?

I use Arduino servo library. myServo.write(value) etc..

BR. Adre
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The servo library doesn't use PWM, it uses PPM.
Are you sure the grounds are all connected correctly?

Maybe look at some decoupling.
String a 220uF across the servo supply.
Stuff like that.
« Last Edit: August 06, 2010, 08:13:50 am by AWOL » Logged

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, so we are using PPM.

We have already tried to string capacitors across servo voltage supply. So noise in GND line would be small as possible. It didn't have effect. Still one servo works fine but when we connect another system goes crazy.

We have also tried to use very short wires as signal wires to reject external noise. It didn't help either. I guess we should try also small capacitors between signal wire and GND.

Servo ground goes to collector of transistor. Emitter of transistor goes to Arduino GND port.

BR. Adre
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't typically need a transistor to control a servo. The signal wire draws very little current. The Arduino typically has not problem supply enough current to signal the servo to move.

Try getting rid of the transistors. Just connect the signal wires from the servos to digital pins. Connect the +V of the servo to +V of the battery, and ground of the servo to ground of the battery AND ground of the Arduino.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We are having transistor in servo GND and servo regulator because otherwise regulator would eat battery all the time. Could transistor somehow disturb the servo signal that way?

Servo signal wire goes straight to servo.

Battery +V (12V) goes to regulator. Regulator +V (6V) goes to servo. Regulator GND and servo GND go to collector of transistor. And emitter of transistor goes to Arduino GND. Transistor base is controlled with Arduino digital output (and we have base resistor).

BR. Adre
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, we got it working.

We put regulator GND straight to battery GND, not to transistor collector. Now everything seems to be working fine.

Br. Adre
Logged

Pages: [1]   Go Up
Jump to: