Arduino overloading?

So I'm using an Arduino Duemilanove. Im using 4 PWMs for my motor driver (do not ask why). It works. But when i hook up my servos (also PWMs), problems occur. Here's my code:

define SERVO1 10

define SERVO2 11

void setup() { servo1.attach(SERVO1); servo2.attach(SERVO2); servo1.write(90); servo2.write(90); motors.init(); }

void loop() { motors.setLeftSpeed(400); motors.setRightSpeed(400);

delay(1000);

motors.setLeftSpeed(100); motors.setRightSpeed(100);

delay(1000);

servo1.write(170); servo2.write(170);

delay(1000);

servo1.write(10); servo2.write(10);

delay(1000); }

When the "servo.attach()" and "servo.write()" lines are removed, the motors spin accordingly. However, when the codes are reintroduced, the "motors.setRightSpeed()" don't get executed.

Any help?

If you're powering your servos from the Arduino's 5V output you're probably causing brownouts and resetting the Arduino.

Chagrin:
If you’re powering your servos from the Arduino’s 5V output you’re probably causing brownouts and resetting the Arduino.

In which case you want to hook them up as shown attached.

servo power.png

I am powering my servos directly from the power supply (8x1.2V NiMH batteries min.1900mAh). Only the control wires are connected to the arduino.

Here's how the circuit look like (sorry i don't have schematics):

Circuit Image

Maybe that battery pack is just on the limit of its current ability?

(Side note: why are you powering 5-7V servos with almost 10V?)

Only the control wires are connected to the arduino.

You also need to connect the external power supply ground to the arduino ground.

zoomkat:
You also need to connect the external power supply ground to the arduino ground.

According to the linked pic, they are all commoned zk.

JimboZA: Maybe that battery pack is just on the limit of its current ability?

That would be my guess as well. 3C is the high limit for NiMH; that'd be 570ma for his batteries. Duracell NiMH AA Datasheet for reference.

I'd suggest, for troubleshooting purposes, to find a 5V power supply >= 1A and use that instead of the batteries.

Suppose i use a 5V power supply, would that affect the speed of the motors. I am powering the motor drivers directly from the power supply as per the image i linked to.

l30_aquino: Suppose i use a 5V power supply, would that affect the speed of the motors.

Yes it will: check the manufacturer's site. They normal quote the time it takes to move 60 degrees, usually somewhere like 0.15 to 0.2 seconds, and sometimes they give that for different supply voltages.

I am powering the motor drivers directly from the power supply as per the image i linked to.

Well 10V to a 5-7V motor is not going to do it any good at all. But as I said in PM, just how bad it is, nobody would be able to say.