Running Servo Motors from Main Power - issues!

So I have a project in which I am using 4 Towerpro MG996R servos under fairly High Load (only one at a time for a few seconds)…

I first tested the servos with 4 AA batteries in series which works fine (an example of the circuit I used is attached although the voltage says 4V which is obviously wrong)! The project needs to be run off mains power so i brought a 5 Volt, 3 Amp mains adapter thinking that it would have plenty of power however when i wired it up to just 1 servo it couldn’t handle it (let alone 4)… the servo rotates ok (under no load) but when it gets to its destination it twitches and sometimes it starts its movement is a bit weird as well (the led on the plug also switches off when the servo is moving)… I assume this is because it cant draw enough current/voltage from the plug? What can I do to fix this?

I have looked at adding a capacitor… Would this help? Where should I add it? What value should it be?

I have researched it online and all the posts I have found suggested that replacing the batteries with the adapter should work fine… but it doesn’t :confused:

Please Help!

If you use only one servo at a time, a 5V, 3 amp adapter should work. Perhaps it is defective, or providing noisy power. Note: AA batteries can supply only 1-2 amps for a short time, even when fresh.

Servos "twitching" all the time is normal, and doesn't necessarily mean you have a bad power supply. It's just the way that servos work.

You might want to try testing your power supply to see if it really can supply 3 amps. You need something with a resistance of about 1.5 ohms, that won't melt. Easier said than done. One suggestion would be old-style brake lamps from a car.

Servos "twitching" all the time is normal,

Mine don't, yours must have issues.

Just for kicks, let's see the code....

Hi,

Can you please post a picture of your project. So we can see your layout.

Tom..... :)

#include <Servo.h> 
 
Servo myservo;  
                
 
int pos = 0;    
 
void setup() 
{ 
  myservo.attach(9);  
} 
 
 
void loop() 
{ 
  delay(5000);
  for(pos = 75; pos < 140; pos += 2)  
  {                                  
    myservo.write(pos);              
    delay(15);                      
  }
  delay(5000);
  for(pos = 140; pos>=75; pos-= 2)     
  {                                
    myservo.write(pos);              
    delay(15);                       
  } 
}

Im literally just using this test code with 1 servo at the moment to see if I can get it working from the mains.

It is the same as in the schematic Tom apart from I am using mains power instead of the 4V battery pack shown.

I don’t think its the code or the wiring because the servo is working fine with the batteries? And the Arduino ground and power supply ground are definitely connected if that was the worry?

The servo runs smoothy whilst connected to batteries so it definitely shouldn’t be twitching with mains unless its some kind of power surge issue that the plug cant handle? I will try using a different adapter today… if that doesn’t work how could I fix the power surge issue? A capacitor somewhere maybe?

how could I fix the power surge issue

Unlikely to be a problem, unless the power adapter is faulty. A 220 - 1000 uF capacitor across the power supply leads will help with electrical noise, if that is a problem, and won't hurt in any case.