Compensation method, device and storage medium

The encoder compensation value and the code value to be compensated are obtained through the reciprocating motion of the target motor, and the motor current and electrical angle are directly controlled for nonlinear compensation, which solves the problem of periodic deviation caused by the error of the magnetic encoder and improves precision control.

CN113670358BInactive Publication Date: 2024-10-22BEIJING XIAOMI MOBILE SOFTWARE CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110921561.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-11
Publication Date
2024-10-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the existing technology, magnetic encoders have periodic deviations due to error effects, resulting in periodic deviations between the encoder feedback value and the actual value, affecting high-precision control.

Method used

Through the reciprocating motion of the target motor, the encoder compensation value and the code value to be compensated are obtained. Based on these values, the target code value is determined to achieve nonlinear compensation, directly control the motor current and electrical angle, and reduce the dependence on external correction devices.

Benefits of technology

It reduces the speed fluctuation of the joint driver, improves the accuracy of motor position and torque control, eliminates periodic deviations, and improves accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113670358B_ABST
    Figure CN113670358B_ABST
Patent Text Reader

Abstract

The present invention discloses a compensation method, device and storage medium. The method comprises: after the target motor is started, obtaining an encoder compensation value and an encoding value to be compensated, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; and determining a target encoding value for the target motor based on the encoder compensation value and the encoding value to be compensated. The present invention solves the technical problem that the magnetic encoder in the prior art has periodic deviation due to the influence of errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of encoder correction, and in particular to a compensation method, device and storage medium. Background Art

[0002] At present, most encoder nonlinearity correction schemes use the method of supporting with a high-precision encoder for correction. The motor is rotated at a fixed speed by supporting, and the position information of the corrected encoder and the reference encoder are read and compared to obtain the error curve and save it in the encoder. During normal operation, compensation is performed according to the error curve corresponding to the absolute position information index.

[0003] However, although this solution has high position compensation accuracy, it requires specific calibration fixtures and will be affected by the accuracy of the support coupling. During use, due to the influence of errors such as installation and welding, in most cases, there is a periodic deviation between the encoder feedback value and the actual value. Therefore, to achieve high-precision control, it is necessary to eliminate such deviations.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a compensation method, a device and a storage medium to at least solve the technical problem in the prior art that a magnetic encoder has periodic deviation due to the influence of errors.

[0006] According to one aspect of an embodiment of the present invention, a compensation method is provided, comprising: after a target motor is started, obtaining an encoder compensation value and an encoder value to be compensated, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; and determining a target encoder value for the target motor based on the encoder compensation value and the encoder value to be compensated.

[0007] Optionally, the encoder compensation value is determined by the reciprocating motion of the target motor, including: controlling the target motor to change from a first electrical angle value to a second electrical angle value, and determining a first encoding value set generated by the encoder during the change, wherein the first encoding value set includes at least one first encoding value; controlling the target motor to change from the second electrical angle value to the first electrical angle value, and determining a second encoding value set generated by the encoder during the change, wherein the first encoding value set includes at least one second encoding value; determining the encoder compensation value based on the first encoding value set and the second encoding value set.

[0008] Optionally, the encoder compensation value is determined based on the first encoding value set and the second encoding value set, including: determining each of the first encoding values ​​corresponding to different electrical angle values ​​in the first encoding value set, and determining each of the second encoding values ​​corresponding to different electrical angle values ​​in the second encoding value set; and determining the encoder compensation value based on the first encoding value and the second encoding value corresponding to the same electrical angle.

[0009] Optionally, the encoder compensation value is determined based on the first encoding value and the second encoding value corresponding to the same electrical angle, including: determining the encoding compensation value between the first encoding value and the second encoding value corresponding to each electrical angle; and determining the encoding compensation value corresponding to the unknown electrical angle according to the encoding compensation value corresponding to each electrical angle.

[0010] Optionally, the method further includes: the first change speed of the target motor changing from the first electrical angle value to the second electrical angle value is the same as the first change speed of the target motor changing from the second electrical angle value to the first electrical angle value, and there are at least two adjacent electrical angle change values ​​that are the same.

[0011] Optionally, before obtaining the encoder compensation value and the encoder value to be compensated, the method further includes: controlling the driver to power on and enable; giving the rated current of the first axis of the target motor to control the torque of the target motor to meet predetermined requirements, and setting the current of the second axis of the target motor to zero, wherein the second axis is perpendicular to the first axis.

[0012] According to another aspect of an embodiment of the present invention, a compensation device is also provided, including: an acquisition module, used to obtain an encoder compensation value and an encoding value to be compensated after the target motor is started, the above encoder compensation value is determined by the reciprocating motion of the above target motor; a determination module, used to determine the target encoding value for the above target motor based on the above encoder compensation value and the above encoding value to be compensated.

[0013] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing any one of the above-mentioned compensation methods.

[0014] According to another aspect of an embodiment of the present invention, a processor is further provided, and the processor is used to run a program, wherein the program is configured to execute any one of the above compensation methods when running.

[0015] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any one of the above compensation methods.

[0016] In an embodiment of the present invention, after the target motor is started, an encoder compensation value and an encoder value to be compensated are obtained, and the above encoder compensation value is determined by the reciprocating motion of the above target motor; based on the above encoder compensation value and the above encoder value to be compensated, the target encoder value for the above target motor is determined; the purpose of directly controlling the motor current and electrical angle to perform nonlinear compensation on the encoder without the need for an external correction device is achieved, thereby achieving the technical effect of reducing the speed fluctuation of the joint drive and improving the position and torque control accuracy of the motor, and further solving the technical problem in the prior art that the magnetic encoder has periodic deviations due to the influence of errors. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0018] Figure 1 is a flow chart of an optional compensation method according to an embodiment of the present invention;

[0019] Figure 2 is a flow chart of an optional generation of a collection of coded values ​​according to an embodiment of the present invention;

[0020] Figure 3 is a flowchart of an optional process of determining a coding compensation value corresponding to an unknown electrical angle according to an embodiment of the present invention;

[0021] Figure 4 is a schematic diagram of an optional compensation device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] Example 1

[0025] According to an embodiment of the present invention, a compensation method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0026] Figure 1 is a flow chart of an encoder compensation method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0027] Step S102, after the target motor is started, obtaining an encoder compensation value and an encoder value to be compensated, wherein the encoder compensation value is determined by the reciprocating motion of the target motor;

[0028] Step S104 , determining a target encoder value for the target motor based on the encoder compensation value and the encoder value to be compensated.

[0029] In an embodiment of the present application, after the target motor is started, an encoder compensation value and an encoder value to be compensated are obtained, and the above encoder compensation value is determined by the reciprocating motion of the above target motor; based on the above encoder compensation value and the above encoder value to be compensated, the target encoder value for the above target motor is determined, thereby achieving the purpose of directly controlling the electrical angle value of the motor to perform nonlinear compensation on the encoder without the need for an external correction device, thereby achieving the technical effect of reducing the speed fluctuation of the drive and improving the position and torque control accuracy of the motor, and further solving the technical problem in the prior art that the magnetic encoder has periodic deviations due to the influence of errors.

[0030] It should be noted that the embodiments of the present application may be, but are not limited to, applicable to scenarios where high torque accuracy requirements are placed on joint drivers. The executing entity of the embodiments of the present application may be a controller in a machine or a separate device, for example: a robot, a robot joint, a precision machining lathe, etc.; the above-mentioned target motor may be, but is not limited to, a servo motor.

[0031] As an optional embodiment, the motion process of the reciprocating motion of the above-mentioned target motor is not specifically limited, and the motion process of the reciprocating motion can be multiple, for example: forward A steps, backward A steps; first backward, then forward; forward A steps, backward An steps; and selecting one step of the A steps and one step of the A steps backward for calculation.

[0032] Optionally, the encoder compensation value is determined by the reciprocating motion of the target motor, including:

[0033] Step S202, controlling the target motor to change from a first electrical angle value to a second electrical angle value, and determining a first encoding value set generated by an encoder during the change process, wherein the first encoding value set includes at least one first encoding value;

[0034] Step S204, controlling the target motor to change from the second electrical angle value to the first electrical angle value, and determining a second encoding value set generated by the encoder during the change process, wherein the first encoding value set includes at least one second encoding value;

[0035] Step S206: determining the encoder compensation value based on the first encoding value set and the second encoding value set.

[0036] In an optional embodiment, the process of obtaining the first code value set and the second code value set generated during the above-mentioned different electrical angle value changes is as follows: Figure 2 As shown, in the process of controlling the target motor to increase from the first electrical angle value to the second electrical angle value, a plurality of first coding values ​​corresponding to a plurality of different electrical angle values ​​are obtained; and in the process of decreasing from the second electrical angle value to the first electrical angle value, a plurality of second coding values ​​corresponding to the plurality of different electrical angle values ​​are obtained. The first coding value collection includes at least one first coding value; and the second coding value collection includes at least one second coding value.

[0037] It should be noted that the above-mentioned multiple different electrical angle values ​​differ by a smaller fixed value, the above-mentioned smaller fixed value can be 2*pi / 128, the above-mentioned first electrical angle value can be 0, and the above-mentioned second electrical angle value can be 2*pi*Npp, wherein pi is the pi, and Npp is the pole pair number; when the electrical angle value of the above-mentioned target motor increases from the first electrical angle value to the second electrical angle value, the motor rotates one step; the above-mentioned first electrical angle value reaches the above-mentioned second electrical angle value after increasing N times by a smaller fixed value, N is 128, so the above-mentioned multiple different electrical angle values, the multiple first coding values ​​and the multiple second coding values ​​can record 128; the above-mentioned multiple different electrical angle values ​​can be but are not limited to the electrical angle values ​​obtained when the servo motor rotates one step.

[0038] As an optional embodiment, the second electrical angle value is obtained by gradually increasing from the first electrical angle value to a smaller fixed value. The smaller fixed value can be set according to actual conditions. For example, in the embodiment of the present application, the smaller fixed value is set to 2*pi / 128, where pi is the pi; the first electrical angle value can be 0; and the multiple different electrical angle values ​​are recorded as N. In the embodiment of the present application, the value of N is 128. In the process from the first electrical angle value to the second electrical angle value and from the second electrical angle value to the first electrical angle value, N first coding values ​​and second coding values ​​can be obtained, that is, the encoder generates the first coding value set and the second coding value set during the change process; the encoder compensation value is based on the first coding value set and the second coding value set.

[0039] Optionally, the determining the encoder compensation value based on the first encoding value set and the second encoding value set includes:

[0040] Step S302, determining each of the first coding values ​​corresponding to different electrical angle values ​​in the first coding value set, and determining each of the second coding values ​​corresponding to different electrical angle values ​​in the second coding value set;

[0041] Step S304: determining the encoder compensation value based on the first encoding value and the second encoding value corresponding to the same electrical angle.

[0042] In an optional embodiment, the first code value set includes at least one first code value; the second code value set includes at least one second code value; the encoder compensation value is determined based on the first code value and the second code value corresponding to the same electrical angle. In the process of controlling the target motor to increase from the first electrical angle value to the second electrical angle value, the first code values ​​corresponding to multiple different electrical angles theta_ref are evenly recorded. Error1[i]=theta_ref / NPP-theta_actual, 128*NPP points can be recorded, and theta_actual represents the actual mechanical angle.

[0043] And in the process of reducing from the above-mentioned second electrical angle value to the above-mentioned first electrical angle value, the multiple second coding values ​​error2[128*Npp-1-i]=theta_ref / NPP-theta_actual corresponding to the above-mentioned multiple different electrical angles theta_ref are evenly recorded. Optionally, 128*NPP points can be recorded.

[0044] It should be noted that the above-mentioned different electrical angles are recorded as theta_ref, the above-mentioned first coding value is the error value of the corresponding encoder feedback value, recorded as error1[i]=theta_ref / NPP-theta_actual, and the above-mentioned second coding value is the error value of the corresponding encoder feedback value, for example, it can be recorded as error2[128*Npp-1-i]=theta_ref / NPP-theta_actual.

[0045] Optionally, the determining of the encoder compensation value based on the first encoding value and the second encoding value corresponding to the same electrical angle further includes:

[0046] Step S402, determining a coding compensation value between the first coding value and the second coding value corresponding to each of the electrical angles;

[0047] Step S404: determining the encoding compensation value corresponding to the unknown electrical angle according to the encoding compensation value corresponding to each electrical angle.

[0048] In the embodiment of the present application, the process of determining the encoding compensation value corresponding to the unknown electrical angle is as follows: Figure 3As shown; according to the data recorded by the above-mentioned first-pass code value and the above-mentioned second code value, error[i]=(error1[i]+error2[i]) / 2 can be obtained; 128 points can be taken to obtain the error curve offset_lut[i]=error[i*NPP]*POS_CPR / (2.0*PI), wherein i takes 0, 1...127, POS_CPR is the encoder resolution, and 14 bits 16384 are taken in the embodiment of the present application, and the above-mentioned Npp is the number of pole pairs. The encoder data is compensated after calling the value in the error curve according to the absolute position and interpolating to obtain the final encoder compensation value. The above-mentioned error curve is stored in the storage medium of the driver, for example: driver FLASH, etc.; the storage medium of the above-mentioned driver can be read by electronic devices such as computers.

[0049] In the embodiment of the present application, the above interpolation processing is based on certain data of the above error curve, and the intermediate points between the known points are calculated according to the corresponding algorithm, and the calculation result is the above interpolation processing result. Since the error takes 128 points, and the actual encoder resolution is 14 bits, the upper 7 bits of the encoder data can be used as the index value of the error curve. Assuming that the 14-bit data read from the encoder is pos.raw, the specific interpolation process is as follows:

[0050] pos1 = pos.raw >> 7;

[0051] pos2 = (pos1 + 1) % 128;

[0052] rawMod = pos.raw%128;

[0053] off_1 = offset_lut[pos1];

[0054] off_2 = offset_lut[pos2];

[0055] off_interp=off_1+(((off_2-off_1)*rawMod)>>7);

[0056] pos.now_angle=pos.raw+off_interp;

[0057] It should be noted that in the above interpolation process, pos.raw represents the original 14-bit data read from the encoder; pos1 and pos2 represent the two adjacent indexes of the compensation array corresponding to the current position; rawMod represents the lower 7-bit data of the original encoder data, which can be used for interpolation; off_1 and off_2 represent the two adjacent compensation values ​​corresponding to the two indexes; offset_lut represents the compensation error array with a length of 128; off_interp represents the error data compensated after interpolation; after compensation, pos.now_angle is the output result after compensation.

[0058] Optionally, the above method further includes:

[0059] Step S502, the first change speed of the target motor changing from the first electrical angle value to the second electrical angle value is the same as the first change speed of the target motor changing from the second electrical angle value to the first electrical angle value, and there are at least two adjacent electrical angle change values ​​that are the same.

[0060] In an embodiment of the present application, during the operation of the target motor decreasing from the second electrical angle value to the first electrical angle value and increasing from the first electrical angle value to the second electrical angle value, the processes of gradual increase and gradual decrease both change uniformly with a smaller fixed value, and the speed values ​​of the two processes are equal. In an embodiment of the present application, the smaller fixed value is 2*pi / 128, and therefore, there are at least two adjacent electrical angles with the same change value.

[0061] In an optional embodiment, before obtaining the encoder compensation value and the encoder value to be compensated, the method further includes:

[0062] Step S602, controlling the driver to power on and enable;

[0063] Step S604, giving a rated current of the first axis of the target motor to control the torque of the target motor to meet a predetermined requirement, and setting the current of the second axis of the target motor to zero, wherein the second axis is perpendicular to the first axis.

[0064] In an optional embodiment, the first axis of the target motor is a direct axis, i.e., the d-axis, and the second axis of the target motor is a quadrature axis, i.e., the q-axis. It should be noted that the method of making the motor open-loop operate given the rated current of the d-axis of the given target motor is not limited to controlling only the current of the d-axis, but can also indirectly control the current by changing the voltage, resistance or current direction, and the magnitude of the current is not limited.

[0065] According to the above embodiment, after the target motor is started, an encoder compensation value and an encoding value to be compensated are obtained, and the above encoder compensation value is determined by the reciprocating motion of the above target motor; a technical solution for determining the target encoding value for the above target motor based on the above encoder compensation value and the above encoding value to be compensated can realize the function of self-correction of encoder nonlinear error without the need for specific correction tooling; since the correction error is based on the actual electrical angle of the motor, the control accuracy of the torque is higher. Therefore, the embodiment of the present application is particularly suitable for occasions such as joint drives that have high requirements on torque accuracy.

[0066] Example 2

[0067] According to an embodiment of the present invention, a device embodiment for implementing the above compensation method is also provided. Figure 4 is a schematic diagram of the structure of a compensation device according to an embodiment of the present invention. Figure 4 As shown, the compensation device includes: an obtaining module 40 and a determining module 42, wherein:

[0068] The acquisition module 40 is used to obtain the encoder compensation value and the encoder value to be compensated after the target motor is started, and the above encoder compensation value is determined by the reciprocating motion of the above target motor; the determination module 42 is used to determine the target encoder value for the above target motor based on the above encoder compensation value and the above encoder value to be compensated.

[0069] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0070] It should be noted that the compensation device described above corresponds to step S102 to step S104 in Example 1, and the examples and application scenarios implemented by the modules described above are the same as those of the corresponding steps, but are not limited to the contents disclosed in Example 1. It should be noted that the modules described above can be run in a computer terminal as part of the device.

[0071] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in Example 1, which will not be repeated here.

[0072] The above-mentioned compensation device may further include a processor and a memory. The above-mentioned compensation device and the like are stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.

[0073] The processor includes a kernel, which retrieves the corresponding program unit from the memory. The kernel may be one or more. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one memory chip.

[0074] According to an embodiment of the present application, an embodiment of a computer-readable storage medium is also provided. Optionally, in this embodiment, the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any of the above compensation methods.

[0075] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group, and the computer-readable storage medium includes a stored program.

[0076] Optionally, when the program is running, the device where the computer-readable storage medium is located is controlled to perform the following functions: after the target motor is started, an encoder compensation value and an encoding value to be compensated are obtained, and the above encoder compensation value is determined by the reciprocating motion of the above target motor; based on the above encoder compensation value and the above encoding value to be compensated, the target encoding value for the above target motor is determined.

[0077] Optionally, when the program is running, the device where the computer-readable storage medium is located is controlled to perform the following functions: control the target motor to change from a first electrical angle value to a second electrical angle value, and determine a first set of encoding values ​​generated by the encoder during the change, wherein the first set of encoding values ​​includes at least one first encoding value; control the target motor to change from a second electrical angle value to a first electrical angle value, and determine a second set of encoding values ​​generated by the encoder during the change, wherein the first set of encoding values ​​includes at least one second encoding value; determine the encoder compensation value based on the first set of encoding values ​​and the second set of encoding values.

[0078] Optionally, when the program is running, the device where the computer-readable storage medium is located is controlled to perform the following functions: determine each of the above-mentioned first coding values ​​corresponding to different electrical angle values ​​in the above-mentioned first coding value set, and determine each of the above-mentioned second coding values ​​corresponding to different electrical angle values ​​in the above-mentioned second coding value set; determine the above-mentioned encoder compensation value based on the above-mentioned first coding value and the above-mentioned second coding value corresponding to the same electrical angle.

[0079] Optionally, when the program is running, the device where the computer-readable storage medium is located is controlled to perform the following functions: determine the coding compensation value between the first coding value corresponding to each of the above-mentioned electrical angles and the second coding value; determine the above-mentioned coding compensation value corresponding to the unknown electrical angle based on the above-mentioned coding compensation value corresponding to each of the above-mentioned electrical angles.

[0080] Optionally, when the program is running, the device where the computer-readable storage medium is located is controlled to perform the following functions: control the driver to power on and enable; give the rated current of the first axis of the above-mentioned target motor to control the torque of the above-mentioned target motor to meet predetermined requirements, and set the current of the second axis of the above-mentioned target motor to zero, wherein the above-mentioned second axis is perpendicular to the above-mentioned first axis.

[0081] According to an embodiment of the present application, an embodiment of a processor is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein any one of the compensation methods is executed when the program is run.

[0082] According to an embodiment of the present application, an embodiment of an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any one of the compensation methods.

[0083] Optionally, when the program is running, the electronic device is controlled to perform the following functions: after the target motor is started, an encoder compensation value and an encoding value to be compensated are obtained, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; and a target encoding value for the target motor is determined based on the encoder compensation value and the encoding value to be compensated.

[0084] According to an embodiment of the present application, an embodiment of a computer program product is also provided, which, when executed on a data processing device, is suitable for executing a program initialized with any of the above-mentioned compensation method steps.

[0085] Optionally, when the program is running, the computer program product is controlled to perform the following functions: after the target motor is started, an encoder compensation value and an encoder value to be compensated are obtained, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; and a target encoder value for the target motor is determined based on the encoder compensation value and the encoder value to be compensated.

[0086] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0087] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0088] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0089] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0090] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0091] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a computer-readable storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned computer-readable storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0092] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A compensation method, characterized in that: include: After the target motor is started, an encoder compensation value and an encoder value to be compensated are obtained, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; Determine a target encoder value for the target motor based on the encoder compensation value and the encoder value to be compensated; The reciprocating motion of the target motor includes: controlling the target motor to increase from a first electrical angle value to a second electrical angle value, and to decrease from the second electrical angle value to the first electrical angle value, a first change speed of the target motor changing from the first electrical angle value to the second electrical angle value is the same as a second change speed of the target motor changing from the second electrical angle value to the first electrical angle value, and there are at least two adjacent electrical angle change values ​​that are the same; Among them, the encoder compensation value is determined by the reciprocating motion of the target motor, including: determining a first set of encoding values ​​generated by the encoder in the process of the target motor changing from the first electrical angle value to the second electrical angle value, the first set of encoding values ​​including at least one first encoding value; determining a second set of encoding values ​​generated by the encoder in the process of the target motor changing from the second electrical angle value to the first electrical angle value, the first set of encoding values ​​including at least one second encoding value; determining the encoder compensation value based on the first set of encoding values ​​and the second set of encoding values.

2. The method according to claim 1, characterized in that The determining the encoder compensation value based on the first encoding value set and the second encoding value set comprises: Determine each of the first coding values ​​corresponding to different electrical angle values ​​in the first coding value set, and determine each of the second coding values ​​corresponding to different electrical angle values ​​in the second coding value set; The encoder compensation value is determined based on the first encoding value and the second encoding value corresponding to the same electrical angle.

3. The method according to claim 2, characterized in that The determining the encoder compensation value based on the first encoding value and the second encoding value corresponding to the same electrical angle includes: Determine a coding error value between the first coding value and the second coding value corresponding to each of the electrical angles, wherein the coding error value between the first coding value and the second coding value corresponding to each of the electrical angles is an average of the first coding value and the second coding value corresponding to each of the electrical angles; The encoder compensation value corresponding to the unknown electrical angle is determined according to the encoding error value corresponding to each electrical angle.

4. The method according to claim 1, characterized in that: Before obtaining the encoder compensation value and the encoder value to be compensated, the method further includes: Control the driver to power on and enable; A rated current of a first axis of the target motor is given to control the torque of the target motor to meet a predetermined requirement, and a current of a second axis of the target motor is set to zero, wherein the second axis is perpendicular to the first axis.

5. A compensation device, characterized in that: include: An acquisition module, used for acquiring an encoder compensation value and an encoder value to be compensated after the target motor is started, wherein the encoder compensation value is determined by the reciprocating motion of the target motor; A determination module, configured to determine a target encoder value for the target motor based on the encoder compensation value and the encoder value to be compensated; The obtaining module is further used to control the target motor to increase from a first electrical angle value to a second electrical angle value, and to decrease from the second electrical angle value to the first electrical angle value, a first change speed of the target motor from the first electrical angle value to the second electrical angle value is the same as a second change speed of the target motor from the second electrical angle value to the first electrical angle value, and there are at least two adjacent electrical angle change values ​​that are the same; Wherein, the acquisition module is also used to determine a first set of encoding values ​​generated by the encoder in the process of the target motor changing from the first electrical angle value to the second electrical angle value, the first set of encoding values ​​including at least one first encoding value; determine a second set of encoding values ​​generated by the encoder in the process of the target motor changing from the second electrical angle value to the first electrical angle value, the first set of encoding values ​​including at least one second encoding value; determine the encoder compensation value based on the first set of encoding values ​​and the second set of encoding values.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the compensation method according to any one of claims 1 to 4.

7. A processor, characterized in that: The processor is used to run a program, wherein the program is configured to execute the compensation method according to any one of claims 1 to 4 when running.

8. An electronic device, comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the compensation method according to any one of claims 1 to 4.