Download PDF version

By Alihusain Sirohiwala and Wade Bussing,

Allegro MicroSystems, LLC

Numerous applications in industries ranging from industrial automation and robotics to electronic power steering and motor position sensing require monitoring the angle of a rotating shaft, either in an on-axis or off-axis arrangement.

The design of any successful angle measurement system for such applications needs to be based on the particular user's requirements. These may include: arrangement (off-axis or on-axis), air-gap, accuracy, and temperature range, among others. In particular, minimizing angle error over temperature, positional misalignment, and air-gap, is a key objective.

These variables are related, in turn, to system level design choices like magnet geometry, magnet arrangement (on-axis or off-axis), magnetic material, and mechanical tolerances. As such, flexibility is required of the angle sensor IC, in order to work around these potential error sources without adding complexity and cost to the system-level design. Even the best magnetic angle sensor IC is only as good as the magnetic field that it senses.

A magnetic angle measurement system has two main sources of error:

- sensor IC related errors: intrinsic nonlinearity, parametric temperature drift and noise.
- magnetic input related errors: field strength variation and field non-linearity.

Angle error is the difference between the actual position of the magnet and the position of the magnet as measured by the angle sensor IC. This measurement is done by reading the angle sensor IC output and comparing it with a high resolution encoder.

When using a magnet in a design, the magnetic input will probably not be homogeneous over the entire range of rotation: it will have inherent errors. These magnetic input errors cause measurement errors in the system, and become especially important when considering side-shaft or off-axis designs that have higher intrinsic magnetic errors— see Figure 1.

Even the most accurately calibrated angle sensor IC will produce inaccurate results if the error contribution from the magnetic input dominates. In most cases, even on-axis magnetic designs suffer from relatively large misalignments that occur during the assembly of the customer module in the production line. These magnetic error sources are inevitable, and mitigating them is often impossible and almost always expensive.

As far as angle sensor IC related errors are concerned, intrinsic non-linearity and parametric temperature drift are optimized by the manufacturer before shipping to the customer. Noise performance can be optimized for the customer application by using on-chip filtering.

This document describes an angle sensor IC (the Allegro A1332) in which this problem is solved by using advanced linearization techniques to compensate for these errors at the customer’s end-of-line manufacturing location. In particular, it shows how magnetic input related errors in excess of ±20° can be linearized to as low as ±0.3°: roughly a 65× improvement.

This linearization can be performed based on data from a single rotation of the target magnet around the angle sensor IC. The angle readings from this rotation are used to generate linearization coefficients which can then be stored into on-chip EEPROM, optimizing that angle sensor IC for that magnetic system.

Two different linearization techniques are used in the A1332 angle
sensor IC: *segmented linearization* and *harmonic linearization*:

- Segmented linearization is a programmable feature that allows adjustment of the transfer characteristic of the angle sensor IC such that linear changes in the applied magnetic field vector angle can be output as corresponding linear angle increments by the angle sensor IC. It is performed on the data collected from one rotation of the magnet around the angle sensor IC.
- Harmonic linearization applies linearization in the form of 15 correction harmonics whose phase and amplitude are determined by means of an FFT (Fast Fourier Transform) performed on the data collected from one rotation of the magnet around the angle sensor IC.

Both of these techniques can be readily implemented using Allegro-supplied software to calculate coefficients and program on-chip EEPROM. Contact your local Allegro Representative to obtain the latest DLLs, software GUIs, and programming hardware.

Two different air-gap definitions can be used when talking about magnetic field sensors: package air-gap and crystal air-gap.

Package air-gap is defined as the distance between the nearest edge of the sensor housing and the nearest face/tangent-plane of the magnet.

Crystal air-gap is defined as distance between the sensing element in the sensor housing and the nearest face of the magnet.

To illustrate this difference, Figure 2 shows both the crystal air-gap (4.0 mm) and package air-gap (2.386 mm) for an A1332 angle sensor IC and magnet in a side-shaft or off-axis configuration.

In this document, the term air-gap always refers to the package air-gap unless otherwise stated. The sensing elements are 0.36 mm below the top surface of the package. The distance between the sensing element center and the closest short edge of the package is 1.614 mm.

Angle error is the difference between the actual position of the magnet and the position of the magnet as measured by the angle sensor IC. This measurement is done by reading the angle sensor IC output and comparing it with a high resolution encoder (see Figure 3).

Further down in this document, the angle error is displayed as a function of misalignment. For that purpose, it is necessary to introduce a single angle error definition for a full rotation. The ‘summarized’ angle error on one full rotation is defined as angular accuracy error, and it is calculated according to the following formula:

In other words, it is the amplitude of the deviation from a perfect straight line between 0° and 360°.

It is important to distinguish between angle sensor IC related errors and magnetic input related errors. This document highlights how advanced features in the A1332 angle sensor IC can be used to compensate for magnetic input related errors.

As far as angle sensor IC related errors are concerned, intrinsic non-linearity and parametric temperature drift are optimized for each Allegro angle sensor IC at Allegro’s end-of-line test operation (see datasheet specifications for those parameters) before shipping to the customer. Noise performance can be optimized for the customer application by using on-chip filtering (see ORATE settings in A1332 Programming Manual).

In order to compare the performance of the segmented or the harmonic linearization options, both linearization techniques were performed on the same magnets. The magnets used were neodymium N45 di-pole ring magnets available from Super Magnets. Figure 4 and Figure 5 illustrate magnet dimensions.

Magnet Name | Manufacturer | Inner Diameter | Outer Diameter | Height | Material |
---|---|---|---|---|---|

R1 | Super Magnets | 7 mm | 10 mm | 3 mm | N45 Ni Plated |

R2 | Super Magnets | 5 mm | 10 mm | 5 mm | N45 Ni Plated |

The first step in the system design is to choose an appropriate magnet for the application air-gap. Usually the air-gap is in a range from 2 to 4 mm. Figure 5 shows the magnetic field as a function of air-gap for the magnets R1 and R2.

By default, many Allegro angle sensor ICs are trimmed to provide optimum performance at 300 G (30 mT). In the case of the A1332, there is also a magnetic auto-scaling feature available upon request that dynamically adjusts internal gains to compensate for dynamic variations in air-gap. However, care should be taken with the magnetic design so that the air-gap variation does not result in fields that are too low (inadequate signal to noise ratio) or too high (saturation of signal-chain blocks). In general, a field strength of roughly 300 G is ideal.

Using magnet R1, an analysis was performed of the inherent non-linearity observed in the magnetic signal when measuring angle with a calibrated A1332 under ideal alignment, as shown in Figure 7 and Figure 8.

Based on one rotation sampling the angle sensor IC output at equidistant angular points, we get the transfer characteristic as shown in Figure 9.

Analyzing the above angle error in the frequency domain with an FFT, we get the error versus harmonics as shown below in Figure 10.

Figure 11 shows a similar analysis on magnet R2.

It is clear from the FFT data that most of the inherent error in
both magnets R1 and R2 is from 2^{nd} harmonic contributions,
whereas 1^{st}, 4^{th}, 3^{rd}, and higher harmonics are responsible for the
remainder of the error. The root cause of this error is a mismatch
in the amplitude of the radial (B_{r}) and tangential (B_{t}) components.
The magnetic field vector, whose phase or angle is being measured
by the angle sensor IC, can be expressed as two orthogonal
components, B_{r} and B_{t}, as shown in Figure 12.

Ideally, these components should be identical in amplitude and orthogonal in phase. Any deviation from this ideality introduces error in the resultant angle measurement. In ring magnets for side-shaft sensing, the mismatch in the radial and tangential component is inherent to the magnet design and manufacturing process, and can vary depending on the manufacturer and the manufacturing method. In the case of cylindrical magnets, the radial and tangential mismatch can be introduced by adding eccentricity or misalignment between the angle sensor IC and magnet.

These mismatches result in an angle error profile with terms at
multiple harmonics. Therefore, it is clear that only correcting for
the 2^{nd} harmonic error term will not be sufficient, especially if
high accuracy performance is required.

The A1332 segmented linearization is a programmable feature that allows adjustment of the transfer characteristic of the device so that changes in the applied magnetic field can be output as corresponding linear increments.

Figure 15 above illustrates the angle output of the A1332 both with and without the segmented linearization.

In order to achieve this, an initial set of linearization coefficients must be created. The user takes 15 samples of angle: at every 1/16 interval of the full rotational range from 0 to 360 degrees. The 0-reference point is set by the LIN_OFFSET EEPROM field. This becomes the zero-error point, and is therefore not represented in the coefficient table. Likewise, the 360-degree point is identical to the 0-reference point and is also not represented in the coefficient table. The rest of the measured angles at the segment boundaries are placed in the LIN_COEFF1 ... LIN_COEFF15 EEPROM fields. The following instructions describe the basic algorithm for applying these linearization coefficients. Sample implementations of this method are available as Allegro customer evaluation software tools.

- Collect Data

Turn off all algorithmic processing except segmented linearization (SL), angle compensation (AC), and IIR filtering (FI), if these are desired (FI and AC bits in CFG_2, word 6, EEPROM bits 12+13, SRAM bits 16+17, SL bit is in). Turn on the segmented linearization bypass bit (SB bit, word 6, EEPROM bit 21, SRAM bit 25). This function can be used to take the measurements required for segmented linearization without having to otherwise pre-program the linearization table to a straight line.

Find the desired zero-reference point, realizing that the linearly interpolated segments will be +22.5, +45, etc., from this reference point. For side-shaft, choosing a point where the error is at a peak or valley is optimal. The angle sensor IC reading at that point will be entered into the LIN_OFFSET coefficient in the next step.

Move the encoder in the direction of increasing angle position. If the sensor angle output does not also increase, then either set the LR bit to reverse the direction of the angle sensor IC or rotate the encoder in opposite direction for this calibration step, in which case the post-linearization rotate bit (RO) will likely need to be set after calibration is complete. See A1332 programming reference for more details.

Move in encoder steps of 22.5° and read 15 angle sets. This process will produce the 15 LIN_COEFF coefficients.

- Program Coefficients

Program LIN_OFFSET after multiplying with * (4096/360), written in HEX after rescale.

Program each of LIN_COEFF after multiplying with * (4096/360), written in HEX after rescale.

- Enable Linearization

Set EEPROM bit SB=0, as it is no longer needed to bypass the linearization function— data collection in step 1 is already completed. Set EEPROM bit SL = 1 (note: it should already be set to 1 from step 1) to enable segmented linearization. The angle sensor IC output should now linearly interpolate along each segment and produce a corrected angle output.

Figure 16 illustrates the segmented linearization performance in the form of angle error compared to a known-good encoder angle reference.

Although accurate as shown, Figure 16 is not an insightful depiction of the true angle error performance: it only shows the angle error at the points in the transfer function where the post-linearization error is the least. If one were to measure the same device again with a much smaller angle step between samples, one would see results as shown in Figure 17. Notice the “lobes” of error between successive linearization points. These are expected because, in each segment, the error is approximated as a straight line when in fact it is sinusoidal. Given this type of sinusoidal input error pattern, Figure 17 is about the best performance one can achieve with a segmented approach using 16 segments. The segmented linearization implemented in the A1332 only allows for this 16-segment linearization. The performance of this method could conceivably be improved by either increasing the number of segments or by making the segment length variable, so that finer segments could be used for areas with higher curvature. However, both of these enhancements result in higher processing time and complexity.

As observed from analyzing errors from magnets R1 and R2, it is clear the errors are sinusoidal in nature, meaning that they can usually be well-described by constituent harmonics of appropriate phase and amplitude. Harmonic linearization takes advantage of this property and applies the linearization in the form of 15 harmonics whose phase and amplitude are determined by means of an FFT (Fast Fourier Transform) performed on the data collected from one rotation of the magnet around the angle sensor IC at the customer’s end-of-line.

There is a great deal of flexibility built into the harmonic linearization function. The value of the individual harmonic amplitudes and phases are stored in 12-bit EEPROM fields for each of 15 harmonics.

The number of harmonics that need to be applied in a linearization can be specified by using the 4-bit HAR_MAX EEPROM field. This setting determines how many individual harmonic components (from 1 to 15) are used for computing harmonic linearization (the Adv fields are used to determine which harmonics are applied for each component).

The 2-bit field ‘Adv’ field sets the increment between sequential
pairs of applied harmonic components. The value entered,
*n* (in the range 0 to 3), indicates how many harmonics are skipped from the previous component to the current component.
The count is applied as 1 + *n*. For example, the first component
(0x0C) minimum (*n* = 0) is the 1^{st} harmonic, and the maximum
(*n* = 3) is the 4^{th} harmonic. The effect is cumulative: when all
components are set to *n* = 3, the 60^{th} harmonic is available at the
fifteenth component (0x1A). As an example, we use magnet R1
in a side-shaft configuration in order to linearize an A1332.

In addition to enabling side-shaft applications, the flexibility built into this linearization method is also very useful in removing static misalignment errors at the customer’s end-of-line.

- Collect Data

Turn off all algorithmic processing except temperature compensation and IIR filtering, if these are desired (FI and TC bits in CFG_2, word 6, EEPROM bits 12+13, SRAM bits 16+17).

Move the encoder in the direction of increasing angle position. If the angle sensor IC does not also increase, then either set the LR bit to reverse the direction of the angle sensor IC or rotate the encoder in opposite direction for calibratio, in which case the post-linearization rotate bit (RO) will likely need to be set. See A1332 programming reference for more details.

Move in encoder steps such that the resultant data is a power of 2. Usually, 32 or 64 evenly spaced data points are sufficient.

- Program Coefficients

Perform an FFT on the measured data and then program the HARMONIC_AMPLITUDE, HARMONIC_PHASE, ADV, and HAR_MAX fields based on the preferred implementation. A sample implementation of these features is available from your Allegro representative.

- Enable Linearization

Set EEPROM bit HL=1 to enable harmonic linearization. The sensor output should now produce a corrected angle output.

Figure 19 shows harmonic linearization performance for magnet
R1, with HARMAX = 1 through 15 (and all ADV fields = 0). In other words, this shows the performance as harmonic correction
is incrementally applied from the 1^{st} up to the 15^{th} harmonic.

The same result is summarized in Figure 20 to show the pk-pk
angle error (on the y-axis) versus the number of correction
harmonics applied. The sharp drop in angle error after the 2^{nd}
harmonic correction is expected since the majority of the spectral
error content resides in the 2^{nd} harmonic (see section analyzing
magnetic errors).

In order to further investigate the error performance with harmonic linearization applied, especially when using small angular steps, the same device was re-measured several times with finer angle steps (higher resolution) for each run. The data shows no underlying higher error regions. The post-linearization error is < 0.3°.

Both segmented and harmonic linearization techniques are well suited for on-axis and off-axis magnetic applications. While segmented linearization divides the magnetic range into smaller sections which are linearized in a piece-wise fashion, harmonic linearization allows for a sinusoidal-based compensation of the error signal, which helps remove the high harmonic error content in misaligned as well as side-shaft arrangements. The added performance from harmonic linearization comes at the cost of higher computation time.

Figure 22 describes the additional latency to the angle measurement for each harmonic added to the harmonic linearization. For example, based on the data in Figure 20, in order to to achieve <1°, at least 7 harmonics of correction are needed, adding a processing time latency of 35 μs. This means that every angle sample will take an additional 35 μs to process. In contrast, the segmented linearization requires an additional computation time of 22 μs. Therefore, for this particular magnet, the improved error performance of harmonic linearization comes at a cost of an additional 13 μs of latency.

For many applications, the additional latency will not be a problem. For example, in typical electronic power steering (EPS) system hand-wheel angle sensor ICs, a new angle value is requested every 1 ms, meaning that there is more than enough time to perform even 15 harmonics of linearization. In addition, many systems will avail of the ORATE feature of the A1332 in order to reduce the noise-floor of the angle measurement by over-sampling. This will also inherently provide enough time to perform linearization functions without added latency since the additional averaging with allow for more time to be budgeted for linearization operations.

In this section, we analyze the performance of an angle sensor IC that has been linearized for magnets R1 and R2, and then mapped for misalignment errors in the X, Y and Z axes as shown in Figure 23. In the case of both magnets R1 and R2, we use an initial starting position at X (air-gap) = 2.75 mm and 4 mm respectively, with Y, Z = 0 mm, such that the angle sensor IC is positioned in the middle of the magnet height. We use this position as our Cartesian origin, and map misalignment performance from this reference according to the Table 2.

Magnet R1 Axes | Min (mm) | Linearization Point (mm) | Max (mm) |
---|---|---|---|

X (Air-gap) | 2.0 | 2.75 | 4.5 |

Y (Lateral) | -2.0 | 0.0 | 2.0 |

Z (Vertical) | -2.0 | 0.0 | 3.0 |

Magnet R2 Axes | Min (mm) | Linearization Point (mm) | Max (mm) |

X (Air-gap) | 4.0 | 4.0 | 8.0 |

Y (Lateral) | -2.0 | 0.0 | 2.0 |

Z (Vertical) | -2.0 | 0.0 | 3.0 |

The angle error performance for both magnets R1 and R2 as a function of air-gap (X axis) is illustrated in Figure 24.

A few observations can be made by studying the plot in Figure 24. From the value of the angle error at the linearization point (denoted by the red circle), it is clear that the angle sensor IC is able to achieve very similar post-linearization performance for both magnets. From that limited perspective, both magnets can be used to achieve identical performance. However, upon studying the shape of the error curves versus air-gap in Figure 24, it is clear that magnet R1 (black trace) has a steeper rise in error as the angle sensor IC is misaligned away from the linearization point (red circle), as compared to magnet R2 (blue trace).

As an example, increasing the air-gap between the angle sensor IC and magnet R1 by 1 mm results in the about the same performance degradation as increasing the air-gap between the same angle sensor IC and magnet R2 by 4 mm. The better air-gap performance of magnet R2 can be attributed to the fact that it is a thicker ring magnet (5 mm thick) as compared to R1 (3 mm thick).

In a similar fashion, we can analyze the misalignment performance in both the lateral and vertical (Y and Z) axes by comparing the two filled contour plots for magnets R1 and R2, shown in Figure 25 and Figure 26 respectively. These plots have been generated by using the data from lab measurements mapping the performance at each point in space. For both plots, the origin (Y = 0, Z = 0) position represents the performance at the linearized point (the same as the red dots in Figure 24). As the angle sensor IC is misaligned from this origin, the angle error observed at each point is placed in a color “bin” according to the legend shown. The numbers on the legend represent degrees of peak error. As an example, the white region in the middle of each plot denotes the area for which the angle error performance remains below ±1°. Similarly, the brown areas in each plot denote regions where the angle error is greater than ±7°.

Looking at the two contour plots, it is clear that, for the same
misalignment in Y and Z, the angle sensor IC + magnet R2
combination result is lower angle error increase as compared
to angle sensor IC + magnet R1. As an example, the white area
for which the angle error is less than ±1° is 0.669 mm^{2} for
magnet R1, while it is 1.10 mm^{2} for magnet R2. Additionally, it
is clear that the white area is vertically “elongated” in the case
of R2, compared to R1. This makes sense considering that the
vertical height of ring magnet R2 (5 mm) is greater than that of
ring magnet R1 (3 mm). These contours show the dependence of
angle error performance on magnet geometry.

On-chip, programmable, and customizable linearization, as implemented in the A1332 angle sensor IC, allows the system designer to meet the aforementioned accuracy objectives without adding additional complexity and cost to the system design.

While segmented linearization achieves faster processing times, it is limited in its ability to correct for sinusoidal error terms. In this regard, the harmonic linearization performs better. Moreover, the flexibility in the harmonic linearization approach, particularly the ability to change the number of correction harmonics used, allows the user to achieve the optimal trade-off between computation time and error performance. The result is that ±20° of angle error can be brought to within ±0.3° when linearization is applied.

Lastly, using the mapping technique, the effect of mechanical misalignment of the linearized angle sensor IC was studied. It was seen that a taller ring magnet translates into better tolerance to vertical misalignments, whereas a thicker ring magnet translates into better tolerance to changes in air-gap.

Whatever the angle sensing challenges faced by the system-level designer, a combination of appropriate magnetic design and advanced on-chip linearization, found in the Allegro A1332, can help achieve the desired performance while minimizing added complexity and cost.

*Originally published in *EE Times Europe*, June 2015. *