A magnetic encoder angle calibration method, an encoder, a storage medium and a product

CN121384119BActive Publication Date: 2026-09-04WUXI YISI SEMICONDUCTOR CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511729949.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-24
Publication Date
2026-09-04
Estimated Expiration
2045-11-24

AI Technical Summary

Technical Problem

[0004]然而,由于基准角度数据和被测角度数据是通过两个独立的通道被外部系统所采集,数据链路的传输延迟、外部采集系统的处理时钟与被测编码器内部采样时钟之间的微小偏差或抖动,都会导致采集到的两组数据在时间戳上难以做到绝对对齐

Benefits of technology

1、本申请提供了一种磁编码器角度校准方法,在预设转速匀速转动过程中,基于预设角度分辨率计算采样时间间隔,这确保了原始测量角度值的采集均匀分布。MCU主控单元按照固定时间间隔采集并存储原始测量角度值,建立了完整的角度映射关系。当需要校准时,通过在存储的原始测量角度值中定位待校准角度所在区间,并使用线性插值方法,可以将任意待测角度映射到对应的校准角度。降低了由于机械安装误差、磁场不均匀等因素导致的测量偏差。整个校准过程无需复杂的数学模型,仅通过查表和简单计算即可完成,既提高了校准精度,又降低了计算负担。此外,由于校准数据存储在非易失性存储器中,确保了掉电后数据不丢失,使得编码器可以持续保持校准状态,提高了校准的稳定性和可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121384119B_ABST
    Figure CN121384119B_ABST
Patent Text Reader

Abstract

A magnetic encoder angle calibration method, an encoder, a storage medium and a product, in the method, a high-precision encoder servo motor is controlled to rotate at a preset rotating speed; a zero position pulse signal output by the high-precision encoder servo motor is monitored; when the zero position pulse signal is received, a current position is determined as a zero degree reference point; a time interval between two adjacent sampling times is calculated; an original measurement angle value is collected by an MCU master control unit according to the time interval, and the original measurement angle value is stored in a non-volatile memory; when angle calibration is performed, an original measurement angle to be calibrated output by a magnetic sensing chip is obtained; an interval in which the original measurement angle to be calibrated is located is determined; a position of the original measurement angle to be calibrated between two adjacent original measurement angle values is determined, a calibrated angle value is calculated through linear interpolation; and the calibrated angle value is taken as an actual angle output of the encoder. The application is used for improving the accuracy of magnetic encoder angle calibration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of magnetic encoder calibration technology, and in particular relates to a magnetic encoder angle calibration method, encoder, storage medium and product. Background Technology

[0002] A magnetic encoder is a precision measuring device that converts physical displacement signals into magnetic field signals, and then further into electrical signals to calculate the corresponding displacement. It is commonly used to measure physical quantities such as the number of rotations, speed, and angle of rotating objects. During the manufacturing process of magnetic encoders, limitations in technology inevitably lead to an inherent nonlinear error between the output angle signal and the actual angle. When a magnetic encoder rotates at a constant speed, the angle value it outputs within one cycle does not increase nonlinearly. The angle change is faster than the actual rotation in some intervals, while slower in others. This nonlinear characteristic introduces errors in the measurement data, affecting the control accuracy and reliability of the equipment.

[0003] In related technologies, external high-precision reference equipment is typically used to calibrate magnetic encoders. The magnetic encoder under test is coaxially connected to a high-precision optical encoder, and both are driven to rotate synchronously. During rotation, an external data acquisition system acquires high-precision reference angle data from the optical encoder and raw measured angle data from the magnetic encoder under test in parallel and in real time. After acquisition, the external system performs offline comparison and calculation on these two sets of data to generate a complete error compensation data table. Finally, this data table is downloaded or burned into the internal memory of the magnetic encoder under test for subsequent correction of angle readings.

[0004] However, since the reference angle data and the measured angle data are acquired by the external system through two independent channels, transmission delays in the data link, and slight deviations or jitters between the processing clock of the external acquisition system and the internal sampling clock of the encoder under test, can make it difficult to achieve absolute alignment of the two sets of data in terms of timestamps. This time asynchrony directly introduces calibration errors, making it difficult for the final compensation data table to accurately reflect the true error of the magnetic encoder under test at any instant, thereby reducing the accuracy of the magnetic encoder angle calibration. Summary of the Invention

[0005] This application provides a magnetic encoder angle calibration method, encoder, storage medium, and product for improving the accuracy of magnetic encoder angle calibration.

[0006] In one aspect, this application provides a magnetic encoder angle calibration method, which controls a high-precision encoder servo motor to rotate at a preset speed at a uniform speed, so that the encoder servo motor rotates synchronously. When the encoder angle is determined to be zero, the encoder's current position is set as the zero-degree reference point, and a timer is started to perform timing counting. Based on a preset constant rotation speed and a preset angle resolution, the time interval between two adjacent samples is calculated. The original measured angle values ​​are acquired by the MCU main control unit at time intervals and stored in non-volatile memory in the order of acquisition time. During angle calibration, the original measurement angle to be calibrated is obtained from the magnetic sensing chip through the MCU main control unit; The interval containing the original measurement angle to be calibrated is determined by searching in non-volatile memory, and the interval is defined by two adjacent original measurement angle values. Determine the position of the original measurement angle to be calibrated between two adjacent original measurement angle values, and calculate the calibrated angle value through linear interpolation; The calibrated angle value is used as the actual angle output of the encoder.

[0007] By adopting the above technical solution, the sampling time interval is calculated based on the preset angle resolution during uniform rotation at a preset speed, ensuring a uniform distribution of the original measured angle values. The MCU main control unit collects and stores the original measured angle values ​​at fixed time intervals, establishing a complete angle mapping relationship. When calibration is required, the interval of the angle to be calibrated is located in the stored original measured angle values, and a linear interpolation method is used to map any measured angle to the corresponding calibration angle. This reduces measurement deviations caused by mechanical installation errors, magnetic field inhomogeneity, and other factors. The entire calibration process does not require a complex mathematical model; it can be completed simply by looking up tables and performing simple calculations, which improves calibration accuracy and reduces computational burden. Furthermore, since the calibration data is stored in non-volatile memory, data is not lost after power failure, allowing the encoder to continuously maintain the calibration state, improving the stability and reliability of the calibration.

[0008] In conjunction with some implementations of the first aspect, in some implementations, a search is performed in non-volatile memory to determine the interval containing the original measurement angle to be calibrated, specifically including: Round the original measured angle to be calibrated down to obtain the corresponding integer angle value; Calculate the search range centered on integer angle values; Read all raw measured angle values ​​within the retrieval range from the non-volatile memory; The original measured angle to be calibrated is compared with the original measured angle value one by one to determine the interval in which the original measured angle to be calibrated lies.

[0009] By employing the above technical solution, the angle to be calibrated is rounded down to obtain an integer angle value, and a search range is established centered on this value, thus optimizing data retrieval efficiency. This approach avoids traversing the entire storage space, instead directly locating the most probable region. Within the defined search range, the original measured angle values ​​are read, and the interval containing the angle to be calibrated is determined through step-by-step comparisons. This step-by-step search strategy improves efficiency. Especially when processing large amounts of angle data, this method reduces the number of comparisons and lowers system response time. Since the search range is dynamically determined based on the angle to be calibrated, even if the original measured angle values ​​are unevenly distributed, the target interval can be accurately located, improving the real-time performance of calibration.

[0010] In conjunction with some implementation methods of the first aspect, in some implementation methods, the calibrated angle value is calculated by linear interpolation, specifically including: Read two adjacent original measurement angle values ​​stored in the non-volatile memory, and use the original measurement angle value with the smaller value as the first original reference angle and the original measurement angle value with the larger value as the second original reference angle; Based on the storage locations of the first and second original reference angles in the non-volatile memory, the corresponding first and second ideal angles are determined with a preset angle resolution. Based on the relative position of the original measured angle to be calibrated between the first original reference angle and the second original reference angle, linear interpolation is performed between the first ideal angle and the second ideal angle to obtain the calibrated angle value.

[0011] By employing the above technical solution, an ideal angle is determined through a preset angle resolution, providing an accurate reference benchmark for linear interpolation. During interpolation calculations, the corresponding calibration angle value can be accurately mapped based on the relative position of the angle to be calibrated between the reference boundaries. This linear interpolation method is characterized by its simplicity and real-time performance. In particular, by utilizing stored location information to determine the ideal angle, the need for additional storage of the ideal angle value is avoided, saving storage space. This method can not only handle continuously changing angle values ​​but also cope with nonlinear distortions caused by mechanical errors. Through piecewise linear interpolation, it maintains both accuracy and computational efficiency.

[0012] In conjunction with some embodiments of the first aspect, in some embodiments, after outputting the calibrated angle value as the actual angle of the encoder, the method further includes: When the number of encoders is greater than 1, the complete cycle is divided into multiple consecutive angle intervals based on the number of magnetic encoders, and each angle interval corresponds to a magnetic encoder. When the high-precision encoder servo motor rotates to each angle range, only the original measured angle value output by the corresponding encoder is collected; After a complete rotation cycle is completed, the relative positions of multiple magnetic encoders are shifted by a preset angle, and the step of acquiring the original measured angle values ​​output by the corresponding encoder is repeated until each encoder has completed the acquisition of all angles. The raw measurement angle values ​​collected by each encoder are segmented and spliced ​​together to obtain the corresponding raw measurement angle value sequence; The original measured angle value sequence corresponding to each encoder is stored in a preset area of ​​the corresponding non-volatile memory; During angle calibration, the corresponding original measured angle value sequence is read from the corresponding preset area based on the identification information of the encoder to be calibrated, and then the step of retrieving the original measured angle to be calibrated from the non-volatile memory is performed to determine the interval where the original measured angle to be calibrated is located.

[0013] By adopting the above technical solution, for situations with multiple encoders, the complete cycle is divided into multiple continuous angle intervals, and each interval is assigned to a specific encoder, thus achieving optimized allocation of system resources. By controlling the overall offset of the relative positions of the encoders and repeatedly collecting data in different intervals, it is ensured that each encoder obtains complete angle measurement data. This partitioned acquisition strategy not only avoids mutual interference that may be caused by multiple encoders working simultaneously, but also improves the quality of data acquisition. By segmenting and splicing the acquired data and storing them separately in corresponding preset areas, a clear data management mechanism is established. During calibration, the system can quickly locate and read the corresponding data sequence based on the encoder identifier, improving data processing efficiency. This partitioned management and splicing processing method enables the system to efficiently handle multi-encoder scenarios while improving data integrity and accuracy.

[0014] In conjunction with some implementations of the first aspect, in some implementations, the relative positions of multiple magnetic encoders are controlled to shift by a preset angle, and the step of acquiring the original measured angle values ​​output by the corresponding encoders is repeatedly executed until each encoder has completed the acquisition of all angles, specifically including: Determine the start and end angles of the current angle range for each encoder; Calculate the overlapping area of ​​the angle ranges acquired by each encoder; The offset of the preset angle is determined based on the size of the overlapping area, so that the angle ranges of two adjacent acquisitions have an overlap of a preset ratio. Control the overall offset of multiple encoders by a preset angle; When the high-precision encoder servo motor rotates to each angle range, only the original measured angle value output by the corresponding encoder is collected; Repeat the steps of controlling the overall offset of multiple encoders by a preset angle until each encoder has completed the acquisition of all angles; The raw measured angle values ​​collected by each encoder are segmented and spliced ​​together to obtain the corresponding raw measured angle value sequence.

[0015] By adopting the above technical solution, the offset of the preset angle is determined based on the size of the overlapping area, ensuring that the angle ranges of two adjacent acquisitions have a preset proportion of overlap, thus improving the continuity and reliability of the data. When controlling multiple encoders to offset by a preset angle as a whole, the accuracy of the acquisition can be verified by comparing the data in the overlapping area due to the existence of the overlapping area. When the high-precision encoder servo motor rotates to each angle range, redundant data acquisition is avoided by only acquiring the original measured angle value output by the corresponding encoder. The offset and acquisition steps are repeated until all angle acquisitions are completed, and finally, a complete angle value sequence is obtained by segmenting and stitching together, which not only improves the accuracy and reliability of angle measurement but also realizes the self-verification function of the data.

[0016] In conjunction with some implementations of the first aspect, in some implementations, the method further includes, before dividing the complete cycle into multiple consecutive angular intervals based on the number of magnetic encoders: The ratio of the number of teeth on the driving gear to the number of teeth on the driven gear between two adjacent encoders is determined as the reduction ratio; Using a high-precision encoder servo motor as the first stage of transmission, the angle value of the encoder corresponding to each stage of transmission is calculated in turn when it rotates one revolution. The angle value is equal to the complete cycle divided by the reduction ratio of the corresponding transmission level. Use the largest angle value as the reference angle value; The number of angle intervals for each encoder is determined based on the ratio of the angle value corresponding to each encoder to the reference angle value. A mapping table is established based on the number of angle intervals and the corresponding angle values ​​for each encoder; The system divides the complete cycle into angle intervals based on the mapping table, and then performs the step of collecting only the original measured angle value output by the corresponding encoder when the high-precision encoder servo motor rotates to each angle interval.

[0017] By adopting the above technical solution, the reference angle value was determined by sequentially calculating the angle values ​​corresponding to each stage of the transmission encoder during one revolution. The selection method of this reference angle value (taking the maximum angle value) improves the rationality of subsequent segmentation. By establishing the ratio between the angle value of each encoder and the reference angle value, the number of angle intervals for each encoder was determined, and a mapping table was used to guide the segmentation of angle intervals. This interval segmentation method based on the ratio of reduction ratio and angle value makes the sampling process more systematic and standardized. Because the mechanical relationships between each stage of the transmission chain are considered, the segmented angle intervals accurately reflect the actual working characteristics of each encoder. This scientific interval segmentation method not only improves the targeting and efficiency of sampling but also ensures that the collected data fully reflects the characteristics of each transmission level, ultimately achieving more accurate and efficient angle measurement.

[0018] In conjunction with some implementations of the first aspect, in some implementations, the number of angle intervals for each encoder is determined based on the ratio of the angle value corresponding to each encoder to the reference angle value, specifically including: Calculate the ratio of the angle value corresponding to each encoder to the reference angle value; Set the number of encoder angle interval references corresponding to the reference angle value to a preset value; Set the number of angle intervals for each encoder to the base number of angle intervals divided by the corresponding ratio; If the number of angle intervals for each encoder is not an integer, round the number of angle intervals up.

[0019] By adopting the above technical solution, the number of angle intervals for each encoder is determined by dividing by the corresponding ratio. This calculation method ensures that the interval division is proportional to the angle value. Especially when handling non-integer cases, a rounding-up approach is used, ensuring complete sampling coverage. This method of determining the number of intervals based on proportional relationships solves the problem of uneven sampling density among multiple encoders. Although the rounding-up approach may slightly increase the number of sampling points, it avoids sampling dead zones and improves the continuity and completeness of angle measurements.

[0020] In a second aspect, embodiments of this application provide an encoder comprising: one or more processors and a memory; the memory is coupled to one or more processors and is used to store computer program code, the computer program code including computer instructions, wherein one or more processors invoke the computer instructions to cause the encoder to perform the method described in the first aspect and any possible implementation thereof.

[0021] Thirdly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on an encoder, cause the encoder to perform the method described in the first aspect and any possible implementation thereof.

[0022] Fourthly, embodiments of this application provide a computer program product that, when run on an encoder, causes the encoder to perform the method described in any possible implementation of the first aspect.

[0023] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. This application provides a magnetic encoder angle calibration method. During uniform rotation at a preset speed, the sampling time interval is calculated based on a preset angle resolution, ensuring a uniform distribution of the original measured angle values. The MCU main control unit collects and stores the original measured angle values ​​at fixed time intervals, establishing a complete angle mapping relationship. When calibration is required, the interval of the angle to be calibrated is located in the stored original measured angle values, and a linear interpolation method is used to map any measured angle to the corresponding calibration angle. This reduces measurement deviations caused by mechanical installation errors, magnetic field inhomogeneity, and other factors. The entire calibration process does not require a complex mathematical model; it can be completed simply by looking up tables and performing simple calculations, improving calibration accuracy and reducing computational burden. Furthermore, since the calibration data is stored in non-volatile memory, data is not lost after power failure, allowing the encoder to continuously maintain a calibration state, improving the stability and reliability of the calibration.

[0024] 2. This application provides a magnetic encoder angle calibration method. For multiple encoders, it optimizes system resource allocation by dividing the complete cycle into multiple continuous angle intervals and assigning each interval to a specific encoder. By controlling the overall offset of the encoder's relative position and repeatedly collecting data in different intervals, it ensures that each encoder obtains complete angle measurement data. This partitioned acquisition strategy not only avoids mutual interference that may be caused by multiple encoders working simultaneously but also improves the quality of data acquisition. By segmenting and splicing the acquired data and storing them in corresponding preset areas, a clear data management mechanism is established. During calibration, the system can quickly locate and read the corresponding data sequence based on the encoder identifier, improving data processing efficiency. This partitioned management and splicing processing method enables the system to efficiently handle multi-encoder scenarios while improving data integrity and accuracy.

[0025] 3. This application provides a magnetic encoder angle calibration method. By sequentially calculating the angle values ​​corresponding to each stage of the transmission encoder during one revolution, a reference angle value is determined. The selection method of this reference angle value (taking the maximum angle value) improves the rationality of subsequent segmentation. By establishing the ratio between the angle value of each encoder and the reference angle value, the number of angle intervals for each encoder is determined, and a mapping table guides the segmentation of angle intervals. This interval segmentation method based on the ratio of reduction ratio and angle value makes the sampling process more systematic and standardized. Because the mechanical relationships between each stage of the transmission chain are considered, the segmented angle intervals accurately reflect the actual working characteristics of each encoder. This scientific interval segmentation method not only improves the targeting and efficiency of sampling but also ensures that the collected data fully reflects the characteristics of each transmission level, ultimately achieving more accurate and efficient angle measurement. Attached Figure Description

[0026] Figure 1 This is a schematic diagram illustrating an application scenario of a magnetic encoder angle calibration method in an embodiment of this application.

[0027] Figure 2 This is a flowchart illustrating a magnetic encoder angle calibration method in an embodiment of this application.

[0028] Figure 3 This is another flowchart illustrating a magnetic encoder angle calibration method in an embodiment of this application.

[0029] Figure 4 This is another flowchart illustrating a magnetic encoder angle calibration method in the embodiments of this application.

[0030] Figure 5 This is a schematic diagram of the physical device structure of an encoder provided in an embodiment of this application. Detailed Implementation

[0031] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.

[0032] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0033] In modern industrial automation, robotics, and precision instruments, the accuracy of angle measurement is crucial to system performance. Magnetic encoders, as non-contact angle measurement devices, are widely used due to their simple structure, strong vibration resistance, and lack of mechanical wear. However, in practical applications, the measurement accuracy of magnetic encoders can be affected by various factors.

[0034] In related technologies, magnetic encoders typically employ the principle of magnetic induction, determining the rotation angle by detecting changes in the magnetic field. Common implementations include Hall effect sensor arrays and magnetoresistive sensors. These sensors can sense changes in the magnetic field generated by a magnet and convert them into electrical signals, thereby calculating the rotation angle. To improve measurement accuracy, existing technologies typically employ methods such as increasing the number of sensors, optimizing magnet design, and improving signal processing algorithms.

[0035] This application is primarily used in scenarios requiring high-precision angle measurement, such as servo motor control systems, robotic arm joint position detection, and precision turntable positioning. In these applications, the accuracy of angle measurement directly affects the system's control accuracy and performance. For example, in robotic arm control, measurement errors in joint angles accumulate and amplify at the end effector, leading to a decrease in positioning accuracy.

[0036] However, the related technologies exhibit the following drawbacks when implemented in the application scenarios described in this application: First, the uneven magnetization of the magnet leads to an unsatisfactory magnetic field distribution, resulting in periodic errors in the measurement results; second, mechanical errors such as misalignment and tilting between the magnetic chip and the magnet introduce additional measurement deviations; third, temperature changes affect the magnetic properties of the magnet and the sensitivity of the sensor, causing measurement drift; finally, traditional calibration methods often require complex mathematical models and substantial computational resources, making them unsuitable for embedded system implementation. These issues limit the effectiveness of magnetic encoders in high-precision applications.

[0037] The following is a combination of... Figure 1 This application describes the application scenarios of the magnetic encoder angle calibration method provided in this application. Please refer to [link / reference]. Figure 1This is a schematic diagram illustrating an application scenario of a magnetic encoder angle calibration method according to an embodiment of this application. It includes servo motor 1 and servo motor 2 connected via shaft 1, shaft 2, and a connector. Servo motor 1 is connected to a high-resolution magnetic encoder and is electrically connected to a servo motor 1 controller; servo motor 2 is connected to an encoder under test, and the encoder under test is connected to a mobile terminal.

[0038] The following example is used in conjunction with Figure 2 The following describes a magnetic encoder angle calibration method in an embodiment of this application: Please see Figure 2 This is a flowchart illustrating a magnetic encoder angle calibration method in an embodiment of this application.

[0039] S201. Control the high-precision encoder servo motor to rotate at a preset speed at a uniform speed, so that the encoder servo motor rotates synchronously. A high-precision encoder servo motor refers to a servo motor system equipped with a high-resolution encoder, whose angle measurement accuracy typically reaches the arcsecond level. The preset speed refers to a constant rotational speed pre-set according to calibration requirements; the selection of this speed needs to consider factors such as sampling frequency and data processing capabilities. Uniform rotation means that the motor maintains a constant angular velocity throughout the calibration process, avoiding the impact of acceleration and deceleration on calibration accuracy. The encoder servo motor refers to the motor installed on the magnetic encoder to be calibrated, which achieves synchronous rotation with the high-precision encoder servo motor through a mechanical connection. Synchronous rotation requires good rigidity in the mechanical connection between the two motors to avoid slippage or elastic deformation during transmission. The specific value of the preset speed can be adjusted according to actual application requirements, generally selected within the range of 10-100 rpm, and is not limited here.

[0040] The first specific method for implementing this step is to directly connect the two motor shafts using a rigid coupling. The process is as follows: First, fix the high-precision encoder servo motor on the test platform. Then, ensure the coaxiality of the motor shafts using a high-precision alignment tool. Next, connect the motor shaft of the encoder to be calibrated to the high-precision encoder servo motor shaft using a rigid coupling. Finally, send speed commands to the high-precision encoder servo motor via a servo driver, causing it to rotate at a preset speed. The second method is to use a synchronous belt drive mechanism. Specifically, install synchronous pulleys with the same number of teeth on each of the two motor shafts, and connect the two pulleys with a synchronous belt, ensuring a 1:1 transmission ratio. After starting the high-precision encoder servo motor, the synchronous belt drive causes the motor of the encoder to be calibrated to rotate synchronously. This method effectively isolates vibration transmission between the two motors.

[0041] S202. When the encoder angle is determined to be zero, the current position of the encoder is set as the zero-degree reference point, and a timer is started to perform timing counting. In this step, the encoder specifically refers to the magnetic encoder to be calibrated. An angle of zero means that the angle measurement output by the encoder under test, after signal processing, is exactly zero or has flipped from its maximum value to its minimum value, for example, from 359.9 degrees to 0.0 degrees. Determining the encoder's angle to be zero is an event detection process. The current position is the uncalibrated raw angle reading output by the encoder at any given time. The zero-degree reference point is a logically crucial reference marker that firmly binds a specific physical position of the encoder (i.e., its self-reported zero position) to the time zero point and ideal angle zero point of the entire calibration data acquisition process, serving as the cornerstone for all subsequent data alignment. A timer is typically a hardware peripheral within a microcontroller (MCU) capable of measuring the passage of time with extremely high accuracy and stability. Starting the timer for timing counting means using software instructions to cause the hardware timer's counter to increment from zero, thereby accurately recording the elapsed time from the moment the zero-degree reference point is determined. The complete description of this step is as follows: The system monitors the encoder under test, which is rotating at a constant speed, and continuously waits for a critical event to occur—that is, the angle value output by the encoder passes through its own zero point. Once this event is captured, the system immediately performs two related actions: First, logically marking this physical position as the zero-degree cornerstone for the entire calibration cycle; second, like the sound of a starting gun, instantly activating an internal high-precision timer. The core purpose of this action is to establish an unquestionable synchronous reference, so that every raw measurement angle subsequently acquired can be accurately deduced, through the timer's timestamp, into a corresponding, error-free ideal angle, thus laying the foundation for subsequent error mapping and calibration calculations.

[0042] The first method is zero-point detection based on software polling. In its main control program, the MCU continuously reads the real-time angle value of the encoder under test via a communication bus (e.g., SPI or I2C) at the highest possible frequency. After each read, the program checks if the value meets the zero-crossing condition; for example, it checks if the current angle value is less than a small positive threshold (e.g., 0.1 degrees) and the previously read angle value is greater than a large negative threshold (e.g., 359.9 degrees). Once this condition of jumping from the maximum to the minimum value is met, the program immediately executes code to reset and start a pre-configured hardware timer. This method is relatively simple to implement and does not rely on additional hardware signals from the encoder, but it continuously consumes some of the MCU's processing resources, and the precise timing of the detection is limited by the polling cycle. The second method utilizes the encoder's index signal (Z-phase signal) and the MCU's hardware capture function. Many encoders, in addition to outputting angle data, provide an index signal that generates a pulse only once per revolution at the zero point. This signal line can be connected to a special pin on the MCU that supports input capture functionality. Then, the MCU's timer is configured to input capture mode. When this pin detects a valid edge (e.g., a rising edge) of the index signal, the hardware automatically captures the timer's current count value into a register, or directly triggers a timer reset, generating an interrupt simultaneously. In the interrupt service routine, the system knows that the zero point has been precisely reached and records or confirms that the timer has started counting from zero. This method consumes almost no CPU time and has extremely low response latency, achieving nanosecond-level synchronization accuracy.

[0043] S203. Based on the preset rotational speed and preset angular resolution, calculate the time interval between two adjacent samples; The preset angle resolution refers to the minimum interval for angle sampling during calibration, determining the density and accuracy of the calibration data. The calculation of the time interval needs to consider the motor's rotational speed and the desired angle sampling density. The formula is: Time Interval = Angle Resolution / (Rotational Speed ​​× 360 degrees / revolution). For example, if the rotational speed is 60 revolutions per minute and the angle resolution is 1 degree, then the time interval is 1 / (60 × 360 / 60) = 1 / 360 second, approximately 2.78 milliseconds. This calculation process requires unit conversion to ensure that the unit of the time interval is consistent with the timer's timing unit. The selection of the preset angle resolution requires a trade-off between calibration accuracy and storage capacity, generally between 0.1 degrees and 1 degree; no specific limit is set here.

[0044] The first implementation method optimizes the calculation using integer arithmetic. Considering the low efficiency of floating-point operations in embedded systems, the calculation process can be converted into integer operations. Specifically, the angle unit is converted to the encoder's smallest resolution unit, such as representing 360 degrees as 36,000 0.01-degree units, thus avoiding floating-point division. Simultaneously, the time unit is converted to the timer's counting unit, such as microseconds or timer clock cycles. The second implementation method is a pre-calculated lookup table method. During system initialization, all possible time interval values ​​are pre-calculated based on possible combinations of rotational speed and angle resolution, and stored in a lookup table. During runtime, only the current rotational speed and resolution parameters need to be looked up to obtain the time interval, avoiding the overhead of real-time calculation.

[0045] S204. The original measured angle values ​​are collected by the MCU main control unit according to the time interval, and the original measured angle values ​​are stored in the non-volatile memory in the order of collection time. The raw measured angle value refers to the uncalibrated angle data output by the magnetic encoder to be calibrated at each sampling moment. The acquisition process requires communication between the MCU main control unit and the magnetic sensing chip to read the value of the angle register. Non-volatile memory refers to storage media whose data is not lost after power failure, such as EEPROM and Flash. Maintaining the storage order is crucial for subsequent data retrieval, requiring the establishment of a suitable indexing mechanism. The acquisition and storage processes need to consider data integrity and consistency to avoid data corruption due to power failure during the writing process. The communication interface can be SPI, I2C, etc., and the storage format can be fixed-point or floating-point; no specific limitation is made here.

[0046] The first implementation uses a circular buffer with a batch write strategy. Specifically, a circular buffer is created in RAM. Each time a timer interrupt occurs, the acquired angle value is written to the buffer. When the buffer is full or a full sampling cycle is completed, the entire buffer's data is written to non-volatile memory in batches. This method reduces the number of writes to non-volatile memory, extending memory lifespan. The second implementation uses a dual-buffer ping-pong operation. Two buffers are set up. While one buffer is receiving new data, data in the other buffer is being written to non-volatile memory. The two buffers are used alternately, ensuring that data acquisition and storage processes do not interfere with each other, improving system real-time performance.

[0047] One potential new technical problem arising during storage is the write cycle limit of non-volatile memory. To address this, a wear-leveling algorithm can be implemented. Specifically, the storage space is divided into multiple regions, each containing complete calibration data and a write counter. Each time the calibration data is updated, the region with the fewest write cycles is selected for writing, and its counter is updated accordingly. Simultaneously, a data version number is stored at the beginning of each region; during retrieval, the region with the latest version number is selected, effectively extending the memory's lifespan.

[0048] S205. When performing angle calibration, the original measurement angle to be calibrated is obtained from the magnetic sensing chip through the MCU main control unit. The magnetic sensor chip is the core sensing element of the magnetic encoder, capable of detecting changes in the magnetic field and outputting the corresponding angle value. The raw measured angle to be calibrated refers to the angle data obtained in real time without calibration processing. The acquisition process is typically completed through a digital communication interface, and must adhere to the chip's communication protocol and timing requirements. Angle calibration can be triggered periodically or on demand. The MCU main control unit needs to ensure that the magnetic sensor chip's data has been updated when reading the angle value, avoiding reading data in a transitional state. Error detection and retry mechanisms during communication also need to be considered, but are not limited here.

[0049] The first method is to use an interrupt-driven data readiness mechanism. The magnetic sensor chip generates a data readiness interrupt signal after completing an angle measurement, and the MCU immediately reads the angle data upon receiving the interrupt. This method ensures the real-time performance and validity of the data, avoiding the resource waste caused by polling. In practice, the interrupt output pins and trigger conditions of the magnetic sensor chip need to be configured, and the corresponding interrupt service routine needs to be configured on the MCU side. The second method is timed polling. The MCU actively queries the status register of the magnetic sensor chip at fixed time intervals. When a new data flag is detected, the value of the angle register is read. This method is simple to implement, but the polling period needs to be set reasonably to ensure that data updates are not missed while avoiding excessively frequent queries.

[0050] S206. Search in non-volatile memory to determine the interval containing the original measurement angle to be calibrated; The process of retrieving the original measurement angle to be calibrated from non-volatile memory to determine the interval includes: rounding the original measurement angle to be calibrated down to obtain the corresponding integer angle value; calculating the retrieval range centered on the integer angle value; reading all original measurement angle values ​​within the retrieval range from the non-volatile memory; and comparing the original measurement angle to be calibrated with the original measurement angle values ​​one by one to determine the interval in which the original measurement angle to be calibrated is located.

[0051] The core of this step is to quickly locate the angle to be calibrated within the pre-stored calibration data. The retrieval process needs to consider the data storage structure and access efficiency. Rounding the original measured angle down to obtain the corresponding integer angle value simplifies the subsequent retrieval process. Determining the retrieval range needs to consider the potential error range of the angle value, typically set to a range of several degrees before and after the integer angle value. Comparing the original measured angle values ​​needs to consider the periodicity of the angle, i.e., the continuity between 0 degrees and 360 degrees. Determining the interval provides the basic data for subsequent interpolation calculations. The retrieval algorithm can be sequential search, binary search, etc., and is not limited here.

[0052] The first retrieval method uses segmented indexing for acceleration. The 360-degree range is divided into several segments, and an index is created for each segment recording the starting address and number of data points within that segment. During retrieval, the segment containing the angle to be calibrated is first determined, and then a local search is performed within that segment. This method significantly reduces the amount of data that needs to be compared, improving retrieval efficiency. Specifically, the 360 ​​degrees can be divided into 36 segments of 10 degrees each, with the index information for each segment occupying a fixed number of bytes. The second implementation method uses a binary search algorithm. Since the stored raw measured angle values ​​are arranged in the order of acquisition and have monotonicity, binary search can be used for fast location. The specific process involves setting upper and lower bounds for the search interval, comparing the value at the middle position with the angle to be calibrated each time, adjusting the search interval based on the comparison results, until two adjacent values ​​containing the angle to be calibrated are found.

[0053] S207. Determine the position of the original measurement angle to be calibrated between two adjacent original measurement angle values, and calculate the calibrated angle value through linear interpolation; The process involves determining the position of the original measurement angle to be calibrated between two adjacent original measurement angle values, and calculating the calibrated angle value through linear interpolation. Specifically, this includes: reading two adjacent original measurement angle values ​​stored in non-volatile memory, using the smaller original measurement angle value as the first original reference angle and the larger original measurement angle value as the second original reference angle; determining the corresponding first ideal angle and second ideal angle based on the storage positions of the first and second original reference angles in the non-volatile memory using a preset angle resolution; and performing linear interpolation between the first ideal angle and the second ideal angle based on the relative position of the original measurement angle to be calibrated between the first and second original reference angles to obtain the calibrated angle value.

[0054] Linear interpolation is a simple and effective numerical approximation method that assumes the change between two known points is linear. In this step, two adjacent original measured angle values ​​serve as reference points for interpolation, and the relative position of the angle to be calibrated between these two points determines the interpolation result. Determining the minimum and maximum reference angle values ​​requires consideration of data validity and completeness. The ideal angle refers to the angle value that should be measured under ideal conditions without any error. The accuracy of the interpolation calculation depends on the density of the calibration data and the reasonableness of the linear assumption. The calculation method can be either first-order linear interpolation or higher-order interpolation; no specific limitation is made here.

[0055] The first interpolation method uses the standard linear interpolation formula. Let the angle to be calibrated be x, and two adjacent original measurements be x1 and x2, corresponding to ideal angles y1 and y2. Then the calibrated angle y = y1 + (x - x1) × (y2 - y1) / (x2 - x1). This method is simple to calculate and suitable for embedded system implementation. In actual programming, care must be taken to prevent division by zero errors and integer overflow. The second method optimizes the calculation using fixed-point arithmetic. The angle value is multiplied by a certain factor to convert it to an integer, such as multiplying the degree by 1000 to represent it as a thousandth of a degree, performing integer operations, and then converting it back to a floating-point number. This method can improve calculation speed while maintaining sufficient accuracy.

[0056] A potential technical challenge in interpolation calculations is interpolation error caused by local nonlinearity. To address this, adaptive interpolation density adjustment can be implemented. Specifically, during initial calibration, in addition to sampling at fixed intervals, the degree of nonlinearity between adjacent sampling points, such as the magnitude of the second-order difference, should be recorded. In practical applications, if a high degree of nonlinearity is detected in the current interval, local densification calibration can be triggered, i.e., additional calibration points are added within that interval. By dynamically adjusting the local calibration density, calibration accuracy in nonlinear regions can be improved while maintaining a moderate overall data volume.

[0057] S208. Use the calibrated angle value as the actual angle output of the encoder.

[0058] The calibrated angle value is an accurate angle data after error compensation, representing the encoder's true rotational position. The actual angle output needs to consider factors such as output format, communication protocol, and update frequency. The output process may include steps such as data format conversion, communication frame assembly, and checksum calculation. The encoder's output interface can be in various forms, including analog signals, digital communication, and pulse signals. The timeliness and stability of the output are crucial for downstream control systems. The output method and format can be configured according to specific application requirements and are not limited here.

[0059] The first output method is through a standard communication protocol. For example, using the SSI (Synchronous Serial Interface) protocol, the calibrated angle value is encoded according to the protocol's specified format, including start bits, data bits, and parity bits, and then serially output synchronously via a clock. This method offers good compatibility and strong anti-interference capabilities. Specific implementation requires configuring communication parameters such as data bit width and clock frequency. The second method is through an analog incremental encoder output. The calibrated angle value is converted into two quadrature A and B pulse signals. The number of pulses represents the angle change, and the phase relationship represents the rotation direction. This method can directly replace traditional photoelectric encoders without modifying the downstream control system.

[0060] In the above embodiments, during uniform rotation at a preset speed, the sampling time interval is calculated based on a preset angular resolution, ensuring a uniform distribution of the original measured angle values. The MCU main control unit collects and stores the original measured angle values ​​at fixed time intervals, establishing a complete angle mapping relationship. When calibration is required, the interval containing the angle to be calibrated is located in the stored original measured angle values, and a linear interpolation method is used to map any measured angle to the corresponding calibration angle. This reduces measurement deviations caused by mechanical installation errors, magnetic field inhomogeneity, and other factors. The entire calibration process does not require a complex mathematical model; it can be completed simply by looking up tables and performing simple calculations, which improves calibration accuracy and reduces computational burden. Furthermore, since the calibration data is stored in non-volatile memory, data is not lost after power failure, allowing the encoder to continuously maintain the calibration state, improving the stability and reliability of the calibration.

[0061] The above embodiments describe an angle calibration method for a single encoder. However, in practical applications, multiple encoders may operate simultaneously. In multi-encoder systems, coordinating the operation of each encoder and efficiently managing calibration data become problems that need to be solved. The following section combines... Figure 3 Another magnetic encoder angle calibration method in the embodiments of this application is described below: Please see Figure 3 This is another flowchart illustrating a magnetic encoder angle calibration method in an embodiment of this application.

[0062] S301. When the number of encoders is greater than 1, the complete cycle is divided into multiple continuous angle intervals based on the number of magnetic encoders. When the number of encoders is greater than one, the complete cycle is divided into multiple consecutive angular intervals based on the number of magnetic encoders, with each angular interval corresponding to one magnetic encoder. The number of encoders refers to the number of magnetic encoders requiring simultaneous angle calibration; these encoders can be installed at different positions on the same rotating shaft or on different rotating shafts. The complete cycle refers to the complete 360-degree rotation range. A consecutive angular interval refers to several adjacent, non-overlapping angular segments into which the 360-degree range is divided equally according to the number of encoders or according to a specific ratio. The division method can be uniform, meaning each interval has an equal angular range, or non-uniform, allocating different sized angular intervals based on the characteristics of each encoder or application requirements. Each angular interval corresponding to one magnetic encoder means that only data from that encoder is collected within that interval, while other encoders are in standby mode. The purpose of this division strategy is to avoid electromagnetic interference and data processing conflicts caused by multiple encoders working simultaneously. The specific division method can be determined based on factors such as the physical layout of the encoders and sampling accuracy requirements, and is not limited here.

[0063] The first method for implementing angle interval division is the equal-angle division method. The specific implementation process is as follows: First, obtain the total number N of encoders to be calibrated, and then calculate the angle range of each interval as 360 / N degrees. For example, if there are 4 encoders, each encoder is responsible for a 90-degree angle interval; the first encoder is responsible for 0-90 degrees, the second for 90-180 degrees, and so on. During implementation, a mapping table between encoder serial numbers and angle intervals needs to be established, storing the start and end angles of each encoder's corresponding interval. The second implementation method is the dynamic weighted division method. Different sized angle intervals are assigned based on the measurement accuracy requirements or usage frequency of each encoder. Specifically, first, set the weight coefficient for each encoder, and then allocate the angle range according to the weight ratio. For example, if encoder 1 has a weight of 2 and encoder 2 has a weight of 1, then encoder 1 is assigned a measurement range of 240 degrees, and encoder 2 is assigned a measurement range of 120 degrees.

[0064] S302. When the high-precision encoder servo motor rotates to each angle range, only the original measured angle value output by the corresponding encoder is collected. The current angular position of the high-precision encoder servo motor needs to be monitored in real time to determine which angular range it is currently in. Data acquisition only from the corresponding encoder means that within a specific angular range, only the encoder assigned to that range acquires and records data; other encoders, although still rotating, do not record data. This selective acquisition can be achieved through software control or hardware intelligent signal control. The acquisition frequency and accuracy requirements for the raw measured angle values ​​are the same as for a single-encoder system. The acquisition process needs to ensure data synchronization, meaning the recorded angle value must correspond to the reference angle of the high-precision encoder. The specific method of controlling the acquisition can be software judgment or hardware triggering; this is not limited here.

[0065] The first implementation method is selective acquisition based on software judgment. The main control program reads the current angle of the high-precision encoder in real time, determines which interval the current angle belongs to by looking up a table or calculation, and then intelligently acquires data from the corresponding encoder. Specifically, in the timer interrupt service routine, a reference angle is first read, and then the active encoder is determined through conditional judgment. Communication reading and data storage operations are only performed on the active encoder. This method is highly flexible and facilitates adjustments to the interval division strategy. The second implementation method uses hardware comparator triggering. Using programmable logic devices or dedicated comparator chips, the angle output of the high-precision encoder is compared in real time with preset interval boundary values. When the angle enters a specific interval, the hardware automatically generates an enable signal, triggering data acquisition from the corresponding encoder. This method has a fast response speed and reduces software overhead.

[0066] S303. After a complete rotation cycle is completed, control the relative positions of multiple magnetic encoders to shift by a preset angle as a whole, and repeat the step of acquiring the original measured angle values ​​output by the corresponding encoder until each encoder has completed the acquisition of all angles. After a complete rotation cycle, the relative positions of multiple magnetic encoders are shifted by a preset angle, and the process of acquiring the original measured angle values ​​output by the corresponding encoders is repeated until each encoder has acquired all angles. Specifically, this includes: determining the start and end angles of the current angle range for each encoder; calculating the overlapping area of ​​the angle ranges acquired by each encoder; determining the preset angle offset based on the size of the overlapping area, ensuring that adjacent acquisition angle ranges have a preset proportion of overlap; controlling the overall shift of multiple encoders by a preset angle; when the high-precision encoder servo motor rotates to each angle range, only acquiring the original measured angle values ​​output by the corresponding encoder; repeating the process of controlling the overall shift of multiple encoders by a preset angle until each encoder has acquired all angles; and segmenting and splicing the original measured angle values ​​acquired by each encoder to obtain the corresponding sequence of original measured angle values.

[0067] A complete rotation cycle refers to the high-precision encoder servo motor completing a 360-degree rotation. Overall relative position offset means that all encoders simultaneously change the same angle relative to the mounting position of the rotating shaft; this can be achieved through mechanical adjustment or electrical phase compensation. The preset angle refers to the amount of angle offset each time, the magnitude of which determines the number of cycles required to complete all data acquisition. The repeated execution process requires precise control to ensure that each encoder ultimately covers the complete 360-degree range. The preset overlap ratio ensures data continuity and integrity; data in the overlapping area can be used for verification and smoothing. The offset method can be mechanical rotation or electronic phase adjustment; the offset angle can be determined based on the number of encoders and accuracy requirements, and is not limited here.

[0068] The first method to achieve offset adjustment is mechanical rotation. All encoders are mounted on a rotatable circular base, driven by a stepper motor or servo motor. After each data acquisition cycle, the base motor rotates by a preset angle, synchronously changing the relative positions of all encoders. In practice, the base is equipped with precise angle scales or encoders to ensure accurate and controllable angle adjustments for each rotation. The preset angle is typically chosen to be the size of the initially assigned angle range, ensuring that after N rotations, each encoder fully covers 360 degrees. The second method is electronic phase compensation. While keeping the physical position of the encoders constant, a phase offset is added to the measured value of each encoder during data processing. In practice, a phase offset register is maintained in the software, and the offset is increased by a preset angle value after each cycle. In subsequent data acquisitions, the original measured value plus the current phase offset is used as the actual angular position.

[0069] S304. The original measured angle values ​​collected by each encoder are segmented and spliced ​​together to obtain the corresponding original measured angle value sequence; Segmented stitching is the process of combining multiple sets of partial angle data into a complete 360-degree data sequence. Each encoder collects data from different angle ranges at different offset positions, and these data segments need to be combined in the correct order and positional relationship. The original measured angle value sequence refers to the set of measurement data arranged in angular order, covering the entire period. The stitching process needs to handle issues such as data fusion in overlapping areas and interpolation of missing data. The accuracy of stitching directly affects the effect of subsequent calibration. Data sorting, deduplication, and interpolation are all important steps in the stitching process. Stitching algorithms can use simple merging, weighted averaging, spline interpolation, etc., which are not limited here.

[0070] The first method of data stitching is sequential stitching based on timestamps. During data acquisition, a timestamp and corresponding reference angle information are added to each measurement value. During stitching, all data segments are first sorted according to the reference angle, and then overlapping areas are identified. For overlapping parts, data quality indicators (such as signal-to-noise ratio, stability, etc.) from different acquisitions are compared, and data with better quality is selected for retention. In practice, a temporary data structure is established, containing fields such as angle value, measurement value, timestamp, and quality indicators, and stitching is completed through sorting and filtering algorithms. The second method is index stitching based on an angle mapping table. A complete angle index table is pre-built, with each entry in the table corresponding to an ideal sampling angle. During stitching, data from each acquisition is mapped to the corresponding position in the index table according to its reference angle. If there are multiple data points at a certain position, a weighted average or median filtering method is used to determine the final value. If there is no data at a certain position, it is filled by linear interpolation of adjacent data.

[0071] S305. Store the original measured angle value sequence corresponding to each encoder into the preset area of ​​the corresponding non-volatile memory; A pre-allocated area refers to an independent storage space pre-allocated for each encoder in non-volatile memory. This partitioned storage strategy facilitates data management and retrieval. Each encoder's data is stored independently, avoiding the risks of data scrambling and overwriting. The storage format needs to include metadata such as encoder identifier, data version, and verification information. The capacity allocation of non-volatile memory needs to consider factors such as the number of encoders, data precision, and redundancy backup. The calculation and management of storage addresses are crucial for achieving efficient access. Memory types can include EEPROM, Flash, FRAM, etc., and storage formats can be raw binary, compressed, etc., without limitation here.

[0072] The first storage implementation is fixed partition mapping. During system initialization, the storage space is divided into multiple fixed-size partitions based on the maximum number of encoders and the amount of data per encoder. The starting address of each partition is calculated using a simple multiplication: Partition starting address = Base address + Encoder sequence number × Partition size. A metadata area, containing data validity flags, write time, checksum, and other information, is stored at the beginning of each partition. The data area follows immediately, storing the angle value sequence sequentially. This method is simple to calculate and has high access efficiency. The second implementation is a dynamic linked list structure. Storage space is managed in a file system-like manner, with each encoder's data stored as a file. An index table is created to record information such as the starting address, data length, and next data block address for each encoder's data. This method can flexibly handle datasets of different sizes and supports dynamic addition, deletion, and space reclamation.

[0073] S306. When performing angle calibration, after reading the corresponding original measurement angle value sequence from the corresponding preset area according to the identification information of the encoder to be calibrated, the step of retrieving in the non-volatile memory to determine the interval where the original measurement angle to be calibrated is located is executed.

[0074] The encoder's identification information is a unique identifier for each encoder, which can be a serial number, installation location number, communication address, etc. This identification information is used to determine which storage area to read calibration data from. The reading process requires first calculating or looking up the corresponding storage address based on the identification information, and then reading the complete angle value sequence from that address. The read data needs to be verified for integrity to ensure that the data is not corrupted. Subsequent retrieval and calibration processes are similar to those of a single encoder system, but it is necessary to ensure that data from the correct encoder is used. The encoding method of the identification information, the addressing method of the storage area, etc., can be flexibly determined according to the system design and are not limited here.

[0075] The first implementation method is fast location based on hash mapping. Encoder identification information is mapped to the storage area index using a hash function, establishing a fast lookup table from identifier to storage address. Specifically, during system initialization, the hash value of each encoder identifier is calculated, and a hash table is built and stored in RAM. When data needs to be read, the hash value of the encoder identifier to be calibrated is calculated, the storage area address is directly obtained through the hash table, and then the data at that address is read. This method has a fast lookup speed with a time complexity of O(1). The second implementation method is hierarchical lookup based on a two-level index. A two-level index structure is established. The first-level index categorizes encoders by type or group, and the second-level index locates the encoder within each group based on its specific identifier. This method is suitable for situations with a large number of encoders and clear classifications, reducing the search range and improving efficiency.

[0076] In the above embodiments, for the case of multiple encoders, the system resources are optimized by dividing the complete cycle into multiple continuous angle intervals and assigning each interval to a specific encoder. By controlling the overall offset of the relative positions of the encoders and repeatedly collecting data in different intervals, it is ensured that each encoder can obtain complete angle measurement data. This partitioned acquisition strategy not only avoids mutual interference that may be caused by multiple encoders working simultaneously, but also improves the quality of data acquisition. By segmenting and splicing the acquired data and storing them separately in corresponding preset areas, a clear data management mechanism is established. During calibration, the system can quickly locate and read the corresponding data sequence based on the encoder identifier, improving data processing efficiency. This partitioned management and splicing processing method enables the system to efficiently handle multi-encoder scenarios while improving data integrity and accuracy.

[0077] The above embodiments achieve collaborative operation of multiple encoders by dividing the complete cycle into multiple continuous angle intervals. However, in practical applications, there are often transmission ratio relationships between encoders, which makes the division of angle intervals need to consider more mechanical characteristics. To better adapt to multi-encoder systems with transmission chain structures, the following combines... Figure 4 The following describes another magnetic encoder angle calibration method in the embodiments of this application: Please see Figure 4 This is another flowchart illustrating a magnetic encoder angle calibration method in this application.

[0078] S401. The ratio of the number of teeth on the driving gear to the number of teeth on the driven gear between two adjacent encoders is determined as the reduction ratio; The driving gear is the gear in the transmission chain that provides power output, usually connected to the previous stage drive shaft or motor output shaft. The driven gear is the gear that receives power input, connected to the next stage drive shaft or the shaft being measured. The number of teeth refers to the total number of teeth on the circumference of the gear. The reduction ratio is the ratio of the number of teeth on the driving gear to the number of teeth on the driven gear, reflecting the speed change relationship between two adjacent transmission stages. When the reduction ratio is greater than 1, it indicates a speed-reducing transmission; when the reduction ratio is less than 1, it indicates a speed-increasing transmission; when the reduction ratio is equal to 1, it indicates a constant-speed transmission. Two adjacent encoders refer to encoders installed in the transmission chain that are directly connected at two measurement positions via gear transmission. Accurate calculation of the reduction ratio is crucial for subsequent angle interval division, as it directly determines the angle correspondence between different levels of encoders. Gear types can be spur gears, helical gears, bevel gears, etc., and the transmission method can be single-stage or multi-stage transmission; no limitation is made here.

[0079] The first method for determining the reduction ratio is direct measurement. This involves directly measuring the number of teeth on the driving and driven gears using mechanical measuring tools such as calipers or gear measuring instruments. The specific process is as follows: First, position the transmission system at rest for easy observation. Mark a tooth on the driving gear as the starting point. Then, manually rotate the gear, counting the number of teeth one by one until the marked point returns to the starting position, and record the total number of teeth. Perform the same operation on the driven gear. Finally, calculate the ratio of the two teeth to obtain the reduction ratio. To improve accuracy, multiple measurements can be taken and the average value taken. The second method is kinematic measurement. This involves indirectly calculating the reduction ratio by measuring the rotational speed or rotation angle of the driving and driven gears. Specifically, a high-precision encoder or speed sensor is installed on both the driving and driven gears. Simultaneously, the driving gear is driven to rotate a fixed angle or number of revolutions, and the corresponding rotation of the driven gear is recorded. The reduction ratio equals the rotation of the driving gear divided by the rotation of the driven gear. This method avoids disassembling the equipment and is suitable for already assembled systems.

[0080] S402. Using a high-precision encoder servo motor as the first stage of transmission, calculate the angle value of the encoder corresponding to each stage of transmission when it rotates one revolution. Using a high-precision encoder servo motor as the first-stage transmission, the angle value corresponding to each stage of the transmission during one revolution of the encoder is calculated sequentially. The angle value is equal to the complete cycle divided by the reduction ratio of the corresponding transmission stage. The first-stage transmission refers to the transmission stage directly connected to the output shaft of the high-precision encoder servo motor. Each stage of the transmission refers to each transmission level in the transmission chain formed from the motor output through multiple gear transmission links. One revolution of the encoder means that the encoder installed on that transmission stage completes a full 360-degree rotation. The corresponding angle value is the angle rotated by the first-stage transmission (i.e., the high-precision encoder) when that stage of the encoder rotates one revolution. This angle value is calculated based on the cumulative effect of the reduction ratios between each stage. The complete cycle here still refers to 360 degrees. The formula for calculating the angle value is: Angle value = 360 degrees ÷ (product of all reduction ratios from the first stage to this stage). This calculation method establishes a precise angle mapping relationship between different transmission stages. The number of transmission stages, the combination of reduction ratios, etc., can be determined according to the actual mechanical structure and are not limited here.

[0081] The first calculation method is a recursive calculation. Starting from the first stage of transmission, the angle value of each stage is calculated progressively. Specifically, the angle value of the first stage is set to 360 degrees (because it is directly connected to the motor, and one rotation is 360 degrees). For the second stage, its angle value is equal to the first stage angle value divided by the reduction ratio from the first to the second stage. For the third stage, its angle value is equal to the second stage angle value divided by the reduction ratio from the second to the third stage. This process continues until all transmission stages have been calculated. In the program implementation, an array is used to store the angle values ​​of each stage, and a loop structure is used to complete the calculation. The second implementation method is a matrix operation algorithm. A transformation matrix of the transmission system is constructed, where each matrix element represents the transmission relationship between two adjacent stages. Matrix multiplication is used to calculate the angle correspondence of all stages at once. Specifically, an n×n transmission matrix is ​​established (n is the number of transmission stages), with the elements below the diagonal representing the reduction ratio of each stage, and the remaining elements being 0. Matrix operations can quickly obtain the angle transformation relationship between any two stages.

[0082] S403. Use the largest angle value as the reference angle value; The maximum angle value refers to the largest angle value among all transmission levels corresponding to one revolution of the encoder in the first stage of transmission. The reference angle value serves as the standard for all subsequent angle interval divisions and calculations. The maximum angle value is chosen as the reference because it represents the stage with the slowest rotational speed and the largest reduction ratio in the transmission system. Using this as the reference ensures that the angle intervals of all other stages are integer multiples of the reference interval, facilitating unified management and calculation. This reference angle value typically appears at the end of the transmission chain because, after multiple reduction stages, the rotational speed at the end is the lowest, corresponding to the largest angle value. Determining the reference angle value is simple and direct; it can be obtained by comparing all calculated angle values. The comparison algorithm, data structure, and other implementation details can be selected according to system requirements and are not limited here.

[0083] The first implementation method is the sequential comparison method. All angle values ​​of the transmission stages are stored in an array, and the maximum value is found by traversing the array. Specifically, a variable is initialized to store the current maximum value, with the initial value set to the first angle value. Each element in the array is traversed; if the current element is greater than the stored maximum value, the maximum value is updated. After traversal, the stored value is the baseline angle value. The transmission stage index corresponding to the maximum value is also recorded for subsequent processing. The second implementation method is the sorting and selection method. All angle values ​​are sorted, and the last element after sorting is directly selected as the baseline angle value. Efficient sorting algorithms such as quicksort and mergesort can be used. The advantage of sorting is that it not only obtains the maximum value but also provides an ordered arrangement of all angle values, facilitating subsequent ratio calculations and analysis.

[0084] S404. Determine the number of angle intervals for each encoder based on the ratio of the angle value corresponding to each encoder to the reference angle value; The number of angle intervals for each encoder is determined based on the ratio of its corresponding angle value to the reference angle value. This involves: calculating the ratio of each encoder's angle value to the reference angle value; setting the reference number of angle intervals for the encoder corresponding to the reference angle value as a preset value; setting the number of angle intervals for each encoder as the reference number divided by the corresponding ratio; and rounding up the number of angle intervals if the number of angle intervals for each encoder is not an integer. The ratio of the angle value to the reference angle value reflects the speed relationship between different transmission stages; a smaller ratio indicates a faster rotational speed at that stage, requiring a larger number of angle intervals. The reference number of angle intervals is the initial number of intervals set for the encoder corresponding to the reference angle value. The selection of this preset value needs to consider the accuracy requirements of data acquisition and storage capacity limitations. Setting the number of angle intervals as the reference number divided by the ratio ensures that faster encoders are allocated more intervals, guaranteeing the uniformity of sampling density. The rounding up process avoids the problem of insufficient interval numbers, ensuring that each encoder has sufficient sampling intervals. The size of the preset value and the rounding method can be adjusted according to the system accuracy requirements and are not limited here.

[0085] The first implementation method is direct calculation. For each encoder, the following calculation process is performed: First, calculate the ratio of the encoder's angle value to the reference angle value, obtaining a decimal between 0 and 1 (because the reference angle value is the maximum value). Then, divide the preset reference number of angle intervals by this ratio to obtain the theoretically required number of intervals for the encoder. If the calculation result is not an integer, use a rounding function (such as the ceil function) to obtain the final number of intervals. For example, if the reference number is 10 and the ratio of an encoder is 0.6, then the number of intervals is ceil(10 / 0.6) = ceil(16.67) = 17. The second implementation method is lookup table mapping. A mapping table is pre-established to the number of intervals, mapping common ratio ranges to corresponding interval numbers. In specific implementation, the ratio range is divided into several intervals, such as [0, 0.1), [0.1, 0.2), etc., each interval corresponding to a predetermined number of intervals. The number of intervals can be quickly determined by looking up the table, suitable for situations where the ratio variation range is limited.

[0086] S405. Establish a mapping table based on the number of angle intervals and the corresponding angle values ​​for each encoder; The mapping table is a data structure connecting encoder characteristics with angle interval divisions, containing all the configuration information required for multi-encoder collaborative sampling. Each record in the table should include information such as encoder identifier, number of angle intervals, angle range of a single interval, and starting angle offset. The number of angle intervals is the result calculated in the previous step. The corresponding angle value is used to calculate the actual angle range of each interval, i.e., 360 degrees divided by the number of angle intervals. The process of establishing the mapping table needs to consider data integrity and consistency, ensuring that all encoder intervals can seamlessly cover the entire measurement range. The table's storage format can be an array, linked list, hash table, or other data structures, chosen based on access patterns and efficiency requirements. The update mechanism and indexing method of the mapping relationship can be determined based on the application scenario and are not limited here.

[0087] The first method for establishing the mapping table is a static array implementation. Define an array of structures, each containing fields such as encoder ID, number of intervals, interval angle, and starting index. The implementation process is as follows: first, allocate array space based on the number of encoders; then, iterate through each encoder, filling in its corresponding information. The interval angle is calculated by dividing 360 degrees by the number of intervals. The starting index is used to quickly locate the encoder's data within the overall dataset. To improve access efficiency, it can be sorted by encoder ID, supporting binary search. This implementation is simple in structure, fast in access, and suitable for scenarios with a fixed number of encoders. The second implementation method is a dynamic hash table structure. Use the encoder ID as the key and store objects containing all relevant information as values ​​in the hash table. In the implementation, you can use the hash table data structure provided by the standard library or implement your own. The choice of hash function should ensure a uniform distribution of key-value pairs to reduce collisions. This method supports dynamically adding and deleting encoders, offering greater flexibility.

[0088] S406. Divide the angle interval of the complete cycle according to the mapping relationship table, and execute the step of only collecting the original measured angle value output by the corresponding encoder when the high-precision encoder servo motor rotates to each angle interval.

[0089] Dividing angle intervals according to the mapping table means allocating the complete 360-degree cycle to each encoder according to the interval configuration recorded in the table. This division is not a simple equal division, but an optimized allocation based on the characteristics and requirements of each encoder. The data acquisition process is similar to the aforementioned partitioned acquisition, but the interval division is based on a more scientific and reasonable approach. The motion control of the high-precision encoder servo motor needs to work closely with the mapping table to ensure that the correct encoder is activated in the correct angle interval. The acquisition of the original measured angle values ​​still follows the selective acquisition principle to avoid resource waste and data conflicts. The specific algorithm for interval division, acquisition triggering method, etc., can be determined according to the system's real-time requirements and are not limited here.

[0090] The first implementation method is interrupt-triggered interval switching. Based on the mapping table, a list of angle trigger points is generated, with each trigger point corresponding to the start or end position of an interval. These trigger points are configured into hardware timers or position comparators. When the output of the high-precision encoder reaches a trigger point, an interrupt signal is generated. In the interrupt service routine, the mapping table is consulted based on the current angle to determine the encoder to be activated, and the data acquisition channel is switched. This method offers timely response and is suitable for high-speed rotation applications. The second implementation method is state machine-based interval management. A finite state machine is designed, where each state corresponds to an angle interval, and the transition between states occurs when the angle reaches the interval boundary. In the main control loop, the current angle is continuously monitored, and when the state transition condition is met, a state switch is executed, simultaneously updating the active encoder. The state machine method has clear logic and is easy to debug and maintain.

[0091] A potential new technical challenge during this step is the discrepancy between the actual angle and the theoretically calculated angle due to the dynamic characteristics of the transmission system. To address this, a real-time angle compensation mechanism can be introduced. Specifically, during the acquisition process within each angle interval, the reference angle of the high-precision encoder and the actual measured angle of the target encoder are recorded simultaneously. The dynamic deviation is calculated by comparing the expected angle calculated using the theoretical transmission ratio with the actual measured angle. This deviation data is then filtered to extract the systematic deviation component. In subsequent acquisition processes, the interval boundaries are adjusted in real-time based on the current operating status and historical deviation data. For example, if the actual angle in a certain interval is generally too large, the starting angle of that interval is advanced appropriately to ensure that the acquired data covers the correct angle range.

[0092] In the above embodiments, a reference angle value is determined by sequentially calculating the angle values ​​corresponding to each stage of the transmission encoder during one revolution. The selection method of this reference angle value (taking the maximum angle value) improves the rationality of subsequent division. By establishing the ratio between the angle value of each encoder and the reference angle value, the number of angle intervals for each encoder is determined, and a mapping table guides the division of angle intervals. This interval division method based on the ratio of reduction ratio and angle value makes the sampling process more systematic and standardized. Because the mechanical relationships between each stage of the transmission chain are considered, the divided angle intervals accurately reflect the actual working characteristics of each encoder. This scientific interval division method not only improves the targeting and efficiency of sampling but also ensures that the collected data fully reflects the characteristics of each transmission level, ultimately achieving more accurate and efficient angle measurement.

[0093] The encoder in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference]. Figure 5This is a schematic diagram of the physical device structure of an encoder provided in an embodiment of this application.

[0094] It should be noted that, Figure 5 The encoder structure shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0095] like Figure 5 As shown, the encoder includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a program stored in Read-Only Memory (ROM) 502 or a program loaded from storage section 508 into Random Access Memory (RAM) 503. The RAM 503 also stores various programs and data required for encoder operation. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An Input / Output (I / O) interface 505 is also connected to the bus 504.

[0096] The following components are connected to I / O interface 505: input section 506 including a camera, infrared sensor, etc.; output section 507 including a liquid crystal display (LCD) and speakers, etc.; storage section 508 including a hard disk, etc.; and communication section 509 including a network interface card such as a LAN (Local Area Network) card and a modem, etc. Communication section 509 performs communication processing via a network such as the Internet. Drive 510 is also connected to I / O interface 505 as needed. Removable media 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 510 as needed so that computer programs read from them can be installed into storage section 508 as needed.

[0097] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs the various functions defined in the present invention.

[0098] It should be noted that the computer-readable medium shown in the embodiments of the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an encoder, device, or apparatus that is electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. The transmitted data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof.

[0099] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of encoders, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based encoder that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0100] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the encoder described in the above embodiments; or it may exist independently and not assembled into the encoder. The storage medium carries one or more computer programs that, when executed by a processor of an encoder, cause the encoder to implement the methods provided in the above embodiments.

[0101] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

[0102] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0103] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0104] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A magnetic encoder angle calibration method, applied to a magnetic encoder, characterized in that, The magnetic encoder integrates an MCU main control unit, a magnetic sensing chip, and a non-volatile memory. The servo motor of the magnetic encoder is coaxially fixedly connected to the high-precision encoder servo motor via a detachable connector. The method includes: The high-precision encoder servo motor is controlled to rotate at a preset speed at a uniform speed, so that the magnetic encoder servo motor rotates synchronously. When the angle of the magnetic encoder is determined to be zero, the current position of the magnetic encoder is set as the zero-degree reference point, and a timer is started to perform timed counting. Based on the preset rotational speed and preset angular resolution, the time interval between two adjacent samples is calculated. The original measured angle values ​​are acquired by the MCU main control unit according to the time interval, and the original measured angle values ​​are stored in the non-volatile memory in the order of acquisition time. During angle calibration, the original measurement angle to be calibrated is obtained by the magnetic sensing chip output by the MCU main control unit; The interval in the non-volatile memory to determine the original measurement angle to be calibrated is defined by two adjacent original measurement angle values, specifically including: The original measurement angle to be calibrated is rounded down to obtain the corresponding integer angle value; Calculate the search range centered on the integer angle value; Read all raw measured angle values ​​within the retrieval range from the non-volatile memory; The original measurement angle to be calibrated is compared one by one with the original measurement angle value to determine the interval in which the original measurement angle to be calibrated lies. Determine the position of the original measurement angle to be calibrated between two adjacent original measurement angle values, and calculate the calibrated angle value through linear interpolation, specifically including: Read two adjacent original measurement angle values ​​stored in the non-volatile memory, and use the original measurement angle value with the smaller value as the first original reference angle and the original measurement angle value with the larger value as the second original reference angle; Based on the storage locations of the first original reference angle and the second original reference angle in the non-volatile memory, the corresponding first ideal angle and second ideal angle are determined with the preset angle resolution. Based on the relative position of the original measurement angle to be calibrated between the first original reference angle and the second original reference angle, linear interpolation is performed between the first ideal angle and the second ideal angle to obtain the calibrated angle value; The calibrated angle value is used as the actual angle output of the magnetic encoder.

2. The method according to claim 1, characterized in that, After using the calibrated angle value as the actual angle output of the magnetic encoder, the method further includes: When the number of magnetic encoders is determined to be greater than 1, the complete cycle is divided into multiple consecutive angle intervals based on the number of magnetic encoders, and each angle interval corresponds to one magnetic encoder. When the high-precision encoder servo motor rotates to each of the angle ranges, only the original measured angle value output by the corresponding magnetic encoder is collected; After a complete rotation cycle is completed, the relative positions of the multiple magnetic encoders are shifted by a preset angle, and the step of acquiring the original measured angle values ​​output by the corresponding magnetic encoder is repeated until each magnetic encoder has completed the acquisition of all angles. The original measured angle values ​​collected by each magnetic encoder are segmented and spliced ​​together to obtain the corresponding sequence of original measured angle values; The original measured angle value sequence corresponding to each magnetic encoder is stored in a preset area of ​​the corresponding non-volatile memory; During angle calibration, after reading the corresponding original measured angle value sequence from the corresponding preset area according to the identification information of the encoder to be calibrated, the step of retrieving in the non-volatile memory to determine the interval where the original measured angle to be calibrated is located is executed.

3. The method according to claim 2, characterized in that, The step of controlling the relative positions of the multiple magnetic encoders to shift by a preset angle and repeatedly performing the step of acquiring the original measured angle values ​​output by the corresponding magnetic encoders until each magnetic encoder has completed the acquisition of all angles specifically includes: Determine the start and end angles of the current angle range for each magnetic encoder; Calculate the overlapping area of ​​the angle ranges acquired by each of the magnetic encoders; The offset of the preset angle is determined based on the size of the overlapping area, so that the angle ranges of two adjacent acquisitions have an overlapping part with a preset ratio. Control the collective magnetic encoders to shift off by the preset angle; When the high-precision encoder servo motor rotates to each of the angle ranges, only the original measured angle value output by the corresponding magnetic encoder is collected; Repeat the step of controlling the multiple magnetic encoders to shift as a whole by the preset angle until each magnetic encoder has completed the acquisition of all angles; The original measured angle values ​​collected by each magnetic encoder are segmented and spliced ​​together to obtain the corresponding original measured angle value sequence.

4. The method according to claim 2, characterized in that, Before dividing the complete cycle into multiple consecutive angle intervals based on the number of magnetic encoders, the method further includes: The ratio of the number of teeth on the driving gear to the number of teeth on the driven gear between two adjacent magnetic encoders is determined as the reduction ratio; Using the high-precision encoder servo motor as the first stage of transmission, the angle value corresponding to the magnetic encoder of each stage of transmission is calculated sequentially when it rotates one revolution. The angle value is equal to the complete cycle divided by the reduction ratio of the corresponding transmission level. The largest angle value is used as the reference angle value; The number of angle intervals for each magnetic encoder is determined based on the ratio of the angle value corresponding to each magnetic encoder to the reference angle value; A mapping table is established based on the number of angle intervals and the corresponding angle values ​​for each magnetic encoder; The complete cycle is divided into angle intervals according to the mapping table, and the step of collecting only the original measured angle value output by the corresponding magnetic encoder is performed when the high-precision encoder servo motor rotates to each angle interval.

5. The method according to claim 4, characterized in that, The step of determining the number of angle intervals for each magnetic encoder based on the ratio of the angle value corresponding to each magnetic encoder to the reference angle value specifically includes: Calculate the ratio of the angle value corresponding to each magnetic encoder to the reference angle value; Set the number of reference angle intervals of the magnetic encoder corresponding to the reference angle value to a preset value; The number of angle intervals for each magnetic encoder is set as the reference number of angle intervals divided by the corresponding ratio; If the number of angle intervals for each magnetic encoder is not an integer, the number of angle intervals is rounded up.

6. A magnetic encoder, characterized in that, The magnetic encoder includes: One or more processors and a memory; the memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the magnetic encoder to perform the method as described in any one of claims 1-5.

7. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on the magnetic encoder, the magnetic encoder performs the method as described in any one of claims 1-5.

8. A computer program product, characterized in that, When the computer program product is run on the magnetic encoder, it causes the magnetic encoder to perform the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Magnetic encoder calibrating method and system

    CN106679710A

  • Calibration method for angle sensor and sensing system

    WO2023240468A1