A simple algorithm for microstepping a bipolar stepper motor

Jose Quinones, Texas Instruments

July 11, 2011

Jose Quinones, Texas Instruments


Current regulation
To induce multiple microsteps embedded into a single full-step, we must have the capability to regulate current. The great majority of integrated H-bridges commercially available have some means to achieve this goal. Current regulation is then easily obtained by measuring current flowing through a SENSE resistor as shown in Figure 2.


Click on image to enlarge.

Figure 2.    A SENSE resistor in series with the motor winding gives off the dropped voltage, which is directly proportional to the winding current.

The SENSE resistor is in series with the motor winding, so we are measuring the actual winding current. The voltage drop across this resistor is amplified by some known gain. We need to amplify the voltage, as the resistor is fairly small, in order to minimize losses. The amplified version is then compared against a reference voltage (VREF). When the winding current gives off a voltage such that it is larger than the supplied VREF, the H-bridge is disabled for a fixed amount of time. After this time elapses, the H-bridge is enabled again. The process to disable the H-bridge as current reaches an ITRIP target, is repeated ad infinitum, giving us a regulated current.

This reference voltage is provided by the application. If VREF is modulated, the winding current is then also modulated. This is how we achieve microstepping. If the current magnitude changes, so will the stator magnetic field change. By controlling the winding current, we can then control the stator magnetic field strength, which in turn controls the rotor position.

For example, if a 200 step stepper is commutated with full current, then each step is 1.8 degrees. But if the same motor is commutated with full current and half current, then each step is 0.9 degrees. We can keep subdividing the current by as much as we want and we will always obtain even smaller step sizes or larger resolutions.

Microstepping commutation
Bipolar stepper motors are often commutated with full-steps by coordinating each winding phase current in one of the four possible pattern combinations, as shown in Figure 3. These combinations are: HI-LO, HI-HI, LO-HI and LO-LO, where HI implies current is regulated to IMAX and LO implies current is regulated to –IMAX. If we follow this sequence, the motor moves in one direction. If we now reverse the same sequence, the motor moves in the opposing direction.


Click on image to enlarge.

Figure 3.    The typical quadrature pattern used to full-step commutate a bipolar stepper motor.

Rotor position is controlled by counting the number of steps being issued with regards to a known starting point. To set up the stepping speed, you would then coordinate the amount of time in between steps. Speed is then the inverse of this time with the unit of measurement being the step per second (SPS).

A way of generating these steps is to use an internal timer resource configured to count time intervals. Its interrupt service routine (ISR) can then be used to update the phases according to the desired direction of rotation. For example, if the current step is at quadrature position HI-HI, you would issue a commutation polarity of LO-HI to move the motor one step forward, or HI-LO to move it backwards.

By adding the VREF magnitude modulation to the H-bridge circuitry, we add a current component on top of the full-step commutation, which gives us microstepping commutation. Figure 4  shows this mechanism.


Click on image to enlarge.

Figure 4.    VREF modulation information is embedded on top of the full-step commutation, resulting in microstepping commutation being applied to the bipolar stepper motor windings.

Notice the PHASE information is always a positive value. However, when PHASE is HI, the motor winding current is positive, whereas when PHASE is LO, motor current is negative. Hence, the digital signal PHASE (also called DIRECTION on some H-bridges) gives us current direction, not current magnitude. Current magnitude is obtained by modulating VREF.

In the following example, we embedded half of a sine wave shape into the VREF terminal. In essence, you can use any continuous wave shape as long as it offers soft motion. Sine waves are industry standard, but they are not a requirement. Designers are encouraged to try any other wave shape that can offer good results. This level of flexibility is one of the main advantages of using a microcontroller or digital signal processor (DSP) to achieve microstepping.

The result of embedding VREF information on top of phase information is an AC signal, in this case a sine wave used to commutate each stepper motor winding. So how do we generate the VREF information?

To generate VREF we use some form of DAC module. Since bipolar stepper motors are made of two windings, two DAC channels are required. If a real DAC is not available, a high-speed pulse-width modulation (PWM) output with a low-pass filter can be used to create a crude, but equally useful, programmable analog voltage. The analog magnitudes into this analog output come from an internal lookup table storing the wave shape we have determined to be appropriate for our application. Every time a step is issued, said value is fetched from the lookup table and into the DAC register.

There are a few key notes you must have in mind when it comes to generating and using this lookup table. First is the lookup table depth. This table needs to hold as many elements as twice the number of current settings. That is, if you want to divide each full-step eight times (eight microsteps), you need eight current settings, and the table will be 16 steps wide. This takes care of 180 degrees worth of information. The other 180 degrees comes from reusing the table in its entirety, but for the alternate polarity. That is, we use the table for positive current and then the same table for negative current.
< Previous
Page 2 of 3
Next >

Loading comments...

Most Commented

  • Currently no items

Parts Search Datasheets.com

KNOWLEDGE CENTER