Nonlinear calibration method and device for a magnetic encoder

By setting multiple inflection points on the angle curve of the magnetic encoder and obtaining compensation coefficients, the calibration algorithm is simplified, resource consumption is reduced, the calibration accuracy of the magnetic encoder is improved, and the measurement values ​​of the angle measuring instrument are adapted.

CN115979324BActive Publication Date: 2026-05-12SENKSEMI-ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SENKSEMI-ELECTRONICS CO LTD
Filing Date
2022-12-29
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing magnetic encoder compensation algorithms consume too many resources or have too much computing power, making it difficult to meet the needs of high-precision servo motor control systems.

Method used

By setting multiple inflection points on the angle curve, the angle period is divided into multiple first-order curve segments. The compensation coefficient and angle output threshold of each segment are obtained. The slope of each curve segment is approximated to 1 by using the compensation coefficient, thus simplifying the calibration algorithm.

Benefits of technology

The compensation algorithm has been simplified, resource consumption has been reduced, the calibration accuracy of the magnetic encoder has been improved, and the measurement values ​​of the angle measuring instrument have been adapted.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115979324B_ABST
    Figure CN115979324B_ABST
Patent Text Reader

Abstract

The application discloses a nonlinear calibration method and device of a magnetic encoder. The method comprises the following steps: setting multiple inflection points on an angle curve diagram formed based on an angle scanning result to divide an angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; acquiring a compensation coefficient of each angle curve segment; acquiring an angle output threshold value of each angle curve segment; and starting calibration after detecting a data valid signal, acquiring a target output angle after calibration based on the corresponding compensation coefficient and the angle output threshold value according to an input angle. The application divides a complete angle period into multiple angle curve segments by setting multiple inflection points, and each angle curve segment is approximately a first-order curve. Then, the slope of each angle curve segment is approximated to 1 through a compensation coefficient, and a target output angle compatible with an angle measurement value of an angle measuring instrument is obtained after calibration. The compensation algorithm is simplified, and resource consumption is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of magnetic encoder technology, and in particular to a nonlinear calibration method and apparatus for a magnetic encoder. Background Technology

[0002] Due to limitations in manufacturing processes and inherent system biases, the angle measured by a magnetic encoder will deviate somewhat from the actual value; this deviation is known as nonlinear error. For systems with low precision requirements, the impact of this deviation is negligible; however, for high-precision devices with servo motor control systems, this deviation needs to be minimized. Therefore, a compensation algorithm suitable for magnetic encoders is needed to reduce this nonlinear error.

[0003] Common compensation algorithms in existing technologies include interpolation, least squares, neural network compensation, and lookup tables. While these compensation schemes can reduce linearity errors, their implementation is overly complex and consumes excessive resources or computational power. Summary of the Invention

[0004] The purpose of this invention is to provide a nonlinear calibration method and apparatus for magnetic encoders that simplifies the compensation algorithm and reduces resource consumption, so as to solve the technical problem that existing compensation algorithms for magnetic encoders consume extremely high resources or huge computing power.

[0005] To achieve the above objectives, the present invention provides a nonlinear calibration method for a magnetic encoder, comprising the following steps: setting multiple inflection points on an angle curve graph formed based on angle scanning results to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; obtaining the compensation coefficient of each angle curve segment; obtaining the angle output threshold of each angle curve segment; and starting calibration when a valid data signal is detected, and obtaining the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold.

[0006] To achieve the above objectives, the present invention also provides a nonlinear calibration device for a magnetic encoder, comprising: a setting module for setting multiple inflection points on an angle curve graph formed based on angle scanning results to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; a first acquisition module for acquiring a compensation coefficient for each angle curve segment; a second acquisition module for acquiring an angle output threshold for each angle curve segment; and a calibration module for initiating calibration upon detecting a valid data signal, and acquiring the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold.

[0007] This invention divides a complete angle cycle into multiple angle curve segments by setting multiple inflection points, with each angle curve segment approximating a first-order curve. Then, the slope of each angle curve segment is approximated to 1 by a compensation coefficient. After calibration, a target output angle that matches the angle measurement value of the angle measuring instrument is obtained. This simplifies the compensation algorithm and reduces resource consumption. Attached Figure Description

[0008] Figure 1 A flowchart illustrating a nonlinear calibration method for a magnetic encoder according to an embodiment of the present invention;

[0009] Figure 2 This is a schematic diagram of inflection point setting according to an embodiment of the present invention;

[0010] Figure 3 This is a schematic diagram of the nonlinear calibration device for a magnetic encoder provided in an embodiment of the present invention. Detailed Implementation

[0011] The technical solutions in the embodiments of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0012] Please see Figure 1 This is a flowchart of a nonlinear calibration method for a magnetic encoder provided in an embodiment of the present invention. Figure 1 As shown, the method described in this embodiment includes the following steps: S1, setting multiple inflection points on the angle curve graph formed based on the angle scanning results to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; S2, obtaining the compensation coefficient of each angle curve segment.

[0013] S3. Obtain the angle output threshold for each angle curve segment; and S4. Start calibration after detecting a valid data signal, and obtain the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold.

[0014] This embodiment divides a complete angle cycle into multiple angle curve segments by setting multiple inflection points, with each angle curve segment approximating a first-order curve. Then, the slope of each angle curve segment is approximated to 1 by a compensation coefficient. After calibration, a target output angle that matches the angle measurement value of the angle measuring instrument is obtained. This simplifies the compensation algorithm and reduces resource consumption.

[0015] In some embodiments, the angle curve is formed by drawing the results of multiple angle scans, and the inflection points are set and written to a register using the angle measurement values ​​from an angle measuring instrument as the angle standard. The set inflection points are designed to ensure that the curve between inflection points is as close to a straight line as possible. The angle measuring instrument can be a high-precision angle sensor XG700A.

[0016] The inflection point can be written to the register as follows: 360° is represented by 16'hFFFF (a hexadecimal number, which is 65535 in decimal). The inflection point is then converted and written to the register. Taking a 45° inflection point as an example, 45 / 360*65535=8192, and 8192 is written to the register.

[0017] If the magnetic encoder chip (or magnet) rotates by a certain angle (based on the angle measurement value of an angle measuring instrument, assuming the angle measurement value is 45°), due to signal noise, system errors (caused by structure and manufacturing process), and calculation errors, the chip's angle output value may be 44°. Therefore, it is necessary to compensate for this angle output value so that the chip's current 44° output becomes 45°. In this embodiment, the inflection point is set by selecting a point with a large deviation on the angle curve graph drawn based on the angle scanning results; then, a compensation coefficient is applied to calibrate the chip's current angle output value to the target output angle.

[0018] like Figure 2 As shown, curve 21 is drawn based on the angle scanning result, and straight line 22 is drawn based on the ideal target output angle. The dots indicate the set inflection points 23. The horizontal axis of the coordinate system is the angle measurement value θ of the angle measuring instrument, and the vertical axis is the angle output value theta of the chip. The set inflection points 23 are designed to ensure that the curves (angle curve segments) between the inflection points are as close to a straight line as possible. It should be noted that the first angle curve segment 24 is divided by the starting point of curve 21 on the angle curve graph (shown as the origin of the coordinate system) and the first inflection point, and the last angle curve segment is divided by the last inflection point and the end point of curve 21.

[0019] In some embodiments, step S2, obtaining the compensation coefficient for each angle curve segment, further includes: 1) taking the reciprocal of the slope of the line connecting the two endpoints of the angle curve segment to obtain the adjustment coefficient corresponding to the angle curve segment; 2) obtaining the difference between the adjustment coefficient and 1 as the compensation coefficient.

[0020] Ideally, the rotation angle of the magnetic encoder chip (or magnet) equals the chip output angle, so k = 1. In reality, there are errors in the output at certain angles, so the angle needs to be compensated, that is, the slope k is approximated to 1.

[0021] Based on multiple angle curve segments obtained from inflection point settings, the two endpoints of each angle curve segment are the corresponding inflection points (or the start / end point on the angle curve). The slope k is calculated by connecting adjacent points. The purpose of calibration is to approximate the slope k of each segment to 1 using a coefficient coeff, k*coeff=1. After obtaining the slope k, the corresponding coefficient coeff can be obtained, which is defined as the adjustment coefficient. In particular, the chip internally processes the coefficient, with a default adjustment range of 1±20%, so the actual adjustment coefficient is coeff-1, defined as the compensation coefficient coeff_code. For example, if the slope k=1.2, then the adjustment coefficient coeff=1 / k=0.833333, and the compensation coefficient coeff_code=coeff-1=-0.1666666.

[0022] In some embodiments, the method further includes: converting the compensation coefficient into a digital codeword and writing it into a register, wherein if the compensation coefficient is positive, the digital codeword conversion is performed as follows: coeff_code * 20479; if the compensation coefficient is negative, the digital codeword conversion is performed as follows: 8192 - |coeff_code| * 20479; where coeff_code is the compensation coefficient. Also, the compensation coefficient coeff_code is the coefficient actually to be written into the register. To facilitate writing into the register, the result of coeff-1 can be converted into a digital codeword. For example, coeff_code = coeff-1 = -0.1666666, which is converted into the digital codeword 8192 - |coeff-1| * 20479 = 13'h12AB.

[0023] like Figure 2 As shown, through steps S1 and S2, this embodiment sets 4 inflection points and obtains 5 compensation coefficients; the inflection points and compensation coefficients are filled into the register and burned.

[0024] In some embodiments, step S3, obtaining the angle output threshold for each angle curve segment, further includes: calculating the angle output threshold using the following formula: current threshold = (current inflection point - previous inflection point) / current compensation coefficient + previous threshold.

[0025] The angle output threshold can actually be directly obtained from the plotted angle curve; to save storage resources, this embodiment calculates it using a multiplexed divider based on the inflection point and compensation coefficient. Figure 2Taking the angle curve shown as an example, calculate the angle output threshold of the curve between the inflection points inflection1 and inflection2. For the inflection point inflection1, the angle output value of the chip is A' (this value is defined as the angle output threshold). The angle measurement value of the angle measuring instrument (i.e., the setting value of the inflection point inflection1), that is, the value read after calibration, is A. Therefore, A' = A / coeff.

[0026] The specific calculation formula is as follows:

[0027] threshold_present=(inflection_present-inflection_previous) / coeff_present+threshold_previous. (Formula 1)

[0028] For calculating the angle output threshold of the curve between inflection1 and inflection2, in Formula 1, inflection_previous is the current inflection point, i.e., inflection2; inflection_present is the previous inflection point, i.e., inflection1; coeff_present is the current compensation coefficient, i.e., the compensation coefficient required for the curve between inflection1 and inflection2; and threshold_previous is the previous threshold, i.e., threshold1. Since the inflection point is set based on the angle scan result, it is a known quantity; the current compensation coefficient is calculated through step S2 above, and is also a known quantity; the previous threshold is the result calculated in the previous segment (the threshold of the initial segment can be preset, for example, to 0), and is used as a known quantity here. Based on the above known quantities, the current threshold threshold_present of the curve is calculated, which is the angle output threshold of the curve. The angle output threshold is also an angle value, which can be calculated within the chip using an algorithm module based on the above known quantities, and does not need to be backfilled into the register.

[0029] In some embodiments, step S4, which involves initiating calibration after detecting a valid data signal and obtaining the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold, further includes: 1) matching the target angle output threshold, the target inflection point, and the target compensation coefficient based on the input angle; 2) obtaining the angle change based on the difference between the input angle and the target angle output threshold; 3) restoring the target adjustment coefficient based on the target compensation coefficient; and obtaining the target output angle based on the angle change and the target adjustment coefficient.

[0030] In some embodiments, the step of obtaining the calibrated target output angle based on the input angle, a corresponding compensation coefficient, and an angle output threshold further includes: obtaining the target output angle using the following calculation formula: Target output angle = (Input angle - Target angle output threshold) * (1 + Target compensation coefficient) + Target inflection point. That is, theta_out = (theta_in - threshold) * (1 + coeff_code) + inflection.

[0031] In some embodiments, the method further includes: delaying the target output angle by a preset number of clock cycles via a register before outputting it.

[0032] Please refer to it again. Figure 2 After detecting a valid data signal, calibration is initiated, and the following steps are executed: Step 1: Compare the input angle theta_in with the angle output thresholds obtained in step S3 to determine the angle range. The main purpose of determining the angle range is to select the corresponding compensation coefficient and determine the corresponding inflection point. Step 2: Calculate the angle change, i.e., theta_in - threshold_present, denoted as theta_tmp. Step 3: Based on the target compensation coefficient, obtain the target adjustment coefficient, coeff = 1 + coeff_code = 1 / k. Step 4: Calculate the target output angle: theta_tmp * coeff + inflection. Step 5: Output the calculated target output angle using a register with a clock cycle. The purpose of clock cycle is to ensure timing correctness. The method of clock cycle is to pass the signal through the register once. Clock cycle can be understood as delaying a signal by one clock cycle, clock cycle 2 clock cycles, and clock cycle n clock cycles.

[0033] For example, if theta_in is greater than threshold1 and less than or equal to threshold2, meaning the angle range is between the inflection points inflection1 and inflection2, then the target angle output threshold (i.e., threshold_present) is threshold2, the target inflection point is inflection1, and the target compensation coefficient is the compensation coefficient of the curve between inflection points inflection1 and inflection2; the angle change theta_tmp = theta_in - threshold2; the target output angle theta_out = theta_tmp * coeff + inflection1 (all values ​​in the formula use the same encoding form). The target output angle theta_out is the calibrated angle theta_calib.

[0034] Based on the same inventive concept, the present invention also provides a nonlinear calibration device for a magnetic encoder, which can realize the nonlinear calibration of the magnetic encoder described in the present invention, that is, to obtain a target output angle that matches the angle measurement value of the angle measuring instrument by using a simplified compensation algorithm.

[0035] Please see Figure 3 This is a schematic diagram of the nonlinear calibration device for a magnetic encoder provided in an embodiment of the present invention. Figure 3 As shown, the nonlinear calibration device for the magnetic encoder described in this embodiment includes: a setting module 31, a first acquisition module 32, a second acquisition module 33, and a calibration module 34.

[0036] Specifically, the setting module 31 is used to set multiple inflection points on the angle curve graph formed based on the angle scanning results, so as to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; the first acquisition module 32 is used to acquire the compensation coefficient of each angle curve segment; the second acquisition module 33 is used to acquire the angle output threshold of each angle curve segment; the calibration module 34 is used to start calibration after detecting a valid data signal, and acquire the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold. Please refer to the working mode of each module for details. Figures 1-2 The descriptions of the methods shown are not repeated here.

[0037] In some embodiments, the device further includes a register 35 for storing the inflection point, the compensation coefficient, and for outputting the target output angle after delaying it by a preset number of clock cycles.

[0038] As can be seen from the above, the nonlinear calibration method and device for the magnetic encoder provided in this embodiment divides a complete angle cycle into multiple angle curve segments by setting multiple inflection points, and each angle curve segment is approximately a first-order curve; then, the slope of each angle curve segment is approximated to 1 by a compensation coefficient, and after calibration, a target output angle that matches the angle measurement value of the angle measuring instrument is obtained; the compensation algorithm is simplified and resource consumption is reduced.

[0039] It should be noted that the above embodiments are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. The terms "comprising" and "having," and their variations, used in this invention document are intended to cover non-exclusive inclusion. The terms "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence, unless explicitly indicated by the context. It should be understood that such data can be used interchangeably where appropriate. Furthermore, embodiments and features within embodiments of this invention can be combined with each other unless otherwise specified. In addition, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this invention.

[0040] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A nonlinear calibration method for a magnetic encoder, characterized in that, The method includes the following steps: setting multiple inflection points on the angle curve graph formed based on the angle scanning results to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; obtaining the compensation coefficient of each angle curve segment, wherein the step of obtaining the compensation coefficient of each angle curve segment further includes: taking the reciprocal of the slope of the line connecting the two endpoints of the angle curve segment to obtain the corresponding adjustment coefficient for the angle curve segment, and obtaining the difference between the adjustment coefficient and 1 as the compensation coefficient; obtaining the angle output threshold of each angle curve segment; and starting calibration when a valid data signal is detected, and obtaining the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold.

2. The method according to claim 1, characterized in that, The angle curve is drawn from the results of multiple angle scans, and the inflection point is set and written into the register using the angle measurement value of the angle measuring instrument as the angle standard.

3. The method according to claim 1, characterized in that, The method further includes: converting the compensation coefficient into a digital codeword and writing it into a register, wherein if the compensation coefficient is positive, the digital codeword conversion is performed as follows: coeff_code*20479; if the compensation coefficient is negative, the digital codeword conversion is performed as follows: 8192-|coeff_code|*20479; wherein coeff_code is the compensation coefficient.

4. The method according to claim 1, characterized in that, The step of obtaining the angle output threshold for each angle curve segment further includes: calculating the angle output threshold using the following formula: current threshold = (current inflection point - previous inflection point) / current compensation coefficient + previous threshold.

5. The method according to claim 1, characterized in that, The step of obtaining the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold further includes: matching the target angle output threshold, the target inflection point, and the target compensation coefficient based on the input angle; obtaining the angle change based on the difference between the input angle and the target angle output threshold; restoring the target adjustment coefficient based on the target compensation coefficient; and obtaining the target output angle based on the angle change and the target adjustment coefficient.

6. The method according to claim 5, characterized in that, The step of obtaining the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold further includes: obtaining the target output angle using the following calculation formula: target output angle = (input angle - target angle output threshold) * (1 + target compensation coefficient) + target inflection point.

7. The method according to claim 1, characterized in that, The method further includes: delaying the target output angle by a preset number of clock cycles through a register before outputting it.

8. A nonlinear calibration device for a magnetic encoder, characterized in that, include: A setting module is used to set multiple inflection points on the angle curve graph formed based on the angle scanning results to divide the angle period into multiple angle curve segments, wherein each angle curve segment is approximately a first-order curve; a first acquisition module is used to acquire the compensation coefficient of each angle curve segment, wherein the first acquisition module acquires the corresponding adjustment coefficient based on the reciprocal of the slope of the line connecting the two endpoints of the angle curve segment, and acquires the difference between the adjustment coefficient and 1 as the compensation coefficient; a second acquisition module is used to acquire the angle output threshold of each angle curve segment; and a calibration module is used to start calibration when a valid data signal is detected, and acquire the calibrated target output angle based on the input angle, the corresponding compensation coefficient, and the angle output threshold.

9. The apparatus according to claim 8, characterized in that, The device further includes a register for storing the inflection point, the compensation coefficient, and for outputting the target output angle after delaying it by a preset number of clock cycles.