Magnetic encoder and method for calculating fine electrical angle values thereof
By combining a non-uniform sector design with three pairs of magnetic sensors, the problems of boundary magnetic pole truncation and angle ambiguity of the magnetic encoder are solved, achieving high-precision and high-speed response absolute angle calculation.
Patent Information
- Application Number
- CN202611299838.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-06
AI Technical Summary
Magnetic encoders suffer from boundary magnetic pole truncation, magnetic field distortion, and angular ambiguity under uniform sector division, making it difficult to achieve both high resolution and high real-time processing.
A non-uniform sector design is adopted, with the mechanical angles of the first, second, and third sectors being unequal. Three pairs of magnetic sensors are deployed on the circuit board, and the efficient calculation of fine electrical angle values is achieved by calculating the electrical angle difference and phase compensation.
It effectively suppresses magnetic field distortion, eliminates angular ambiguity, improves the absolute accuracy and dynamic response performance of the encoder, and supports high-speed real-time calculation at high resolution.
Smart Images

Figure CN123045404A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of encoder technology, and in particular to a magnetic encoder and a method for calculating its fine electrical angle value. Background Technology
[0002] In applications such as industrial automatic control, robot joint drive, and high-precision CNC machine tools, encoders, as sensing devices that convert mechanical displacement (including angular displacement and linear displacement) into electrical signal output, are widely used in position detection and speed feedback.
[0003] Based on the signal reading method, encoders can be divided into two categories: contact and non-contact. According to the signal output mechanism, encoders are generally divided into two main types: incremental encoders and absolute encoders. Absolute encoders use a unique digital code that corresponds one-to-one with the spatial position. Their output value directly reflects the current absolute position, and the measurement result depends only on the code values of the starting and ending positions, and is independent of the intermediate motion process. Therefore, they possess power-off memory capability and anti-interference advantages.
[0004] A magneto-electric encoder is a non-contact encoder that uses changes in a magnetic field to sense position. A typical structure includes a magnetic ring rotor fixed to a rotating shaft and a magnetic sensing element arranged opposite it. The magnetic sensing element can be a Hall effect element or various magnetoresistive sensors (such as anisotropic magnetoresistive or giant magnetoresistive). When the rotating shaft drives the magnetic ring rotor to rotate, the magnetic field vector (including direction and amplitude) in the surrounding space changes periodically. The magnetic sensing element detects this magnetic field fluctuation in real time and outputs a sine / cosine analog voltage signal that is functionally related to it. This analog signal is amplified, filtered, and bias-compensated by subsequent signal conditioning circuitry, and then subjected to analog-to-digital conversion and digital signal processing (such as counting, table lookup, or CORDIC algorithm decoding) to finally output digital data representing the current displacement state.
[0005] To meet the stringent requirements of high-end applications such as servo control and collaborative robots for high-resolution absolute angles per revolution (e.g., 24 bits or more), a common approach is to uniformly divide the magnetic ring into three 120° sectors and fill them with coprime pole pairs (e.g., 11, 12, and 13 pole pairs), using the principle of vernier calipers for calculation. However, this approach has three major drawbacks: First, the uniform sector division leads to pole truncation at the boundaries, causing magnetic field distortion and harmonics, resulting in distorted sine / cosine signals. Since the arctangent calculation function is extremely sensitive to amplitude disturbances, uncompensated jump errors will occur at the boundaries. These jump errors drift with rotational speed and temperature and cannot be effectively compensated for through static calibration or filtering, severely limiting the accuracy of the magnetic encoder. Second, boundary distortion creates angular ambiguity points, significantly reducing linearity and repeatability. Third, traditional calculations rely on floating-point operations and lookup tables, resulting in poor real-time performance and difficulty in meeting high-speed output requirements above 30kHz. Therefore, it is urgent to solve the problems of boundary distortion, angle ambiguity and low solution efficiency caused by uniform sector division. Summary of the Invention
[0006] The purpose of this invention is to solve the technical problems of boundary magnetic pole truncation and magnetic field distortion caused by the uniform sector division of the magnetic ring in magnetic encoders, angle ambiguity at sector boundaries, and the difficulty in simultaneously achieving high resolution and high real-time calculation. This invention proposes a magnetic encoder and its refined electrical angle value calculation method, which effectively suppresses boundary magnetic field distortion, eliminates angle ambiguity, and enables high-speed real-time calculation at high resolution, thereby significantly improving the absolute accuracy and dynamic response performance of the encoder.
[0007] In a first aspect, to solve the above-mentioned technical problems, embodiments of the present invention disclose a magnetic encoder, comprising: a circuit board; a magnetic ring rotor, wherein the circuit board and the magnetic ring rotor are spaced apart along the axial direction, and the magnetic ring rotor includes a first sector, a second sector, and a third sector along the circumferential direction; wherein the first sector is provided with multiple pairs of first magnetic pole pairs, the multiple pairs of first magnetic pole pairs are distributed along the circumferential direction, and the first sector has a first mechanical angle; the second sector is provided with multiple pairs of second magnetic pole pairs, the multiple pairs of second magnetic pole pairs are distributed along the circumferential direction, and the second sector has a second mechanical angle; the third sector is provided with multiple pairs of third magnetic pole pairs, the multiple pairs of third magnetic pole pairs are distributed along the circumferential direction, and the third sector has a third mechanical angle, wherein the first mechanical angle, the second mechanical angle, and the third mechanical angle are not equal to each other.
[0008] By adopting the above technical solution, by setting the first mechanical angle, the second mechanical angle, and the third mechanical angle to be unequal, the spatial phases of each sampled signal are staggered, avoiding the three signals falling near the zero-crossing point of the magnetic pole period. This avoids the magnetic pole truncation phenomenon that occurs at the boundary of some sectors when the 120° uniform division is used in the traditional solution, and eliminates the angle ambiguity point from a physical perspective, laying the foundation for achieving high linearity and high repeatability absolute angle measurement.
[0009] According to another specific embodiment of the present invention, the first mechanical angle is 130°; the second mechanical angle is 120°; and the third mechanical angle is 110°.
[0010] According to another specific embodiment of the present invention, the first sector is provided with 11 pairs of magnetic pole pairs, the second sector is provided with 12 pairs of magnetic pole pairs, and the third sector is provided with 13 pairs of magnetic pole pairs, wherein the widths of the first pair of magnetic pole pairs, the second pair of magnetic pole pairs, and the third pair of magnetic pole pairs are not equal to each other.
[0011] According to another specific embodiment of the present invention, the circuit board is provided with a first pair of magnetic sensors, a second pair of magnetic sensors, and a third pair of magnetic sensors; wherein, the first pair of magnetic sensors corresponds to the first sector in spatial position; the second pair of magnetic sensors corresponds to the second sector in spatial position; and the third pair of magnetic sensors corresponds to the third sector in spatial position.
[0012] By adopting the above technical solution, only three pairs of magnetic sensors (i.e., six magnetic sensing elements) need to be arranged on the circuit board. Compared with the arrangement of eight magnetic sensing elements required in the prior art, the circuit board area is effectively reduced, which is conducive to the development of the overall encoder structure towards miniaturization and lightweighting, and effectively reduces production costs.
[0013] According to another specific embodiment of the present invention, the first magnetic sensor pair is disposed at the position where the first sector and the second sector are connected; the second magnetic sensor pair is disposed at the position where the second sector and the third sector are connected; and the third magnetic sensor pair is disposed at the position where the third sector and the first sector are connected.
[0014] According to another specific embodiment of the present invention, the first magnetic sensor pair is disposed above, below, or around the magnetic ring rotor; the second magnetic sensor pair is disposed above, below, or around the magnetic ring rotor; and the third magnetic sensor pair is disposed above, below, or around the magnetic ring rotor.
[0015] According to another specific embodiment of the present invention, any one of the magnetic sensors in the first pair of magnetic sensors is a tunnel magnetoresistive angle sensor or an anisotropic magnetoresistive sensor; any one of the magnetic sensors in the second pair of magnetic sensors is a tunnel magnetoresistive angle sensor or anisotropic magnetoresistive sensor; and any one of the magnetic sensors in the third pair of magnetic sensors is a tunnel magnetoresistive angle sensor or anisotropic magnetoresistive sensor.
[0016] Secondly, embodiments of the present invention disclose a method for calculating the fine electrical angle value of a magnetic encoder. The magnetic encoder includes a circuit board and a magnetic ring rotor. The magnetic ring rotor includes a first sector, a second sector, and a third sector along the circumferential direction. The first sector has a first mechanical angle, the second sector has a second mechanical angle, and the third sector has a third mechanical angle. The first mechanical angle, the second mechanical angle, and the third mechanical angle are not equal to each other. The method involves: obtaining the first electrical angle value of the first sector; obtaining the second electrical angle value of the second sector; obtaining the third electrical angle value of the third sector; determining a first electrical angle difference between the first electrical angle value and the second electrical angle value, and a second electrical angle difference between the second electrical angle value and the third electrical angle value; determining a coarse angle value based on the first electrical angle difference and / or the second electrical angle difference; determining the target sector where the coarse angle value is located, where the target sector is any one of the first sector, the second sector, and the third sector; and correcting the coarse angle value based on the electrical angle value and the number of magnetic pole pairs in the target sector to obtain the fine electrical angle value.
[0017] By adopting the above technical solution, the present invention first obtains three electrical angle values of three sectors, then determines the coarse angle value by calculating the first electrical angle difference and / or the second electrical angle difference. Furthermore, the target sector to which the coarse angle value belongs is determined based on the coarse angle value, and the electrical angle value and the number of magnetic pole pairs of the target sector itself are selected for fine correction to obtain the fine electrical angle value. This effectively avoids the interference of boundary magnetic field distortion on coarse positioning in the traditional uniform sector scheme, eliminates angle ambiguity points, and thus significantly improves the absolute accuracy and dynamic response performance of the encoder.
[0018] According to another specific embodiment of the present invention, the circuit board is provided with a first magnetic sensor pair, a second magnetic sensor pair and a third magnetic sensor pair, wherein the first magnetic sensor pair corresponds to the first sector in spatial position; the second magnetic sensor pair corresponds to the second sector in spatial position; and the third magnetic sensor pair corresponds to the third sector in spatial position.
[0019] The first quadrature sensing signal output by the first magnetic sensor is acquired; the first quadrature sensing signal is converted from analog to digital and processed by arctangent to obtain the first initial electrical angle value of the first sector; the first phase zero compensation value of the first sector is acquired, and the first initial electrical angle value is moduloed and normalized based on the first phase zero compensation value to obtain the first electrical angle value of the first sector.
[0020] Acquire the second orthogonal sensing signal output by the second magnetic sensor; perform analog-to-digital conversion and arctangent processing on the second orthogonal sensing signal to obtain the second initial electrical angle value of the second sector; obtain the second phase zero compensation value of the second sector, and perform modulo and normalization processing on the second initial electrical angle value based on the second phase zero compensation value to obtain the second electrical angle value of the second sector;
[0021] The third quadrature sensing signal output by the third magnetic sensor is acquired; the third quadrature sensing signal is converted from analog to digital and processed by arctangent to obtain the third initial electrical angle value of the third sector; the third phase zero-point compensation value of the third sector is obtained, and the third initial electrical angle value is modulo-normalized based on the third phase zero-point compensation value to obtain the third electrical angle value of the third sector.
[0022] According to another specific embodiment of the present invention, a coarse angle value is determined by a binary search method based on the first electrical angle difference and the second electrical angle difference; or, the coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the first electrical angle difference; or, the coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the second electrical angle difference.
[0023] Using the above technical solution, when all magnetic sensors are working normally, the coarse angle value is determined by binary search based on the first electrical angle difference and the second electrical angle difference; when any magnetic sensor pair corresponding to any sector fails, the coarse angle value can still be obtained by independently querying the one-dimensional lookup table based on the remaining effective electrical angle difference and the complete angle output can be completed, which can meet the high-precision calculation under normal and abnormal working conditions.
[0024] According to another specific embodiment of the present invention, the starting angle value and the number of magnetic pole pairs of the target sector are obtained; the actual electrical angle value is obtained by data processing based on the coarse angle value and the starting angle value; the ideal electrical angle value is obtained by data processing based on the actual electrical angle value and the number of magnetic pole pairs; the correction value is obtained by normalization based on the actual electrical angle value and the ideal electrical angle value, and the coarse angle value is corrected according to the correction value to obtain the fine electrical angle value.
[0025] According to another specific embodiment of the present invention, after obtaining the fine electrical angle value, the current fine angle value, the previous fine angle value, and the hysteresis threshold are acquired, wherein the hysteresis threshold includes a first hysteresis threshold and a second hysteresis threshold; when the previous fine angle value is greater than the first hysteresis threshold and the current fine angle value is less than the second hysteresis threshold, the number of revolutions is incremented by 1; when the previous fine angle value is less than the second hysteresis threshold and the current fine angle value is greater than the first hysteresis threshold, the number of revolutions is decremented by 1; and the absolute position value is determined based on the current accumulated number of revolutions and the current fine angle value.
[0026] By adopting the above technical solution, this invention sets up a revolution register continuously powered by a battery, which can still record the revolution changes caused by external force rotation and other factors in real time after the encoder is powered off, and there is no need to perform a zero-finding operation when power is restored. At the same time, by setting a first hysteresis threshold and a second hysteresis threshold to form an anti-shake window, the revolution accumulation or subtraction is triggered only when the current fine angle value reliably crosses the boundary of the whole revolution, avoiding false counting caused by the electrical angle value jittering near the critical point due to mechanical vibration or electromagnetic interference, thereby ensuring the accuracy and stability of the absolute position value of multiple revolutions.
[0027] Thirdly, embodiments of the present invention also disclose a computer storage medium, including a memory and a processor, the memory being adapted to store computer instructions, and the processor being adapted to execute, when running the computer instructions, a fine electrical angle value calculation method for a magnetic encoder as described in any of the preceding claims.
[0028] Fourthly, embodiments of the present invention also disclose a computer program product, including a computer program / instruction, which, when executed by a processor, implements the fine electrical angle value calculation method for a magnetic encoder as described in any of the preceding claims. Attached Figure Description
[0029] Figure 1A A schematic diagram of the structure of the magnetic encoder provided in an embodiment of this application is shown.
[0030] Figure 1B An exploded view of the sector of a magnetic encoder provided in an embodiment of this application is shown.
[0031] Figure 1C A second schematic diagram of the structure of the magnetic encoder provided in an embodiment of this application is shown.
[0032] Figure 2A A schematic diagram illustrating the signal output principle of the first magnetic sensor pair provided in an embodiment of this application is shown.
[0033] Figure 2B A schematic diagram illustrating the signal output principle of the second magnetic sensor pair provided in an embodiment of this application is shown.
[0034] Figure 2C A schematic diagram illustrating the signal output principle of the third magnetic sensor pair provided in an embodiment of this application is shown.
[0035] Figure 3 A schematic diagram of the application scenario structure of the magnetic encoder provided in the embodiments of this application is shown.
[0036] Figure 4A A schematic diagram illustrating the application principle of the magnetic encoder provided in this application embodiment is shown.
[0037] Figure 4B A schematic diagram of the architecture of the data acquisition and processing module provided in an embodiment of this application is shown.
[0038] Figure 4C A schematic diagram of the architecture of the battery management module provided in an embodiment of this application is shown.
[0039] Figure 5 A detailed parameter diagram of the humanoid robot left knee joint module provided in an embodiment of this application is shown.
[0040] Figure 6 A flowchart is shown of a method for calculating the fine electrical angle value of a magnetic encoder according to an embodiment of this application.
[0041] Figure 7 A schematic diagram illustrating the performance requirements of the humanoid robot provided in this application embodiment is shown.
[0042] Figure 8 A block diagram of an electronic device provided in an embodiment of this application is shown.
[0043] Figure 9 A block diagram of a system-on-a-chip (SoC) provided in an embodiment of this application is shown.
[0044] Explanation of icon numbers:
[0045] 100. Magnetic ring rotor;
[0046] 101. First magnetic pole pair; 102. Second magnetic pole pair; 103. Third magnetic pole pair;
[0047] 200. Circuit board;
[0048] 201. First magnetic sensor pair; 202. Second magnetic sensor pair; 203. Third magnetic sensor pair;
[0049] 300. Electric motor;
[0050] 301. Sensor bracket; 302. MCU; 303. TMR sensor; 304. Motor output shaft; 305. Communication chip. Detailed Implementation
[0051] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Although the description of the present invention is presented in conjunction with preferred embodiments, this does not mean that the features of the invention are limited to these embodiments. On the contrary, the purpose of describing the invention in conjunction with embodiments is to cover other options or modifications that may be derived based on the claims of the present invention. To provide a deep understanding of the invention, many specific details will be included in the following description. The invention may also be implemented without using these details. Furthermore, to avoid confusion or obscuring the focus of the invention, some specific details will be omitted in the description. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0052] It should be noted that in this specification, similar reference numerals and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0053] In the description of this embodiment, it should be noted that the terms "upper", "lower", "inner", "bottom", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship that the product of the invention is usually placed in during use. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting the present invention.
[0054] The terms “first”, “second”, etc., are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0055] In the description of this embodiment, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set up," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this embodiment based on the specific circumstances.
[0056] Before proceeding to the main text of the instruction manual, the following terms will be explained:
[0057] FPGA stands for Field-Programmable Gate Array. It is an integrated circuit whose logic functions can be reconfigured after leaving the factory through a hardware description language. It is often used in high-speed signal preprocessing, parallel computing, and interface protocol conversion.
[0058] PMU stands for Power Management Unit. In a circuit system, the PMU is responsible for converting external input power into different voltage rails (such as VDD / VSS) required by various chips, and providing stable, low-noise power to ADCs, FPGAs, MCUs, and communication chips to ensure the electromagnetic compatibility and operational stability of the system under various operating conditions.
[0059] Electrical angle: refers to the 360° periodic electrical signal angle corresponding to a single magnetic pole pair (N pole and S pole) of a magnetic encoder.
[0060] Mechanical angle: refers to the actual 360° circumferential angle of the encoder shaft in physical space. For a sector with P pole pairs, its electrical angle and mechanical angle satisfy: Electrical angle = P × Mechanical angle.
[0061] In applications such as industrial automatic control, robot joint drive, and high-precision CNC machine tools, encoders, as sensing devices that convert mechanical displacement (including angular displacement and linear displacement) into electrical signal output, are widely used in position detection and speed feedback.
[0062] Based on the signal reading method, encoders can be divided into two categories: contact and non-contact. According to the signal output mechanism, encoders are generally divided into two main types: incremental encoders and absolute encoders. Absolute encoders use a unique digital code that corresponds one-to-one with the spatial position. Their output value directly reflects the current absolute position, and the measurement result depends only on the code values of the starting and ending positions, and is independent of the intermediate motion process. Therefore, they possess power-off memory capability and anti-interference advantages.
[0063] A magneto-electric encoder is a non-contact encoder that uses changes in a magnetic field to sense position. A typical structure includes a magnetic ring rotor fixed to a rotating shaft and a magnetic sensing element arranged opposite it. The magnetic sensing element can be a Hall effect element or various magnetoresistive sensors (such as anisotropic magnetoresistive or giant magnetoresistive). When the rotating shaft drives the magnetic ring rotor to rotate, the magnetic field vector (including direction and amplitude) in the surrounding space changes periodically. The magnetic sensing element detects this magnetic field fluctuation in real time and outputs a sine / cosine analog voltage signal that is functionally related to it. This analog signal is amplified, filtered, and bias-compensated by subsequent signal conditioning circuitry, and then subjected to analog-to-digital conversion and digital signal processing (such as counting, table lookup, or CORDIC algorithm decoding) to finally output digital data representing the current displacement state.
[0064] To meet the stringent requirements of high-end applications such as servo control and collaborative robots for high-resolution single-turn absolute angles (e.g., 24 bits or more), existing technologies generally employ multi-pole magnetic rings combined with the principle of vernier calipers for absolute angle calculation. A typical implementation involves dividing the magnetic ring into three uniform sectors (i.e., 120° each) along its circumference, and filling each sector with coprime magnetic fields of different numbers of pole pairs, such as 11, 12, and 13 pole pairs. In this scheme, each sector outputs a pair of orthogonal differential signals (i.e., Sin+, Sin-, Cos+, Cos-) that are 90° out of phase. Thus, the three sectors output three sets of differential signals, requiring six analog signal lines. When the mechanical axis rotates one revolution, the first, second, and third sectors output 11, 12, and 13 complete sine / cosine cycles, respectively. Utilizing the uniqueness of the coprime pole pair combination within a 360° range, the absolute angle information is calculated. However, the existing solutions mentioned above still have the following significant drawbacks in practical engineering applications:
[0065] First, uniform sector division leads to boundary magnetic field distortion. In the aforementioned 120° equally divided architecture, the total number of pole pairs is 36, with a theoretical span of 10° per pair. Calculations show that only sector 2 with 12 pole pairs can be precisely aligned with the 120° sector boundary over a full cycle, while sector 1 with 11 pole pairs and sector 3 with 13 pole pairs inevitably experience pole truncation at the boundaries. This pole truncation effect causes abrupt magnetic field boundaries at the 120° and 240° mechanical positions, resulting in severe nonlinear magnetic field distortion and high-order harmonics. This distortion directly leads to waveform distortion of the sine / cosine signal output by the magnetic sensing element, causing unexpected jumps in the electrical angle obtained subsequently based on arctangent (atan2) calculations at the boundaries. Furthermore, this error originates from the physical structure and cannot be eliminated by conventional software filtering or compensation algorithms. In applications requiring 24-bit or higher ultra-high resolution, this systematic error caused by magnetic field distortion has become a technical bottleneck restricting further improvements in encoder accuracy.
[0066] Secondly, there is the existence of angular ambiguity. When the rotor rotates to the aforementioned sector boundary position of 120° or 240°, the angle calculation value jumps due to magnetic field distortion, forming the so-called "angular ambiguity". These ambiguities seriously affect the measurement accuracy of the encoder's linearity index and lead to a decrease in repeatability accuracy, especially in low-speed servo control and precision alignment applications, where the impact of this problem is particularly prominent.
[0067] Third, traditional angle calculation methods are inefficient and struggle to support high-speed data refresh rates. To achieve absolute angle calculation, existing algorithms typically rely on floating-point operations and linear lookup tables (LUTs) for angle matching and interpolation. Since handling the combination relationships between multiple sets of coprime pole-logarithmic signals is necessary, floating-point operations are computationally intensive, and linear lookup methods are significantly time-consuming when traversing large-scale code tables. In high-speed real-time control systems requiring data output rates above 30kHz, these traditional methods struggle to update the angle within a given time window, thus limiting the improvement of system bandwidth and control performance.
[0068] In view of this, the present invention aims to solve the problems caused by the uniform sector division of the magnetic ring of the magnetic encoder, such as the truncation of the boundary magnetic poles and magnetic field distortion, the ambiguity of the angle at the sector boundary, and the difficulty in balancing high resolution and high real-time calculation. The present invention proposes a magnetic encoder and its fine electrical angle value calculation method, which realizes the effective suppression of the boundary magnetic field distortion of the magnetic encoder, the elimination of the ambiguity of the angle, and high-speed real-time calculation at high resolution, thereby significantly improving the absolute accuracy and dynamic response performance of the encoder.
[0069] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0070] This application discloses a magnetic encoder. Figure 1A This is a schematic diagram of the structure of a magnetic encoder provided in an embodiment of this application. Figure 1B This paper shows an exploded sector diagram of a magnetic encoder provided in an embodiment of this application. (Refer to...) Figure 1A and Figure 1B The magnetic encoder includes a circuit board 200 and a magnetic ring rotor 100. The circuit board 200 and the magnetic ring rotor 100 are spaced apart along the axial direction. The magnetic ring rotor 100 includes a first sector a, a second sector b and a third sector c along the circumferential direction.
[0071] The first sector a is provided with multiple pairs of first magnetic pole pairs 101. For example, the first sector a is provided with 11 pairs of magnetic pole pairs, each pair of magnetic pole pairs including an S pole and an N pole. The multiple pairs of first magnetic pole pairs 101 are distributed circumferentially. The first sector a has a first mechanical angle θ1. Preferably, the first mechanical angle θ1 is 130°.
[0072] The second sector b is provided with multiple pairs of second magnetic pole pairs 102. For example, the second sector b is provided with 12 pairs of magnetic pole pairs, each pair of magnetic pole pairs including an S pole and an N pole. The multiple pairs of second magnetic pole pairs 102 are distributed circumferentially. The second sector b has a second mechanical angle θ2. Preferably, the second mechanical angle θ2 is 120°.
[0073] The third sector c is provided with multiple pairs of third magnetic pole pairs 103. For example, the third sector c is provided with 13 pairs of magnetic pole pairs, each pair of magnetic pole pairs including an S pole and an N pole. The multiple pairs of third magnetic pole pairs 103 are distributed circumferentially. The third sector c has a third mechanical angle θ3. The first mechanical angle θ1, the second mechanical angle θ2 and the third mechanical angle θ3 are not equal to each other. Preferably, the third mechanical angle θ3 is 110°.
[0074] It should be noted that the above angle ranges are merely illustrative and do not constitute a limitation on the scope of protection of this invention. Any embodiment where the sum of the first machine angle θ1, the second machine angle θ2, and the third machine angle θ3 is 360°, and where the first machine angle θ1, the second machine angle θ2, and the third machine angle θ3 are not equal to each other, falls within the scope of protection of this invention. For example, the first machine angle θ1 has an angle range of 0°-130°, the second machine angle θ2 has an angle range of 0°-120°, and the third machine angle θ3 has an angle range of 0°-110°, these three ranges continuously covering the entire circumference. For example, the first machine angle θ1 is 150°, the second machine angle θ2 is 120°, and the third machine angle θ3 is 90°. For example, the first machine angle θ1 is 140°, the second machine angle θ2 is 100°, and the third machine angle θ3 is 120°.
[0075] Furthermore, the widths of the first magnetic pole pair 101, the second magnetic pole pair 102, and the third magnetic pole pair 103 are not equal.
[0076] In this embodiment, by setting the first mechanical angle, the second mechanical angle, and the third mechanical angle to be unequal, and the widths of the first magnetic pole pair 101, the second magnetic pole pair 102, and the third magnetic pole pair 103 to be unequal, the spatial phases of each sampled signal are staggered, avoiding the three signals falling near the zero-crossing point of the magnetic pole period. This ensures that any displacement of the mechanical angle will cause the electrical angle in the three sectors to change at different rates, avoiding the magnetic pole truncation phenomenon at the boundary of some sectors when uniformly divided at 120° in the traditional scheme. This eliminates the angle ambiguity point from a physical perspective, laying the foundation for achieving high linearity and high repeatability absolute angle measurement.
[0077] The circuit board 200 is provided with a first magnetic sensor pair 201, a second magnetic sensor pair 202, and a third magnetic sensor pair 203. The first magnetic sensor pair 201 corresponds spatially to a first sector a, meaning its axial projection falls within the first sector a. Preferably, the first magnetic sensor pair 201 is positioned at the junction of the first sector a and the second sector b. It should be noted that as long as the axial projection of the first magnetic sensor pair 201 falls within the first sector a, any position of the first magnetic sensor pair 201 is within the protection scope of this invention. For example, the first magnetic sensor pair 201 may be positioned at half the position of the first sector a, or at one-quarter of the position of the first sector a.
[0078] The second magnetic sensor pair 202 corresponds to the second sector b in spatial position, that is, the axial projection of the second magnetic sensor pair 202 falls within the second sector b. Preferably, the second magnetic sensor pair 202 is set at the position where the second sector b and the third sector c are connected. It should be noted that as long as the axial projection of the second magnetic sensor pair 202 falls within the second sector b, any positional configuration of the second magnetic sensor pair 202 is within the protection scope of the present invention. For example, the second magnetic sensor pair 202 is set at the half position of the second sector b, or at the quarter position of the second sector b.
[0079] The third magnetic sensor pair 203 corresponds to the third sector c in spatial position, that is, the axial projection of the third magnetic sensor pair 203 falls within the third sector c. Preferably, the third magnetic sensor pair 203 is set at the position where the third sector c and the first sector a are connected. It should be noted that as long as the axial projection of the third magnetic sensor pair 203 falls within the third sector c, any position of the third magnetic sensor pair 203 is within the protection scope of the present invention. For example, the third magnetic sensor pair 203 is set at the half position of the third sector c, or at the quarter position of the third sector c.
[0080] Specifically, please refer to Figure 1A The first magnetic sensor pair 201 is positioned above the magnetic ring rotor 100, the second magnetic sensor pair 202 is positioned above the magnetic ring rotor 100, and the third magnetic sensor pair 203 is positioned above the magnetic ring rotor 100.
[0081] Figure 1C Schematic diagram 2 of the magnetic encoder provided in the embodiments of this application, refer to Figure 1CThe first magnetic sensor pair 201 is disposed around the magnetic ring rotor 100, the second magnetic sensor pair 202 is disposed around the magnetic ring rotor 100, and the third magnetic sensor pair 203 is disposed around the magnetic ring rotor 100.
[0082] Furthermore, the first magnetic sensor pair 201, the second magnetic sensor pair 202, and the third magnetic sensor pair 203 can all be positioned below the magnetic ring rotor 100. It should be noted that the first magnetic sensor pair 201, the second magnetic sensor pair 202, and the third magnetic sensor pair 203 can all be positioned above, below, or around the magnetic ring rotor 100.
[0083] Each pair of magnetic sensors includes a radial sensing axis sensor (the X-axis sensor shown in Figure 1) and a tangential sensing axis sensor (the Y-axis sensor shown in Figure 1), which are arranged orthogonally in space to output sine and cosine voltage signals with a 90° phase difference. Figure 2A This is a schematic diagram of the signal output principle of the first magnetic sensor 201 provided in an embodiment of this application. Figure 2B This is a schematic diagram of the signal output principle of the second magnetic sensor 202 provided in the embodiments of this application. Figure 2C The schematic diagram of the signal output of the third magnetic sensor to 203 provided in the embodiments of this application is shown below. Figure 2A , Figure 2B and Figure 2C The first magnetic sensor pair 201, the second magnetic sensor pair 202, and the third magnetic sensor pair 203 output differential voltage signals (Sin+ / Sin-, Cos+ / Cos-) that have a sine / cosine relationship, respectively.
[0084] In one optional embodiment, any one of the magnetic sensors in the first magnetic sensor pair 201 is a tunneling magnetoresistive angle sensor (TMR) or anisotropic magnetoresistive sensor (AMR); any one of the magnetic sensors in the second magnetic sensor pair 202 is a tunneling magnetoresistive angle sensor or anisotropic magnetoresistive sensor; and any one of the magnetic sensors in the third magnetic sensor pair 203 is a tunneling magnetoresistive angle sensor or anisotropic magnetoresistive sensor. It should be noted that the sensor types listed above are merely illustrative and do not constitute a limitation on the scope of protection of this invention. Those skilled in the art can select other sensing elements with equivalent magnetic sensing functions (such as giant magnetoresistive sensors, Hall effect elements, etc.) according to actual application needs, cost budgets, and performance indicators. As long as they can achieve orthogonal differential detection of magnetic field signals in each sector, they should be considered to fall within the scope of this invention.
[0085] Figure 3 This is an application scenario diagram of the magnetic encoder provided in the embodiments of this application, with reference to... Figure 3 The magnetic encoder provided by this invention can be built into a rotary actuator such as a servo motor 300, a robot joint module, or a CNC machine tool spindle, and is used to detect the absolute angular displacement and number of rotations of the magnetic ring rotor 100 in real time, providing a high-precision position feedback signal for the control system.
[0086] Specifically, the magnetic ring rotor 100 (e.g., outer diameter 12 mm, inner diameter 8 mm, thickness 3 mm) is fixedly mounted on the motor output shaft 304 of the motor 300, achieving synchronous rotation with the motor output shaft 304 without relative slippage. The end face of the magnetic ring rotor 100 is divided into multiple magnetized sectors along the circumference, forming a spatially periodically changing magnetic field. The sensor bracket 301 is fixed to the end cover or stator side of the motor 300, and three pairs of magnetic sensor chips are mounted on it. Each pair of magnetic sensors is spatially aligned with the three sectors of the magnetic ring, and the sensitive surface of the sensor chip is parallel to the plane of the magnetic ring rotor 100 to ensure maximum magnetic flux coupling efficiency.
[0087] Figure 4A This is an application principle diagram of the magnetic encoder provided in the embodiments of this application, for reference. Figure 3 and Figure 4AWhen the rotor of motor 300 drives the output shaft 304 and the magnetic ring rotor 100 to rotate synchronously, the spatial magnetic field vector in each sector changes periodically. The data acquisition and processing module processes the acquired digital signals to obtain electrical angle data and sends the electrical angle data to the MCU. The MCU runs an angle calculation algorithm to obtain a high-resolution absolute angle position and sends the absolute angle position to the communication chip. During this process, the battery management module includes multiple power management units, which continuously provide stable and independent power supply voltages to the data acquisition and processing module, the MCU, and the communication chip.
[0088] Specifically, Figure 4B This is a schematic diagram of the architecture of the data acquisition and processing module in an embodiment of this application. Figure 4C This is a schematic diagram of the battery management module architecture according to an embodiment of this application. (Refer to...) Figure 4A , Figure 4B and Figure 4C Three pairs of magnetic sensors, taking the TMR sensor 303 as an example (V1~V6 in the figure represent six analog signal output terminals), detect the magnetic field components in their respective sectors in real time and output three sets of differential sine and cosine analog voltage signals (i.e., V1 / V2, V3 / V4, and V5 / V6 correspond to the Sin+ / Sin- and Cos+ / Cos- channels, respectively). These six analog signals are first sent to an analog-to-digital converter (ADC), sampled and held, and quantized and encoded to be converted into digital signals, which are then transmitted to a field-programmable gate array (FPGA). The FPGA preprocesses the acquired digital signals (including filtering, synchronization, amplitude normalization, and angle subdivision), and sends the processed electrical angle data of the three sectors to the main control MCU (Microcontroller Unit). The MCU internally runs an angle calculation algorithm, determining the coarse angle value by calculating the difference between the electrical angles of each sector. Then, using the principle of vernier calipers and fine calibration, it obtains a high-resolution absolute angle position. Finally, the calculated angular displacement data is output to the upper controller in differential digital signal form via an RS485 communication chip (represented by QEI in the diagram), achieving long-distance, interference-resistant real-time data transmission. Furthermore, multiple power management units (PMUs) in the diagram provide stable and independent power supply voltages to the ADC, FPGA, MCU, and communication chip, ensuring normal operation of each device within a wide voltage range and improving the system's electromagnetic compatibility and power supply noise suppression capabilities.
[0089] Next, this application will describe in detail the actual application scenarios of humanoid robots.
[0090] Humanoid robots typically contain 20 to 40 active joints, with typical configurations including hip (3 degrees of freedom), knee (1 degree of freedom), ankle (2 degrees of freedom), shoulder (3 degrees of freedom), elbow (1 degree of freedom), and wrist (2 degrees of freedom). Each joint module is driven by a frameless torque motor 300 with a collimated drive or a high-reduction-ratio harmonic reducer. A magnetic encoder needs to be installed at the reducer output (i.e., the load side) to meet the following core requirements:
[0091] (a) Closed-loop position / torque control: The servo control cycle shall not exceed 200µs (equivalent bandwidth ≥ 5kHz), and the magnetic encoder data output rate shall not be less than 10kHz.
[0092] (ii) Absolute position and orientation known immediately upon power-up: After the system is powered off, the joints may be passively displaced by external forces. After power-up, the current absolute angle and accumulated number of revolutions must be restored immediately without performing zeroing or parameter seeking operations.
[0093] (III) Multi-turn displacement recording: The knee joint travel is approximately ±120°, while the travel of joints such as waist rotation and wrist rotation can reach ±540° or more (i.e., more than 3 turns), requiring the magnetic encoder to have reliable multi-turn absolute position recording capability;
[0094] (iv) High-precision positioning: The foot positioning accuracy in gait planning needs to be controlled within 0.1mm. After the length of the rod is enlarged, the measurement accuracy of the corresponding joint angle needs to be better than 0.005° (approximately 18 arcseconds).
[0095] Figure 5 For specific parameters of the humanoid robot left knee joint module provided in the embodiments of this application, refer to... Figure 5 The magnetic encoder proposed in this application can fully meet the above performance requirements, and is especially suitable for the comprehensive needs of humanoid robot joints for high precision, high reliability and fast response. During installation, the magnetic ring rotor 100 and the reducer output shaft are connected by tight fit and end face glue, with an axial air gap of 0.5±0.1mm; the circuit board 200 equipped with a magnetic sensor is fixed to the inside of the reducer rear end cover by three M2 screws to ensure radial concentricity ≤0.05mm.
[0096] The embodiments of this application also disclose a method for calculating the fine electrical angle value of a magnetic encoder. Figure 6 A flowchart illustrating the fine electrical angle value calculation method of the magnetic encoder according to an embodiment of this application is shown. (Refer to...) Figure 6 This includes the following steps:
[0097] S100: Obtain the first electrical angle value of the first sector a.
[0098] In one optional embodiment, the first quadrature sensing signal output by the first magnetic sensor to 201 is acquired; the first quadrature sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the first initial electrical angle value of the first sector a; the first phase zero compensation value of the first sector a is acquired, and the first initial electrical angle value is modulo-normalized based on the first phase zero compensation value to obtain the first electrical angle value of the first sector a.
[0099] Specifically, the first quadrature sensing signal output by the first magnetic sensor to 201 is acquired. The first quadrature sensing signal includes a sinusoidal analog voltage signal Sin1 and a cosine analog voltage signal Cos1. The sinusoidal analog voltage signal Sin1 and the cosine analog voltage signal Cos1 are converted from analog to digital by an analog-to-digital converter (ADC). Then, using the CORDIC (Coordinate Rotation Digital Calculation) algorithm or a pre-stored arctangent lookup table, the atan2(Sin1, Cos1) operation is performed to obtain the first initial electrical angle value of the first sector a. , The value range is (-180°, 180°).
[0100] Then, the system pre-stores the first phase zero-point compensation value of the first sector a. First phase zero-point compensation value This value, pre-stored by the system and obtained through factory calibration, is used to compensate for fixed phase shifts caused by magnetic sensor installation position deviations, magnetic ring magnetization phase deviations, and circuit delays, according to the formula: The first electrical angle value θ1 of the first sector a is obtained, where the wrap360 operation means mapping the angle result to the half-open interval [0°, 360°), that is, eliminating negative values or values exceeding 360° that may be introduced by phase compensation through the modulo operation.
[0101] For example, First initial electrical angle value: (Original value); First electrical angle value: .
[0102] S100: Obtain the second electrical angle value of the second sector b.
[0103] In one optional embodiment, the second quadrature sensing signal output by the second magnetic sensor to 202 is acquired; the second quadrature sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the second initial electrical angle value of the second sector b; the second phase zero-point compensation value of the second sector b is acquired, and the second initial electrical angle value is modulo-normalized based on the second phase zero-point compensation value to obtain the second electrical angle value of the second sector b.
[0104] Specifically, the second orthogonal sensing signal output by the second magnetic sensor to 202 is acquired. The second orthogonal sensing signal includes a sinusoidal analog voltage signal Sin2 and a cosine analog voltage signal Cos2. The sinusoidal analog voltage signal Sin2 and the cosine analog voltage signal Cos2 are converted from analog to digital by an analog-to-digital converter (ADC). Then, using the CORDIC (Coordinate Rotation Digital Calculation) algorithm or a pre-stored arctangent lookup table, the atan2(Sin2, Cos2) operation is performed to obtain the second initial electrical angle value of the second sector b. , The value range is (-180°, 180°).
[0105] Then, the system pre-stores the second phase zero-point compensation value of the second sector b. Second phase zero-point compensation value This value, pre-stored by the system and obtained through factory calibration, is used to compensate for fixed phase shifts caused by magnetic sensor installation position deviations, magnetic ring magnetization phase deviations, and circuit delays, according to the formula: The second electrical angle value θ2 of the second sector b is obtained. The wrap360 operation means mapping the angle result to the half-open interval of [0°, 360°), that is, eliminating negative values or values exceeding 360° that may be introduced by phase compensation through the modulo operation.
[0106] For example, Second initial electrical angle value: Second electrical angle value: .
[0107] S100: Obtain the third electrical angle value of the third sector c.
[0108] In one optional embodiment, the third quadrature sensing signal output by the third magnetic sensor to 203 is acquired; the third quadrature sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the third initial electrical angle value of the third sector c; the third phase zero-point compensation value of the third sector c is obtained, and the third initial electrical angle value is modulo-normalized based on the third phase zero-point compensation value to obtain the third electrical angle value of the third sector c.
[0109] Specifically, the third orthogonal sensing signal output by the third magnetic sensor to 203 is acquired. The third orthogonal sensing signal includes a sinusoidal analog voltage signal Sin3 and a cosine analog voltage signal Cos3. The sinusoidal analog voltage signal Sin3 and the cosine analog voltage signal Cos3 are converted from analog to digital by an analog-to-digital converter (ADC). Then, using the CORDIC (Coordinate Rotation Digital Calculation) algorithm or a pre-stored arctangent lookup table, the atan2(Sin3, Cos3) operation is performed to obtain the third initial electrical angle value of the third sector c. , The value range is (-180°, 180°).
[0110] Then, the system pre-stores the third phase zero-point compensation value of the third sector c. Third phase zero-point compensation value This value, pre-stored by the system and obtained through factory calibration, is used to compensate for fixed phase shifts caused by magnetic sensor installation position deviations, magnetic ring magnetization phase deviations, and circuit delays, according to the formula: The third electrical angle value θ3 of the third sector c is obtained. The wrap360 operation means mapping the angle result to the half-open interval [0°, 360°), that is, eliminating negative values or values exceeding 360° that may be introduced by phase compensation through the modulo operation.
[0111] For example, The third initial electrical angle value: Third electrical angle value: .
[0112] For example, the knee joint of the humanoid robot bends from fully extended to 85.37°, simulating a typical movement during a humanoid robot's squat. This application scenario is used as an example to illustrate in detail the method for calculating the fine electrical angle value of the magnetic encoder provided in the embodiments of this application.
[0113] Step S1: Signal acquisition and electrical angle calculation.
[0114] Specifically, the six TMR sensors are synchronously sampled by the ADC to obtain three pairs of orthogonal sensing signals. These signals are then compensated for at zero point (during production line calibration). , , After that, the electrical angle value is calculated as follows:
[0115] First initial electrical angle value: (Original value);
[0116] First electrical angle value: ;
[0117] Second initial electrical angle value: ;
[0118] Second electrical angle value: ;
[0119] Third initial electrical angle value: ;
[0120] Third electrical angle value: ;
[0121] The theoretically verified electrical angle value is: for θ = 85.37°, the ideal electrical angle is:
[0122] θ1_ideal = wrap360(11 × 85.37) = wrap360(939.07) = 219.07°;
[0123] θ2_ideal=wrap360(12 × (85.37-130))=wrap360(12×(-44.63))=wrap360(-535.56) = 184.44°;
[0124] θ3_ideal = wrap360(13 × (85.37-250)) = wrap360(13 × (-164.63)) =wrap360(-2140.19) = 19.81°;
[0125] It is evident that there is a difference between the actual sampled electrical angle value and the ideal electrical angle value. This difference stems from the non-ideal magnetization of the magnetic ring, the eccentricity of the air gap, and the sensor position deviation, which are precisely the objects to be corrected in the subsequent interpolation process.
[0126] To demonstrate the effect of fine interpolation, biased sampled values are provided here. In practical high-quality magnetic rings, the bias is typically ≤ ±3° electrical angle.
[0127] To make the calculation process easier to follow in this example, the following derivation will use ideal electrical angles (i.e., assuming perfect calibration and magnetization):
[0128] The first electrical angle value θ1 = 219.07°; the second electrical angle value θ2 = 184.44°; the third electrical angle value θ3 = 19.81°.
[0129] S200: Determine the first electrical angle difference between the first electrical angle value and the second electrical angle value, and the second electrical angle difference between the second electrical angle value and the third electrical angle value.
[0130] Specifically, firstly, the difference between the first electrical angle value θ1 and the second electrical angle value θ2 is calculated, and then the wrap360 normalization operation is performed on this difference to obtain the first electrical angle difference: Similarly, by subtracting the second electrical angle value θ2 from the third electrical angle value θ3 and performing the same wrap360 normalization operation, the second electrical angle difference is obtained: .
[0131] It should be noted that since the number of pole pairs magnetized in the first sector a, the second sector b, and the third sector c are 11, 12, and 13 pairs respectively, the difference between any two of them is 1, i.e., |11-12|=1, |12-13|=1. According to the principle of vernier calipers, when the mechanical shaft rotates a full revolution (360° mechanical angle), and Each electrical angle difference is strictly monotonically traversed once within the range of [0°, 360°). This characteristic means that each electrical angle difference has a one-to-one mapping relationship with the mechanical position within the circumference, without repetition or ambiguity. Therefore, the current coarse angle position can be uniquely determined by using the electrical angle difference alone.
[0132] Next, taking the application scenario of a humanoid robot as an example, we will proceed to step S2.
[0133] Step S2: Calculation of electrical angle difference.
[0134] ;
[0135] .
[0136] S300: Determine the coarse angle value based on the first electrical angle difference and / or the second electrical angle difference.
[0137] In one optional implementation, the coarse angle value is determined by a binary search method based on the first electrical angle difference and the second electrical angle difference; or, the coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the first electrical angle difference; or, the coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the second electrical angle difference.
[0138] Specifically, calculation , The LUT (Least Usage Unit) generated in advance with a mechanical angle step of 0.01° (each stored (q) 12 _tab,q 23 In `_tab,θcoarse)`, candidates are selected using binary search and bucketing, and then sorted by circular distance. By selecting the nearest neighbor, we obtain θ_coarse ∈ [0°, 360°), with an accuracy of approximately 0.01°.
[0139] Next, taking the application scenario of a humanoid robot as an example, we will proceed to step S3.
[0140] Step S3: Quantization and LUT coarse angle lookup table.
[0141] Quantized to a 16-bit unsigned integer:
[0142] q 12= Q16(34.63°) = round(34.63 / 360 × 65535) = 6,303;
[0143] q 23 = Q16(324.63°) = round(324.63 / 360 × 65535) = 59,099;
[0144] Construct the lookup key target_key = (6303 << 16) | 59099 = 0x18A1_E6DB;
[0145] In the LUT, perform a binary search, taking ±5 candidate windows and selecting the nearest neighbor based on the circular distance:
[0146]
[0147] The matching result returned: θ_coarse = 85.37°.
[0148] When any one of the magnetic sensor pairs 201, 202, and 203 fails, a coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the first electrical angle difference; or, a coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the second electrical angle difference. For example, when the magnetic sensor in the third sector c fails, only... Use a one-dimensional LUT to obtain the coarse angle value.
[0149] For example, in the application scenario of humanoid robots, if a sensor in a certain sector fails due to impact or aging (such as a failure of the magnetic sensor in the third sector c):
[0150] The MCU detects abnormal Sin3 / Cos3 amplitude (outside the calibration range ±30%) or a sudden increase in noise power; switches to single-differential degradation mode: only uses The coarse angle is obtained by checking the one-dimensional LUT; the fine interpolation is changed to the electrical angle value of the first sector a or the second sector b (depending on the region where the coarse angle value is located); the position diagnostic flag SENSOR_DEGRADED notifies the upper controller to reduce the joint running speed and torque limit; the accuracy is reduced from nominal ≤0.005° to about ≤0.02°, but low-speed safe movement can still be maintained (such as slowly squatting down and locking the joint).
[0151] S400: Determine the target sector where the coarse angle value is located. The target sector is any one of the first sector a, the second sector b, and the third sector c. Based on the electrical angle value and the number of magnetic pole pairs in the target sector, the coarse angle value is corrected to obtain the fine electrical angle value.
[0152] In this embodiment, three electrical angle values of three sectors are first obtained. Then, a coarse angle value is determined by calculating the first electrical angle difference and / or the second electrical angle difference. Further, the target sector to which the coarse angle value belongs is determined based on the coarse angle value, and the electrical angle value and the number of magnetic pole pairs of the target sector itself are selected for fine correction to obtain a fine electrical angle value. This effectively avoids the interference of boundary magnetic field distortion on coarse positioning in the traditional uniform sector scheme, eliminates angle ambiguity points, and thus significantly improves the absolute accuracy and dynamic response performance of the encoder.
[0153] In one optional implementation, the starting angle value and the number of magnetic pole pairs of the target sector are obtained; the actual electrical angle value is obtained by data processing based on the coarse angle value and the starting angle value; the ideal electrical angle value is obtained by data processing based on the actual electrical angle value and the number of magnetic pole pairs; the correction value is obtained by normalization based on the actual electrical angle value and the ideal electrical angle value, and the coarse angle value is corrected based on the correction value to obtain the fine electrical angle value.
[0154] Specifically, the target sector containing the coarse angle value is determined, the starting angle value and the number of pole pairs of the target sector are obtained, and the coarse angle value θ_coarse and the starting angle value are used to determine the target sector. Calculate the actual electrical angle value: The ideal electrical angle value is obtained based on the actual electrical angle value and the number of magnetic pole pairs: The correction value is: The coarse angle value is corrected based on the correction value to obtain the fine electrical angle value: Finally, the 24-bit raw value of the fine electrical angle is output for each single turn: ,scope .
[0155] It should be noted that when calculating the fine electrical angle value θ_fine, due to the influence of mechanical vibration, electromagnetic interference, or quantization noise, when the actual mechanical position is exactly near the sector boundary, θ_fine may jump back and forth between different angle values (for example, near 0°, it may oscillate between 359.9° and 0.1° due to noise), resulting in unstable output angle and poor repeatability. To overcome this problem, a ±1° hysteresis comparison can be introduced in the θ_fine output stage. The details of hysteresis comparison are not elaborated in this application.
[0156] For example, assume the actual mechanical angle θ = 55° (falling in the first sector a). ;
[0157] Ideal electrical angle value (for demonstration purposes, consistent with the S1 calculation result):
[0158] θ1 = wrap360(11×55) = 245°;
[0159] θ2 =wrap360(12×(55-130))=180°;
[0160] θ3=wrap360(13×(55-250))=345°.
[0161] difference:
[0162] ;
[0163] Quantification (approximation):
[0164] q12≈Q16(65°)≈11,833; q23≈Q16(195°)≈35,498;
[0165] LUT lookup: Nearest neighbor returns θ_coarse≈55.00°;
[0166] Fine interpolation (first sector a, P=11):
[0167]
[0168] θ_fine=wrap360(55.00+0 / 11)=55.00°;
[0169] 24-bit output: ;
[0170] No multiple laps are performed (before crossing 0° / 360°).
[0171] Below, taking the application scenario of a humanoid robot as an example, we will execute steps S4 and S5.
[0172] Step S4: Fine interpolation.
[0173] Determine the sector: θ_coarse = 85.37° ∈ [0°, 130°), the target sector is the first sector a, P1=11. ;
[0174] θ_local = wrap360(85.37- 0°) = 85.37°;
[0175] θ_ideal = wrap360(11 × 85.37°) = wrap360(939.07°) = 219.07°;
[0176] ;
[0177] θ_fine = wrap360(85.37° + 0.00° / 11) = 85.37°.
[0178] In the scenario with deviation: if the measured θ1= 219.40° (including an electrical angle deviation of +0.33°), then: , mechanical angle error = 0.33° / 11 = 0.030°, θ_fine=wrap360(85.37° + 0.030°) = 85.400°.
[0179] In the embodiments of the present application, the subdivision effect of 11 pole pairs makes the electrical angle error of 0.33° only cause a mechanical angle error of 0.030°, achieving error reduction of approximately 1 / P1.
[0180] Step S5: 24-bit single-turn output.
[0181] raw24 = round((85.37° / 360°) × 2 24 )= round(0.23714 × 16,777,216)=3,978,824
[0182] Expressed in binary: 0x3CB_CC8 (24 bits).
[0183] In an optional embodiment, a current fine angle value, a previous fine angle value and a hysteresis threshold are acquired, wherein the hysteresis threshold includes a first hysteresis threshold and a second hysteresis threshold; when the previous fine angle value is greater than the first hysteresis threshold and the current fine angle value is less than the second hysteresis threshold, the number of turns is increased by 1; when the previous fine angle value is less than the second hysteresis threshold and the current fine angle value is greater than the first hysteresis threshold, the number of turns is decreased by 1; and an absolute position value is determined based on the current accumulated turn value and the current fine angle value.
[0184] Specifically, the first hysteresis threshold: LOW=10°, the second hysteresis threshold: HIGH=350°, the previous fine angle value is prev_angle, and the current fine angle value is current_angle. If (prev_angle>HIGH and current_angle<LOW), then turn_count++, and if (prev_angle<LOW and current_angle>HIGH), then turn_count--, and then a 56-bit absolute position value is output: abs56=(turn_count<<24) | raw24.
[0185] For example, at time t0: θ_fine(prev_angle)=359.70°; at t1: θ_fine(current_angle)=0.15° (zero point crossing in the forward direction);
[0186] Counting logic: if prev_angl > 350° and current_angler < 10°, turn_count = turn_count + 1
[0187] Update 56-bit: abs56=(turn_count<<24) | raw24(current_angle).
[0188] Next, taking the application scenario of a humanoid robot as an example, we will proceed to step S6.
[0189] Step S6: Multi-lap counting.
[0190] In this scenario, the knee joint bends from 0° to 85.37° without crossing the zero point, i.e., 0° and 360°, and the number of rotations remains unchanged.
[0191] Assuming a complete multi-rotation event has already occurred (such as the positive rotation crossing the zero point during wrist rotation joint calibration), then:
[0192] turn_count = 1 (already has a turn count);
[0193] prev_angle=78.52° (previous fine angle value);
[0194] current_angle = 85.37° (current fine angle value);
[0195] It does not satisfy the condition that prev_angle > 350° and current_angle < 10°, nor does it satisfy the condition that prev_angle < 10° and current_angle > 350°;
[0196] The turn_count value remains at 1, meaning the cumulative lap count is 1.
[0197] 56-bit absolute position value output:
[0198] abs56 = (turn_count << 24) | raw24= (1 << 24) |3,978,824= 16,777,216+3,978,824
[0199] = 20,756,040= 0x01_3CB_CC8.
[0200] Furthermore, joints may be moved by external forces after the robot falls or experiences an emergency power outage. Since turn_count is stored in the battery backup RAM and the magnetic encoder outputs the absolute single-turn angle value upon power-up, after the system is powered on again: it reads turn_count from the battery backup RAM; performs a complete S1~S5 calculation to obtain the current θ_fine and raw24; outputs abs56 to directly restore the absolute pose of the joints without needing to find zero or return to the origin; the upper-level gait controller reads abs56 of all joints, reconstructs the whole-body kinematic model, and restores standing balance.
[0201] When the humanoid robot walks briskly, the knee joint angular velocity can reach 300° / s (approximately 0.83 revolutions / s), with a servo loop cycle of 200µs. During this period: the magnetic encoder calculation time (S1~S6) is measured to be less than 3.5µs on an STM32H743@400MHz; the angle change within a 200µs servo cycle = 300° / s × 200µs = 0.06°; the magnetic encoder accuracy is less than or equal to 0.005°, far less than the angle change in a single cycle, and will not introduce control delay. Therefore, a single calculation fully meets the real-time requirements of the servo loop, and the remaining time can be used for parallel tasks such as current loop and torque estimation.
[0202] The joint module's internal temperature range is -10°C to +80°C (motor heats up to 300 kW), and it continuously withstands gait impact vibrations (peak 10g): The MCU has a built-in temperature sensor or an external NTC, with the temperature-phase coefficient set according to the production line specifications. Real-time phase zero correction: , where k i Typical value is approximately 0.01° / °C; the TMR sensor differential output naturally suppresses common-mode vibration interference; the ADC sampling window is < 4µs, much smaller than the vibration period (typically > 1ms), and angle changes during sampling are negligible; moving average filtering: a 4-point moving average is applied to θ_fine, and the equivalent cutoff frequency at a 10kHz output rate is approximately 2.5kHz, satisfying the 5kHz servo loop bandwidth while suppressing high-frequency noise.
[0203] at last, Figure 7 This is a schematic diagram illustrating the performance requirements of the humanoid robot provided in the embodiments of this application. (Refer to...) Figure 7 The fine electrical angle value calculation method for magnetic encoders provided in this application embodiment can directly meet the core requirements of high precision, high real-time performance, power failure retention, and functional safety degradation in humanoid robot joint modules. It is a cost-effective solution to replace traditional optical encoders.
[0204] Furthermore, the present invention also provides a computer storage medium, including a memory and a processor, wherein the memory is adapted to store computer instructions, and the processor is adapted to execute the fine electrical angle value calculation method of the magnetic encoder described in any of the above embodiments when running the computer instructions.
[0205] Now for reference Figure 8 The diagram shows a block diagram of an electronic device 600 according to one embodiment of this application. The electronic device 600 is, for example, a smart mobile terminal. The electronic device 600 may include one or more processors 601 coupled to a controller hub 603. In at least one embodiment, the controller hub 603 communicates with the processor 601 via a multi-branch bus such as a Front Side Bus (FSB), a point-to-point interface such as a QuickPath Interconnect (QPI), or a similar connection 606. The processor 601 executes instructions controlling general-type data processing operations. In one embodiment, the controller hub 603 includes, but is not limited to, a Graphics & Memory Controller Hub (GMCH) (not shown) and an Input / Output Hub (IOH) (which may be on a separate chip) (not shown), wherein the GMCH includes memory and a graphics controller and is coupled to the IOH.
[0206] Electronic device 600 may also include a coprocessor 602 and a memory 604 coupled to a controller hub 603. Alternatively, one or both of the memory and GMCH may be integrated within the processor, with memory 604 and coprocessor 602 directly coupled to processor 601 and controller hub 603, which is located on a single chip with IOH.
[0207] Memory 604 may be, for example, Dynamic Random Access Memory (DRAM), Phase Change Memory (PCM), or a combination of both. Memory 604 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. The computer-readable storage medium stores instructions, specifically, temporary and permanent copies of those instructions. The instructions may include, when executed by at least one of the processors, causing the electronic device 600 to perform, as... Figure 6 Instructions for calculating the fine electrical angle value of the magnetic encoder shown. When executed on a computer, the instructions cause the computer to perform the method disclosed in any of the above embodiments or combinations thereof to assign the current contract to an operator.
[0208] In one embodiment, the coprocessor 602 is a dedicated processor, such as, for example, a high-throughput MIC (Many Integrated Core) processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU (General-purpose computing on graphics processing units), or an embedded processor, etc. Optional properties of the coprocessor 602 are indicated by dashed lines. Figure 8 middle.
[0209] In one embodiment, electronic device 600 may further include a network interface (NIC, Network Interface Controller) 606. Network interface 606 may include a transceiver for providing a radio interface for electronic device 600 to communicate with any other suitable device, such as a front-end module, antenna, etc. In various embodiments, network interface 606 may be integrated with other components of electronic device 600. Network interface 606 can implement the functionality of the communication unit in the above embodiments.
[0210] Electronic device 600 may further include input / output (I / O) devices 605. I / O 605 may include: a user interface designed to enable a user to interact with electronic device 600; a peripheral component interface designed to enable peripheral components to also interact with electronic device 600; and / or sensors designed to determine environmental conditions and / or location information related to electronic device 600.
[0211] It is worth noting that, Figure 8 This is merely an example. That is, although... Figure 8 The electronic device 600 shown includes multiple devices such as a processor 601, a controller hub 603, and a memory 604. However, in practical applications, devices using the methods of this application may include only a portion of the devices in the electronic device 600. For example, it may include only the processor 601 and the network interface 606. Figure 8 The properties of the optional devices are shown by dashed lines.
[0212] Now for reference Figure 9 The diagram shown is a block diagram of a SoC (System on Chip) 700 according to an embodiment of this application. Figure 9 In the diagram, similar components share the same reference numerals. Additionally, dashed boxes are an optional feature for more advanced SoCs. Figure 9In this SoC, the SoC includes: an interconnect unit 750 coupled to a processor 710; a system proxy unit 780; a bus controller unit 790; an integrated memory controller unit 740; a group or one or more coprocessors 720, which may include integrated graphics logic, an image processor, an audio processor, and a video processor; a static random-access memory (SRAM) unit 730; and a direct memory access (DMA) unit 760. In one embodiment, the coprocessor 720 includes a dedicated processor, such as, for example, a network or communication processor, a compression engine, a GPGPU (General-purpose computing on graphics processing units), a high-throughput MIC processor, or an embedded processor.
[0213] Static Random Access Memory (SRAM) cell 730 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. The computer-readable storage medium stores instructions, specifically, temporary and permanent copies of those instructions. These instructions may include, when executed by at least one of the processors, causing the SoC implementation to... Figure 6 The instructions for calculating the fine electrical angle value of the magnetic encoder are shown. When the instructions are executed on a computer, the computer performs the method disclosed in the above embodiments.
[0214] This application also provides a computer program product for implementing the fine electrical angle value calculation method of the magnetic encoder provided in the above embodiments.
[0215] Various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or combinations of these implementation methods. Embodiments of this application can be implemented as computer program modules or module code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0216] Computer program modules or module code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.
[0217] Module code can be implemented using a high-level modular language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used to implement module code when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0218] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, optical discs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagated signals. Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0219] While the present invention has been illustrated and described with reference to certain preferred embodiments, those skilled in the art should understand that the above description is a further detailed explanation of the invention in conjunction with specific embodiments, and should not be construed as limiting the specific implementation of the invention to these descriptions. Various changes in form and detail can be made by those skilled in the art, including several simple deductions or substitutions, without departing from the spirit and scope of the invention.
Claims
1. A magnetic encoder, characterized in that, include: Circuit board; A magnetic ring rotor, wherein the circuit board and the magnetic ring rotor are spaced apart axially, and the magnetic ring rotor includes a first sector, a second sector, and a third sector circumferentially; wherein... The first sector is provided with multiple pairs of first magnetic pole pairs, which are distributed along the circumferential direction, and the first sector has a first mechanical angle; The second sector is provided with multiple pairs of second magnetic poles, which are distributed along the circumferential direction, and the second sector has a second mechanical angle; The third sector is provided with multiple pairs of third magnetic poles, which are distributed along the circumference. The third sector has a third mechanical angle, and the first mechanical angle, the second mechanical angle, and the third mechanical angle are not equal to each other.
2. The magnetic encoder as described in claim 1, characterized in that, The first mechanical angle is 130°; The second mechanical angle is 120°; The third mechanical angle is 110°.
3. The magnetic encoder as described in claim 1, characterized in that, The first sector has 11 pairs of magnetic poles, the second sector has 12 pairs of magnetic poles, and the third sector has 13 pairs of magnetic poles. The widths of the first, second, and third magnetic pole pairs are not equal.
4. The magnetic encoder as described in claim 1, characterized in that, The circuit board is equipped with a first pair of magnetic sensors, a second pair of magnetic sensors, and a third pair of magnetic sensors; wherein... The first magnetic sensor pair corresponds to the first sector in spatial location; The second magnetic sensor pair corresponds to the second sector in spatial location; The third magnetic sensor corresponds to the third sector in spatial location.
5. The magnetic encoder as described in claim 4, characterized in that, The first magnetic sensor pair is located at the junction of the first sector and the second sector; The second magnetic sensor is positioned at the junction of the second sector and the third sector; The third magnetic sensor is located at the junction of the third sector and the first sector.
6. The magnetic encoder as described in claim 4 or 5, characterized in that, The first magnetic sensor is positioned above, below, or around the magnetic ring rotor; The second magnetic sensor is disposed above, below, or around the magnetic ring rotor; The third magnetic sensor is positioned above, below, or around the magnetic ring rotor.
7. The magnetic encoder as described in claim 6, characterized in that, Any one of the magnetic sensors in the first pair of magnetic sensors is a tunnel magnetoresistive angle sensor or an anisotropic magnetoresistive sensor. Either of the magnetic sensors in the second pair of magnetic sensors is a tunnel magnetoresistive angle sensor or an anisotropic magnetoresistive sensor. Any of the magnetic sensors in the third pair of magnetic sensors is a tunnel magnetoresistive angle sensor or anisotropic magnetoresistive sensor.
8. A method for calculating the fine electrical angle value of a magnetic encoder, characterized in that, The magnetic encoder includes a circuit board and a magnetic ring rotor. The magnetic ring rotor includes a first sector, a second sector, and a third sector along the circumferential direction. The first sector has a first mechanical angle, the second sector has a second mechanical angle, and the third sector has a third mechanical angle. The first mechanical angle, the second mechanical angle, and the third mechanical angle are not equal to each other. Obtain the first electrical angle value of the first sector; Obtain the second electrical angle value of the second sector; Obtain the third electrical angle value of the third sector; Determine a first electrical angle difference between the first electrical angle value and the second electrical angle value, and a second electrical angle difference between the second electrical angle value and the third electrical angle value; The coarse angle value is determined based on the first electrical angle difference and / or the second electrical angle difference; The target sector containing the coarse angle value is determined. The target sector is any one of the first sector, the second sector, and the third sector. The coarse angle value is corrected based on the electrical angle value and the number of magnetic pole pairs in the target sector to obtain the fine electrical angle value.
9. The method for calculating precise electrical angle values as described in claim 8, characterized in that, The circuit board is provided with a first pair of magnetic sensors, a second pair of magnetic sensors, and a third pair of magnetic sensors, wherein the first pair of magnetic sensors corresponds to the first sector in spatial position; the second pair of magnetic sensors corresponds to the second sector in spatial position; and the third pair of magnetic sensors corresponds to the third sector in spatial position. The step of obtaining the first electrical angle value of the first sector includes: Collect the first orthogonal sensing signal output by the first magnetic sensor; The first orthogonal sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the first initial electrical angle value of the first sector. Obtain the first phase zero-point compensation value of the first sector, and perform modulo and normalization processing on the first initial electrical angle value based on the first phase zero-point compensation value to obtain the first electrical angle value of the first sector. The step of obtaining the second electrical angle value of the second sector includes: Acquire the second orthogonal sensing signal output by the second magnetic sensor; The second orthogonal sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the second initial electrical angle value of the second sector; Obtain the second phase zero-point compensation value of the second sector, and perform modulo and normalization processing on the second initial electrical angle value based on the second phase zero-point compensation value to obtain the second electrical angle value of the second sector; The step of obtaining the third electrical angle value of the third sector includes: Acquire the third orthogonal sensing signal output by the third magnetic sensor; The third orthogonal sensing signal is subjected to analog-to-digital conversion and arctangent processing to obtain the third initial electrical angle value of the third sector; Obtain the third phase zero-point compensation value of the third sector, and perform modulo and normalization processing on the third initial electrical angle value based on the third phase zero-point compensation value to obtain the third electrical angle value of the third sector.
10. The method for calculating the fine electrical angle value as described in claim 8, characterized in that, The step of determining the coarse angle value based on the first electrical angle difference and / or the second electrical angle difference includes: Based on the first electrical angle difference and the second electrical angle difference, the coarse angle value is determined using a binary search method; or... The coarse angle value is obtained by querying a pre-generated and stored one-dimensional lookup table based on the first electrical angle difference; Alternatively, the coarse angle value can be obtained by querying a pre-generated and stored one-dimensional lookup table based on the second electrical angle difference.
11. The method for calculating the fine electrical angle value as described in claim 8, characterized in that, The process of determining the target sector where the coarse angle value is located, wherein the target sector is any one of the first sector, the second sector, and the third sector, and correcting the coarse angle value based on the electrical angle value and the number of magnetic pole pairs in the target sector to obtain a fine electrical angle value, includes: Obtain the starting angle value and the number of magnetic pole pairs of the target sector; The actual electrical angle value is obtained by data processing based on the coarse angle value and the initial angle value. The ideal electrical angle value is obtained by data processing based on the actual electrical angle value and the number of magnetic pole pairs. The correction value is obtained by normalizing the actual electrical angle value and the ideal electrical angle value, and the coarse angle value is corrected according to the correction value to obtain the fine electrical angle value.
12. The method for calculating the fine electrical angle value as described in claim 8, characterized in that, After obtaining the fine electrical angle value, the process further includes: Obtain the current fine angle value, the previous fine angle value, and the hysteresis threshold, wherein the hysteresis threshold includes a first hysteresis threshold and a second hysteresis threshold; When the previous fine angle value is greater than the first hysteresis threshold and the current fine angle value is less than the second hysteresis threshold, the number of revolutions is incremented by 1; When the previous fine angle value is less than the second hysteresis threshold and the current fine angle value is greater than the first hysteresis threshold, the number of revolutions is reduced by 1; The absolute position value is determined based on the current accumulated circle value and the current fine angle value.
13. A computer storage medium, characterized in that, The system includes a memory and a processor, the memory being adapted to store computer instructions, and the processor being adapted to execute, when running the computer instructions, the fine electrical angle calculation method of the magnetic encoder according to any one of claims 8 to 12.
14. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processor, implements the method for calculating the fine electrical angle value of the magnetic encoder according to any one of claims 8 to 12.
