A method, system and related devices for encoder delay compensation

By acquiring and calculating current, electrical angular velocity, and voltage in the motor controller, a fitting model is established to compensate for encoder delay in real time. This solves the angle lag problem caused by encoder signal processing delay and improves the accuracy and performance of motor control.

CN121036610BActive Publication Date: 2026-03-20SHENZHEN ZHONGQING ROBOT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In high-precision servo control, the encoder signal processing delay cannot be accurately compensated, resulting in inaccurate motor angle information and affecting control performance, especially in high-speed rotation or high-precision control scenarios where there is a significant lag.

Method used

By acquiring current, electrical angular velocity, and voltage when the motor is running at a constant speed under no-load, the initial angle deviation is calculated using the motor model, and a fitting model is established during the iterative adjustment process to obtain compensation coefficients and compensate for the encoder delay error in real time.

Benefits of technology

It effectively compensates for encoder signal processing delay, improving the accuracy and performance of motor control, especially the accuracy of angle information within different speed ranges.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121036610B_ABST
    Figure CN121036610B_ABST
Patent Text Reader

Abstract

The application discloses a method, system and related device for compensating the encoder delay, which can effectively compensate the angle lag caused by the encoder signal processing delay in different speed ranges, and improve the control performance of the motor. The method comprises the following steps: obtaining the current, the electrical angular velocity and the first voltage output by the control loop in the motor controller under the steady state condition of the motor running at a constant speed and no load; calculating the second voltage based on the motor model according to the current, the electrical angular velocity and the motor operating parameters; calculating the initial angle deviation of the encoder according to the first voltage and the second voltage; iteratively adjusting the initial angle deviation until the difference between the first voltage and the second voltage meets the preset error threshold; establishing a fitting model according to at least two groups of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient; and when the motor is running, compensating the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of motor control technology, in particular to a method and system for compensating encoder delay and related devices. BACKGROUND

[0002] An encoder is generally installed inside a permanent magnet synchronous motor to detect the rotation angle of the motor, i.e., the motor position. In high-precision servo control, most applications currently use absolute encoders, which usually have a built-in data processing chip that can convert detected physical signals (such as magnetic, optical, or electrical signals) into angle values and provide them to an external servo controller through communication. However, during the entire process of signal processing by the encoder itself and communication to obtain angle values by the servo controller, time delay is inevitably generated.

[0003] In the prior art, communication delay is generally compensated by periodic communication, for example, a communication request is sent within the current 100-microsecond control period, and the returned result is used in the next period (100 microseconds later), thereby fixing the communication delay as a known control period. Since the period is very short, the motor speed can be considered constant during this period, so the angle deviation caused by communication delay can be calculated by multiplying the known delay (100 microseconds) by the current motor speed and then compensated.

[0004] However, the delay caused by the encoder's own signal processing cannot be compensated by the above method, and the fundamental defect lies in that the internal processing delay of the encoder is an unknown quantity, which is determined by factors such as the chip operation speed, solving algorithm, and internal filtering of the encoder, and manufacturers usually do not provide this parameter in the data manual. In low-speed or low-performance applications, this unknown delay is often ignored. However, in high-speed motor rotation or high-precision control applications, this delay can cause significant angle lag, resulting in inaccurate angle information obtained by the controller, thereby affecting the control performance. SUMMARY

[0005] The present application provides a method and system for compensating the angle lag caused by the encoder signal processing delay in different speed ranges, thereby improving the control performance of the motor.

[0006] The first aspect of the present application provides a method for compensating encoder delay, comprising:

[0007] In the steady state condition of the motor running at a constant speed and under no load, the current, the electrical angular velocity, and the first voltage output by the control loop in the motor controller are obtained;

[0008] The second voltage is calculated based on the motor model according to the current, the electrical angular velocity, and the motor operating parameters;

[0009] calculating an initial angle deviation of the encoder according to the first voltage and the second voltage;

[0010] applying the initial angle deviation to the motor controller and iteratively adjusting the initial angle deviation until a difference between the first voltage and the second voltage meets a preset error threshold;

[0011] repeating the above steps at at least two different electrical angular velocities to obtain at least two sets of electrical angular velocity and corresponding angle deviation data;

[0012] establishing a fitting model according to the at least two sets of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient;

[0013] when the motor is running, performing time delay compensation on an output angle of the encoder according to the compensation coefficient and a real-time electrical angular velocity.

[0014] Optionally, the calculating an initial angle deviation of the encoder according to the first voltage and the second voltage comprises:

[0015] decomposing the first voltage into a first voltage vector composed of a direct-axis component and a quadrature-axis component, and calculating a corresponding first vector angle;

[0016] decomposing the second voltage into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and calculating a corresponding second vector angle;

[0017] determining the initial angle deviation of the encoder according to a difference between the first vector angle and the second vector angle.

[0018] Optionally, the establishing a fitting model according to the at least two sets of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient comprises:

[0019] performing linear fitting through the origin on the at least two sets of electrical angular velocity and corresponding angle deviation data, taking the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable;

[0020] judging whether a fitting goodness of the linear fitting meets a preset precision requirement;

[0021] if yes, determining the compensation coefficient according to a result of the linear fitting;

[0022] if no, under the condition of ensuring that a fitting curve passes through the origin, re-fitting based on the fitting goodness using a quadratic function, a piecewise linear function or a high-order function, and determining the compensation coefficient according to a fitting result.

[0023] Optionally, the applying the initial angle deviation to the motor controller and iteratively adjusting the initial angle deviation comprises:

[0024] fusing the electrical angle value output by the current encoder with the initial angle deviation to obtain a compensated angle value, and inputting the compensated angle value to the motor controller;

[0025] controlling the motor to run at a constant speed again at the same electrical angular velocity, reacquiring the current, the electrical angular velocity and the first voltage output by the control loop, and recalculating the second voltage according to the acquired data;

[0026] when the difference between the first voltage and the second voltage does not satisfy a preset error threshold, calculating and updating the initial angle deviation.

[0027] Optionally, when the difference between the first voltage and the second voltage does not satisfy a preset error threshold, calculating and updating the initial angle deviation, comprising:

[0028] when the difference between the first voltage and the second voltage does not satisfy a preset error threshold, determining a compensation step according to the change trend of the difference between the first voltage and the second voltage;

[0029] increasing or decreasing the value of the initial angle deviation by the compensation step to update the initial angle deviation;

[0030] wherein, when the change direction of the difference between the first voltage and the second voltage remains the same in a plurality of consecutive iterations, the compensation step is increased, and when the change direction of the difference between the first voltage and the second voltage is reversed, the compensation step is decreased.

[0031] Optionally, the method further comprises:

[0032] continuously sampling the current, the electrical angular velocity and the first voltage output by the control loop in the motor controller when the motor runs at a constant speed to obtain a plurality of sets of motor running data;

[0033] calculating the arithmetic mean or the filter mean of the plurality of sets of motor running data, and determining the current, the electrical angular velocity and the first voltage of the motor under the steady state condition according to the calculation result.

[0034] Optionally, when the motor is running, the output angle of the encoder is compensated for delay according to the compensation coefficient and the real-time electrical angular velocity, comprising:

[0035] when the motor is running, acquiring the real-time electrical angular velocity of the motor, and multiplying the compensation coefficient by the real-time electrical angular velocity to obtain a real-time angle compensation amount.

[0036] adding the real-time angle compensation amount to the original angle value output by the encoder to obtain a target angle value after time delay compensation;

[0037] feeding back the target angle value to the motor controller.

[0038] Optionally, before the time delay compensation on the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity, the method further comprises:

[0039] calibrating the communication time delay between the encoder and the motor controller;

[0040] calibrating the static accuracy of the encoder.

[0041] The second aspect of the present application provides an encoder time delay compensation system, comprising:

[0042] a first acquisition unit configured to acquire a current, an electrical angular velocity and a first voltage output by a control loop in the motor controller under a steady state condition of a motor running at a constant speed under no load;

[0043] a first calculation unit configured to calculate a second voltage based on a motor model according to the current, the electrical angular velocity and motor running parameters;

[0044] a second calculation unit configured to calculate an initial angle deviation of the encoder according to the first voltage and the second voltage;

[0045] an adjustment unit configured to apply the initial angle deviation to the motor controller and iteratively adjust the initial angle deviation until the difference between the first voltage and the second voltage meets a preset error threshold;

[0046] a second acquisition unit configured to repeat the above steps under at least two different electrical angular velocities to acquire at least two groups of electrical angular velocity and corresponding angle deviation data;

[0047] a fitting unit configured to establish a fitting model according to the at least two groups of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient;

[0048] a compensation unit configured to perform time delay compensation on the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity when the motor is running.

[0049] Optionally, the first calculation unit is specifically configured to:

[0050] decompose the first voltage into a first voltage vector composed of a direct-axis component and a quadrature-axis component and calculate a corresponding first vector angle;

[0051] decompose the second voltage into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and calculate a corresponding second vector angle;

[0052] determine an initial angle deviation of the encoder according to a difference between the first vector angle and the second vector angle.

[0053] Optionally, the fitting unit is specifically configured to:

[0054] perform linear fitting through the origin point, with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable, in the at least two groups of electrical angular velocities and the corresponding angle deviation data;

[0055] determine whether the fitting degree of the linear fitting meets a preset accuracy requirement;

[0056] if yes, determine a compensation coefficient according to a result of the linear fitting;

[0057] if no, perform re-fitting based on the fitting degree by using a quadratic function, a piecewise linear function or a high-order function under the condition that the fitting curve passes through the origin point, and determine a compensation coefficient according to a fitting result.

[0058] Optionally, the adjustment unit is specifically configured to:

[0059] fuse and calculate an electrical angle value output by a current encoder and the initial angle deviation to obtain a compensated angle value, and input the compensated angle value to the motor controller;

[0060] control the motor to run at the same electrical angular velocity again, reacquire the current, the electrical angular velocity and the first voltage output by the control loop, and re-calculate the second voltage according to the acquired data;

[0061] when a difference between the first voltage and the second voltage does not meet a preset error threshold, calculate and update the initial angle deviation.

[0062] Optionally, the adjustment unit is specifically configured to:

[0063] when a difference between the first voltage and the second voltage does not meet a preset error threshold, determine a compensation step according to a change trend of the difference between the first voltage and the second voltage;

[0064] update the initial angle deviation by sequentially increasing or decreasing a value of the initial angle deviation according to the compensation step;

[0065] When the change direction of the difference between the first voltage and the second voltage remains consistent in a plurality of consecutive iterations, the compensation step is increased, and when the change direction of the difference between the first voltage and the second voltage reverses, the compensation step is decreased.

[0066] Optionally, the first obtaining unit is specifically configured to:

[0067] When the motor operates at a constant rotating speed, the current, the electrical angular velocity in the motor controller, and the first voltage output by the control loop are continuously sampled to obtain a plurality of sets of motor operating data;

[0068] An arithmetic mean or a filter mean of the plurality of sets of motor operating data is calculated, and the current, the electrical angular velocity, and the first voltage of the motor under a steady state condition are determined according to the calculation result.

[0069] Optionally, the compensation unit is specifically configured to:

[0070] When the motor operates, a real-time electrical angular velocity of the motor is obtained, and the compensation coefficient is multiplied by the real-time electrical angular velocity to obtain a real-time angular compensation amount;

[0071] The real-time angular compensation amount is added to an original angular value output by the encoder to obtain a target angular value after delay compensation;

[0072] The target angular value is fed back to the motor controller.

[0073] Optionally, the system further comprises:

[0074] A calibration unit configured to calibrate a communication delay between the encoder and the motor controller, and calibrate a static accuracy of the encoder.

[0075] The third aspect of the present application provides an encoder delay compensation device, and the device comprises:

[0076] A processor, a memory, an input / output unit, and a bus;

[0077] The processor is connected with the memory, the input / output unit, and the bus;

[0078] The memory stores a program, and the processor invokes the program to execute the method of the first aspect and any optional encoder delay compensation method in the first aspect.

[0079] The fourth aspect of the present application provides a computer readable storage medium, and the computer readable storage medium stores a program, and the program executes the method of the first aspect and any optional encoder delay compensation method in the first aspect when executed on a computer.

[0080] From the above technical solutions, the present application has the following advantages:

[0081] By obtaining the first voltage of the motor controller loop output and the second voltage calculated based on the motor model under the steady-state condition of the motor running at a constant speed, the initial angle deviation of the encoder is calculated using the difference between the first voltage and the second voltage, and the real time delay of the encoder signal in the actual control link is obtained. By applying the initial angle deviation to the motor controller and iteratively adjusting in the closed-loop operation, the difference between the first voltage and the second voltage gradually converges to within the preset threshold, thereby obtaining the optimal delay compensation amount.

[0082] Further, by repeatedly measuring at multiple different electrical angular velocities and establishing a fitting model between the electrical angular velocity and the angle deviation, a compensation coefficient for real-time compensation is obtained, so that the compensation amount can dynamically change with the motor speed, thereby effectively compensating for the angle lag caused by the encoder signal processing delay in different speed ranges. The delay compensation method provided by the present application avoids the dependence on unknown delay parameters inside the encoder, and the entire process can be realized only by relying on the motor itself and the controller. After delay compensation, the rotor angle information obtained by the motor controller is more accurate, which can significantly improve the control performance of the motor. BRIEF DESCRIPTION OF DRAWINGS

[0083] In order to more clearly illustrate the technical solutions in the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0084] Figure 1 An embodiment flowchart of the encoder delay compensation method provided by the present application is shown in the figure.

[0085] Figure 2 A d-q coordinate system diagram in the encoder delay compensation method provided by the present application is shown in the figure.

[0086] Figure 3 Another embodiment flowchart of the encoder delay compensation method provided by the present application is shown in the figure.

[0087] Figure 4 An embodiment structure diagram of the encoder delay compensation system provided by the present application is shown in the figure.

[0088] Figure 5 An embodiment structure diagram of the encoder delay compensation device provided by the present application is shown in the figure. DETAILED DESCRIPTION

[0089] The application provides an encoder delay compensation method, system and related device, which is used for effectively compensating angle lag caused by encoder signal processing delay in different rotating speed ranges, and improving control performance of a motor.

[0090] It should be noted that the encoder delay compensation method provided by the application can be executed by various control devices. For example, the method can be directly integrated into a servo driver or a controller of the motor as a firmware program, and executed by a micro controller unit (MCU) or a digital signal processor (DSP) in the controller, so as to realize in-machine self-calibration of the device. The method can also be executed by an external host computer, a programmable logic controller (PLC) or a dedicated production line device. In this case, the external device can issue a command of uniform speed running at different rotating speeds to the motor driver through a communication interface, read the required running data from the driver, complete iterative calculation and model fitting on the external device to obtain compensation coefficients, and finally download the compensation coefficients to the driver for real-time compensation. For the convenience of description, the embodiments of the application are described based on the control device, but this is not a limitation on the protection scope of the application.

[0091] Please refer to Figure 1 , Figure 1 An embodiment of the encoder delay compensation method provided by the application includes the following steps.

[0092] 101. In a steady state condition of uniform speed and no-load running of the motor, current in the motor controller, electrical angular velocity and a first voltage output by a control loop are obtained.

[0093] Step 101 is a data collection stage of executing angle deviation calibration, and the purpose is to obtain a group of electrical parameters actually output by the motor controller when the motor is stably running at a specific rotating speed, including current in the motor controller, electrical angular velocity and a first voltage output by a control loop. The current refers to the direct-axis current and the quadrature-axis current for control in the d-q coordinate system after coordinate transformation; the electrical angular velocity represents the rotating speed of the motor rotor magnetic field, which can be calculated from the angle (i.e. rotor angle) detected by the encoder, and specifically can be obtained from the angle change rate of the encoder, and the electrical angular velocity has positive and negative values according to the different rotating directions; the first voltage refers to the d-q axis voltage value actually calculated and output by the motor control loop according to the encoder angle in order to maintain the direct-axis current and the quadrature-axis current.

[0094] It should be noted that the steady-state condition requires the motor to run at a constant speed, i.e. uniform speed, to ensure that all electrical parameters such as current, voltage, etc. inside the motor have reached a steady state, excluding the interference of dynamic processes such as acceleration or deceleration. The steady-state condition also requires the motor to be in an idle state, because when idle, the motor only needs to overcome its own friction and does not need to output additional torque, so the required current value is very small. In the subsequent steps, the first voltage obtained in this step needs to be compared with another voltage calculated based on a theoretical formula. When the current value is very small, the calculation result of the theoretical formula is affected by the current measurement error and is minimized, and its accuracy is mainly determined by the back electromotive force term (i.e. the product of the electrical angular velocity and the flux linkage). Therefore, the selection of the idle condition can significantly improve the accuracy of the subsequent theoretical calculation and provide a reliable data basis for the entire compensation scheme.

[0095] 102. Calculate a second voltage based on a motor model according to the current, the electrical angular velocity, and motor operating parameters;

[0096] The motor model specifically refers to the steady-state d-q axis voltage equation of the permanent magnet synchronous motor, which describes the deterministic mathematical relationship between the d-q axis terminal voltage of the motor and the current, the electrical angular velocity, and the inherent physical parameters of the motor when the motor is running stably. On the basis of d-q axis, the physical quantities of the motor satisfy the following equations:

[0097]

[0098] where the subscripts d and q represent the physical quantities of the d-axis and the q-axis, Ud and Uq are the voltages, Rs is the motor resistance, id and iq are the currents, Ld and Lq are the inductances, ωe is the electrical angular velocity, and Ψm is the motor flux linkage. When the motor is running stably (i.e. the speed and load do not change), the current and voltage of the d-axis and the q-axis will remain constant, and at this time the second term related to the change of current in the above two equations is 0, so the equation can be simplified to the following steady-state equation:

[0099]

[0100] In specific implementation, the motor controller will call the steady-state current value and the electrical angular velocity value obtained in step 101, and read a set of pre-calibrated or set motor operating parameters from the memory. These parameters are inherent physical characteristics of the motor, including motor resistance, direct-axis inductance, quadrature-axis inductance, and motor permanent magnet flux linkage. The motor controller substitutes all the known parameters into the steady-state equation to perform calculations, thereby calculating a set of theoretical d-q axis voltage values, which are the second voltages to be obtained in this step.

[0101] 103. Calculate the initial angle deviation of the encoder according to the first voltage and the second voltage;

[0102] ​​First, the basic principle of deviation calculation needs to be explained: the voltage vector of the same motor will decompose into different voltage components under different dq coordinate systems. In a typical three-phase permanent magnet synchronous motor, voltage and current exist on the three-phase windings A, B, and C, which can be considered as rotating voltage and current vectors after vector synthesis. Then, the motor controller, based on the angle of the motor rotor (i.e., the physical quantity to be detected by the encoder), decomposes the voltage vector into d- and q-axis components after coordinate transformation. The accuracy of this coordinate transformation depends entirely on the angle provided by the encoder. For an example using the voltage vector, please refer to [link to relevant documentation]. Figure 2 As shown, the motor's dq-axis coordinate system is established on the rotor. If the rotor angle detection is accurate, as shown by θ1 in the figure, an accurate dq-axis can be established, and the decomposition of the voltage vector U can also yield accurate Ud and Uq (corresponding to the blue part in the figure). However, if the rotor angle detection is deviated due to delay, as shown by θ2 in the figure, then the dq-axis established by the controller will be incorrect, and the Ud and Uq obtained from the decomposition of the same voltage vector U will also be deviated (corresponding to the brown part in the figure). Figure 2 As can be seen, for the same motor vector U, the different angles will lead to significant differences in the decomposed Ud and Uq.

[0103] Using this principle, the first voltage obtained in step 101 is a voltage component calculated by the control loop based on the angle with delay deviation, while the second voltage obtained in step 102 is calculated based on the motor steady-state model and measured parameters, and is the theoretical reference voltage component. Due to the existence of angle deviation, the voltage vector angles represented by these two sets of voltage components are different. Therefore, the initial angle deviation of the encoder can be calculated based on the first and second voltages. This initial angle deviation corresponds to the coordinate system deflection angle caused by the encoder delay.

[0104] 104. Apply the initial angle deviation to the motor controller and iteratively adjust the initial angle deviation until the difference between the first voltage and the second voltage meets the preset error threshold.

[0105] The initial angle deviation calculated in step 103 is an estimated value based on data collected in an uncompensated state. Since these input data are already affected by the angle deviation, the first calculated value is an approximate solution, not the optimal solution. To obtain the most accurate compensation value at this speed, the initial angle deviation can be applied to the motor controller, and then the consistency between the first voltage (loop voltage) and the second voltage (formula voltage) under this compensation can be re-evaluated until the difference between the first voltage and the second voltage meets a preset error threshold for tolerating measurement noise and model error, for example, set to a difference of less than 10% between the magnitudes of the two voltage vectors.

[0106] This adjustment process will continue to correct the compensation value and re-determine the difference between the first voltage and the second voltage until the d, q components of the first voltage and the second voltage are substantially equal, i.e. their difference meets the preset error threshold. At this time, the angle deviation value obtained in the motor controller makes the controller's compensated angle consistent with the motor's true physical angle, and the angle deviation value is the finally determined angle compensation data at the specific steady-state speed.

[0107] 105. Repeat the above steps at at least two different electrical angular speeds to obtain at least two sets of electrical angular speed and corresponding angle deviation data;

[0108] Steps 101 to 104 are to obtain an accurate angle deviation data at a specific electrical angular speed through iterative adjustment. However, the core technical problem to be solved by the present application is the internal processing delay of the encoder, which is a dynamic error. The angle lag caused by the internal processing delay of the encoder will significantly increase as the motor speed increases. Therefore, the compensation value obtained at a single speed cannot meet the compensation needs of the motor at other different speeds, especially at high speed.

[0109] In order to establish a compensation model that can cover all working conditions, the present step requires that the above-mentioned steps 101 to 104 be completely repeated at at least two different electrical angular speeds. In a specific embodiment, the controller will automatically control the motor to run stably at multiple speed points, for example, at 40%, 60%, 80%, 100% of the highest speed, and multiple speed points including reverse speed. Through multiple calibrations, multiple sets of data pairs can be obtained, each set of data clearly corresponds an electrical angular speed to the final angle deviation data measured at the speed, describing the dependence of the angle deviation on the electrical angular speed.

[0110] 106. Establish a fitting model according to at least two sets of electrical angular speed and corresponding angle deviation data to obtain a compensation coefficient;

[0111] Since the angle delay is caused by a relatively fixed internal processing time of the encoder, there is a stable and continuous functional relationship between the angle deviation caused by the delay and the electrical angular speed of the motor. By taking the obtained multiple sets of electrical angular speed and corresponding angle deviation data as multiple sampling points on an unknown function curve, a fitting model can be established, and a compensation coefficient can be abstracted. For example, in a simple linear model, the coefficient is the slope k of the fitting curve. This compensation coefficient represents the inherent dynamic delay characteristics of the encoder.

[0112] 107. When the motor is running, the output angle of the encoder is compensated for delay according to the compensation coefficient and the real-time electrical angular speed.

[0113] When the motor is running, the motor controller will obtain the current electric angular velocity in each control cycle, which reflects the current instantaneous speed and direction of the motor. The motor controller will take this real-time electric angular velocity as input and substitute it into the function relationship obtained by establishing the fitting model in step 106 to dynamically calculate a real-time angle compensation corresponding to the current speed. This compensation accurately quantifies the angle deviation caused by the internal delay of the encoder at the current instantaneous speed. Using this dynamically calculated real-time angle compensation, the original angle value read directly from the encoder can be corrected and adjusted to generate a final angle value after delay compensation. This value more accurately reflects the physical position of the motor rotor than the original encoder output angle.

[0114] It should be noted that the motor controller can periodically update the compensation coefficient based on the real-time acquisition of the electric angular velocity and the angle deviation data during operation. When the motor load characteristics or operating temperature changes are detected to exceed the preset threshold, the recalibration process of the fitting model can be automatically triggered to obtain new compensation coefficients to correct the delay characteristic deviation caused by environmental changes.

[0115] In this embodiment, by obtaining the first voltage output by the motor controller loop and the second voltage calculated based on the motor model under the steady-state condition of the motor running at a constant speed, the initial angle deviation of the encoder is calculated using the difference between the first voltage and the second voltage, and the real delay of the encoder signal in the actual control link is obtained. By applying the initial angle deviation to the motor controller and iteratively adjusting in closed-loop operation, the difference between the first voltage and the second voltage gradually converges within the preset threshold, thereby obtaining the optimal delay compensation.

[0116] Further, by repeatedly measuring at multiple different electric angular velocities and establishing a fitting model between the electric angular velocity and the angle deviation, the compensation coefficient for real-time compensation is obtained, so that the compensation amount can dynamically change with the motor speed, thereby effectively compensating for the angle lag caused by the encoder signal processing delay in different speed ranges. The delay compensation method provided by the present application avoids the dependence on unknown delay parameters inside the encoder, and the entire process can be realized only by relying on the motor itself and the controller. After delay compensation, the rotor angle information obtained by the motor controller is more accurate, which can significantly improve the control performance of the motor.

[0117] The method for compensating the delay of the encoder provided by the present application will be described in detail below. Please refer to Figure 3 , Figure 3 Another embodiment of the method for compensating the delay of the encoder provided by the present application comprises:

[0118] 301. continuously sampling the current, the electrical angular velocity and the first voltage outputted by the control loop in the motor controller to obtain a plurality of sets of motor running data when the motor is running at a constant rotational speed;

[0119] 302. calculating the arithmetic mean or the filter mean of the plurality of sets of motor running data, and determining the current, the electrical angular velocity and the first voltage of the motor under the steady state condition according to the calculation result;

[0120] In an actual motor control system, it is difficult to achieve an ideal steady state in which all parameters are absolutely constant, even under a constant rotational speed instruction, due to slight mechanical friction fluctuations, electrical noise and fine tuning of the control loop. The values such as the current, the electrical angular velocity and the first voltage in the motor controller always have slight instantaneous fluctuations. To solve this problem, steps 301 to 302 first continuously record the current, the electrical angular velocity and the first voltage outputted by the control loop in a preset time period at a certain frequency after the motor is stably running at a set constant rotational speed, to obtain a plurality of sets of motor running data. Then, the arithmetic mean or the filter mean of the plurality of sets of motor running data is calculated to obtain a set of averaged parameters. The calculation result is determined as the current, the electrical angular velocity and the first voltage under the steady state condition. This method of equating the average value in a time period to the steady state value avoids the large error caused by instantaneous sampling values, and improves the accuracy and reliability of the subsequent angle deviation calculation.

[0121] Among them, the arithmetic mean refers to the average result obtained by summing up the sampling values in the sampling time period and dividing by the number of samplings, which is used to reflect the overall level of the motor parameters under the steady state. The filter mean is an anti-interference filtering algorithm added in the calculation process, such as sliding average, weighted average or low-pass filtering, which is used to suppress the instantaneous noise and system jitter in the sampling process, and obtain more smooth and stable parameters.

[0122] 303. calculating the second voltage based on the motor model according to the current, the electrical angular velocity and the motor running parameters;

[0123] In this embodiment, step 303 is similar to step 102 of the foregoing embodiment, which will not be described here.

[0124] 304. calculating the initial angle deviation of the encoder according to the first voltage and the second voltage;

[0125] In this embodiment, the physical voltage vector of the same motor, when decomposed in two coordinate systems with different angles, will inevitably have different dq components. The angle difference between these two coordinate systems is the required angle deviation. Based on this, the first voltage obtained in step 302 is decomposed into a first voltage vector composed of a direct-axis component and a quadrature-axis component. Then, the angle of this first voltage vector in the dq coordinate plane is calculated based on its direct-axis component and quadrature-axis component, which is the first vector angle. Figure 2 α2 in the equation. Subsequently, the second voltage obtained in step 303 is processed in the same way, decomposed into a second voltage vector composed of direct-axis and quadrature-axis components, and the angle of this second voltage vector in the dq coordinate plane is calculated, which is the second vector angle, corresponding to... Figure 2 In the equation α1, the motor controller calculates the difference between the first and second vector angles, α2-α1. This angle difference is physically equivalent to the coordinate system deflection caused by the encoder delay. Since the encoder's output angle has a certain lag, its feedback coordinate system deflects relative to the actual magnetic field coordinate system. Therefore, α2-α1 can be directly regarded as the initial angle deviation under this steady-state electrical angular velocity.

[0126] Through the above calculations, the motor controller can accurately obtain the encoder delay error angle without external sensors, relying solely on the existing control signals and model calculation results. The calculation process is simple and has strong real-time performance.

[0127] 305. Add the current encoder output electrical angle value to the initial angle deviation to obtain the compensated angle value, and input the compensated angle value to the motor controller;

[0128] The motor controller adds the current encoder output electrical angle value to the calculated initial angle deviation to obtain the compensated angle value. The electrical angle value refers to the equivalent angle of the rotor angle signal output by the encoder in the electrical cycle, and is generally used to construct the motor's dq coordinate system. The compensated angle value obtained by superimposing it with the initial angle deviation can be understood as the real-time angle after correcting for encoder signal delay. This compensated angle value is re-inputted into the motor controller to update the angle reference in the control loop, thereby adjusting the decoupling direction of vectors such as voltage and current in the control calculation, and realigning the control coordinate system with the actual magnetic field direction of the motor.

[0129] 306. Control the motor to run at the same electrical angular velocity again, reacquire the current, electrical angular velocity and the first voltage output by the control loop, and recalculate the second voltage based on the acquired data;

[0130] After the compensated angle value is input, the motor controller controls the motor to run at the same electrical angular velocity again to verify the compensation effect. The electrical angular velocity is kept unchanged here to ensure consistent comparison conditions and to make the new measurement accurately reflect the adjustment effect of the compensated angle. During this steady-state running process, the motor controller re-acquires the current, electrical angular velocity, and the first voltage output by the control loop, and calculates the corresponding second voltage according to the re-acquired data. At this time, if the compensated angle is appropriate, the theoretical voltage (second voltage) and the control output voltage (first voltage) should tend to be consistent in direction and amplitude.

[0131] 307、When the difference between the first voltage and the second voltage does not satisfy the preset error threshold, calculate and update the initial angle deviation;

[0132] The motor controller compares the above-mentioned re-acquired first voltage and second voltage to determine whether the difference between them is within the preset error threshold. If there is still a significant deviation between them, it means that the current compensation angle has not completely eliminated the delay error. At this time, the controller will automatically calculate and update the initial angle deviation according to the size and direction of the difference. The update can be gradual adjustment or direct positioning of the new compensation value through phase difference calculation. When the difference does not satisfy the preset error threshold, the motor controller can increase or decrease the compensation value by a preset angle step at a time, and repeat the measurement process of steps 305 and 306 until the difference converges; or the motor controller directly calculates a new compensation angle according to the phase difference between the voltage vectors, thereby achieving fast correction at one time.

[0133] In some specific embodiments, when the difference between the first voltage and the second voltage does not satisfy the preset error threshold, the compensation step can be dynamically determined according to the trend of the difference between the first voltage and the second voltage; and the value of the initial angle deviation can be increased or decreased by the compensation step to update the initial angle deviation. Specifically, the controller first analyzes the voltage difference values sampled for several times in succession, and determines the convergence trend of the current angle compensation according to the direction of the difference value change: when the voltage difference value changes in the same direction for several times in succession, it means that the current compensation speed is too slow, and the compensation step can be increased accordingly to speed up the convergence process; when the direction of the voltage difference value change reverses, it indicates that the compensation may have over-adjusted, and the compensation step should be decreased to prevent oscillation near the target point. Through this dynamic step adjustment method based on the trend of the difference value, the initial angle deviation can be quickly and stably approximated without fixed step, which can significantly shorten the calibration time.

[0134] Through this iterative adjustment mechanism, the motor controller can find and approximate the optimal delay compensation angle without the need for external test equipment, so that the first voltage and the second voltage are highly consistent during steady-state running.

[0135] 308、repeat the above steps at at least two different electrical angular velocities to obtain at least two sets of electrical angular velocity and corresponding angle deviation data;

[0136] 309、establish a fitting model according to the at least two sets of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient;

[0137] In the embodiment, steps 308-309 are similar to steps 106-107 of the foregoing embodiment, and thus are not described again.

[0138] In some specific embodiments, linear fitting through the origin can be performed on the at least two sets of electrical angular velocity and corresponding angle deviation data, with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable. It is determined whether the fitting degree of the linear fitting meets a preset accuracy requirement. If yes, the compensation coefficient is determined according to the result of the linear fitting. If no, the fitting curve is re-fitted based on the fitting degree under the condition of passing through the origin, using a quadratic function, a piecewise linear function or a high-order function, and the compensation coefficient is determined according to the fitting result.

[0139] The principle is: generally, the signal processing and communication delay of the motor controller has an approximately linear relationship with the change in rotational speed, that is, the higher the electrical angular velocity, the greater the angular deviation caused by the delay. Based on this feature, the electrical angular velocity is first taken as the independent variable and the angular deviation is taken as the dependent variable, and a linear fitting method passing through the origin is used for fitting analysis. This linear relationship can be used to reflect the basic trend of delay compensation. In actual operation, the motor controller uses the least squares algorithm to linearly fit the data points to obtain a fitting straight line passing through the coordinate origin. At this time, the slope of the fitting straight line represents the delay angle compensation amount corresponding to the unit electrical angular velocity, that is, the compensation coefficient. In order to ensure the reliability of the compensation coefficient, the goodness of fit can be further calculated, for example, through the R² coefficient or residual analysis, to determine whether the current fitting model meets the preset accuracy requirement. If the goodness of fit reaches the set threshold, it is considered that the linear model is sufficient to accurately describe the delay characteristics, and the compensation coefficient is directly determined by the linear result. In this case, there is only a single compensation coefficient. If the goodness of fit does not meet the preset requirement, it means that the relationship between the encoder delay and the electrical angular velocity is not strictly linear, and may be affected by non-linear factors such as signal sampling rate, filtering delay, or system control delay. At this time, the motor controller will re-model using a higher-order fitting method under the premise that the fitting curve still passes through the origin, such as quadratic function fitting, piecewise linear fitting, or high-order polynomial fitting, and determine the compensation coefficient according to the fitting result. In this case, there will be two or more compensation coefficients, each corresponding to a different order term in the fitting function, or corresponding to a compensation segment in different speed intervals. In this way, the non-linear characteristics of the delay with the change in speed can be more comprehensively described, and the compensation coefficient can remain accurate throughout the speed range.

[0140] Further, when the goodness of fit is below the threshold, a higher-order function form can be adaptively selected according to the deviation distribution characteristics, such as using a quadratic function to fit the non-linear relationship, or using a piecewise linear function in different speed intervals, or using a high-order function in complex fluctuation conditions, to minimize the fitting residual and obtain the optimal model. This selection process dynamically adjusts based on the real-time evaluation results of the goodness of fit, so that the compensation model can automatically switch the function structure according to the data characteristics and maintain the constraint of passing through the origin, thereby obtaining high-precision compensation results in both the low-speed linear region and the high-speed nonlinear region.

[0141] It should be noted that this embodiment requires the fitted curve to pass through the origin, meaning the fitting function does not include an intercept term. This design is based on the physical characteristics of encoder delay error: the angular deviation caused by the delay only manifests when the motor is rotating. When the motor is stationary, since the angular velocity is zero, even with a time delay, there will be no angular deviation. Therefore, when the electrical angular velocity is zero, the angular deviation must be zero. Thus, the mathematical relationship between the electrical angular velocity and the angular deviation should satisfy the origin constraint condition, meaning that when the independent variable is zero, the dependent variable should also be zero. Therefore, regardless of the function form used, the fitted curve should satisfy the constraint condition of passing through the origin to ensure that the compensation amount remains zero when the velocity is zero.

[0142] 310. When the motor is running, obtain the real-time electrical angular velocity of the motor, and multiply the compensation coefficient by the real-time electrical angular velocity to obtain the real-time angle compensation amount;

[0143] When the motor is running, the motor controller acquires the current electrical angular velocity in real time. The controller then multiplies the compensation coefficient established in the previous steps by this real-time electrical angular velocity to obtain the current real-time angle compensation. This compensation, in a physical sense, represents the angular lag caused by system delay, and its value dynamically adjusts with changes in rotational speed. In this way, the compensation model can automatically increase the compensation angle during high-speed or acceleration operation, and automatically decrease or return to zero during low-speed or stationary operation, achieving speed-adaptive delay correction.

[0144] 311. The real-time angle compensation amount is fused with the original angle value output by the encoder to obtain the target angle value after delay compensation.

[0145] The motor controller fuses the real-time angle compensation value with the original angle value output by the encoder to obtain the target angle value after delay compensation. The original angle value is the rotor position information directly output by the encoder, which contains a certain delay error; while the real-time angle compensation value represents the theoretically corrected lag angle. The target angle value obtained by adding the two can be regarded as the equivalent real-time angle signal after delay compensation, which is closer to the actual instantaneous magnetic field position of the rotor. However, this embodiment does not simply add the original angle values ​​algebraically, but performs a fusion calculation.

[0146] The fusion calculation specifically refers to dynamically fusing the real-time angle compensation quantity and the original angle value output by the encoder to generate a target angle value after time delay compensation. Specifically, the motor controller calculates a corresponding real-time angle compensation quantity according to the current electrical angular velocity in each sampling period, and the compensation quantity reflects the angle lag trend caused by the time delay of the encoder signal. Subsequently, the original angle value and the compensation quantity are weighted and fused or filtered and smoothed according to the preset fusion weight or time filtering coefficient, so as to ensure the continuity and stability of the compensation result between adjacent sampling periods. Through this fusion calculation method, the transient influence of noise on the compensation result can be effectively inhibited, and the fluctuation of the current loop and the speed loop caused by the sudden change of the compensation signal can be avoided, so that a smooth and accurate target angle feedback is obtained. The target angle value obtained after calculation can effectively eliminate the measurement error caused by the sampling and signal transmission time delay of the encoder, so that the d-q coordinate system in the control system is consistent with the actual magnetic field direction of the motor.

[0147] 312, feeding the target angle value to the motor controller.

[0148] Finally, the motor controller re-enters the target angle value after time delay compensation into the control loop as the angle reference of the current loop and the speed loop. The control system performs real-time voltage vector decomposition and current control according to the target angle, so as to realize accurate field-oriented control. In this process, the compensation model continuously updates the compensation quantity according to the real-time electrical angular velocity, so that the system can maintain stable and consistent control effect under various operating conditions. Through such a real-time compensation mechanism, online time delay correction of the encoder signal can be realized, which can not only significantly reduce the angle lag error under high-speed rotation conditions, but also maintain control accuracy in the scene of dynamic load change or frequent start-stop.

[0149] Compared with the traditional scheme of using fixed compensation quantity or static correction table, the present method has the advantages of strong adaptability, fast response speed and simple implementation, and can significantly improve the dynamic response performance and control stability of the motor system, and is especially suitable for application scenarios such as servo system, robot joint driving and high-precision motion control.

[0150] It should be noted that the encoder time delay compensation method of the present application is mainly used to compensate the angle lag caused by the signal processing and control response delay of the encoder during dynamic operation. Before implementing the present method, there may be other types of error sources in the system, such as communication time delay or static installation error of the encoder. In order to ensure the accuracy of the compensation effect, in some specific embodiments, the following two types of errors are preferably pre-calibrated before the time delay compensation method of the present application is performed:

[0151] Firstly, the communication delay between the encoder and the motor controller is calibrated. The communication delay refers to the fixed time difference consumed in the whole process from the acquisition and transmission of the encoder output signal to the reception by the controller. Such delay is mainly determined by the communication protocol, bus bandwidth and processing cache mechanism, and has relatively fixed nature. By measuring the response time of the communication link in the system initialization stage, and setting the corresponding delay compensation parameters in the controller, the angle lag caused by communication transmission can be eliminated at the source, thereby avoiding the interference on the dynamic delay calculation result.

[0152] Secondly, the precision of the encoder in the static state is calibrated. The static precision calibration, also known as zero angle calibration, aims to eliminate the factors such as the mechanical installation deviation of the encoder, the initial reference angle error or the zero position setting error. When the motor is in a static state, the zero angle of the encoder is accurately measured and corrected by an external reference sensor or a specific mechanical positioning method, so that the output angle of the encoder can be consistent with the actual magnetic pole position of the motor. After this step, the angle output of the encoder has high accuracy in the static condition, providing a reliable reference for the subsequent dynamic delay compensation.

[0153] By completing the above two types of calibration steps before implementing the delay compensation algorithm of the present application, the influence of different types of error sources can be effectively isolated, so that the angle deviation calculated by the present application only reflects the real dynamic error caused by signal delay during motor operation. Therefore, the model established by the present application in the dynamic compensation stage is more accurate, the delay correction effect is more significant, and the control accuracy and system stability of the motor in the full speed range are ensured.

[0154] The encoder delay compensation system provided by the present application will be described in detail below. Please refer to Figure 4 , Figure 4 Another embodiment of the encoder delay compensation system provided by the present application comprises:

[0155] The first acquisition unit 401 is configured to acquire the current, the electrical angular velocity and the first voltage output by the control loop in the motor controller under the steady state condition of the motor running at no load and uniform speed.

[0156] The first calculation unit 402 is configured to calculate the second voltage based on the motor model according to the current, the electrical angular velocity and the motor running parameters.

[0157] The second calculation unit 403 is configured to calculate the initial angle deviation of the encoder according to the first voltage and the second voltage.

[0158] The adjustment unit 404 is configured to apply the initial angle deviation to the motor controller, and iteratively adjust the initial angle deviation until the difference between the first voltage and the second voltage meets the preset error threshold.

[0159] The second acquisition unit 405 is configured to repeatedly perform the above steps at at least two different electrical angular velocities to obtain at least two groups of electrical angular velocity and corresponding angle deviation data.

[0160] The fitting unit 406 is configured to establish a fitting model according to the at least two groups of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient.

[0161] The compensation unit 407 is configured to perform time delay compensation on the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity when the motor is running.

[0162] Optionally, the first calculation unit 402 is specifically configured to:

[0163] decompose the first voltage into a first voltage vector composed of a direct-axis component and a quadrature-axis component, and calculate a corresponding first vector angle;

[0164] decompose the second voltage into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and calculate a corresponding second vector angle;

[0165] determine the initial angle deviation of the encoder according to the difference between the first vector angle and the second vector angle.

[0166] Optionally, the fitting unit 406 is specifically configured to:

[0167] perform linear fitting through the origin in the at least two groups of electrical angular velocity and corresponding angle deviation data, taking the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable;

[0168] determine whether the fitting degree of the linear fitting meets a preset accuracy requirement;

[0169] if yes, determine the compensation coefficient according to the result of the linear fitting;

[0170] if no, perform re-fitting based on the fitting degree by using a quadratic function, a piecewise linear function or a high-order function under the condition that the fitting curve passes through the origin, and determine the compensation coefficient according to the fitting result.

[0171] Optionally, the adjustment unit 404 is specifically configured to:

[0172] fuse and calculate the electrical angle value output by the current encoder and the initial angle deviation to obtain a compensated angle value, and input the compensated angle value to the motor controller;

[0173] control the motor to run at the same electrical angular velocity again, reacquire the current, the electrical angular velocity and the first voltage output by the control loop, and re-calculate the second voltage according to the acquired data;

[0174] When the difference between the first voltage and the second voltage does not satisfy the preset error threshold, the initial angle deviation is calculated and updated.

[0175] Optionally, the adjusting unit 404 is specifically configured to:

[0176] When the difference between the first voltage and the second voltage does not satisfy the preset error threshold, a compensation step is determined according to a change trend of the difference between the first voltage and the second voltage.

[0177] The value of the initial angle deviation is sequentially increased or decreased by the compensation step to update the initial angle deviation.

[0178] When the change direction of the difference between the first voltage and the second voltage remains consistent in the continuous iterations, the compensation step is increased, and when the change direction of the difference between the first voltage and the second voltage is reversed, the compensation step is decreased.

[0179] Optionally, the first obtaining unit 401 is specifically configured to:

[0180] When the motor operates at a constant speed, the current, the electrical angular velocity in the motor controller and the first voltage output by the control loop are continuously sampled to obtain a plurality of sets of motor operation data.

[0181] The arithmetic mean or the filter mean of the plurality of sets of motor operation data is calculated, and the current, the electrical angular velocity and the first voltage of the motor under the steady state condition are determined according to the calculation result.

[0182] Optionally, the compensation unit 407 is specifically configured to:

[0183] When the motor operates, the real-time electrical angular velocity of the motor is obtained, and the compensation coefficient is multiplied by the real-time electrical angular velocity to obtain a real-time angle compensation amount.

[0184] The real-time angle compensation amount is added to the original angle value output by the encoder to obtain a target angle value after delay compensation.

[0185] The target angle value is fed back to the motor controller.

[0186] Optionally, the system further comprises:

[0187] The calibration unit 408 is configured to calibrate the communication delay between the encoder and the motor controller, and calibrate the static accuracy of the encoder.

[0188] In the system of the embodiment, the functions of the units correspond to the steps in the method embodiments shown in the foregoing Figure 1 or Figure 3 The description is not repeated here.

[0189] The application also provides an encoder delay compensation device, please refer to Figure 5, Figure 5 An embodiment of the apparatus for providing encoder delay compensation is provided in the present application, and the apparatus comprises:

[0190] The processor 501, the memory 502, the input / output unit 503, and the bus 504;

[0191] The processor 501 is connected with the memory 502, the input / output unit 503, and the bus 504;

[0192] The memory 502 stores a program, and the processor 501 invokes the program to perform any of the above encoder delay compensation methods.

[0193] The present application also relates to a computer readable storage medium, and the computer readable storage medium stores a program, and when the program runs on a computer, the computer performs any of the above encoder delay compensation methods.

[0194] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, apparatus, and unit can refer to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0195] In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely schematic, for example, the division of the unit is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, devices, or units, and can be electrical, mechanical, or other forms.

[0196] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment scheme.

[0197] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0198] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the various embodiments of the method of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, read-only memory), a random access memory (RAM, random access memory), a magnetic disk or an optical disk, and various media that can store program codes.

Claims

1. A method of encoder delay compensation, characterized in that, The method comprises: In the steady state condition of the motor running at a constant speed and under no load, obtaining the current, the electrical angular velocity and the first voltage output by the control loop in the motor controller; Calculating the second voltage based on the motor model according to the current, the electrical angular velocity and the motor operating parameters; Calculating the initial angle deviation of the encoder according to the first voltage and the second voltage; Applying the initial angle deviation to the motor controller and iteratively adjusting the initial angle deviation until the difference between the first voltage and the second voltage meets the preset error threshold; Repeating the above steps at at least two different electrical angular velocities to obtain at least two groups of electrical angular velocity and corresponding angle deviation data; Establishing a fitting model according to the at least two groups of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient; When the motor is running, performing time delay compensation on the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity.

2. The method of claim 1, wherein, The calculation of the initial angle deviation of the encoder according to the first voltage and the second voltage comprises: Decomposing the first voltage into a first voltage vector composed of a direct-axis component and a quadrature-axis component and calculating a corresponding first vector angle; Decomposing the second voltage into a second voltage vector composed of a direct-axis component and a quadrature-axis component and calculating a corresponding second vector angle; Determining the initial angle deviation of the encoder according to the difference between the first vector angle and the second vector angle.

3. The method of claim 1, wherein, The establishment of the fitting model according to the at least two groups of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient comprises: In the at least two groups of electrical angular velocity and corresponding angle deviation data, performing linear fitting through the origin with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable; Judging whether the fitting degree of the linear fitting meets the preset precision requirement; If yes, determining the compensation coefficient according to the result of the linear fitting; If no, under the condition of ensuring that the fitting curve passes through the origin, re-fitting based on the fitting degree using a quadratic function, a piecewise linear function or a high-order function, and determining the compensation coefficient according to the fitting result.

4. The method of claim 1, wherein, The application of the initial angle deviation to the motor controller and the iterative adjustment of the initial angle deviation comprise: Fusing the current encoder output electrical angle value and the initial angle deviation to obtain a compensated angle value, and inputting the compensated angle value to the motor controller; Controlling the motor to run at the same electrical angular velocity again to obtain the current, the electrical angular velocity and the first voltage output by the control loop, and recalculating the second voltage according to the obtained data; When the difference between the first voltage and the second voltage does not meet the preset error threshold, calculating and updating the initial angle deviation.

5. The method of claim 4, wherein, The calculation and update of the initial angle deviation when the difference between the first voltage and the second voltage does not meet the preset error threshold comprise: When the difference between the first voltage and the second voltage does not meet the preset error threshold, determining a compensation step according to the trend of the difference between the first voltage and the second voltage. The initial angle deviation is updated by sequentially increasing or decreasing the value of the initial angle deviation according to the compensation step size; The compensation step size is increased when the change direction of the difference between the first voltage and the second voltage remains consistent in a plurality of consecutive iterations, and the compensation step size is decreased when the change direction of the difference between the first voltage and the second voltage reverses.

6. The method of claim 1, wherein, The current, the electrical angular velocity and the first voltage output by the control loop in the motor controller are obtained under the steady state condition of the motor running at a constant speed and under no load. The current, the electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled when the motor runs at a constant speed, to obtain a plurality of sets of motor operation data. The arithmetic mean or the filter mean of the plurality of sets of motor operation data is calculated, and the current, the electrical angular velocity and the first voltage of the motor under the steady state condition are determined according to the calculation result.

7. The method according to any one of claims 1 to 6, characterized in that, The output angle of the encoder is time-delay compensated according to the compensation coefficient and the real-time electrical angular velocity when the motor runs. The real-time electrical angular velocity of the motor is obtained when the motor runs, and the compensation coefficient is multiplied by the real-time electrical angular velocity to obtain a real-time angle compensation amount. The real-time angle compensation amount is added to the original angle value output by the encoder to obtain a target angle value after time-delay compensation. The target angle value is fed back to the motor controller.

8. The method according to any one of claims 1 to 6, characterized in that, Before the output angle of the encoder is time-delay compensated according to the compensation coefficient and the real-time electrical angular velocity, the method further comprises: The communication delay between the encoder and the motor controller is calibrated. The static accuracy of the encoder is calibrated.

9. A system for encoder delay compensation, characterized in that, The system comprises: A first obtaining unit is configured to obtain the current, the electrical angular velocity and the first voltage output by the control loop in the motor controller under the steady state condition of the motor running at a constant speed and under no load. A first calculating unit is configured to calculate a second voltage based on a motor model according to the current, the electrical angular velocity and a motor operation parameter. A second calculating unit is configured to calculate an initial angle deviation of the encoder according to the first voltage and the second voltage. An adjusting unit is configured to apply the initial angle deviation to the motor controller, and iteratively adjust the initial angle deviation until the difference between the first voltage and the second voltage meets a preset error threshold. A second obtaining unit is configured to repeat the above steps to obtain at least two sets of electrical angular velocity and corresponding angle deviation data under at least two different electrical angular velocities. A fitting unit is configured to establish a fitting model according to the at least two sets of electrical angular velocity and corresponding angle deviation data to obtain a compensation coefficient. A compensation unit is configured to time-delay compensate the output angle of the encoder according to the compensation coefficient and the real-time electrical angular velocity when the motor runs.

10. An apparatus for encoder delay compensation, the apparatus comprising: The device comprises: A processor, a memory, an input / output unit and a bus; The processor is connected with the memory, the input / output unit and the bus; The memory stores a program, and the processor invokes the program to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Zero position identification method suitable for magnetic encoder of motor of electric moped

    CN118117918A

  • Control method based on differential speed and torque distribution

    CN120454534A