Running a stepper motor directly from Arduino outputs... will zeners help?

OK, I know it's generally a no-no to connect motors straight to an Arduino, but the stepper motor I'm driving is minute. It's tiny. Open frame, just two coils and a little magnetic rotor.

I dug a stepper motor out of an autofocus lens, soldered four little wires to it and stuffed them in the Arduino outputs. I've got spare Atmega chips if I blow this one, but the motor seems to run fine on 5 volts; the current draw is a little under 10mA per coil.

If I was connecting anything else coil-based (like a relay) to an Arduino, I'd stick a diode across the coil facing the other way, so when the coil's power goes off and the magnetic field collapses, any voltage it generates can dissipate through the diode rather than zapping my Arduino. That approach won't work with my stepper, as the voltage across the coil could be in either direction depending on which step the motor's at.

But then I was wondering - those little zener diodes - if you try putting a voltage the wrong way across them they won't conduct unless the voltage goes above their reverse breakdown voltage, at which point they conduct. So could I do this...

...? (I've only marked them as 6.8v as that's what I have sitting in the parts box at home - I'm guessing I just need something larger than 5 and less than whatever the Arduino's maximum GPIO pin voltage is allowed to be).

I think I've seen this two-diodes-facing-each-other thing before, but didn't really understand it. Here, it looks like it could theoretically protect my Arduino against any nasty voltage spikes without interfering with the normal motor operation. And without me having to build a whole H-bridge thingy... ick.

Does this seem sensible? Any tips?

Does this seem sensible?

Well, to me... not entirely.

EDIT: I did want to comment on your excellent hand drawn schematic. Nicely done.

Here's the thing. The setup you show will allow for bi-polar shunt behavior of the reverse biased Zener while the forward biased zener will add a .7v drop to forward voltage... in essence leaving you to shunt excess voltage that must first reach a potential of 7.5V before shunting occurs... which already exceeds maximum pin parameters.

I don't think that is ideal.
Attached drawing is how I would do it... Note: it does duplicate what is already IN the AVR chip at the pins...

stepper.jpg

I agree with pwillard's scheme, however the diodes should be Schottky types (e.g. BAT43) so that they conduct before the Arduino protection diodes do. Note that the Arduino protection diodes are only good for a couple of mA, that's why external diodes are needed in this application.

Have you measured the resistance of a stepper winding? If it's less than 80 ohms then you really should use a driver.

Also consider adding a 100uF capacitor between +5v and ground to receive the energy released when you turn a winding off.

Ooh, can we see picture or link to these tiny steppers?

Thanks for the advice! So I can get my head round this:

pwillard:
... the forward biased zener will add a .7v drop to forward voltage... in essence leaving you to shunt excess voltage that must first reach a potential of 7.5V before shunting occurs... which already exceeds maximum pin parameters.

Understood - seems to be down to my clumsy selection of 6.8v zeners. But if I used 4.7v zeners instead, the voltage would only hit 5.4v before shunting.

Using Schottkys in the configuration you suggested would protect against voltages over 5.33v (assuming BAT-43s with a .33v drop), which is only half a volt-ish more protection than the zeners but with double the component count - is this enough of a reason to use your 8-diode method over my 4 zeners? Is there another reason not to use zeners?

dc42:
Have you measured the resistance of a stepper winding? If it's less than 80 ohms then you really should use a driver.

Resistance of the windings are around 270 ohms if I remember right - oh, which would mean around 18mA draw per IO pin.

MarkT:
Ooh, can we see picture or link to these tiny steppers?

Two types I'm trying to drive with minimal extra circuitry. The first one (not out of a camcorder, d'oh - got my steppers confused - it's from a cheapo Chinese electronic rev counter dial) :

All it has to move is a tiny plastic needle indicator. Inside, it's more like a watch mechanism than a normal stepper:

Two coils, some metal plates to carry the magnetic field (I really don't know what I'm talking about but it all sounds plausible), and the tiny little black cog in the centre is magnetic.

It was a bugger to get back together the first time :slight_smile: It works really well, though; it's surprisingly strong and with the help of the Arduino AccelStepper library it's fast, accurate and repeatable too.

If I can drive them without killing the ucontroller, these are the camcorder lens motors I want to drive. They're like miniature floppy drive head motors. The photo makes them look way bigger than they are in real life. Dinky, huh :slight_smile:

Atmega168 TQFP on the left, 0805 resistor below. (Old obsolete key, feel free to make copies - they won't let you into my secret workshop :wink:

howiem:
Using Schottkys in the configuration you suggested would protect against voltages over 5.33v (assuming BAT-43s with a .33v drop), which is only half a volt-ish more protection than the zeners but with double the component count - is this enough of a reason to use your 8-diode method over my 4 zeners? Is there another reason not to use zeners?

If you use zeners, you need to be sure that the reverse-biased zener + forward biased zener will not conduct at 5V (or whatever the supply voltage happens to be), but will conduct before any appreciable current flows through the pin protection diodes (I would choose 5.5V as a maximum). So it depends on the tolerance of the zener diode. A 4.7V 5% tolerance zener plus forward-biased zener might start to conduct at 5.065V if it were at the bottom of the tolerance range, or at 5.535V if it were at the top. So it's possibly just good enough.

If you are not careful, you may drive the stepper before the supply voltage has reached 5V, and in that instance the zeners will not protected the MCU, which might lock up.

So I think the Schottky diode solution is better, even though it requires more components.

As the calculated current is only 18mA, one other possibility is a snubber (resistor and capacitor in series) connected across each winding, where the resistor has a value lower than the winding resistance. The minimum value of the capacitor depends on the inductance of the winding. It might turn out to be physically rather large, bearing in mind that it can't be a polarised electrolytic capacitor.

I would like to add this to the discussion:

I feel you have set a new standard for taking high quality macro photos. I could count the hairs on a gnats behind if he were sitting on your motors.

If I was connecting anything else coil-based (like a relay) to an Arduino, I'd stick a diode across the coil facing the other way, so when the coil's power goes off and the magnetic field collapses, any voltage it generates can dissipate through the diode rather than zapping my Arduino. That approach won't work with my stepper, as the voltage across the coil could be in either direction depending on which step the motor's at.

DISCLAIMER - I haven't completely thought this through, or analyzed the circuit and current flow.

You can reverse the coil connection, but from the Arduino's point-of-view, you cannot reverse the output polarity and put-out a negative voltage. So, I think a "regular" diode (silicon or schottky) to ground on each Arduino output will protect it from negative spikes, and another diode to +5V will protect it from positive spikes over 5V.

Yup, that's the standard way to do it - but they need to be fast diodes, not 1N4001s. schottkys are inherently fast, 1N4148's are extremely fast too (designed for logic switching). Best to ensure decoupling right next to the diodes too to absorb the spikes at source.

But personally I don't like the idea of directly driving inductors this way, convenient though it is. Certainly schottkys are preferred for a bit of extra margin.