This month, Don wraps up techniques for determining angular position and turns the discussion to sensorless control.
For some time now I've been writing about motion control and digital signal processing (DSP). Throughout our discussions of DSP's role in control functions, we have seen the importance of knowing the location of the shaft of the motor. This information is useful for commutation with brushless motors, but it is also useful in other applications for determining accelerations, velocities, and when the controlled device should stop.
In my last two columns, I discussed techniques for recovering angular position from the output of devices generating cosinusoids in quadrature.
This month, I will review that material in an effort to answer some questions I received about the construction of both sinusoidal encoders and resolvers. I will also examine some other types of position sensors. In the first column of this series, (“DSP and Motion Control,” June 2000, p. 125) we gave some examples of such a system, one that used a stepper motor. This time, however, we will include systems involving synchronous motors, such as permanent magnet motors, and begin a discussion of how sensorless control can be implemented on devices with DSP.
Encoders come in many forms. Not all motors are rotary, and neither are all encoders, but the terminology we use is often related to angular position, especially as it concerns sinusoidal encoders or other sensors that use cosinusoids to indicate position.
Quadrature encoding is a technique that employs sinusoidal signals to represent position and encode them for communication to other machine interfaces. This method is simple and offers a high level of noise immunity.
A quadrature encoder is composed of a light-source, a wheel, and a receptor. The encoder modulates a beam of light, whose intensity is sensed by photoelectrical cells or magnetic (Hall) devices, producing two sinusoidal signals. We'll call them signal A and signal B. Viewed from the shaft side of the encoder, B lags 90 degrees behind A in a clockwise rotation. If the encoder is linear, then B lags behind A in travel from left to right. The number of periods of A and B over a given distance equals the line count, N, of the encoder. The frequency is proportional to the speed of travel and line count of the encoder. A second track carries a reference mark, R, that modulates no more than once each interval.
Figure 1 shows two signals that are 90 degrees out of phase. Phase is the mechanical displacement in radians between A and B.
Because these signals are analog sinusoids, we may easily form a digital output with the addition of some on-board squaring circuitry. In this way, the encoder is capable of sourcing both digital and sinusoidal forms. In practice, however, most digital quadrature encoders generate their signals by shining a light through precisely placed holes on a metal wheel mounted to a rotating shaft which is in turn attached to the motor shaft.
Digital quadrature encoders represent a simple and convenient way to encode incremental motion and direction, and they are generally economical. However, in applications requiring higher resolutions, they become expensive. Alternatives such as laser interferometers are also expensive. As a result, many people use encoders that output the raw sinusoids in quadrature and employ an interpolation scheme to decode greater resolution at much lower costs. Today, you can find interpolating encoder schemes that rival laser interferometers and cost less than $1,000.
In my last two columns, I described how this works. Using a basic trigonometric relationship, we are able to recover angular position from the magnitudes of the quadrature outputs. Look at Figure 1 again, where we have two cosinusoids in quadrature. We establish A, the leading cosinusoid, as the sine, and B, the trailing cosinusoid, as the cosine:
The ratio of these two values is equal to a function called the tangent:
By taking the arctangent of the ratio of the two inputs, we can find the angular position of the shaft of the encoder:
Thus we again have angular (or angularly encoded linear) position.
This is a simple technique, but it can be expensive computationally, either because of the memory required or because of the time it takes to compute the division and arctangent. Last month, I presented tracking demodulation, another method with which to accomplish the same result. In tracking demodulation, we filter and accumulate small differences between the sine and cosine inputs to obtain acceleration, velocity, and position.
In that column, we were concerned mainly with a sinusoidal encoder. Now I would like to open up the discussion a bit to explore working with an inductively coupled device such as a resolver.
Designing with a resolver and sinusoidal encoder
We'll start by reviewing the mechanics of a resolver. In Figure 2, a sinusoidal reference frequency of sufficient amplitude is supplied to the rotating armature of an encoder. Like the sinusoidal encoder, the output of the resolver is composed of two cosinusoids in quadrature. Two secondary windings are placed at right angles (in quadrature) to one another. As the armature sweeps these secondaries, a voltage is induced in each secondary that is proportional to the position of the primary winding. In the illustration, the rotating primary is shown at an angle between the two secondaries. In this position, it will impress a signal (frequency) in equal magnitude on each of the secondaries.
If the primary is at a right angle to one secondary and pointing directly at the other, the secondary at which it points will receive the maximum signal while the secondary to which it is parallel will receive the minimum. As the primary rotates, it will impress a voltage on each secondary proportional to their positions relative to the primary. Taken together, the signals output by the secondaries can be used to recover angular position. To do this, we use the same procedure as that for a sinusoidal encoder, with one important difference. The peak-to-peak values of the sine and cosine outputs on a sinusoidal encoder are constant. This is not the case with the resolver because the voltage that produces the output is based on a reference frequency, whose value fluctuates. The output of the resolver will be greatest when the reference voltage is peaking. It will be zero when the reference voltage passes through zero.
If you design the system using a DSP to generate the reference frequency, it is not too difficult to guarantee that the DSP samples the output of the resolver when the reference frequency is at its peak. Also note that a phase lag will occur between the reference frequency and the output of the resolver, making it necessary to insert a slight delay between the reference generation and magnitude sampling logic.
For either of these two applications-the sinusoidal encoder and the resolver-it is important that each input (sine and cosine) have the same peak-to-peak values. Each uses a separate inductor or photoreceptor, and other gain stages may exist between the A/D converter and the encoder. You can determine whether this is the case with a Lissajous pattern on an oscilloscope. (This requires a two-channel oscilloscope with X/Y capability. We take the sine input to be x and the cosine input to be y. If the two inputs have equal magnitudes, you will get a perfect circle on the display when the encoder is tuned.)
It is also important to note that the sampling frequency of the resolver, and, therefore, its (and the motor's) maximum rotational speed, is directly related to the reference frequency; this is not the case with the sinusoidal encoder because it has no reference frequency. Still, any sinusoidal encoder must be selected with a bandwidth appropriate to the speed of the motor.
Finally, both applications will benefit from some sort of low-pass filtering to help eliminate noise from the amplifier or other digital equipment.
These devices are useful and effective, but it's possible to ascertain position in other ways. For instance, your system may not require this resolution, in which case you could use a much less complex sensor; it could even be that you don't need a sensor at all.
Why use position feedback?
Position sensors come in all forms. They do not necessarily employ sinusoidal or digital quadrature to indicate position. The feedback you need might be flux, eddy currents, acceleration, or temperature. Much of the time, this just means the output of an A/D converter; sometimes though, it is the output of a process, such as an FFT. Incremental and absolute encoders, for example, take digital commands and return their values in the form of a digital word.
Generally speaking, we can divide position sensors into two main categories: relative and absolute. Relative position sensors indicate how far a device has moved since power was applied. This data might take the form of an accumulated value that can somehow be set to zero, either at power-on or by some other means, or the sensor might simply issue a pulse stream representing some increment of motion and encode it with direction. Quadrature encoders fall into this category; they output pulses at precise increments of travel as you move, and indicate direction simultaneously. Maintaining a record of total distance is the responsibility of the controller.
Absolute encoders will provide a value representing the distance from some known point called home. An absolute encoder-even if the sensor moved while power was off-will return the correct value whenever you access it. You can make such a device in several ways, including using a mechanism such as the sinusoidal output discussed earlier. A common technique uses a wheel divided into fractions of radians and encoded with a specific value for each increment. In this way, whenever you read its position it will always return a number representing the position of the rotor or pickup head. Some absolute encoders are only absolute within a single revolution; others will also count the number of revolutions the shaft has made.
Some of the other common position sensors available are tachometers, Hall effect switches, and 1/T counters.
Tachometers come in several different forms. In some, an inductor passes one or more magnetic poles, producing a signal. Other tachometers are optical, using precisely spaced holes on a wheel, or a hole in a shaft through which light can shine. These are often used for elementary forms of velocity control.
Position information can also be obtained using Hall Effect switches. These switches are placed around the core of the motor, and they open or close when the intensity of a nearby magnetic field reaches a certain threshold. Usually, three switches, U, V, and W, are embedded in the motor core. This is often enough information for the controller to know where the shaft of a brushless motor is before any motion actually begins. This allows the controller to commutate the motor without any special procedure for finding the poles.
1/T is another technique-an older one-that's useful, though not applicable in all situations. It can be used with any of the previously mentioned sensors to increase the resolution of the feedback. This technique uses a high-speed counter that is started or cleared with a count or an edge issued by any of the other position sensors. The output from this counter is used to produce the increased resolution. If you intend to implement 1/T, you will need to take some precautions regarding overflow and encoder/tachometer reversal, because either of these conditions can invalidate your count.
When we began this series, I presented some elementary motion control scenarios. One of these involved a stepper motor in an open loop, with no encoder application. Next month, I plan to describe some more sophisticated instances of what is called sensorless control.
Don Morgan is senior engineer at Ultra Stereo Labs and a consultant with 25 years experience in signal processing, embedded systems, hardware, and software. Morgan recently completed a book about numerical methods, featuring multi-rate signal processing and wavelets, called Numerical Methods for DSP Systems in C. He is also the author of Practical DSP Modeling, Techniques, and Programming in C, published by John Wiley & Sons, and Numerical Methods for Embedded Systems from M&T. Don's e-mail address is .
Return to Table of Contents