Go Down

Topic: Trouble when attaching 3rd servo (Duemilanove 328) (Read 2141 times) previous topic - next topic

-Kai

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: [Select]
#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!

AWOL

#1
Dec 24, 2009, 01:48 pm Last Edit: Dec 24, 2009, 01:51 pm by AWOL Reason: 1
Do you have a separate supply for the servos?
You should do.

If you already do, it could be you need some decoupling.
"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.

tarcardoso

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.

Adre

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

AWOL

What is the rating of the regulator supplying the servos?
"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.

Adre

#5
Aug 06, 2010, 12:23 pm Last Edit: Aug 06, 2010, 12:34 pm by jpuustel Reason: 1
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

PaulS


Adre

How else should servos be moved?

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

BR. Adre

AWOL

#8
Aug 06, 2010, 03:11 pm Last Edit: Aug 06, 2010, 03:13 pm by AWOL Reason: 1
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.
"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.

Adre

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

PaulS

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.

Adre

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

Adre

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

Go Up