Servos Twitching On Same Power Supply

Just after some advice on servo motor twitching and possible causes.

I have a project that uses 2 x 12v servo motors powered by 1 x 12v 18AH battery.

When connecting just one servo, there is no twitching and it works fine. When connecting two servos on two separate 12v batteries, they also work fine.

However, when connecting 2 servos onto the one battery which the project requires, the servos become twitchy at random intervals.

The 12v servo motors are 4.3A peak current.

The code used is just the servo sweep example.

The wiring diagram is below.

Any advice would be great, thanks.

Give a LINK to the servos.

Poor quality battery or wiring too thin/long.
Link to the battery, picture of the setup.
Leo..

I've tried multiple quality batteries and the problem repeats so have ruled the battery out. Maybe the wiring is too thin. The 70cm length wiring comes with the servo as it's an underwater servo.

Link to the servos here: High Torque 40 KG Motor Micro Servo – ROVMAKER

You’re using the “servo sweep example”, but with two servos.

Can you post your modified code** that includes the second servo.

Thanks

** please remember to use code tags !

Here's the code being used:


#include <Servo.h>

int pos1 = 0; // servo 1 start position
int pos2 = 92; // servo 2 start position 

Servo myservo1; 
Servo myservo2; 

void setup() {

   // Attach the servos
  myservo1.attach(7); 
  myservo2.attach(6); 
 
  // Start with Servo positions
  myservo1.write(pos1); 
  myservo2.write(pos2);

}

void loop() {

// SERVO MOTOR 1

  for (pos1 = 0; pos1 <= 50; pos1 += 1) { // goes from 0 degrees to 50 degrees
    myservo1.write(pos1);              
    delay(50);                       
  }
  for (pos1 = 50; pos1 >= 0; pos1 -= 1) { // goes from 50 degrees to 0 degrees
    myservo1.write(pos1);              
    delay(50);                       
  }


// SERVO MOTOR 2

  for (pos2 = 92; pos2 >= 43; pos2 -= 1) { // goes from 92 degrees to 43 degrees
    myservo2.write(pos2);             
    delay(50);                        
  }
  for (pos2 = 43; pos2 <= 92; pos2 += 1) { // goes from 43 degrees to 92 degrees
    myservo2.write(pos2);               
    delay(50);                          
  }
}

Hi,
Can you please post a circuit diagram and some images of your project?
So we can see your layout.

Will you be loading the servo shafts down?
What is the application.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

The application is basically a 2 axis gimbal that will be run off a 12v battery. The only image available atm is the circuit diagram at the top. Would a 'servo shield' be worth a try to fix the servo twitching?Thanks

Hi,
What length of power carrying wire between the batteries and the servos?

Have you got the gnds connected exactly as in the picture in post #1?
That is star configuration to the battery negative post?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

The power carrying wire is 70cm long on each servo and the wires that came with the servos are a little thin.

Yes, the grounds are connected just as in the diagram.

Thanks

This

for (pos1 = 0; pos1 <= 50; pos1 += 1) { // goes from 0 degrees to 50 degrees

Tries to set the servo position below the default min value (544 ÎĽs).

From your servo link: image
Servo library defaults for servo.attach(pin, min, max) is servo.attach(pin, 544, 2400)

Try using:

   // Attach the servos
  myservo1.attach(7, 501, 2499); 
  myservo2.attach(6,, 501, 2499); 

Could try this minor adjustment to see if it helps ...

  for (pos1 = 1; pos1 <= 50; pos1 += 1) { // goes from 1 degrees to 50 degrees

Thanks for noticing that and for the code correction, have tried adding it to the code but still getting the random twitching with 2 servos. Thanks

Did you measure the battery voltage for any dips ?

As the servo is a 12v rated device, it might be the servo expects to see a 12v pwm signal also.

Could not see anything in the specs.

Perhaps a call to the supplier could verify.

1 Like

No breadboard is being used, just what's in the circuit diagram image at the top. The battery voltage is the same with one or two servos connected. Thanks

How about trying a test with reference to @Wawa post#4.

Connecting them separately works, but I wonder, as a test, if you connect the 2 batteries in parallel first, then connect your 2 servos. If this works, then it would suggest that a single new battery, or a type with improved specifications would be a solution.

On the software side, perhaps you could try this library:
Control RC Servo motors with interrupt-resilient PWM

1 Like

I entered the text from post#1 into Open AI ...

Rubbish.
Op says battery is 18Ah...how big do you think it needs to be..??

Maybe the battery is bad, maybe they say one thing and are doing another.