Servo not working with L293D-shield

I'm running a motor driver shield based on the L293D on top of the Arduino Uno.

I have problems getting a servo motor working with this.
The two servo signal pins (upper left corner) are extensions from pin 9 and 10 respectively, and the power is 5v supplied from the Arduino Uno.

If i hook up the servo directly to the Arduino Uno using the same pin 9 and run this simple piece of code:

#include <Servo.h>
Servo myservo;
 
void setup()
{
  myservo.attach(9);
}
 
void loop()
{
  myservo.write(0);
  delay(1000);
  myservo.write(180); 
  delay(1000);
  myservo.write(0);
}

...everything works as expected. However, if i run the same code with the shield attached, the servo is making small twitches/steps in intervals and the board repeatedly disconnects from my PC, again and again with even intervals, every two seconds or so.
I have tried with and without external power.

Should I assume the shield is broken or am I missing something obvious?

Badly designed shield. There should not be a servo (power) connector there, and two is a double mistake.
Servo power should never come from/through the Arduino, because most servos draw more (stall) than the 5volt regulator or the PC/laptop/USB supply can safely provide.
Always use separate external power for servos.
A PCA9685 breakout board (with separate servo power connector) is a safe solution.
Leo..

Wawa:
Badly designed shield. There should not be a servo (power) connector there, and two is a double mistake.
Servo power should never come from/through the Arduino, because most servos draw more (stall) than the 5volt regulator or the PC/laptop/USB supply can safely provide.
Always use separate external power for servos.
A PCA9685 breakout board (with separate servo power connector) is a safe solution.
Leo..

I understand, I will look into an alternative, though I'm curious a to what causes the issue when using the shield but not when running directly running from The Arduino. I haven't meaured the voltage yet but I did try to hook up the servo to the 3.3v line on the Arduino to compare and the result was different. Not the repeated disconnects and the skipping movements, just a more tired motor, which makes me think it's not a voltage issue.

The UNO is now supplying logic power for 3 more ICs +(?), how much is that?

Ok, so I measured the voltage at the servo power pins and it shows 4.84 volts, so I'm guessing that's not where the problem is?

JCA34F:
The UNO is now supplying logic power for 3 more ICs +(?), how much is that?

As I understand it, the IC's are supposed to be getting external power if one is hooked up (which it is), and the servo is supposed to run on the Uno's 5 volt

JestonLunnigan:
Ok, so I measured the voltage at the servo power pins and it shows 4.84 volts, so I'm guessing that's not where the problem is?

Did you measure that with a scope?
A DMM won't be fast enough to register the dip during stall (startup) of the servo.
That short dip could cause rebooting of the Arduino.
Put a print statement in setup(), and you will see.
Leo..

Wawa:
Did you measure that with a scope?
A DMM won't be fast enough to register the dip during stall (startup) of the servo.
That short dip could cause rebooting of the Arduino.
Put a print statement in setup(), and you will see.
Leo..

What should be in that print statement? Would be interesting I guess.
I still don't quite understand why it works fine when I run it straight from the Uno though...

Always use separate power for servos, not the Arduino 5V, the on-board regulator cannot reliably handle the load, and if USB powered you are risking your computer's USB port (or worse).

Even small servos peak at around 1A each. Servos have active electronics so if the power droops on a current peak they will reset or go haywire - you simply have to provide a strong enough supply or expect problems.

JestonLunnigan:
What should be in that print statement?

Just print someting in setup(), like "My Arduino motor driver".
You should only see that printed once, since setup only runs once.
If you see it every time...
Leo..

Wawa - Oh, that makes sense. Thank you.

Ok, so I tried hooking up the servo directly to a 5 volt external power supply, which was apparently a stupid idea since it had a really violent startup and cracked the gears inside the servo (sounded like it smashed into it's own 180-degree limit and cracked). I'm expecting this kind of destructive learning process so no biggie, no clue why it happened though. Either way, it does sound like the motor itself is behaving like it should now, so proper powering is probably the issue like you guys concluded.

Since the servo power pins on the shield doesn't connect to the external power connector I guess I can't really use it to run the servo. I don't know the best way to go around this, especially since my project includes two servos, a DC motor and a stepper, but I guess this specific topic is concluded then. The shield is simply not suitable to run servos.

Did you connect power/ground from the external supply and signal/ground to the servo.
Strange things could happen if you forget the Arduino ground.

What stepper. That motor shield is not a stepper driver.
That shield can only drive high impedance steppers (most modern ones are not).

What DC motor. The ancient/inefficient L293 can only drive tiny toy motors.
And expect to loose several volt from the motor supply.
Nobody with a reputation to keep up sells that V1 shield anymore.
Leo..

I connected the servo power and ground to the external supply and the signal to the shield. No Arduino ground. Probably why I wrecked it :slight_smile:

I see, looks like I don't have much use of that shield at all. Perhaps the V2.3 is a better choice. Apparently that one runs its servos on the Arduino 5v as well, and I need to cut that line. Don't understand why they didn't put a jumper on instead, especially since they did prepare through-holes for external power.
Seems like a good option anyway. USB to Arduino, external 5v to the servos and 12v to the stepper and the DC motor.

Thank you all for your very helpful answers.

V2 of that shield has the better mosfet-based drivers, but the same servo power problem.
All motors should be powered with a separate motor supply.

You didn't tell us what motors/stepper/servos you're trying to use.
Post a link to the product pages.
Leo..

Well I have a bunch of old printer steppers to choose from but the one I currently had in mind is an NMB PM42L-048 (link). Maybe running it on 12 volts is a bad idea but I don't really need a lot of torque or speed. The servos are S3003's (link)

Regarding the V2 Adafruit motor shield, according to the instructions it is possible to power the servos externally if i solder pins to the Opt Servo slots in the upper left corner, and cut the 5 volt trace

That stepper seems to have 60 ohm coils, so ok to use with 12volt and a brushed DC motor driver (that shield).
Modern/larger steppers could be a few ohms, and that could release the magic smoke.

Stall (startup) current of a Fubata S3003 seems to be 900mA@6volt.
A 5-6volt >=2Amp supply (or batteries) must be used for two of those servos.
Maybe you can use a 5volt tablet charger.

Didn't know that V2 shield had the option to power servos externally.
The option should have been to add a link to the 5volt rail, not to cut it :slight_smile:
Leo..

I'll give that shield a go then. The through-holes doesnt seem to say anything about polarity on that picture though. I'lI see if I can follow the traces. I have an old internal power supply from a CD-player with one 12 volt line and one 5 volt line that I could use perhaps.

A CD player 5V probably won't be powerful enough. You need high current for servos, I'll keep repeating this - if you provide inadequate power for servos you will have problems.

MarkT:
A CD player 5V probably won't be powerful enough. You need high current for servos, I'll keep repeating this - if you provide inadequate power for servos you will have problems.

I understand that, I didn't assume that power supply would be too weak though, but I will look into it. Otherwise I'll use something else, I have a few to choose from.