A simple algorithm for microstepping a bipolar stepper motor
Here's a simple algorithm that uses conventional microcontroller blocks to control commercially available H-bridges to properly commutate a bipolar stepper motor through a microstepping profile.
Bipolar stepper motors offer a simple way of achieving position control and accurate speed actuation without the need to close the loop through shaft encoders or similar means. To improve performance, we can employ a technique known as microstepping in which a sine wave current wave shape is embedded into the typical full-step commutation wave form.
This article details a simple algorithm utilizing conventional microcontroller blocks to control commercially available H-bridges to properly commutate a bipolar stepper motor through a microstepping profile.
Stepper motors are an excellent motion actuator because they move in steps. This gives us two inherent advantages: 1) position can be easily obtained and maintained by moving a number of steps and then stopping; and 2) an accurate speed can be obtained by properly scheduling the steps in a timely manner.
As a result, steppers can stop at a given angular position and hold that position against external load changes, and at the same time the motor speed can be maintained even when the system undergoes changes in power supply voltage. Whereas other motor topologies could not achieve any of these two feats without the proper amount of closed loop control, the stepper excels at both without the need for any form of closed loop.
However, stepper motors are not perfect, and there are areas in which their performance is severely affected. The most crucial of these inefficacies is resonance, or a vibration induced by the generation of subsequent steps at a time in which further motion is exacerbated. Figure 1 below illustrates what happens to the angular position as a full-step is generated. As the rotor is scheduled to land on the next step, 1.8 degrees away from the current position, it actually oscillates around this angular region before settling at the target.
What if we scheduled a step when the position is farther away or closer to the next step position? When this happens, the distance traveled by the rotor will be much more or much less than what it would have been had the rotor started from the goal position.
Actuation at these speeds is what causes the motor to vibrate and loose torque. It is very easy to see where the vibration-inducing speeds lie on a particular motor, if you slowly accelerate the motor from a slow speed to a higher speed. You will notice the regions where vibrations increase and decrease as the speed is ramped up.
Click on image to enlarge.
Figure 1. A commanded full-step and its angular position oscillations before settling. If a step is issued in a spot in time such that the position is too far off, resonance effects can be observed.
Both vibration and loss of torque are highly undesirable traits for any motor actuator. Therefore, when operating a stepper motor, it is crucial to eliminate both scenarios from the design. One option is to limit the current to such an amount that it reduces the vibrations considerably. Unfortunately, if this current is not dynamically modulated with load changes, the system suffers from step loss, an even worse threat, as the speed and position accuracy are heavily compromised.
A better solution is to eliminate the vibrations by decreasing the distance the rotor must cover on a step-by-step basis. Motors are built to accommodate a step resolution. A 200-step motor moves 1.8 degrees per generated step. If somehow we can divide each step into several microsteps, then the distance traveled is less than 1.8 degrees. With smaller step motions, we need less energy to reach the target position and the vibrations should be minimized.