Encoder delay compensation method, system and related device
By acquiring the current and electrical angular velocity when the motor is running at a constant speed, the initial angle deviation of the encoder is calculated using the motor model and iteratively adjusted. This solves the angle lag problem caused by encoder signal processing delay, achieves more accurate angle compensation, and improves motor control performance.
Patent Information
- Application Number
- CN202511544492.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-10-28
AI Technical Summary
In high-precision servo control, the encoder signal processing delay cannot be accurately compensated, resulting in inaccurate angle information obtained by the motor controller and affecting control performance.
By acquiring the current and electrical angular velocity in the motor controller under steady-state conditions of uniform speed and no-load operation of the motor, the initial angle deviation of the encoder is calculated using the motor model, and the compensation coefficient is obtained by iterative adjustment and fitting of the model to compensate the output angle of the encoder in real time.
The accuracy of encoder signal processing delay compensation has been improved, ensuring that the motor controller obtains more accurate rotor angle information and improving the motor control performance.
Smart Images

Figure CN121036610A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of motor control technology, and in particular to a method, system and related device for encoder delay compensation. Background Technology
[0002] Encoders are typically installed inside permanent magnet synchronous motors to detect the motor's rotation angle, i.e., its position. In high-precision servo control, the vast majority of encoders currently used are absolute encoders. These typically have a built-in data processing chip that can convert the detected physical signals (such as magnetic, optical, and electrical signals) into angle values and provide them to an external servo controller via communication. However, a time delay is unavoidable in the entire process of the encoder processing signals and communicating with the servo controller to obtain the angle value.
[0003] In existing technologies, communication delays are generally compensated for through periodic communication. For example, a communication request is sent within the current 100-microsecond control cycle, and the returned result is used in the next cycle (100 microseconds later), thus fixing the communication delay to a known control cycle. Since the cycle is extremely short, the motor speed can be assumed to remain constant during this period. Therefore, by multiplying the known delay (100 microseconds) by the current motor speed, the angle deviation caused by the communication delay can be calculated and compensated for.
[0004] However, the delay caused by the encoder's own signal processing cannot be compensated for using the above methods. The fundamental flaw lies in the fact that the encoder's internal processing delay is an unknown quantity, determined by various factors such as the encoder's chip processing speed, computation algorithm, and internal filtering. Furthermore, manufacturers typically do not provide this parameter in their datasheets. In low-speed or low-performance applications, this unknown delay is often ignored. However, in applications involving high-speed motor rotation or high-precision control, this delay causes significant angular lag, resulting in severely inaccurate angle information acquired by the controller, thus affecting control performance. Summary of the Invention
[0005] This application provides a method, system, and related apparatus for encoder delay compensation, which can effectively compensate for the angle lag caused by encoder signal processing delay in different speed ranges and improve the control performance of the motor.
[0006] The first aspect of this application provides a method for encoder delay compensation, including: Under steady-state conditions of uniform speed and no-load operation of the motor, the current, electrical angular velocity, and the first voltage output by the control loop in the motor controller are obtained; The second voltage is calculated based on the current, the electric angular velocity, and the motor operating parameters using a motor model. The initial angle deviation of the encoder is calculated based on the first voltage and the second voltage; The initial angle deviation is applied to the motor controller, and the initial angle deviation is iteratively adjusted until the difference between the first voltage and the second voltage meets the preset error threshold. Repeat the above steps at at least two different electric angular velocities to obtain at least two sets of electric angular velocity and corresponding angular deviation data; A fitting model is established based on the at least two sets of electric angular velocities and their corresponding angular deviation data to obtain compensation coefficients; When the motor is running, the output angle of the encoder is delayed and compensated according to the compensation coefficient and the real-time electrical angular velocity.
[0007] Optionally, calculating the initial angle deviation of the encoder based on the first voltage and the second voltage includes: The first voltage is decomposed into a first voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding first vector angle is calculated. The second voltage is decomposed into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding second vector angle is calculated. The initial angle deviation of the encoder is determined based on the difference between the first vector angle and the second vector angle.
[0008] Optionally, the step of establishing a fitting model based on the at least two sets of electric angular velocities and corresponding angular deviation data to obtain compensation coefficients includes: In the at least two sets of electrical angular velocity and corresponding angle deviation data, a linear fit is performed with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable, passing through the origin. Determine whether the goodness of fit of the linear fit meets the preset accuracy requirements; If so, the compensation coefficient is determined based on the results of the linear fitting. If not, then, under the condition that the fitted curve passes through the origin, a quadratic function, a piecewise linear function, or a higher-order function is used for refitting based on the goodness of fit, and the compensation coefficient is determined according to the fitting result.
[0009] Optionally, applying the initial angle deviation to the motor controller and iteratively adjusting the initial angle deviation includes: The current encoder output electrical angle value is fused with the initial angle deviation to obtain a compensated angle value, and the compensated angle value is input to the motor controller. The motor is controlled to run at the same electrical angular velocity again at a constant speed. The current, the electrical angular velocity, and the first voltage output by the control loop are reacquired, and the second voltage is recalculated based on the acquired data. When the difference between the first voltage and the second voltage does not meet the preset error threshold, the initial angle deviation is calculated and updated.
[0010] Optionally, when the difference between the first voltage and the second voltage does not meet a preset error threshold, calculating and updating the initial angle deviation includes: When the difference between the first voltage and the second voltage does not meet the preset error threshold, the compensation step size is determined according to the changing 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. Specifically, when the direction of change of the difference between the first voltage and the second voltage remains consistent in several consecutive iterations, the compensation step size is increased; when the direction of change of the difference between the first voltage and the second voltage reverses, the compensation step size is decreased.
[0011] Optionally, the step of acquiring the current, electrical angular velocity, and first voltage output by the control loop from the motor controller under steady-state conditions of uniform speed and no-load operation includes: When the motor is running at a constant speed, the current, electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled to obtain several sets of motor operating data. Calculate the arithmetic mean or filtered mean of the several sets of motor operating data, and determine the current, electrical angular velocity and first voltage of the motor under steady-state conditions based on the calculation results.
[0012] Optionally, the step of performing delay compensation on the encoder's output angle based on the compensation coefficient and real-time electrical angular velocity when the motor is running includes: When the motor is running, 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 the real-time angle compensation amount; The real-time angle compensation amount is added to the original angle value output by the encoder to obtain the target angle value after delay compensation. The target angle value is fed back to the motor controller.
[0013] Optionally, before performing delay compensation on the encoder's output angle based on the compensation coefficient and the real-time electrical angular velocity, the method further includes: The communication delay between the encoder and the motor controller is calibrated. The static accuracy of the encoder is calibrated.
[0014] A second aspect of this application provides a system for encoder delay compensation, comprising: The first acquisition unit is used to acquire the current, electrical angular velocity and the first voltage output by the control loop in the motor controller under steady-state conditions of the motor running at a constant speed under no-load conditions. The first calculation unit is used to calculate the second voltage based on the current, the electric angular velocity, and the motor operating parameters using a motor model. The second calculation unit is used to calculate the initial angle deviation of the encoder based on the first voltage and the second voltage; An adjustment unit is used 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. The second acquisition unit is used to repeat the above steps at at least two different electric angular velocities to acquire at least two sets of electric angular velocity and corresponding angle deviation data. A fitting unit is used to establish a fitting model based on the at least two sets of electric angular velocities and corresponding angular deviation data to obtain compensation coefficients. The compensation unit is used to perform delay compensation on the output angle of the encoder based on the compensation coefficient and the real-time electrical angular velocity when the motor is running.
[0015] Optionally, the first computing unit is specifically used for: The first voltage is decomposed into a first voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding first vector angle is calculated. The second voltage is decomposed into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding second vector angle is calculated. The initial angle deviation of the encoder is determined based on the difference between the first vector angle and the second vector angle.
[0016] Optionally, the fitting unit is specifically used for: In the at least two sets of electrical angular velocity and corresponding angle deviation data, a linear fit is performed with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable, passing through the origin. Determine whether the goodness of fit of the linear fit meets the preset accuracy requirements; If so, the compensation coefficient is determined based on the results of the linear fitting. If not, then, under the condition that the fitted curve passes through the origin, a quadratic function, a piecewise linear function, or a higher-order function is used for refitting based on the goodness of fit, and the compensation coefficient is determined according to the fitting result.
[0017] Optionally, the adjustment unit is specifically used for: The current encoder output electrical angle value is fused with the initial angle deviation to obtain a compensated angle value, and the compensated angle value is input to the motor controller. The motor is controlled to run at the same electrical angular velocity again at a constant speed. The current, the electrical angular velocity, and the first voltage output by the control loop are reacquired, and the second voltage is recalculated based on the acquired data. When the difference between the first voltage and the second voltage does not meet the preset error threshold, the initial angle deviation is calculated and updated.
[0018] Optionally, the adjustment unit is further configured to: When the difference between the first voltage and the second voltage does not meet the preset error threshold, the compensation step size is determined according to the changing 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. Specifically, when the direction of change of the difference between the first voltage and the second voltage remains consistent in several consecutive iterations, the compensation step size is increased; when the direction of change of the difference between the first voltage and the second voltage reverses, the compensation step size is decreased.
[0019] Optionally, the first acquisition unit is specifically used for: When the motor is running at a constant speed, the current, electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled to obtain several sets of motor operating data. Calculate the arithmetic mean or filtered mean of the several sets of motor operating data, and determine the current, electrical angular velocity and first voltage of the motor under steady-state conditions based on the calculation results.
[0020] Optionally, the compensation unit is specifically used for: When the motor is running, 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 the real-time angle compensation amount; The real-time angle compensation amount is added to the original angle value output by the encoder to obtain the target angle value after delay compensation. The target angle value is fed back to the motor controller.
[0021] Optionally, the system further includes: The calibration unit is used to calibrate the communication delay between the encoder and the motor controller, and to calibrate the static accuracy of the encoder.
[0022] A third aspect of this application provides an encoder delay compensation apparatus, the apparatus comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program that the processor invokes to perform the first aspect and any optional encoder delay compensation method in the first aspect.
[0023] The fourth aspect of this application provides a computer-readable storage medium storing a program that, when executed on a computer, performs the first aspect and any optional encoder delay compensation method of the first aspect.
[0024] As can be seen from the above technical solutions, this application has the following advantages: By acquiring the first voltage output from the motor controller loop and the second voltage calculated based on the motor model under steady-state conditions of uniform motor operation, the difference between the first and second voltages is used to calculate the initial angle deviation of the encoder, thus obtaining the true delay of the encoder signal in the actual control link. By applying this initial angle deviation to the motor controller and iteratively adjusting it during closed-loop operation, the difference between the first and second voltages gradually converges to within a preset threshold, thereby obtaining the optimal delay compensation amount.
[0025] Furthermore, by repeatedly measuring at multiple different electrical angular velocities and establishing a fitting model between the electrical angular velocity and the angle deviation, compensation coefficients for real-time compensation are obtained. This allows the compensation amount to dynamically change with the motor speed, thereby effectively compensating for the angle lag caused by encoder signal processing delay within different speed ranges. The delay compensation method provided in this application avoids dependence on unknown delay parameters within the encoder. The entire process can be implemented solely using the motor itself and the controller. After delay compensation, the rotor angle information obtained by the motor controller is more accurate, significantly improving the motor's control performance. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A schematic flowchart of an embodiment of the encoder delay compensation method provided in this application; Figure 2A schematic diagram of the dq coordinate system in the encoder delay compensation method provided in this application; Figure 3 A schematic flowchart of another embodiment of the encoder delay compensation method provided in this application; Figure 4 A schematic diagram of an embodiment of the encoder delay compensation system provided in this application; Figure 5 A schematic diagram of an embodiment of the encoder delay compensation device provided in this application. Detailed Implementation
[0028] This application provides a method, system, and related apparatus for encoder delay compensation, which can effectively compensate for the angle lag caused by encoder signal processing delay in different speed ranges and improve the control performance of the motor.
[0029] It should be noted that the encoder delay compensation method provided in this application can be executed by various types of control devices. For example, the method can be integrated directly into the servo driver or controller of the motor itself as firmware, executed by its internal microcontroller (MCU) or digital signal processor (DSP) to achieve on-machine self-calibration. Alternatively, the method can be executed by an external host computer, programmable logic controller (PLC), or dedicated production line equipment. In this case, the external device can send instructions to the motor driver to run at uniform speeds at different speeds via a communication interface, read back the required operating data from the driver, perform iterative calculations 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 ease of explanation, the embodiments of this application are described with reference to control devices, but this is not intended to limit the scope of protection of this application.
[0030] Please see Figure 1 , Figure 1 An embodiment of the encoder delay compensation method provided in this application includes: 101. Under steady-state conditions of uniform speed and no-load operation of the motor, obtain the current, electrical angular velocity, and the first voltage output by the control loop in the motor controller; Step 101 is the data acquisition stage for angular deviation calibration. Its purpose is to obtain a set of electrical parameters that represent the actual output of the motor controller when the motor is running stably at a specific speed. These parameters include the current, electrical angular velocity, and the first voltage output by the control loop. The current refers to the direct-axis current and quadrature-axis current used for control in the dq coordinate system after coordinate transformation. The electrical angular velocity represents the rotational speed of the motor rotor's magnetic field, which can be calculated from the angle detected by the encoder (i.e., the rotor angle). Specifically, it can be obtained from the angle change rate output by the encoder, and the electrical angular velocity has positive and negative values depending on the direction of rotation. The first voltage refers to the dq-axis voltage value actually calculated and output by the motor control loop based on the encoder angle to maintain the aforementioned direct-axis current and quadrature-axis current.
[0031] It should be noted that the steady-state condition requires the motor to operate at a constant speed, i.e., uniform speed, ensuring that all internal electrical parameters such as current and voltage have reached a stable state, eliminating interference from dynamic processes such as acceleration or deceleration. The steady-state condition also requires the motor to be in an unloaded state. This is because, under no-load conditions, the motor only needs to overcome its own friction and does not need to output additional torque, requiring a very small current. In subsequent steps, this first set of voltages needs to be compared with another set of voltages calculated based on theoretical formulas. When the current value is very small, the calculation results of the theoretical formula are minimized by the influence of current measurement errors, and their accuracy is mainly determined by the back electromotive force term (i.e., the product of electric angular velocity and magnetic flux). Therefore, choosing the no-load condition can significantly improve the accuracy of subsequent theoretical calculations, providing a reliable data foundation for the entire compensation scheme.
[0032] 102. The second voltage is calculated based on the motor model using the current, electric angular velocity, and motor operating parameters; The motor model specifically refers to the steady-state dq-axis voltage equation of a permanent magnet synchronous motor. This equation describes the deterministic mathematical relationship between the dq-axis terminal voltage, current, electrical angular velocity, and inherent physical parameters of the motor during stable operation. Based on the dq-axis, the physical quantities of the motor satisfy the following equations: ; In this equation, subscripts d and q represent physical quantities along the d-axis and q-axis, respectively; Ud and Uq are voltages; Rs is the motor resistance; id and iq are currents; Ld and Lq are inductances; ωe is the electric angular velocity; and Ψm is the motor flux linkage. When the motor is in steady-state operation (i.e., neither its speed nor load changes), its d-axis current and voltage remain constant. In this case, the second term in the above two equations related to current changes is zero, and the equations can be simplified to the following steady-state equations: .
[0033] In practice, the motor controller will retrieve the steady-state current and electrical angular velocity values obtained in step 101, and read a set of pre-calibrated or preset 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 permanent magnet flux linkage. The motor controller will substitute all the above-mentioned known parameters into the steady-state equation for calculation, thereby obtaining a set of theoretical dq-axis voltage values, which is the second voltage to be obtained in this step.
[0034] 103. Calculate the initial angle deviation of the encoder based on the first voltage and the second voltage; 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.
[0035] 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.
[0036] 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. 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.
[0037] This adjustment process continues, constantly correcting the compensation value and re-evaluating the difference between the first and second voltages, until the d and q components of the first and second voltages are essentially equal, meaning their difference meets the preset error threshold. At this point, the angle deviation value obtained in the motor controller ensures that the compensated angle of the controller matches the actual physical angle of the motor. This angle deviation value is the final angle compensation data determined for that specific steady-state speed.
[0038] 105. Repeat the above steps at at least two different electric angular velocities to obtain at least two sets of electric angular velocity and corresponding angle deviation data; Steps 101 to 104 involve obtaining precise angular deviation data at a specific electrical angular velocity through iterative adjustments. However, the core technical problem this invention aims to solve is that the encoder's internal processing delay is a dynamic error, and the resulting angular lag increases significantly with increasing motor speed. Therefore, the compensation value obtained at only a single speed cannot meet the compensation requirements of the motor at other speeds, especially at high speeds.
[0039] To establish a compensation model that covers all operating conditions, this step requires completely repeating the entire calibration process described in steps 101 to 104 at at least two different electrical angular velocities. In a specific embodiment, the controller automatically controls the motor to operate stably at multiple speed points according to the program, for example, repeating the calibration process at 40%, 60%, 80%, and 100% of the maximum speed, as well as at 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 velocity to the final angle deviation data measured at that speed, describing the dependence of the angle deviation on the change of electrical angular velocity.
[0040] 106. Establish a fitting model based on at least two sets of electric angular velocities and corresponding angular deviation data, and obtain the compensation coefficients; Since the angular delay originates from a relatively fixed internal processing time of the encoder, there is a stable and continuous functional relationship between the angular deviation caused by this delay and the electrical angular velocity of the motor. By using multiple sets of electrical angular velocities and corresponding angular deviation data as multiple sampling points on the unknown function curve, a fitting model can be established, and a compensation coefficient can be abstracted. For example, in a simple linear model, this coefficient is the slope k of the fitted curve. This compensation coefficient represents the inherent dynamic delay characteristic of the encoder.
[0041] 107. When the motor is running, the output angle of the encoder is delayed and compensated according to the compensation coefficient and the real-time electrical angular velocity.
[0042] During motor operation, the motor controller acquires the current electrical angular velocity in real time during each control cycle. This real-time electrical angular velocity reflects the motor's current instantaneous speed and direction of rotation. The motor controller uses this real-time electrical angular velocity as input, substituting it into the functional relationship obtained from the fitting model established in step 106 for calculation, thereby dynamically calculating a real-time angle compensation amount corresponding to the current speed. This compensation amount accurately quantifies the angle deviation caused by the encoder's internal delay at the current instantaneous speed. Using this dynamically calculated real-time angle compensation amount, the original angle value directly read 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 compared to the original encoder output angle.
[0043] It should be noted that during operation, the motor controller can periodically update the compensation coefficients based on real-time collected electrical angular velocity and angular deviation data. Furthermore, when the motor load characteristics or operating temperature changes exceed a preset threshold, it can automatically trigger the recalibration process of the fitted model to obtain new compensation coefficients, thereby correcting the delay characteristic deviation caused by environmental changes.
[0044] In this embodiment, under steady-state conditions of uniform motor operation, the first voltage output by the motor controller loop and the second voltage calculated based on the motor model are obtained respectively. The initial angle deviation of the encoder is calculated using the difference between the first and second voltages, thus obtaining the true delay of the encoder signal in the actual control link. By applying this initial angle deviation to the motor controller and iteratively adjusting it during closed-loop operation, the difference between the first and second voltages gradually converges to within a preset threshold, thereby obtaining the optimal delay compensation amount.
[0045] Furthermore, by repeatedly measuring at multiple different electrical angular velocities and establishing a fitting model between the electrical angular velocity and the angle deviation, compensation coefficients for real-time compensation are obtained. This allows the compensation amount to dynamically change with the motor speed, thereby effectively compensating for the angle lag caused by encoder signal processing delay within different speed ranges. The delay compensation method provided in this application avoids dependence on unknown delay parameters within the encoder. The entire process can be implemented solely using the motor itself and the controller. After delay compensation, the rotor angle information obtained by the motor controller is more accurate, significantly improving the motor's control performance.
[0046] The encoder delay compensation method provided in this application is described in detail below. Please refer to [link / reference]. Figure 3 , Figure 3 Another embodiment of the encoder delay compensation method provided in this application includes: 301. When the motor is running at a constant speed, the current, electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled to obtain several sets of motor operating data. 302. Calculate the arithmetic mean or filtered mean of several sets of motor operating data, and determine the motor current, electric angular velocity and first voltage under steady-state conditions based on the calculation results; In actual motor control systems, even under constant speed commands, achieving an ideal steady state where all parameters remain absolutely constant is difficult due to minute mechanical friction fluctuations, electrical noise, and fine-tuning of the control loop itself. The values of current, electrical angular velocity, and first voltage in the motor controller will always exhibit minute instantaneous fluctuations. To address this issue, steps 301 to 302 first, after the motor has stabilized at a set constant speed, continuously record the current, electrical angular velocity, and the first voltage output by the control loop at a certain frequency over a preset period of time, obtaining several sets of motor operating data. Then, by performing an arithmetic mean or filtered mean calculation on these sets of motor operating data, a set of averaged parameters is obtained. This calculation result is determined as the current, electrical angular velocity, and first voltage under steady-state conditions. This method of equating the average value over a period of time with the steady-state value avoids the huge errors caused by instantaneous sampling values, improving the accuracy and reliability of subsequent angle deviation calculations.
[0047] The arithmetic mean is the average of the summations of all sampled values within the sampling period, divided by the number of samples. It reflects the overall level of the motor parameters under steady-state conditions. The filtered mean incorporates anti-interference filtering algorithms, such as moving average, weighted average, or low-pass filtering, during the calculation process to suppress instantaneous noise and system jitter during sampling, resulting in smoother and more stable parameters.
[0048] 303. The second voltage is calculated based on the motor model using the current, electric angular velocity, and motor operating parameters; In this embodiment, step 303 is similar to step 102 in the previous embodiment, and will not be described again here.
[0049] 304. Calculate the initial angle deviation of the encoder based on the first voltage and the second voltage; 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.
[0050] 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.
[0051] 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; 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.
[0052] 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; After inputting the compensated angle value, the motor controller again controls the motor to run at the same electrical angular velocity at a constant speed to verify the compensation effect. Maintaining a constant electrical angular velocity here ensures consistent comparison conditions, allowing the new measurement results to accurately reflect the adjustment effect of the compensation angle. During this steady-state operation, the motor controller re-acquires the current, electrical angular velocity, and the first voltage output from the control loop, and calculates the corresponding second voltage based on the re-acquired data. If the compensation angle is appropriate, the theoretical voltage (second voltage) and the control output voltage (first voltage) should tend to be consistent in direction and amplitude.
[0053] 307. When the difference between the first voltage and the second voltage does not meet the preset error threshold, calculate and update the initial angle deviation; The motor controller compares the newly acquired first and second voltages to determine if the difference between them is within a preset error threshold. If a significant deviation still exists, it indicates that the current compensation angle has not completely eliminated the delay error. In this case, the controller automatically calculates and updates the initial angle deviation based on the magnitude and direction of the difference. The update can be done gradually or by directly locating a new compensation value by calculating the phase difference. When the difference does not meet the preset error threshold, the motor controller can sequentially increase or decrease the compensation amount according to a preset angle step size and repeat the measurement process in steps 305 and 306 until the difference converges; or the motor controller can directly calculate a new compensation angle based on the phase difference between the voltage vectors, thereby achieving rapid correction in one step.
[0054] In some specific embodiments, when the difference between the first voltage and the second voltage does not meet the preset error threshold, the compensation step size can be dynamically determined based on the changing trend of the difference between the first voltage and the second voltage. The initial angle deviation is then increased or decreased sequentially according to the compensation step size to update the initial angle deviation. Specifically, the controller first analyzes the voltage difference from several consecutive samples and judges the convergence trend of the current angle compensation based on the direction of the difference change: when the voltage difference changes in the same direction in multiple consecutive iterations, it indicates that the current compensation speed is too slow, and the compensation step size can be increased accordingly to accelerate the convergence process; when the direction of the voltage difference change reverses, it indicates that the compensation may be over-adjusted, and the compensation step size is decreased to prevent oscillations near the target point. Through this dynamic step size adjustment method based on the difference change trend, a fast and stable approximation of the initial angle deviation can be achieved without a fixed step size, significantly shortening the calibration time.
[0055] Through this iterative adjustment mechanism, the motor controller can find and approximate the optimal delay compensation angle without the need for external testing equipment, so that the first voltage and the second voltage are highly consistent during steady-state operation.
[0056] 308. Repeat the above steps at at least two different electric angular velocities to obtain at least two sets of electric angular velocity and corresponding angle deviation data; 309. Establish a fitting model based on at least two sets of electric angular velocities and corresponding angular deviation data, and obtain the compensation coefficients; In this embodiment, steps 308-309 are similar to steps 106-107 in the previous embodiment, and will not be described again here.
[0057] In some specific embodiments, a linear fit can be performed on at least two sets of electrical angular velocity and corresponding angle deviation data, with electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable, passing through the origin; it can be determined whether the goodness of fit of the linear fit meets the preset accuracy requirements; if so, the compensation coefficient is determined based on the result of the linear fit; if not, under the condition that the fitted curve passes through the origin, a quadratic function, piecewise linear function or higher-order function is used for refitting based on the goodness of fit, and the compensation coefficient is determined based on the fitting result.
[0058] The principle is as follows: Under normal circumstances, the signal processing and communication delay of the motor controller have 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 characteristic, this embodiment first uses electrical angular velocity as the independent variable and angular deviation as the dependent variable, and employs a linear fitting method passing through the origin 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 perform linear fitting on the data points, obtaining a fitted straight line passing through the origin. At this time, the slope of the fitted straight line represents the delay angle compensation amount corresponding to a unit electrical angular velocity, i.e., the compensation coefficient. To ensure the reliability of this compensation coefficient, the goodness of fit can be further calculated, for example, by using the R² coefficient or residual analysis to determine whether the current fitted model meets the preset accuracy requirements. 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 using this linear result. In this case, only a single compensation coefficient exists. If the goodness of fit does not meet the preset requirements, it indicates that the relationship between encoder delay and electrical angular velocity is not strictly linear, and may be affected by nonlinear factors such as signal sampling rate, filtering delay, or system control delay. In this case, the motor controller will remodel using a higher-order fitting method, such as quadratic function fitting, piecewise linear fitting, or high-order polynomial fitting, while ensuring that the fitted curve still passes through the origin. The compensation coefficients will be determined based on the fitting results. In this case, there will be two or more compensation coefficients, each corresponding to a different order term in the fitted function, or to a compensation segment in a different speed range. This method can more comprehensively describe the nonlinear characteristics of delay changing with speed, ensuring that the compensation coefficients maintain accuracy across the entire speed range.
[0059] Furthermore, when the goodness of fit is below a threshold, a higher-order function form can be adaptively selected based on the characteristics of the deviation distribution. For example, a quadratic function can be used to fit the nonlinear relationship, or a piecewise linear function can be used in different speed ranges, or a higher-order function can be used under complex fluctuation conditions, in order to minimize the fitting residual and obtain the optimal model. This selection process is dynamically adjusted based on the real-time evaluation results of the goodness of fit, enabling the compensation model to 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.
[0060] 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.
[0061] 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; 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.
[0062] 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. 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.
[0063] Fusion calculation specifically refers to the dynamic fusion of the real-time angle compensation value and the original angle value output by the encoder to generate a target angle value after delay compensation. Specifically, within each sampling cycle, the motor controller calculates the corresponding real-time angle compensation value based on the current electrical angular velocity. This compensation value reflects the angle lag trend caused by the encoder signal delay. Subsequently, based on preset fusion weights or time filtering coefficients, the original angle value and the compensation value are weighted and fused or filtered and smoothed to ensure the continuity and stability of the compensation result between adjacent sampling cycles. This fusion calculation method effectively suppresses the transient impact of noise on the compensation result and avoids fluctuations in the current and speed loops caused by sudden changes in the compensation signal, thus obtaining smooth and accurate target angle feedback. The calculated target angle value effectively eliminates measurement errors caused by encoder sampling and signal transmission delays, thereby ensuring that the dq coordinate system in the control system remains consistent with the actual magnetic field direction of the motor.
[0064] 312. Feedback the target angle value to the motor controller.
[0065] Finally, the motor controller re-inputs the delayed-compensated target angle value into the control loop, using it as the angle reference for the current and speed loops. The control system performs real-time voltage vector decomposition and current control based on this target angle, thereby achieving precise field-oriented control. During this process, the compensation model continuously updates the compensation amount based on the real-time electrical angular velocity, ensuring stable and consistent control performance under various operating conditions. This real-time compensation mechanism enables online delay correction of the encoder signal, significantly reducing angular hysteresis errors under high-speed rotation conditions and maintaining control accuracy in scenarios with dynamic load changes or frequent start-stop cycles.
[0066] Compared with traditional methods that use fixed compensation amounts or static calibration tables, this method has the advantages of strong adaptability, fast response speed and simple implementation. It can significantly improve the dynamic response performance and control stability of motor systems, and is especially suitable for applications such as servo systems, robot joint drives and high-precision motion control.
[0067] It should be noted that the encoder delay compensation method of the present invention is mainly used to compensate for the angle lag caused by signal processing and control response delays during the dynamic operation of the encoder. However, before implementing this method, other types of error sources may exist in the system, such as communication delays or encoder static installation errors. To ensure the accuracy of the compensation effect, in some specific embodiments, it is preferable to pre-calibrate the following two types of errors before implementing the delay compensation method of the present invention: First, the communication delay between the encoder and the motor controller is calibrated. Communication delay refers to the fixed time difference consumed during the entire process of the encoder output signal being acquired, transmitted, and received by the controller. This type of delay is mainly determined by the communication protocol, bus bandwidth, and processing buffer mechanism, and is relatively fixed. By measuring the response time of the communication link during the system initialization phase and setting corresponding delay compensation parameters in the controller, the angular lag caused by communication transmission can be eliminated at the source, thereby avoiding its interference with the dynamic delay calculation results.
[0068] Secondly, the encoder's accuracy is calibrated in a static state. Static accuracy calibration, also known as zero-position angle calibration, aims to eliminate factors such as encoder mechanical installation deviations, initial reference angle errors, or zero-position setting errors. When the motor is stationary, the encoder's zero-position angle is accurately measured and corrected using an external reference sensor or a specific mechanical positioning method, ensuring that its output angle matches the actual magnetic pole position of the motor. After this step, the encoder's angle output has high accuracy under static conditions, providing a reliable reference for subsequent dynamic delay compensation.
[0069] By completing the above two types of calibration steps before implementing the delay compensation algorithm of this invention, the influence of different types of error sources can be effectively isolated, ensuring that the angle deviation calculated by this invention only reflects the real dynamic error caused by signal delay during motor operation. Therefore, the model established in the dynamic compensation stage of this method is more accurate, the delay correction effect is more significant, and the control accuracy and system stability of the motor across the entire speed range are ensured.
[0070] The encoder delay compensation system provided in this application is described in detail below. Please refer to [link / reference]. Figure 4 , Figure 4 Another embodiment of the encoder delay compensation system provided in this application, the system includes: The first acquisition unit 401 is used to acquire the current, electrical angular velocity and the first voltage output by the control loop in the motor controller under steady-state conditions of the motor running at a constant speed under no-load conditions. The first calculation unit 402 is used to calculate the second voltage based on the motor model according to the current, electric angular velocity and motor operating parameters. The second calculation unit 403 is used to calculate the initial angle deviation of the encoder based on the first voltage and the second voltage. The adjustment unit 404 is used 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. The second acquisition unit 405 is used to repeat the above steps at at least two different electric angular velocities to acquire at least two sets of electric angular velocity and corresponding angle deviation data. Fitting unit 406 is used to establish a fitting model based on at least two sets of electric angular velocities and corresponding angular deviation data to obtain compensation coefficients. The compensation unit 407 is used to perform delay compensation on the encoder output angle based on the compensation coefficient and the real-time electrical angular velocity when the motor is running.
[0071] Optionally, the first computing unit 402 is specifically used for: The first voltage is decomposed into a first voltage vector composed of direct-axis components and quadrature-axis components, and the corresponding first vector angle is calculated. The second voltage is decomposed into a second voltage vector consisting of a direct-axis component and a quadrature-axis component, and the corresponding second vector angle is calculated. The initial angular deviation of the encoder is determined based on the difference between the first vector angle and the second vector angle.
[0072] Optionally, the fitting unit 406 is specifically used for: In at least two sets of electric angular velocity and corresponding angular deviation data, a linear fit is performed with electric angular velocity as the independent variable and the corresponding angular deviation data as the dependent variable, passing through the origin. Determine whether the goodness of fit of the linear fit meets the preset accuracy requirements; If so, the compensation coefficient is determined based on the results of the linear fitting. If not, then, while ensuring that the fitted curve passes through the origin, refit using a quadratic function, piecewise linear function, or higher-order function based on the goodness of fit, and determine the compensation coefficient based on the fitting results.
[0073] Optionally, the adjustment unit 404 is specifically used for: The current encoder output electrical angle value is fused with the initial angle deviation to obtain the compensated angle value, and the compensated angle value is input to the motor controller. The motor is controlled to run at the same electrical angular velocity again, and the current, electrical angular velocity, and first voltage output by the control loop are reacquired. The second voltage is then recalculated based on the acquired data. When the difference between the first voltage and the second voltage does not meet the preset error threshold, the initial angle deviation is calculated and updated.
[0074] Optionally, the adjustment unit 404 is also specifically used for: When the difference between the first voltage and the second voltage does not meet the preset error threshold, the compensation step size is determined according to the changing 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. Specifically, when the direction of change of the difference between the first voltage and the second voltage is consistent in several consecutive iterations, the compensation step size is increased; when the direction of change of the difference between the first voltage and the second voltage is reversed, the compensation step size is decreased.
[0075] Optionally, the first acquisition unit 401 is specifically used for: When the motor is running at a constant speed, the current, electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled to obtain several sets of motor operating data. Calculate the arithmetic mean or filtered mean of several sets of motor operating data, and determine the motor current, electric angular velocity and first voltage under steady-state conditions based on the calculation results.
[0076] Optionally, the compensation unit 407 is specifically used for: When the motor is running, 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 the real-time angle compensation amount; The real-time angle compensation is added to the original angle value output by the encoder to obtain the target angle value after delay compensation. The target angle value is fed back to the motor controller.
[0077] Optionally, the system may also include: The calibration unit 408 is used to calibrate the communication delay between the encoder and the motor controller, and to calibrate the static accuracy of the encoder.
[0078] In this embodiment, the functions of each unit are the same as described above. Figure 1 or Figure 3 The steps in the method embodiments shown correspond to those in the examples, and will not be repeated here.
[0079] This application also provides an encoder delay compensation device, please refer to [link to relevant documentation]. Figure 5 , Figure 5 One embodiment of the encoder delay compensation apparatus provided in this application includes: Processor 501, memory 502, input / output unit 503, bus 504; The processor 501 is connected to the memory 502, the input / output unit 503, and the bus 504; The memory 502 stores a program, and the processor 501 calls the program to execute any of the encoder delay compensation methods described above.
[0080] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the encoder delay compensation methods described above.
[0081] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0082] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0083] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0084] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0085] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for encoder delay compensation, characterized in that, The method includes: Under steady-state conditions of uniform speed and no-load operation of the motor, the current, electrical angular velocity, and the first voltage output by the control loop in the motor controller are obtained; The second voltage is calculated based on the current, the electric angular velocity, and the motor operating parameters using a motor model. The initial angle deviation of the encoder is calculated based on the first voltage and the second voltage; The initial angle deviation is applied to the motor controller, and the initial angle deviation is iteratively adjusted until the difference between the first voltage and the second voltage meets the preset error threshold. Repeat the above steps at at least two different electric angular velocities to obtain at least two sets of electric angular velocity and corresponding angular deviation data; A fitting model is established based on the at least two sets of electric angular velocities and their corresponding angular deviation data to obtain compensation coefficients; When the motor is running, the output angle of the encoder is delayed and compensated according to the compensation coefficient and the real-time electrical angular velocity.
2. The method according to claim 1, characterized in that, The calculation of the encoder's initial angle deviation based on the first voltage and the second voltage includes: The first voltage is decomposed into a first voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding first vector angle is calculated. The second voltage is decomposed into a second voltage vector composed of a direct-axis component and a quadrature-axis component, and the corresponding second vector angle is calculated. The initial angle deviation of the encoder is determined based on the difference between the first vector angle and the second vector angle.
3. The method according to claim 1, characterized in that, The step of establishing a fitting model based on the at least two sets of electric angular velocities and corresponding angular deviation data to obtain compensation coefficients includes: In the at least two sets of electrical angular velocity and corresponding angle deviation data, a linear fit is performed with the electrical angular velocity as the independent variable and the corresponding angle deviation data as the dependent variable, passing through the origin. Determine whether the goodness of fit of the linear fit meets the preset accuracy requirements; If so, the compensation coefficient is determined based on the results of the linear fitting. If not, then, under the condition that the fitted curve passes through the origin, a quadratic function, a piecewise linear function, or a higher-order function is used for refitting based on the goodness of fit, and the compensation coefficient is determined according to the fitting result.
4. The method according to claim 1, characterized in that, The step of applying the initial angle deviation to the motor controller and iteratively adjusting the initial angle deviation includes: The current encoder output electrical angle value is fused with the initial angle deviation to obtain a compensated angle value, and the compensated angle value is input to the motor controller. The motor is controlled to run at the same electrical angular velocity again at a constant speed. The current, the electrical angular velocity, and the first voltage output by the control loop are reacquired, and the second voltage is recalculated based on the acquired data. When the difference between the first voltage and the second voltage does not meet the preset error threshold, the initial angle deviation is calculated and updated.
5. The method according to claim 4, characterized in that, When the difference between the first voltage and the second voltage does not meet a preset error threshold, the initial angle deviation is calculated and updated, including: When the difference between the first voltage and the second voltage does not meet the preset error threshold, the compensation step size is determined according to the changing 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. Specifically, when the direction of change of the difference between the first voltage and the second voltage remains consistent in several consecutive iterations, the compensation step size is increased; when the direction of change of the difference between the first voltage and the second voltage reverses, the compensation step size is decreased.
6. The method according to claim 1, characterized in that, The process of acquiring the current, electrical angular velocity, and first voltage output from the control loop in the motor controller under steady-state conditions of uniform speed and no-load operation includes: When the motor is running at a constant speed, the current, electrical angular velocity and the first voltage output by the control loop in the motor controller are continuously sampled to obtain several sets of motor operating data. Calculate the arithmetic mean or filtered mean of the several sets of motor operating data, and determine the current, electrical angular velocity and first voltage of the motor under steady-state conditions based on the calculation results.
7. The method according to any one of claims 1 to 6, characterized in that, The step of performing delay compensation on the encoder's output angle based on the compensation coefficient and real-time electrical angular velocity when the motor is running includes: When the motor is running, 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 the real-time angle compensation amount; The real-time angle compensation amount is added to the original angle value output by the encoder to obtain the target angle value after 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 performing delay compensation on the encoder's output angle based on the compensation coefficient and the real-time electrical angular velocity, the method further includes: 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 includes: The first acquisition unit is used to acquire the current, electrical angular velocity and the first voltage output by the control loop in the motor controller under steady-state conditions of the motor running at a constant speed under no-load conditions. The first calculation unit is used to calculate the second voltage based on the current, the electric angular velocity, and the motor operating parameters using a motor model. The second calculation unit is used to calculate the initial angle deviation of the encoder based on the first voltage and the second voltage; An adjustment unit is used 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. The second acquisition unit is used to repeat the above steps at at least two different electric angular velocities to acquire at least two sets of electric angular velocity and corresponding angle deviation data. A fitting unit is used to establish a fitting model based on the at least two sets of electric angular velocities and corresponding angular deviation data to obtain compensation coefficients. The compensation unit is used to perform delay compensation on the output angle of the encoder based on the compensation coefficient and the real-time electrical angular velocity when the motor is running.
10. An encoder delay compensation device, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in 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
Method for controlling motor and controller for motor
JP2004086610A
Cited By
Absolute value encoder for low-delay optomagnetic signal transmission
CN122062736A