Wednesday, May 30, 2012

The Least You Should Know - Stepper Motors pt. 2

If you want to control and drive stepper motors, you can either build a discrete transistor switching circuit or use one of the many off the shelf solutions.  There are integrated circuits that handle most of the nitty-gritty details for you.  For example, a part which has been around a long time, and used by both industry and hobbyists is the Allegro Microsystems A3977 (datasheet here).  The A3977 is designed to take two signals, a clock that times each step, and a logic line to tell it which way to turn, and make those into the analog signals (currents and voltages) to drive the motor.  These are usually called "step and direction" inputs, and a computer parallel port drives them - with some attention to details.  I will just give a couple of brief examples of the drive signals.

The essential way to drive a motor is to give it pulses 90 degrees out of phase to each other on the two windings of the motor.  The timing of this is shown here:

The motor will move one step when given a set of pulses like these.  If the phase lead reverses, so that winding 1 is behind winding 2, the motor steps in the other direction.  You can run a motor all day this way.  One of the tricks that controllers like the A3977 do is called microstepping, dividing each step into up to 8 steps.  The current driving the motor changes more smoothly, approaching a pure sine wave, like this:
Microstepping smooths the motor's motion, and helps with resonance issues, but you can't guarantee that the position is accurately 1/8 of the previous step - which would make the motor I showed last time give 1600 steps per revolution (.225 degree per step).  Wait - resonance?
At specific step rates stepper motors often experience an undesired reaction called resonance. The indications are a sudden loss of torque with possible skipped steps and loss of synchronization.  Resonance is inherent in the design and operation of all stepping motors. Slow stepping rates combined with high rotor inertia and elevated torque produce ringing as the rotor overshoots its desired angular displacement and is pulled back into position. Resonance arises when the step rate coincides with rotor ringing, typically about 100 to 200 steps/sec. Unable to overcome the combined effects of both load inertia and ringing, the motor skips steps and loses torque and synchronization.
If microstepping doesn't stop resonance issues, it has been found that changing the speed or the inertia, usually with some sort of extra load, will cure resonance.  I've seen washers stacked up, and even custom thingies.

You will find stepper motors specified by the current on the coils and small voltages.  A typical example might be 3 or 4 Volts at 2 amps.  The high voltage applied to the motor through a part like the A3977 is often 25V (it needs to be under 35 No Matter What Happens).  This is to allow the chip to hammer a leading edge spike into the motor to help overcome the back EMF and get the thing moving. The voltage settles to what the winding allows. 

Stepper motors can be very useful to have around.  They are the muscle moving all sorts of systems.  The biggest disadvantage is that once you send the command to move, you have no idea whether or not it really moved, and if it did move, if it moved the right number of steps.  Lost steps are the bane of stepper-based systems and can lead to ruined work or damaged systems. 

More as I try to figure out what else is a good "least you should know".
 

6 comments:

Anonymous said...

I seem to recall some steppers w/position feedback available, but fell short of servo system performance and cost - or does my memory miss steps?

itor

Graybeard said...

I don't think I remember that. But me not remembering things doesn't mean as much as it used to.

LeverAction said...

These last two posts are great stuff! I've never taken the time to research steppers (because I haven't yet had the need), but I love learning about new stuff. Last time I did anything with motors was back in design lab courses in college, and that time we had to build our own H-bridges and drive it with the PWM outputs from a microcontroller. I might just be referring back to this one before too long... Thanks!

Graybeard said...

Glad you like, LA, and good to see you again.

You could certainly do it that way, and it's probably a good skill set to have, but the modern chips make it so convenient. Follow the rules of layout and use, and they just plain work. Do all the fancy stuff for you. I was reading a product announcement today at work, for a controller that will microstep in 128th steps, instead of 8th!

Just keeps getting better and better.

Bob said...

SG - Back in the mid '80s I worked on a chip sorter project that replaced mechanical activation & controls with steppers; we used generic 1.8 motors and Compumotor controllers, which changed the 200 step/rev motors to 5K step/rev. If you used their motors you could get 25K step/rev. One neat result was the ability to control ramp up/ramp down speeds and stepping speed differently on each motor, rather than accept the unchangeable speed factors on an induction motor-driven mechanical drive. That alone, by replacing one slotted cam drive, increased throughput about 20%. One challenge we faced - that you mentioned - and never solved completely, was tracking executed steps. If you sent an 1800 step command to stepper D, did the leadscrew actually complete the result of 1800 steps, or only 1792? We were able to incorporate a single LED between two perforated wheels bracketed by a pair of sensors that had an accuracy of +/- 5 steps, which was about 4 minutes either way, and that worked OK within in our tolerances (more closely tracking the accuracy of one step command/step execution would have been nice, but cumulative error over several step commands was more accurate and told us what we needed to know).

Been out of it since early '90s, but looking at CNC developments since then both motors, controllers and sensors have gotten a whole lot better.

Graybeard said...

Yeah, the ability to change speeds and accelerations is a strong advantage to steppers.

A reciprocating drive is a common need in mechanical design and was solved ages ago: a rotating shaft with a cam to push and pull pistons is an example. With a stepper, command a phase reversal and you reverse; you can do that so fast the momentum change will tear your system apart. Do it with an acceleration ramp and you get reciprocating motion.