A New Kind of Absolute Magnetic Encoder

To fulfill the requirement of fields such as robotics, aviation, and special machining, motors with quill shafts or outer rotors have been used. For these special motors, the photoelectric encoder’s volume is normally too big and easy to be polluted by oil or dust; magnetic encoder normally has poor accuracy, and alnico piece may not provide enough magnetic field coverage area. The aim of this essay is to find a new structure of magnetic encoder to improve the precision and magnetic field coverage area. By using two multi-pole alnico rings with a different number of pole pairs to provide a magnetic field, the coverage area could be improved. The position differences between two alnicos pole positions are used to calculate absolute angle value, so the accuracy of the encoder could be absolute and no less than that of a combined magnetic encoder with the same number of pole pairs. A special algorithm is proposed for decoding. This new kind of magnetic encoder could be used on special motors with quill shafts or outer rotors. Its volume and weight are less than the photoelectric encoder and have better performance on antipollution. The alnico ring is easy to modify to suit the structure of the motor.


Introduction
Servo motor systems are widely used nowadays. In fields such as robotics, aviation, and special machining, the system needs to be miniaturized and lightweight owing to the requirements of the working environment. Motors with quill shafts or outer rotors have been proposed and used to meet these needs. To fulfill the required control accuracy, a suitable angular displacement sensor needs to be used in the system. Two kinds of sensors commonly used in servo motor systems are the photoelectric encoder and magnetic encoder. A photoelectric encoder has high accuracy but normally has a relatively big size and high cost and performs poorly in an environment with vibration disturbance or low cleanliness. A magnetic encoder is cheaper and smaller and is strongly resistant to pollution and disturbance, but its accuracy is poorer.
Research on photoelectric encoders has mainly focused on acclimatization and reducing volume. Zhao transformed the signal current from the encoder s receiver into a signal voltage and then processed the signal through other chips, which reduced the effects of environmental temperature and working time on the light source and receiver [1,2]. To reduce the volume, Wang and Xi used single-ring coding to engrave the code disk of the photoelectric encoder, making the code disk smaller [3,4]. Wang also created a metal code disk to improve the impact resistance of the encoder [3]. Yu used an image detector instead with a traditional moiré fringe method and designed a small photographic encoder with a diameter of 50 mm [5].
For a magnetic encoder, the research emphasis has mainly been on increasing the encoder's accuracy and resolution and reducing the effects of disturbance. The method of the look-up table is often used in early research. Nakano used CMOS magnetic sensors to detect magnetic fields, then created a table of sensors offset and used it to correct the final output [6]. Hao created a table of the relationship between Hall sensors' output and photoelectric encoder's output for calibration, increased the accuracy of the encoder to 13bits [7]. This method is still used in recent research. Park used a gear system to combine the main shaft with some subshafts, and the signals from alnicos on subshafts could be broken to subdivide the signal from the alnico of the main shaft [8]. Then Nguyen proposed a self-referencing lookup-table algorithm to improve the accuracy of this encoder [9]. Another method is improving the structure of the encoder. Pavel designed an encoder with a Hall ring and a specially designed permanent magnet to achieve ± 0.1 degrees without calibration [10]. Zhang used coils stimulated by the external current to generate the magnetic field, then used two groups of secondary windings to detect the change of magnetic field and calculate angular by signal processing circuit [11]. Yamamoto designed a magnetic encoder with an eccentric structure, using four linear Hall sensors to receive signals from the eccentrically rotating multi-pole alnico and then calculate the absolute angle through a least-squares algorithm [12]. Wang built a relationship between the time pulse and magnetic signal from magnetoresistance sensors and then calculated the angle by counting the time pulse [13]. Tran used a combined encoder and designed an algorithm based on an adaptive linear neural network to reduce the effects of noise and offset [14].
A motor with a quill shaft always has a relatively large radial dimension. A photoelectric encoder needs more grating to be processed and has a higher cost. From the studies above, it is evident that the oil and dust pollution of the light source and receiver still has not been solved. For a magnetic encoder, the magnetic field from the normal alnico has a saddle-type distortion and limited coverage area. To cover the end face of a quill shaft motor, the alnico needs to be larger but will be easy to break owing to stress. Ripka used a coil as a magnetic field source with a working distance of 20 m, but the accuracy was poor [15]. Therefore, finding a suitable encoder for a motor with a quill shaft is an important problem to research. This paper proposes a new kind of magnetic encoder and a method to determine its absolute angle. This encoder uses alnico rings instead of permanent magnet sheets, so it is more suitable for a motor with a quill shaft than other magnet encoders. By using the position relationship between outer and inner alnico rings to calculate the angular value, the method could eliminate the effects of processing and installing. The structure of this encoder is flexible, and the algorithm is simple. Figure 1 shows the schematic of the magnetic encoder's signal generation principle. Two multi-pole alnico rings are installed on a motor's rotary shaft coaxially and rotate with it, outputting a magnetic signal that correlates with angle. Four Hall linear sensors are installed around alnicos at equal spacings. These sensors collect a magnetic signal and then send it to the MCU. Finally, the absolute angle can be calculated after the MCU is processed.  Figure 2 is a simplified sketch of the magnetic encoder. The dark part is a north pole, and the light part is a south pole, and a north pole and a south pole compose a pole pair. The angle 0 • is set as the start point. When the alnico rotates to point A, the absolute angle of A can be calculated via

Principle of Angle Measurement
where θ is the absolute angle of point A; N i is the pole position, meaning which pair of poles point A is at; θ i is the angle in a single cycle, which is the angle of point A at the current pole pair; m is the number of pole pairs. Two linear Hall sensors are installed around each alnico, and the phase angle between them is set as 90 • . Then θ i can be calculated with the arctangent algorithm: where V A and V B are the voltage signals from Hall sensors A and B, respectively. The arctangent range is [−90 • ,90 • ], so θ i from Formula (2) cannot be directly used to calculate the absolute angle. Owing to the relative magnitudes of V A and V B , the angular range (0 • , 360 • ) can be divided into eight intervals [12]. The angle in each interval can then be calculated via the corresponding formula.
After calculating the angle in a single cycle of θ i , identifying N i is the key to calculate the absolute angle.

Encoding Principle with Two Multi-Pole Alnicos
Two multi-pole alnicos are used in the encoder. Their positions relative to each other can be used to determine a unique characteristic for each pair of poles on the outer alnico. If each point in each pair of poles on the outer alnico in Figure 2 has a non-redundant corresponding point on the inner alnico, then the inner signal can be used as the unique characteristic to identify which pair of poles the outer signal is from. However, Figure 3 shows that when the outer alnico has four pairs of poles, and the inner alnico has two, the position relationship between the outer first pole pair and inner alnico is the same as that of the outer third pole pair and inner alnico, so the signal cannot be used to identify a pole pair. Therefore, the uniqueness of the position relationship needs to be proved first. Consider two random points, i1 and i2, on the outer alnico and their corresponding points, j1 and j2, on the inner alnico. The pole positions of these points are N i1 , N i2 , N j1 , and N j2 . The single-cycle angles of the points are θ i1 , θ i2 , θ j1 , and θ j2 and the absolute angles of i1 and i2 are θ 1 and θ 2 . The difference in angle between the initial position of the north pole of pole-pair x on the outer alnico and the initial position of the north pole of pole-pair x on the inner alnico is θ x . Figure 4 shows a simplified sketch of the encoder. Using Formula (1), the following equations can be obtained: It can be seen that θ 1 = θ 2 when θ i1 = θ i2 or θ j1 = θ j2 . When N i1 =N i2 , points i1 and i2 are in the same cycle, which implies that θ i1 = θ i2 . Similarly, θ j1 = θ j2 when N j1 =N j2 . Therefore, the uniqueness of the position relationship can be proved if a condition can be found that satisfies θ 1 = θ 2 when N i1 = N i2 and N j1 = N j2 .
Assume that θ i1 = θ i2 and θ j1 = θ j2 when N i1 = N i2 and N j1 = N j2 . Subtracting one equation in Formula (3) from the other, the following formula can be obtained: Given that N i ≤ m, it can be seen that when m and n are coprime, Formula (4) cannot be satisfied. Therefore, the position relationship is unique when the two alnicos have a coprime number of pole pairs.
Formula (3) can be transformed into the following formula: Setting λ = θ i m − θ j n , it can be seen that for two random points on the outer alnico, λ 1 = λ 2 when m and n are coprime. Because the values of m, n, and θ x are defined when the encoder is processed, the amount of λ is limited and can be used as a characteristic value. Therefore, θ i m − θ j n can be used to calculate λ, λ can be used to determine N i , and Formula (1) can be used to calculate θ.

Calculation of Characteristic Value
When the encoder has been processed, the positions of the outer and inner alnicos relative to each other are determined. Then the characteristic value can be calculated. Figure 5 is the curve of the characteristic value from an encoder with 16 pole pairs on the outer alnico and seven pole pairs on the inner. Using the value to calculate the angle ensures absoluteness. However, in practical work, the corresponding interval of each value has not been determined at this time owing to the unknown installation position error θ x , which means the pole position corresponding to the value cannot be determined. From Formula (1), the pole position N i can be calculated when the absolute angle θ and single-cycle angle θ i are known. To improve the accuracy of the encoder, a high-accuracy photoelectric encoder will be used to output the absolute angle for calibration. Then the pole position can be calculated, and the relationship between the pole position and characteristic value can be determined by using pole position to calculate characteristic value.
In practical work, the relationship between the absolute angle and single-cycle angle cannot be strict owing to the error, so the calculated pole position may not be accurate. The algorithm below is proposed to solve the problem.

1.
Use the ideal absolute angle to simulate the output of the photoelectric encoder. Set the first sample point as 0 • , the last sample point as 360 • , and the step as 0.01 • . Then the relationship between the absolute and single-cycle angles of the outer alnico is as shown in Figure 6.

2.
Divide the sample points in a whole cycle into M equal intervals. The value of M is based on the number of pole pairs m and number of sample points to make sure M > m and each interval has enough sample points. Figure 6 is a partial curve for M = 256.

3.
Use the value of the first sample point θ Mi in interval i to subtract the value of the first sample point θ Mi−1 in interval i − 1. Then M − 1 differences D i are obtained. Figure 7 shows a partial curve of D i and its corresponding intervals.

4.
Set the pole position of the first sample point in the first interval equals to m, then successively judge whether the D i of subsequent intervals is less than 0. If D i > 0, then the pole position has not changed between the previous and current intervals, so the pole position of the current interval is the same as that of the previous one. If D i < 0, then the pole position has changed at some point between these two intervals, and the pole position of the current interval is that of the previous one plus 1. When the pole position N is greater than m, set it as 1. In Figure 7, D 106 represents the situation when D i > 0, and D 109 represents D i < 0. After this processing, the relationship between intervals and pole positions can be determined preliminarily. Figure 8 shows the relationship between partial intervals and pole positions. There is still an error when M = 108. 5.
Use the pole position of interval i to subtract the pole position of interval i − 1 to obtain difference τ i , and the pole position of the first interval to subtract the pole position of interval M to obtain difference τ 1 . Then M differences are obtained, as shown in Figure 9. 6.
Match each difference with corresponding intervals, then find out the intervals with differences of 1 or 1 − m; these intervals include sample points when the pole position changes. Combine each of these intervals with its previous one. Then m intervals are obtained. These intervals compose a set T.

7.
If the interval of a sample point does not belong to T, there will be no pole position change in the interval. Then the pole position of the point is the same as that of the interval. If the interval of a sample point belongs to T, then the point may be the intersection of pole positions. If the angle of the point is greater than 180 • , its pole position is 1 less than that of the interval; if the angle of the point is greater than 180 • , then its pole position is the same as that of the interval. After the processing, the corresponding relationship between the single-cycle angle and pole position can be determined. The partial result is shown in Figure 10.     According to Formula (5), θ x is needed to build the relationship between the characteristic value and pole position. Transforming Formula (5) gives Calculating the average of the characteristic value λ * and putting it into Formula (6) gives the approximate value of θ x . In this simulation, N 1 = 16, N 2 = 7, and θ x = −24.04 • .
Formula (5) can be written as If θ x is brought into Formula (7), then the relationship between the characteristic value and pole position can be built as shown in Table 1.

Encoder Simulation
The processing flow of the magnetic signal is shown in Figure 11. We perform a Maxwell simulation of the magnetic signal. The step is 0.01 • , anticlockwise is the positive direction, and 36,000 points are taken in the range 0-360 • as the raw signal. These points can be thought of as the signal from an alnico rotating clockwise at low speed. The outer alnico has 16 pole pairs, and the inner alnico has 7.
For the simulation, we use an A1326LLHLX-2-T linear Hall sensor from Allegro. The main characteristic parameters of this sensor are shown in Table 2. When the rotor rotates, the linear Hall sensor could turn the change of magnetic field intensity to the change of voltage, then send the voltage signal to MCU to calculate angular. The rotor's planning speed is 2000 rpm, so this linear Hall sensor's performance is sufficient. The position of the Hall sensors is the start point, the sampling points are taken as the abscissa, and the magnetic field intensity is the ordinate. Figure 12 shows the signals of Hall sensors H1 and H2 around the outer alnico, and Figure 13 shows the signals of Hall sensors H3 and H4 around the inner alnico. The solid curves are the signals of H1 and H3, and the dashed curves are those of H2 and H4.  These signals are put into the simulation platform. Figures 14 and 15 show the decoding results from the arctangent algorithm. The outer alnico has 16 groups of angle values from 0 • to 360 • , and the inner has seven groups of angle values from 0 • to 360 • , in accord with the setting of the outer and inner alnicos.   Table 1 shows the calculated characteristic value and its relationship with pole position. Then the absolute angle can be calculated through Formula (1). Figure 16 shows the corresponding relationship between sample points and pole positions, and Figure 17 shows the calculated absolute angle. Because the pole position of the first sample point is set at 16, the start point of the absolute angle in Figure 17 is not zero.

Conclusions
To fulfill the requirements of a motor with a large radial dimension, this paper has presented the theory of a new combined magnetic encoder with two multi-pole alnico rings. First, it was proved that the position relationship between two alnicos is unique when the alnicos each have a coprime number of pole pairs so that the signal of the inner alnico can be used to identify the pole position of the outer alnico. Then a method of calculating the characteristic value was designed, and this value was used to calculate the absolute angle. Finally, the encoding and decoding theory was verified through simulation.