There are many applications for which the designer must know the position of a shaft relative to a starting point, or relative to its last known position. This is traditionally accomplished in simple applications such as dials or knobs with a linear taper potentiometer; in motor-control systems, multiple Hall-effect sensors or optical encoders are more usual.
All these device types translate rotation into an electrical signal which can be read, typically by a microcontroller; the position, and often speed, of the shaft may be calculated from the signal. All also share some characteristics which are unhelpful to the system design engineer.
First, they tend to be rather complex, both mechanically and electrically. Further, they are readily impaired by contaminants present in the user’s environment: an optical encoder, for example, might perform perfectly in a clean environment but fail when the codewheel is contaminated by dust and grease. Likewise, potentiometers have a limited useful life because they suffer from wear attributable to mechanical friction.
Fortunately for today’s engineer, there is an alternative which is reliable, uses little power, offers resolution equal to or better than that of the other methods, and can survive most industrial environments: the magnetic rotary encoder.
The main system elements There are two basic components of a magnetic encoder system: a round magnet, split down its face between North and South poles, and the encoder itself, which has magnetic Hall sensing elements embedded in it. The magnet is placed on one end of a rotating shaft, with its axis aligned with the axis of the shaft, as shown in Figure 1. It is mounted 1-3mm above the Hall sensor, and parallel to it.
The magnetic field lines cut the sensor perpendicularly, and generate a tiny charge differential across the Hall elements when current is flowing in the device. 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 voltage at the sensor. These relative voltage changes are correlated to the magnet’s angular displacement. The encoder includes a small computing functional block that converts the voltage changes into digital angle measurements.
The output signal from the encoder may be easily read by a microcontroller: it will be an analogue voltage, a PWM signal, or a digital output. This means that there is no requirement for substantial software on the system side to interpret the output from the sensor side.
Because the encoder is a magnetic device, it is completely immune to the dust and grime that affect the optical encoder. And, as the encoder itself is static, it suffers no mechanical wear. Magnetic encoders are, therefore, almost the ideal rotary motion transducers.
Additionally, their measurement 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 provides plenty of tolerance for variations in system assembly. This is especially important when considering wear and the play which may become apparent over time: an encoder system needs good, not perfect, alignment.
A very wide range of encoders, known as magnetic position sensors, is available from ams (www.ams.com). This means that the designer will be able to find a device from ams that is tailored for the requirements of almost any consumer, industrial or automotive application.
In addition, Future Electronics and ams provide extensive help in choosing a magnet of the proper size and field strength for the chosen sensor, and in setting the best distance between magnet and sensor.
The range of magnetic encoder types from ams There are some differences between the various encoders from ams, such as resolution and communication interfaces. The AS5048 has 14-bit resolution, meaning it can resolve to as little as 0.02°. Other devices offer 8-, 10-, or 12-bit resolution. Depending on the version ordered, designated by an A or B extension, it has either an I2C or SPI interface. Both versions of the AS5048 have a PWM output as well.
READ THIS ARTICLE TO FIND OUT ABOUT
- The basic operation of a magnetic rotary encoder
- The reason that a magnetic encoder is robust and immune to contaminants
- How to use a demonstration kit from ams to become familiar with magnetic encoders
In addition, ams rotary encoders are specified as either absolute or incremental types. This means that:
- either they have an internal zero-point reference on which to base their output
- or the output is always relative to the last position, effectively meaning they have no memory of the home position.
Different applications will require one or the other type. The AS5048 is an absolute type of rotary encoder.
Lastly, this device is specified as being ‘on-axis’, meaning it is optimised for systems in which the magnet’s axis passes through the chip package’s centre. ams offers other devices optimised for off-axis placement, for those applications in which on-axis placement is mechanically difficult or impossible.
Using a demonstration board The AS5048-DB demo board from ams serves as a useful development platform for users of the AS5048 rotary position sensor, as shown in Figure 2. It provides all the interface connections needed to connect the device to an external MCU. The board, which is equipped with a backlit LCD, also operates in standalone mode.
On power-up, the LCD reports the parameters being read out of the AS5048. This information may also be viewed on a PC screen via the USB port on the board, and a GUI supplied with the board. The chip provides for either an SPI or I2C connection.
There is an embedded magnet on the end of the centre knob’s shaft, resting just above the encoder. Rotating the magnet in either direction 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 ADC shown by the large font number in the upper right, in a range from 0 to 16,384, as shown in Figure 3 . It is nearly impossible, in fact, to turn 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 it passes through the zero point and the count rolls over.
It is also possible to see the method for compensating for field strength. By lifting the knob away from its settled position, the magnet is moved further from the chip. The two numbers shown at the bottom of the display, labelled ‘AGC’ and ‘MAG’, demonstrate how the AS5048 handles this change.
Increasing the distance between the sensor and the magnet weakens the field coupled to 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. This means that it stays more or less constant, even though the field strength varies.
The Automatic Gain Compensation (AGC) number, however, increases as the magnet moves further from the chip and 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 further away, this gain will increase until it reaches the point at which the field strength is too weak to be usable. This distance is several millimeters, though, providing considerable flexibility in design, as well as tolerance for manufacturing variations and variations between one magnet and another.
The demo board also enables the user to experiment with the AS5048’s rejection of spurious magnetic fields. A relatively weak magnet, such as a refrigerator magnet, may be used to simulate a stray field. Passing it close to the AS5048’s paired magnet while it is positioned correctly over the sensor, the user will see little change to the reported output. This is because the chip’s processing algorithm rejects the stray field, using differential sensing technology unique to ams. This ability is especially important in industrial environments in which motors, dimmers and other electrically noisy devices contribute to a background rich in EMI.
Classical physics, modern devices While no single product can provide a solution to every problem, it is clear from this article that a magnetic rotary encoder can simplify many applications, while reducing the cost of others. Some might not be possible at all without the use of a magnetic encoder. While based on principles of classical physics more than a century old, today’s encoders are highly sophisticated and modern devices, complete with high-quality analogue front-ends for signal conditioning and high-resolution ADCs.
ams has a wealth of parts from which to choose, backed by useful development tools, and technical support for the selection and mounting of the magnet. More information may be found at www.ams.com/eng/Products/Position-Sensors.