Avayanic Electronics Articles

 

Bipolar Stepper Microstepping Controller (Using the A3977)

 

 

Large DC Motor Controller (Using the TD340I)

 

 

11 RC Servo Controller

 

 

Inductive Load Driving

 

 

 

 

|<<>>|

 

 

Ahh!! Stepper motor control! Have I done many times in the past. Long hours have I spent taken microcontroller timers and programming the heck out of them to coordinate GPIO into A, A*, B and B* signals; Digital to Analog Converters to control Reference Voltages which then set a finite point to limit motor current; PWM generators which fed through an RC filter generate a sine wave like output which is then embedded into the phase information of an H Bridge; and so on...

To what extent? Well to control a stepper motor with all sorts of speed, position and resolution control. Most of my application on this site (under the Super Stepper Protocol) have to do with taking a microcontroller and doing all which I mention before, to control a fairly antiquated H Bridge and its respective Bipolar Motor. Today, that is not necessary anymore.

Here comes the integrated indexed microstepping controller/driver chips which take a measly STEP and DIR signal and take care of the rest. All you need to do is clock the STEP input and modify the DIR input accordingly. It can not get any better than this!

Introduction:

In this article, I explain my implementation around the Allegro Micro’s A3977. This device contains all the logic you need to control a Bipolar Stepper Motor with up to 8 degrees of microstepping. Yes, it is not 64 degrees of microstepping and not thousands upon thousands of steps per revolution. But do we really need this?

The picture below, shows a block diagram of my module, which I called MDL-STPR77 as it is a stepper module around the A3977.

BlockDiagram_MDL_STPR77

My module was designed with two projects in mind:

  1. General Purpose Robotic projects using steppers where the module can be interfaced by means of any conventional microcontroller
  2. CNC based equipment where a computer supplies STEP and DIR pulses, as per the GCODE output, through the Parallel Port.

Hence, there are basically two ways to wire the device depending on how it will be used. The board has many ways of connection power, control signals and motor outputs. I like versatility with the intent of a single design able to suit as many applications as possible.

In the upcoming sections I explain all of the flexible levers this little 2” X 2” module has to offer. I recommend the reader to also check Allegromicro’s datasheet as I will not go very deep into how all the A3977 signals work. They have more than enough graphs and diagrams to show its behavior. However, this device is so easy to use, you may not need to read their document before you start using it!!!

The Controller:

To move a stepper, you need to tell the stepper to move in steps (DUH!). Sounds obvious, but it is very important to realize stepper motors are not like DC motors. In DC motors, you apply a voltage and the motor moves. With steppers, applying a voltage may make the motor move a measly step (if you are lucky) and that is it. If you do not modify the magnetic field at the stepper windings, it will not move any more.

It is the controllers job to modify these magnetic fields in order to generate another step. Believe me. It sounds simple, but it is not. The magnetic fields have to be modified on a particular order, or the motor will move erratically. How much do we have to worry about all of this mambo jambo? NOTHING!!!

The A3977 controller takes care of everything. All we have to do is generate the steps and that is done by consecutively toggling the STEP pin. It is just gorgeous!

Whenever STEP goes from LO to HI, the internal circuitry computes what is the next step like, and the voltages and currents are set accordingly. Another LO to HI transition, and the stepper moves yet another step. Keep on with the transitions, and the stepper keeps on moving. Stop the transitions, and the stepper stops moving. It is as simple as that!

But how fast will the motor move? It depends on how fast you clock the STEP pin! If the STEP pin is being clocked at 1 KHz, the stepper will move at 1000 steps per second. If the stepper is a 200 steps per revolution, then it will move at 5 Revolutions per Second or 5 RPS. This may be too fast, so do not get discouraged if your motor can not make it this fast. I will discuss some other techniques to enhance the chances of making it work, though.

What about Direction? My motor is moving forward, but I want to change to the reverse rotation. It just so happens, that once again this is not as easy with stepper as it is with DC motors. With a DC motor you reverse the voltage polarity and POOM! The motor starts to move on the opposite direction. With a stepper, the very intricate sequence of steps has to be reversed.

Well, guess what? You do not have to worry about this either! The A3977 takes care of all this nightmare by giving you a DIR pin. Make this pin LO and the stepper rotates in one direction. Make the DIR pin HI and the stepper rotates on the opposing direction. Which one is which (i.e. Clockwise vs counterclockwise)? That will depend on the motor and how you have hooked it.

GREAT! The stepper is moving and now it is stopped. But boy, the longer I leave the motor standing the hotter it gets. How do I stop this?

Steppers get hot because they are always sinking current. And most of the time this current is whatever current you give it. So they are bound to get hot. The idea is to only pump current when you need the motor to move or hold its position. Otherwise, turn them off. So how do I turn my system off?

In DC motor land we often have an ENABLE line which basically turns the motor on. The A3977 has the same ENABLE line which will disable the H Bridges and stop current flow to the steppers.

ENABLE is not to be confused with SLEEP. Although they would both disable the H Bridges if asserted, the SLEEP goes an extra step into power consumption. When SLEEP is asserted (LO) everything is disabled and the device consumes very little power. De-asserting ENABLE only disables the H Bridges, so the other circuitry remains turned on and consume some power.

I have placed two ways of controlling SLEEP. Through the J3 connector, SLEEP can be interfaced via a microcontroller. To do this, allow the SLEEP jumper to float. However, the SLEEP jumper can be used to set this signal either HI or LO, if a microcontroller is not to be used.

This feature is convenient when using the module in a PC based CNC system. Since the PC parallel port only supports ENABLE/STEP/DIR, the SLEEP must be tied externally to the PC system. The jumper just makes it easier.

That is all you need to move the stepper. In the upcoming articles, I detail how to move the stepper properly, plus:

  • How to configure maximum current
  • How to select microstepping rates
  • How to restart the microstepping indexer.