Future Electronics – Magnetic Rotary Encoders

future-logo
By Vince Owens, FAE, Future Electronics Advanced Engineering Group

Why Magnetic Rotary Encoders?
There are many applications for which you must know the position of a shaft relative to some starting point, or just relative to its last known position. This is traditionally done using a linear taper potentiometer, or, for motor control, multiple Hall effect sensors. We have also had sensors for quite some time called optical encoders that use light passing through an arrangement of slits in a rotating wheel. These schemes all do one thing: translate a rotational motion into an electrical signal which can be read, typically by a microcontroller, and the position (and often speed) of the shaft inferred. All of these methods work very, very well, and if the technology is properly matched to the application, offer a reliable signal which may be used in, say, a closed loop control system.

As different as these traditional methods are conceptually, however, they all share a few characteristics, none of which, as it happens, are especially good news for the engineer charged with making them work. They tend to be rather complex, both mechanically and from a signal processing perspective. Further, they are each environmentally limited; an optical encoder, for example, which performs wonderfully in a relatively clean environment, may be useless in dusty, greasy ones. The pots, particularly, have an upper limit on their useful life from the wear of mechanical friction. And, none of these methods are cheap. In fact, one or more are usually ruled out altogether in the consumer space where tight budgets are the norm. Fortunately for today’s engineer, there is an alternative which is reliable, low power, has equal or better resolution to the other methods, is impervious to most industrial environments, and is also economical. This brief article will introduce you to magnetic rotary encoders in general, and to a series of parts by Austria Microsystem specifically, and show you how your design might benefit from these devices. We will dig into the various flavors of these devices, plus cover some of the special concerns and how AMS addresses them. First, let’s cover some basics.

Figure 1

Figure 1

How It Works
The Hall effect has been known for quite some time; it was first described in 1879 by Edwin Hall, for whom it is named. The physics are straightforward enough, and familiar to anyone who has used Hall sensors for motor control or even for proximity detection. No surprise, magnetic encoders are just built around one or more Hall effect sensor; if a current flows through a conductor exposed to a magnetic field perpendicular to its plane of travel (Figure 1), those electrons will experience a transverse force (that is to say, a force perpendicular to their motion). This is nothing more than the familiar notion behind what makes a motor turn. But, these electrons will also experience a force inside the conductor, leading to a buildup of charge carriers skewed to one side. You will immediately grasp that this difference of charge across the width of the conductor produces a tiny voltage difference. This is the Hall effect voltage, VH . The voltage produced is proportional to field strength, and is reasonably linear within a restricted region. The governing equation is

VH = ρ (I/d x B) , where
ρ is a constant*
I is current in Amps
d is the conductor’s thickness in millimeters
B is the magnetic field strength in Teslas

*ρ, called the “Hall coefficient”, is actually the reciprocal of the product of charge carrier density times the fundamental charge in Coulombs.

The voltages we are talking about are very small; for instance, with typical currents and die geometries, and magnets in the range we normally use, the voltage potential is in the mere microvolts. So, for this to be useful, we are going to have to have some seriously good signal conditioning.

You may also notice there is a vector cross product involved here. The details of this are not important for this discussion, but just note it provides the direction of the induced voltage, following the venerable “right hand rule”.

Putting it to Use
Let’s now imagine a round magnet, split down its face between north and south poles, and then placed on one end of a rotating shaft, with its axis aligned with the axis of the shaft (Figure 2). Further, this magnet rides just a bit above a Hall sensor, and parallel to it. The magnetic field lines cut the sensor perpendicularly, setting up the condition described above to create that tiny differential of charge as we inject a current in the device. Then, as the shaft turns, the north-south magnetic field lines from the attached magnet vary sinusoidally above the Hall sensor, causing a variation in the Hall voltage, and these relative voltage changes can be correlated to the magnet’s angular displacement. Of course, we do not have to do the correlation; that is what the encoder does for us, and provides a corresponding signal, which may be an output voltage, a PWM signal, a digital output, etc., which we can readily read. This is what makes these encoders remarkable; they compactly and efficiently integrate all the elements required to turn that tiny, fluctuating voltage corresponding to the angular position of a shaft above them to a useful signal, all without our incurring all the overhead in other parts of our system. There is therefore no “heavy lifting” on the software side. Further, you can see how dust and grime which would devastate an optical system are irrelevant to such a device. And, as they do not themselves move, sensing only the movement of a shaft, they experience no mechanical wear. These are, in short, practically the ideal rotary motion transducers.

Figure 2

Figure 2

Dealing with Stray Fields
But, you might ask, there must be a catch. These devices surely cannot be immune to all environments? What about stray magnetic fields? Well, there is no magic; different sensor manufacturers address this problem in different ways. As it happens, AMS has a patented design which gives you the greatest rejection of stray fields possible, effectively canceling the “noise” introduced by any but the field lines from the intentional magnet. While the details are involved, and proprietary, we may in general outline the principle by which they achieve this. First, the devices are optimized to reject field components that are not perpendicular to the surface. That is true of any Hall sensor by nature, of course, but AMS then goes it one better. By comparing multiple readings and applying what amounts to an analysis of sums and differences, their algorithm can differentiate true signal from stray components entering at oblique angles.

Additionally, their technique allows them to compensate for small variations in the magnet’s placement, either off-axis or eccentric to the plane of rotation, and this helps ease manufacturing tolerance worries. This is especially important when considering the wear and “play” which may come into a system over time; we only need good, not perfect, alignment.

As for magnet selection, AMS provides extensive help in choosing the proper magnet size, field strength, and in setting the optimum gap between magnet and sensor. AMS has further simplified this by partnering with a magnet company, who produces a line of magnets designed specifically for use with the various AMS encoders. There is no guesswork in the system; you know you are getting the right combination of encoder and magnet. All of this is beyond the scope of this brief article, but the engineer can design confidently, knowing that the all critical magnetic components are already identified and available.

Variations
There are some additional differences between the various encoders, such as resolution and communication interfaces. The AS5048 has 14-bit resolution, meaning it can resolve an incredible 0.02 degrees (other devices offer 8-, 10-, or 12-bit resolution). Depending on the version ordered, designated by an A or B extension, you can get either an I2C or SPI interface. Both versions of this chip have a PWM output, as well. Another detail you should know is that these rotary encoders are specified as being either absolute or incremental types. This means that they either have an internal “zero” reference upon which to base their output, or else the output is always relative to the last position, effectively meaning they have no “memory” of where “home” is. Different applications will require one or the other. The AS5048 is an absolute type of rotary encoder. Finally, as you browse the complete portfolio, you might notice that this device is specified as being “on axis”, meaning it is optimized for systems in which the magnet’s axis passes through the chip package’s center. AMS also offers other devices optimized for off-axis placement for those applications where on-axis placement is mechanically prohibited.

Demonstration
Let’s take a look at this chip now. We will use an AMS demo board (which also serves as a nice development platform) as a hands-on illustration, highlighting the features of one of their more popular encoders, the AS5048.

Figure 3

Figure 3

(These boards, part number AS5048-DB, can be ordered from your local Future office.) Right out of the box (Figure 3), this handy board provides all the interface connections you need to connect the device to an external micro for your own development. The board is standalone, though, complete with a backlit LCD. When you power on the board, the LCD reports the parameters being read out of the AS5048. All of this information may also be viewed on a computer screen via the USB port on the board and the included graphical user interface. This chip allows for either an SPI protocol or an I2C connection (the “B” version on this board has SPI, but an I2C connection is provided for an off-board “A” version. For this illustration, we will select the on-board sensor with the slide switch at the lower left. An external sensor could be used, as well.)

There is an embedded magnet on the end of the center knob’s shaft, resting just above the encoder. Rotating the magnet in either direction, recall, varies the magnetic field sinusoidally. The sensor then makes the data available in its registers, which can be accessed over the serial interface. This version of the sensor can output both the absolute angle in degrees from its zero point, as well as the raw count from its A/D converter (shown by the large font number in the upper left), in this case from 0 to 16,384 (Figure 4). It is nearly impossible, in fact, to advance the knob in single increments, so sensitive is the device to the tiniest rotation. As the knob turns counterclockwise, the degrees advance through the full circle, until you pass through the zero point and the count rolls over.

What about compensating for field strength? To illustrate this, we can lift the knob away from its settled position, raising the magnet above the chip. The two numbers shown at the bottom of the display, the ones labeled “AGC” and “MAG”, demonstrate how the AS5048 handles this situation.

Figure 4

Figure 4

Increasing the distance between the sensor and the magnet of course weakens the field coupled into the device, but the AS5048 compensates for this. The “MAG” number in the picture (for “magnitude”), is an output from an automatic gain section, which boosts the signal, and it stays approximately constant, even though the field strength varies. The AGC number, however, increases as the magnet moves farther from the chip or decreases as it moves closer; this is simply confirmation that the gain is being adjusted to compensate for changes in the field. As the magnet moves farther away, this gain will increase up to the point where the field strength is just too weak to be usable. This distance is several millimeters, though, allowing for a lot of options in design, not to mention tolerance in manufacturing and variations in the magnets themselves.

We can go further illustrating this device’s capabilities, such as its effectiveness in rejecting spurious fields. A relatively weaker magnet, such as a refrigerator magnet, may be used to simulate a weaker, stray field in a setup such as this. Passing it in the vicinity of the “real” magnet while it is positioned correctly over the sensor will produce very little fluctuation in the reported output. This is because the chip’s processing algorithm rejects these weaker, stray fields, as previously explained. This ability is especially important in industrial environments where motors, dimmers, and other electrically noisy devices contribute to a high electromagnetic background.

Conclusion
While no one product can be every solution to every problem, you can see from this brief discussion how a magnetic rotary encoder might simplify, cost reduce, or even make possible at all a particular application. While based on principles of classical physics over a century old, they come to us today in ready-to-go packages, complete with high quality analog front ends for signal conditioning and high resolution A/D converters. With a wealth of models from which to select, development tools, and even help in selecting and mounting the magnet, there has never been a better opportunity to take advantage of these remarkable chips. For more information, contact your local Future Electronics office.

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected by WP Anti Spam