# Optimal Step-Motor Control

A previous article (Standard Step-Motor Driver Interface Limits Performance) on step-motors berated open-loop stepping and the desperate methods used to avoid missed steps and acceleration limitations. This article outlines a path to simple step-motor control that avoids all these historic step-motor problems by using closed-loop phase control of the motor.

What Are Step-Motors?

If you know electronics but not motor theory, then the following explanation is for you: an electronic view of motors. Most step-motors are what motor people would call permanent-magnet synchronous (PMS) motors with two-phase windings and a particular construction that results in many pole-pairs, typically 40 or 50. A synchronous motor has the stationary or stator winding electrical waveforms in synchronism with the rotor magnetic waveforms. To avoid slip rings or brushes, the rotor produces a magnetic field with attached permanent magnets. This field when in motion across the stator windings induces a voltage in the windings just as a transformer winding induces a voltage into another winding, by a change in flux with time, or v = d λ/dt .

Two stator windings can be oriented so that the magnets induce voltages 90 degrees apart, as shown below.

Size 34 step-motor induced-voltage waveforms measured at the winding terminals.

The bottom trace leads the top trace in phase by 90 degrees. Its zero-crossings occur at the extrema (peak and valley) of the top waveform. The mechanical frequency (rotational speed) of the motor can be measured by measuring the electrical frequency of the induced-voltage(s) and dividing by the number of pole-pairs of the motor. Each electrical cycle, the rotor advances by one pole-pair and the mechanical frequency in Hz is the revolutions per second.

To produce torque, the windings are driven by currents in-phase with the induced voltages. By Watt’s Law, P = v x i , and the motor converts this electrical power to mechanical power. The phase offset of the windings allows the field-current vector to rotate in 2D in synchronism with the rotor magnet flux vector to produce torque. When the winding currents and induced voltages are in phase, the motor produces the maximum torque and is said to be field-oriented . This is the basic goal of motor phase control . The amount of current in the windings controls the amount of motor torque. Thus, motor control is vector control – control of current phase and magnitude. The current is a vector because the current of each winding is a vector component of the total motor current which is made to rotate with the rotor. When the winding current is referred to the motor magnetic field, it is field-referred current , often called MMF.

A typical small step-motor has two center-tapped windings with six leads total. The center-taps make it possible for the winding to produce either polarity of flux using unipolar currents. If the center-tap is connected to the positive supply, Vg , then transistor switches to ground on the winding ends can direct current through either half-winding. This results in phase resolution of 90 degrees because each of the two windings can be driven with one of two polarities. These 4 steps of phase per electrical cycle are called full steps . By driving two windings at once, resolution is doubled to 8 half-steps , though the torque magnitude varies with steps, causing vibration. This phase resolution is low and is a crude scheme for phase control, but the motor-drive can be implemented with only four grounded MOSFETs! The lack of phase resolution results in digital-style nonlinearities (limit cycles) in motion and can be remedied by adding more steps by PWMing the MOSFETs. Hence, the step-motor-drive industry moved to microstepping . Motion is still commanded in digitized increments but there are more of them and the current magnitude is controlled based on the phase angle.

Why Phase Control?

Open-loop stepping is limited in control and is well-known for multiple anomalous behaviors. It is like trying to synchronize an oscilloscope by using the holdoff control instead of triggering. If the time delay set by the holdoff control is adjusted “just right”, the horizontally-drifting displayed waveform will slow down and then stop. This is “open-loop synchronization” and is essentially what open-loop step-motor drives try to do. There is no phase feedback from the induced-voltage waveforms of the motor. Consequently, step pulses must be timed “just right” to advance the motor to the next step. Uncertainty in the stepping keeps the motor from achieving maximum torque and acceleration and causes the motor to exhibit nonlinear resonant behaviors.

These serious limitations go away by using the winding induced voltage as a feedback variable of motor phase. One major problem is in sensing the phase while driving the motor. If driven by a current source, the induced voltage appears across the source. Except for very small motors which can be driven with analog amplifiers, motor windings are driven by what are essentially switching amplifiers that are PWMed. During the off-times, no drive from the source is applied to the windings and the induced voltage appears and can be sensed, as shown below.

The negative half-cycle of the induced-voltage waveform of one of the two phase-windings (lower trace) is being driven by the PWM waveform (upper trace), which is shifted to the right somewhat relative to the winding voltage of the lower trace. The PWM high level is the on-time which closes a switch to ground in the lower waveform. (The duty ratio is low but is highest in the center, where the minimum induced-voltage “peak” occurs.) Because the PWM frequency is not much above the electrical motor frequency, the induced voltage can be clearly seen in the lower trace. If the switched drive current is sensed and controlled, then the switching amplifier behaves as a current source and the induced voltage – although chopped by the switching – can be sensed across the winding and filtered out and recovered if the PWM frequency is much greater than the motor electrical frequency.

Another obstacle in recovery of the induced voltage is the series impedance, Zw , of the windings. This is series R and L, and they drop voltage with winding current that adds to the induced voltage. It is not desirable that winding current cease during the PWM off-time because torque is proportional to the current and a constant current produces “smooth” torque. (Torque ripple causes vibration.) The large motor magnetizing inductance reduces this current ripple. The Zw voltage, however, is large at low speed and high torque. It can be compensated as a series RL time constant and has a motor-specified R. If the drive senses winding current, then the voltage across Zw can be determined. Consequently, the induced voltage can be recovered if the motor is spinning.

The most serious limitation of phase-feedback control is at low motor speed. The voltage induced in the windings is proportional to the speed. The rotor magnets produce a constant flux. Then the speed-related induced voltage is

where λme is the electromechanical flux of the motor, the single parameter that relates the electrical and mechanical sides of the motor, as shown in the motor model below using the torque-current analogy for the mechanical side.

The two equations that relate the electrical and mechanical sides are the torque equation,

and the induced-voltage equation,

When the motor is driven field-oriented (winding current, i , aligned in phase with vϖ ) then these equations and the motor model are valid.

In commercial motor specifications, λme is often designated as KV (“voltage constant”) or KT (“torque constant”). They are the same parameter, though this is obscured by writing them with different, though equivalent, units. If you keep in mind that a

and is a unit of flux, then you can convert between the two equal motor parameters.

One scheme for recovery of the motor flux is to use an op-amp or running-average μ C algorithm to integrate v ω . Not only does integration remove high-frequency noise, the integrator output has constant amplitude over motor frequency until at very low speed, the integrator output collapses. In this low-speed region of step-motor operation, the simplest way forward is to revert to open-loop microstepping. At very low speeds, the motor dynamics are negligible (unless the motor is made to go through zero speed at high acceleration), the motor settles into a slightly different position each step, and at low speed can reverse direction easily too. More sophisticated low-speed methods exist. Some of them are used to determine motor phase for starting hard-disk-drive spindle motors. They must rotate in the correct direction from zero speed to avoid “flying” the heads into the disk.

In summary, adherence to a rather simple idea of “listening to what the motor is telling you” is the clearly superior route to step-motor control. It results in being able to drive the motor to its full performance capabilities so that it behaves like a brush motor. Field-oriented (or vector ) control has been replacing open-loop stepping and can also be equally-well applied to three-phase PMS “servo” motors.

Postscript: If there is enough interest among the readership in building your own prototype motor-drive of this kind – with winding-sensed or “sensorless” control – I will consider a project series, replete with source code and circuit diagram. A ready-made version might also become available in that case through my website

## 0 comments on “Optimal Step-Motor Control”

This site uses Akismet to reduce spam. Learn how your comment data is processed.