Robotic designs that operate autonomously or alongside human workers offer convenience, efficiency and accuracy, greatly benefiting the manufacturing and industrial sectors. Here, monitoring motor position under all conditions helps maintain system control and prevents unintentional motion that might cause system damage or bodily harm.
For that, it’s possible to implement contactless angle encoding, using a magnet mounted to the motor shaft to provide input for a magnetic encoder. The magnetic field is not influenced by dirt or grime, and integrating such solutions onto the motor enables a compact solution. The encoder tracks the rotating magnetic field components, which are naturally sinusoidal and 90 degrees out of phase. This relationship enables quick calculation of the angular position using the arctangent of these inputs.
A variety of magnetic encoding technologies will have the same end effect. Magnetoresistance and Hall-effect sensors can detect the changing magnetic field as the magnet rotates on the motor shaft. The devices such as 3D linear Hall-effect sensor are capable of calculating angular position and offer the ability to compensate for temperature drift, unbalanced input magnitudes, and device sensitivity and offset.
Beyond signal-chain errors, mechanical tolerances also influence rotation of the magnet, which will in turn determine the quality of the magnetic field detected. Achieving optimal performance often requires the implementation of a final calibration process through multipoint linearization or harmonic approximation. Once calibrated for mechanical error sources, magnetic encoding can achieve high accuracy.
The driving motor may rotate the load directly, drive a gearbox to increase applied torque, control a rack and pinion, or transfer energy elsewhere through a belt or screw drive. As the shaft of the motor spins, the kinetic energy transfers into a mechanical position change somewhere in the system. Whatever the case, the angle of the motor shaft directly correlates to the position of the moving parts of the mechanism. In cases where the turn ratio is not 1-to-1, it becomes important to track the number of motor rotations as well.
Observing two equal amplitude sinusoidal inputs that are 90 degrees out of phase and using those signals to perform an arctangent calculation tracks the absolute angle of the motor.
The technologies outlined below can calculate the angular position:
- One-dimensional Hall-effect sensors
- Three- dimensional Hall-effect sensors
- Anisotropic magnetoresistance sensors
- Giant magnetoresistance sensors
- Tunnel magnetoresistance sensors
- Inductive sensors
- Optical encoding
- Stepper-motor pulse control
- Sensorless motor control
Stepper motors and sensorless motor control don’t offer absolute position feedback, but rather estimate position based on the relative change from the start position. When the system loses power, determining the actual motor position must occur through alternate means.
For the rest of the technologies listed, the angle encoder uses sinusoidal outputs with a 90-degree phase difference to determine the precise angular position.
Optical encoders tend to offer the highest precision accuracy, but often require bulky enclosures to protect the sensor and aperture from dust, dirt and other contaminants. Additionally, the mechanical elements of the encoder must couple to the motor shaft. Rotation speeds above the mechanical rating of the encoder can cause irreparable damage and result in downtime.
Magnetically sensed technologies such as Hall-effect sensors and magnetoresistive sensors use a magnet fixed to the motor shaft; the sensor does not otherwise require any mechanical connection. The magnetic field associated with the permanent magnet will permeate the area around the magnet, which allows a wide range of freedom for sensor placement. The magnetic field vector components of a rotating magnet are naturally 90 degrees out of phase, which enables monolithic multiaxis magnetic sensors to perform angle encoding with a single device. A compact solution, placement freedom, and contactless configuration make magnetic sensors attractive for angle encoding applications.
Inductive sensors operate similarly to magnetic solutions by coupling AC magnetic fields generated by an inductive coil to create surface-level eddy currents in nearby metallic targets. The target’s change in proximity causes variance in the effective inductance of the system, which when used with a specialized target, can generate sine and cosine outputs.
Let’s consider the ideal inputs produced by a magnet rotating above a 3D Hall-effect sensor such as the TMAG5170, as shown in Figure 1.
Figure 1 On-axis magnetic rotation allows a Hall-effect sensor to calculate angular position. Source: Texas Instruments
Calculating the angle using the arctangent of the inputs, as shown in Figure 2, will provide a perfect corollary to the actual motor angle, assuming an ideal arrangement with no mechanical tolerances. In practice, several mechanical factors can influence the quality of the magnetic field input. The resulting angle error will become a complex combination of each of these factors depending on the severity of each mechanical flaw.
Figure 2 Ideal sine and cosine inputs provide a perfect corollary to the actual motor angle. Source: Texas Instruments
Now, let’s look at several types of assembly errors that impact performance. The effect of each will vary based on sensor position and magnet geometry, although an on-axis alignment tends to be the most forgiving.
If a magnet is not installed perfectly orthogonal to its motor shaft, that magnet will appear to wobble during rotation. Inconsistent alignment of the effective XYZ coordinate space of the magnet to the sensor will result in angle measurement nonlinearity.
Figure 3 Magnet tilt (up) and wobble (below) can result in nonlinearity of angle measurement. Source: Texas Instruments
During the magnet’s rotation, the position of the magnet relative to the sensor will change constantly. Since the magnetic flux density from a magnet is inversely proportional to the square of the distance, this effect can produce significant nonlinearity. As a result, eccentricity of the magnet may result from improper alignment of the magnet to the axis of rotation of the shaft.
Figure 4 Eccentric magnet rotation results from improper alignment of the magnet. Source: Texas Instruments
Systemic position offsets
Placement offsets will introduce unexpected changes in the amplitude and phase of the input magnetic field components. These errors will likewise affect the resulting angle calculations.
Figure 5 Offset sensor placement can introduce unexpected changes in the amplitude and phase of the input magnetic field. Source: Texas Instruments
Depending on the tilt of the magnet and the axes of sensitivity used for the calculation, motor-shaft tilt can result in input signal phase errors. This phase error will produce nonlinearity when performing calculations using the arctangent. In this case, the magnet does not wobble, but the orthogonality of the sensor is lost.
Figure 6 Tilted motor alignment can lead to phase error. Source: Texas Instruments
Sensor soldering misalignment
This case is very similar to motor-shaft tilt. During solder reflow, it’s possible for any device to not align perfectly as the solder sets. This misalignment can lead to package tilt along any axis, which would result in possible amplitude or phase errors from the inputs.
Figure 7 Sensor misalignment can result in amplitude or phase errors. Source: Texas Instruments
Correcting mechanical errors
Figure 8 to Figure 11 show simple forms of the various nonlinearity errors in comparison to an ideal circle centered at the origin. These plots depict the possible impact of various errors when plotting the two input signals against each other.
Figure 8 Here is a comparison between ideal input (blue) and amplitude mismatch (red). Source: Texas Instruments
Figure 9 A comparison is shown between offset and ideal input. Source: Texas Instruments
Figure 10 A comparison is shown between ideal input and phase error. Source: Texas Instruments
Figure 11 A comparison is shown between distortion and ideal input.
In Equation1, θ’ represents the calculated angle. The phase error from the ideal 90 degrees is shown as σ. A(θ) and B(θ) are equivalent functions in the ideal case, but may also describe a simple scalar amplitude mismatch or a cyclically dependent change in amplitude caused by imperfections in the magnet rotation. Varying amplitude would result in distortion that can adversely impact angle linearity.
θ’ = atan (A(θ) sin (θ+σ) + offsetsin)/(B(θ) cos (θ) + offsetcos) (1)
Taking the difference between θ and θ’ calculates the absolute angle error which always repeat periodically. The error shown in Figure 12 is an example of uncorrected error produced by mismatched input amplitudes captured by a sensor not placed on-axis.
Figure 12 This is an example of angle error caused by the non-ideal magnetic input. Source: Texas Instruments
If the sensor was placed in an on-axis alignment instead, any amplitude mismatch would be minimized and the error before correction would have a smaller peak value.
Amplitude mismatch results from sensor placement within the magnetic field, but may also be affected by the sensitivity gain error of the sensor. Adjusting channel sensitivity or applying a scalar in post-processing are two ways to normalize the magnitudes of the inputs.
Signal-chain offsets or offset in the observed magnetic field also require correction of the affected input signal. Performing both of these corrections will have an immediate improvement for overall accuracy.
Figure 13 Residual angle error can be caused by mechanical sources. Source: Texas Instruments
After addressing amplitude and offset errors, the remainder is attributable to phase error and distortion. Typically caused by mechanical misalignment, such errors tend to be unique from system to system, and are somewhat more difficult to correct directly.
There are two common processes for implementing end-of-line calibration: multipoint linearization or harmonic approximation. Both processes require capturing several data points against a known reference to effectively calculate the cyclical error.
Multipoint linearization assumes a linear change between every collected data point. Increasing the number of samples reduces the uncertainty of this approximation. Consider correcting the remaining error shown in Figure 13 with either four, eight, 16 or 32 linearization points. When applied to the error shown in Figure 13, the residual error for this method using 32 points is well under 0.1 degrees for all positions.
Figure 14 Calibration of residual error is performed using four-point linearization. Source: Texas Instruments
Figure 15 Calibration of residual error is performed using eight-point linearization. Source: Texas Instruments
Figure 16 Calibration of residual error is performed using 16-point linearization. Source: Texas Instruments
Figure 17 Calibration of residual error is performed using 32-point linearization. Source: Texas Instruments
On the other hand, harmonic approximation is an advanced approach that recognizes the cyclically repeating nature of the error. Equation 2 describes the total error as the sum of an infinite combination of harmonics:
θ correction = ∑ni=1 αi cos (i * θ) + βi sin (i * θ) (2)
Increasing the number of data points used for calibration enables more accurate determination of scalars α and β for each harmonic, producing an even higher degree of precision than multipoint linearization.
So, instead of using piece-wise linearization, correcting for the error in Figure 13 by subtracting only the first four harmonics results in less than 0.01 degrees of error for all positions.
Figure 18 Here is a broad view of error calibration done by using the harmonic approximation. Source: Texas Instruments
Magnetic sensing in robotics
Magnetic angle sensing is beneficial technology to use in precision robotics applications. While the magnetic field permeates space, it provides a simple means to provide angle information to a microprocessor without a direct mechanical connection to the motor shaft, resulting in fewer mechanisms that may result in system failure.
The challenge in any magnetically sensed solution is the number of possible alignment factors and signal-chain errors that result in periodic angle errors. Careful design can limit the severity of these errors, but some system tolerances will always be present. The combination of all of these sources without calibration may result in unacceptable accuracy. Multipoint linearization or harmonic approximation provide a direct and effective way to calculate motor position for the highest precision.
Scott Bryson, systems engineer for position sensing products at Texas Instruments, has authored the Signal Chain Basics blog # 175 for Planet Analog.
- Sensing the Future, TDK Buys It
- Magnetic Sensors for Motion Control
- Robotics Is Making Jobs, Not Taking Them
- 140-year-old secret in the Hall effect discovered
- Hall-effect sensors measure fields and detect position