arduino + servos + relay ?

so I'm building a project with some servos controlled by an Arduino, powered from an external power source. during "no command signal" (whenever the controller is booting, or just not connected), my servos are misbehaving... (moving fast and out-of-range), so - I decided to cut their power during these periods.

I want to use the Arduino, through one of its digital-out-pins to control the external power supply to the servos. all grounds are commonly connected. what's the best (/easiest) way to do this?

what's the best (/easiest) way to do this?

The easiest way is probably to use a relay, because it's simple and will introduce the lowest loss in a relatively-high-current path.

Whether that's best will depend on your application. The relay consumes power that might be scarce in a battery-operated system, for example. It can be bulky, compared to a transistor. And it may cost more, though the small increment in cost probably won't matter if you're only building one or two of these.

What you'll want to do is set up the transistor that controls the relay so that the default condition is "off" while the Arduino is powering up. This can get tricky, because even a pin that's set as an input may leak a little current, especially if it has an internal pull-up. I haven't done this sort of thing on an Arduino, but I've had to do it on other systems, and what I did was add a resistor of a couple of K to ground, to act as a pull-down until the pin was configured as an output and driven high.


Hi Ran - thanks for your help. I'm a bit confused though, do I still need a transistor if I'm using a relay? what is the general wiring scheme in this case?

also, I though that relays are used when two circuits are electrically decoupled (one just switches the other, each with its own 'battery'). however, here I still need the arduino to control the servos, and hence the ground should be common. would that still be valid ?

You may be able to switch the ground line on/off using the below MTP3055VL MOSFET, which is made for using 5v on the gate.

do I still need a transistor if I'm using a relay?

Yup. The relay coil usually needs more current than an Arduino pin can supply, so you use an external transistor (like a 2N2222) to switch the relay. There are examples in the Playground area of the site for wiring this setup (one of these days I need to figure out how to export Eagle schematics for easy inclusion in forum postings, but today is not that day).

You could use the relay either to switch the positive side of the power going to the servos, or to connect the ground. You do still need to make sure that the servo and Arduino grounds are connected when you're running the servos, because there's a logic signal between them.

I took a look at the datasheet zoomkat linked to, and that actually looks like a good possibility, unless you're running a lot of servos. The problem with solid-state switching in uses like yours is that there's a loss of energy in the transistors: the Darlington transistors most commonly used can lose as much as 2V under heavy load. But the MTP3055VL only wastes about .2V for each Amp of load, which will almost certainly be acceptable for your purposes.

You could use it to switch the ground on the servos, and wire it up just like you would the transistor that controls the relay in the approach I originally suggested.

Make sure that you shop for the MTP3055*VL*: there are some flavors of MTP3055 that don't have "logic level" turn-on thresholds, and won't be as efficient if you try to turn them on with an Arduino pin.