Stepper motor help.

Hola, I just bought my arudino, and a stepper motor with other stuff. I really am confused on the stepper motor portion. It only has a red, black, yellow, brown, and orange wire?? How does that work? I tried using the example code. I want to make it turn a full 360 degrees when I flip my toggle swith on, then when I turn the switch in the off position, it goes backwards 360 degrees. I.e ,my project box has a green led, a toggle switch (has a line and a circle)and the arduino controlling the stepper motor

sorry for such a noob questions.

You need a stepper motor driver. Pololu has a great selection and provides excellent customer support. Pololu - Stepper Motor Drivers You will also need a separate power supply for the motor and driver. It is a bad idea to use the Arduino or its power supply to power any motor.

You will need to give us a lot more information ...

What Arduino do you have?

What stepper motor (include a link to its specification)? If you haven't already got one, be sure to get one that's suitable for your motor (or ask for advice here).

What stepper motor driver board (with a link)?

Post the code you are using. Please put the code between code tags using the # button above the edit window.

...R

Steppers can be real confusing for sure. Lots of styles, voltages and configurations. That never helps.

The idea is pretty simple, at least at the start. The motor uses two different windings to turn the shaft in digital steps. It might take say 8 steps to turn the shaft one full turn. But such motors would be coarse and weak so they usually have a gear box built in to slow the shaft out (and give it more power). IIRC the common little 5 Volt stepper, 28BYJ-48, is 32 steps per shaft turn with a 64:1 gearbox for 2048 total steps to turn the output.

Confusing enough?

There are several schemes for doing this, but generally you energize one of the four coils then also turn on one of the two ‘next to it’ (clockwise or CCW) before shutting it off again. You then have only one on, but turn on the next one in line before shutting it off again in turn. There’s always one or two of the coils (always side by side) on at any time. Or not. This can also be done with only two coils by pushing current both ways through each to get the ‘four beats’ needed to play the song. The most common motors share a common positive lead, and four minus leads like yours. In practice the positive lead is actually center tap (two actually, two sets…) but that’s another story. Each motor can have several sets of poles, our 32 step example has 8 such sets. Run each through four counts (32 steps) and the motor shaft turns once inside. Do that 64 times and the output shaft turns once (slower, but with more authority).

In your case, using that motor you’d simply call for 2048 steps one way, then the other.

A nice refinement is a calibration step. Write your setup so that the motor starts one way and rotates until a switch (or better still disk with a slot for light to get through) tells the Arduino the motor is ‘home’ so you always know where the shaft really is?

Good luck.

RG

ok, jremington is right if he says that you need a stepper motor-driver. but you dont need the ones he has shown you in his link.

a simple L293DNE should work fine, as described here:

hope this could help?!?
cu

The L293 devices are poor choices for driving stepper motors.

"Proper" stepper motor drivers just need 2 connections to the Arduino - step and direction - which makes them very easy to program. And they usually have the ability to limit the current in the motor coils so that you can drive the motor with a much higher voltage for better performance. And they can usually have the inbuilt ability to do microstepping if you need more precision.

Even if I didn't need the extra performance I would choose a proper stepper drive just for the convenience.

...R

since you have a 4 wire stepper, you need to drive it with an H-Bridge. if you have the parts, you can make one using transistors.

if you want to buy one, there are lots of choices.
the L298 is really only half the solution. the L297 is the other half.
the L298 requires 4 wires and programming to sequence the chip.
the more desirable solution is to have only pin out for pulse to make the steps and one pin out for direction.

be careful of the cheap L298 boards few have sense resistors so are always driving maximum power into the motor.

if you had a 5 or 6 wire motor, you would have more options for driving it.

The L293 and L298 motor drivers are old technology and won't work for a large fraction of the available stepper motors.

To decide which driver to use and how to power a stepper motor, you must know the voltage and current ratings (or the current rating and winding resistance) of the motor. If the motor is rated at less than 5V or greater than 1.5 amperes, or has winding resistance of less than roughly 10 ohms, you need a modern "chopper style" driver, like the A4988 or DRV8825.

What are the ratings of your motor, or what are the markings on the motor body?

dave-in-nj:
since you have a 4 wire stepper, you need to drive it with an H-Bridge.

but he said

. It only has a red, black, yellow, brown, and orange wire?

So unless I have forgotten how to count that is five, which means it is a unipolar motor and therefore he does not want a H-bridge. Nor any of the drives quoted so far.

I've never heard a good argument as to why a five wire stepper motor won't work with an H-bridge driver and I'm wondering if this common belief is actually a myth.

If connected as a bipolar motor, during normal operation in full step mode with a bipolar motor driver, the fifth wire (common center tap for all windings) is always at about ground potential and should be left open. This assumes that the winding resistances are all equal, but I've not encountered a motor where they aren't.

So, I did some tests. Despite the claims made by Pololu and others, five wire stepper motors seem to work well under various test conditions with bipolar drivers. I verified proper operation of two different five wire stepper motors under full step mode, one with a significant load, using the Pololu A4988 driver. I checked the potential at the fifth lead relative to motor power supply negative with a scope and although there were small spikes, there did not appear to be anything to cause concern.

During microstepping there may be cross talk between the two windings through the center tap, but if so, how deleterious is it? If anyone has experience to the contrary, or knows a good argument for why five wire steppers should not be used with bipolar drivers, please chime in!

've never heard a good argument as to why a five wire stepper motor won't work with an H-bridge driver and I'm wondering if this common belief is actually a myth

No not a myth it is true. Look at how the two motors work:-
http://www.thebox.myzen.co.uk/Workshop/Motors_3.html
http://www.thebox.myzen.co.uk/Workshop/Motors_4.html

So, I did some tests. Despite the claims made by Pololu and others, five wire stepper motors seem to work well under various test conditions with bipolar drivers.

What sort of tests did you do to "verify" this? Are you confusing work with work correctly?

jremington:
I’ve never heard a good argument as to why a five wire stepper motor won’t work with an H-bridge driver and I’m wondering if this common belief is actually a myth.

During microstepping there may be cross talk between the two windings through the center tap, but if so, how deleterious is it? If anyone has experience to the contrary, or knows a good argument for why five wire steppers should not be used with bipolar drivers, please chime in!

The classic objection is, I think, the ‘abnormal’ condition. Say when both sides of one bridge are high or low (allowed in most cases I think?) the center taps are linked still. The means one coil and one of the 8 pass elements is working harder than the rest. Otherwise, yes, running I think it’s balanced enough.

A better question might be ‘why do it?’. The maker went to extra trouble and expense precisely so you could use cheaper (and often more reliable) parallel driver chips like the 2009 based ones that usually come with the little 5 Volt steppers in the kits.

RG

What sort of tests did you do to "verify" this? Are you confusing work with work correctly?

I ran the two motors under various loads and at various speeds. They provided similar torque, and ran at a similar number of steps/second (maximum) without cogging, as compared to operation with a unipolar driver . There were no particularly worrisome spikes or long term deviations from zero volts relative to common in the 5th lead. That, to me, is correct and normal operation. YMMV.

RetiredGuy raises a couple of good points, including "why bother" -- fair enough!

I thought so. So you never looked at the waveforms then nor assessed the stall speed.

hi again!

since i am new to arduino and motors and things like that: can someone explain the difference between the l293dne as i mentioned and the A4988 or DRV8825 as jremington said?!?

thx for your help!

You can drive a 5-wire stepper from an H-bridge, but you have to ensure each winding is
either open-circuit at both ends or driven one end high, one low. In these modes the centre
tap is at midrail for both windings.

You cannot use PWM (unless its carefully arranged to fit the above rule, which is not
normally the case)

You can never use a chopper drive.

Unless you have full control on all four switches in your H-bridge it may be unable to
fulfil these constraints.

jn-wp:
can someone explain the difference between the l293dne as i mentioned and the A4988 or DRV8825 as jremington said?!?

The L293 and L298 are h-bridges that are primarily intended for controlling DC motors. They can be used to control the current in the coils of a stepper motor but all the “intelligence” about the order of magnetizing the coils has to be provided by the Arduino. They also need 4 connections to an Arduino. And the motor can only be driven with a voltage that doesn’t overload the motor coils.

Proper stepper motor drivers like the A4988 only require two connections to the Arduino - step and direction - and the driver does all the complicated stuff to energize the coils in the right order. The proper drivers are usually also able to drive the motor with microsteps for greater precision - a 200 step motor could be driven with 3200 steps per revolution without any extra “intelligence” needed in the Arduino. Another very valuable feature of proper stepper drivers is the ability to measure and limit the max current in the motor coils. This allows a motor to be driven with a high voltage (30v or so) which allows it to maintain its torque at higher speeds.

This document may be useful http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/CD00003774.pdf

…R

…R

jn-wp:
hi again!

since i am new to arduino and motors and things like that: can someone explain the difference between the l293dne as i mentioned and the A4988 or DRV8825 as jremington said?!?

thx for your help!

now that I have checked and realized that 5 wires are used... this question becomes more academic.

not sure of the definition of 'proper' is in electronics. maybe a different post?

but the L298 is an H-bridge. it has inputs to allow you to use sense resistors so you can control the output current to the motors and not either under power or over power them.

read up on micro-stepping. you can power one coil and the motor will lock into that position. you can power one coil, then another and the motor will lock between the two. this is called a half step. if you charge one coil, release it, then a second, the motor will move from one step to the second step. if you repeat this the motor will spin.

the logic would be 1-2-3-4-1-2-3-4.... and the motor will spin one way. or 4-3-2-1-4-3-2-1.... and it will spin the other way.
there are logic chip that will see only two signals. one is either high or low. the other is simply a pulse input.
so, if you you have the pin high, the output will be 1-2-3-4-1-2-3-4..... the rate of change is dependent on your pulse input.
bring that first pin low and it goes 4-3-2-1-4-3-2-1.... again. the speed of the pulse dictates motor speed.

micro-stepping a whole different process. as stated above, half stepping is powering two coils at the same time. one could quarter step. or charge one coil more and the second one less. this can be done in quarter steps, eighths steps, 10th's, 16's, 32's, 128's.......

but, in reality, the motor can only move in half or quarter steps. the reason for the micro-steps is to have the motor move between steps with a smooth transition. the holding power between coils falls rapidly as the number of micro-steps increases.
http://www.micromo.com/microstepping-myths-and-realities.aspx

stepper motors are low speed devices. when you try to spin them fast, they get in their own way and miss steps. the micro stepping is a way to get more speed out of a motor without missing steps.

bottom line, if you can, get a step and direction driver board. your sketch will be much simpler and the control of the motor much easier.