Pulse position compensation method and device of encoder and storage medium

By periodically calculating the encoder pulse increment error and employing a dual-threshold criterion and multi-data source fusion method, the problem of encoder signal distortion under strong electromagnetic interference environment was solved, thereby achieving the reliability of encoder signal and high precision stability of servo system.

CN122015919APending Publication Date: 2026-05-12JIANGMEN MENGDE ELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGMEN MENGDE ELECTRIC CO LTD
Filing Date
2026-02-13
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In environments with strong electromagnetic interference, the pulse communication between the encoder and the driver is susceptible to noise interference, which can lead to signal distortion or loss, affecting the control accuracy and stability of the servo system. It is also difficult to actively eliminate transient interference through signal processing algorithms.

Method used

By periodically acquiring the encoder's pulse signal value, calculating the error between the actual and theoretical pulse increments, and using dual threshold criteria and multi-data source fusion, interference signals are intelligently identified and isolated. Compensation is then performed using smooth theoretical increment values ​​to ensure the continuity and accuracy of position feedback.

Benefits of technology

It achieves intrinsic reliability of encoder signals under strong interference environments, ensuring high-precision and stable operation of the servo system, avoiding control instability and accidents, and without increasing hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122015919A_ABST
    Figure CN122015919A_ABST
Patent Text Reader

Abstract

The invention provides a pulse position compensation method and device of an encoder and a storage medium. The pulse position compensation method comprises the steps of periodically obtaining a pulse signal value of the encoder; subtracting the pulse signal value of the previous period from the pulse signal value of the current period in the process of acquiring the pulse signal in any period after the starting period to obtain an actual pulse increment value of the current period; acquiring a rotating speed value in the previous period, and determining a theoretical pulse increment value in the current period according to the rotating speed value; subtracting the theoretical pulse increment value from the actual pulse increment value to obtain a pulse increment error value in the current period; if the pulse increment error value is smaller than a first threshold value, determining a pulse compensation position in the current period according to an actual pulse increment value in the current period and a pulse signal value in the previous period; and if the pulse increment error value is greater than or equal to a first threshold value, determining a pulse compensation position in the current period according to a theoretical pulse increment value, thereby enhancing the signal fidelity and control precision of the encoder under strong interference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electrical automation technology, and in particular to a pulse position compensation method, device and storage medium for an encoder. Background Technology

[0002] As the core feedback element of a servo system, the accuracy of the encoder's output signal directly determines the position accuracy, response speed, and system stability of the servo control. In practical industrial applications, servo systems are often deployed in harsh environments with strong electromagnetic interference, such as high radiation and high-power frequency converters. The pulse communication between the encoder and the driver is highly susceptible to noise interference, leading to signal distortion or momentary loss, which can cause control abnormalities or even safety accidents.

[0003] Existing technical solutions mostly focus on hardware-level filtering and physical shielding to reduce the probability of interference reception. However, these methods can only attenuate, not eliminate, interference and cannot actively identify and remove noise at the signal level. Therefore, it is difficult to accurately reconstruct the true position and velocity information from the contaminated signal, and the control accuracy cannot be fundamentally guaranteed. Therefore, how to actively eliminate transient interference at the signal processing algorithm level and ensure the inherent reliability of the feedback signal has become a key technical challenge for improving the robustness and accuracy of industrial servo systems. Summary of the Invention

[0004] The purpose of this application is to at least solve one of the technical problems existing in the prior art, and to provide a pulse position compensation method, device and storage medium for encoders, which can enhance the signal fidelity and control accuracy of encoders under strong interference without increasing hardware costs.

[0005] To achieve the above objectives, a first aspect of this application proposes a pulse position compensation method for an encoder, characterized by comprising: The encoder's pulse signal value is acquired periodically; The process of acquiring pulse signal values ​​in any period after the initial period includes the following steps: Subtract the pulse signal value of the previous cycle from the pulse signal value of the current cycle to obtain the actual pulse increment value of the current cycle; Obtain the encoder's rotational speed value in the previous cycle, and determine the theoretical pulse increment value for the current cycle based on the rotational speed value; Subtracting the theoretical pulse increment value from the actual pulse increment value yields the pulse increment error value of the encoder in the current cycle. If the pulse increment error value is less than the preset first threshold, the pulse compensation position of the encoder in the current cycle is determined based on the actual pulse increment value of the current cycle and the pulse signal value of the encoder in the previous cycle. Alternatively, if the pulse increment error value is greater than or equal to the first threshold, the pulse compensation position of the encoder in the current cycle is determined based on the theoretical pulse increment value.

[0006] Furthermore, in some embodiments, the pulse compensation position of the encoder in the current cycle is determined based on the actual pulse increment value, the theoretical pulse increment value, and the encoder's pulse signal value in the previous cycle, including: Obtain the actual pulse increment value of the encoder in the previous cycle, and calculate the average value between the actual pulse increment value of the current cycle and the actual pulse increment value of the previous cycle; If the average value is greater than or equal to the second threshold, the sum of the pulse signal value of the encoder in the previous cycle and the average value is used as the pulse compensation position of the encoder in the current cycle. Alternatively, if the average value is less than the second threshold, the sum of the encoder's pulse signal value in the previous cycle and the actual pulse increment value in the current cycle is used as the pulse compensation position of the encoder in the current cycle.

[0007] Furthermore, in some embodiments, the first preset ratio is one-third.

[0008] Furthermore, in some embodiments, determining the encoder's pulse compensation position in the current cycle based on the theoretical pulse increment value includes: Determine the pulse accumulation value of the encoder in the current cycle; If the pulse accumulation value in the current cycle is less than or equal to the second preset ratio of the encoder's pulse resolution, then the sum of the theoretical pulse increment value and the pulse accumulation value in the current cycle will be used as the pulse compensation position of the encoder in the current cycle. Alternatively, if the pulse accumulation value in the current cycle is greater than the second preset ratio of the pulse resolution, the encoder is controlled to stop working and generate fault information; The pulse resolution is the minimum physical displacement value actually generated by the pulse signal.

[0009] Furthermore, in some embodiments, the second preset ratio is one-half.

[0010] Furthermore, in some embodiments, determining the pulse accumulation value of the encoder in the current cycle includes: Determine the pulse accumulation value of the encoder in the previous cycle; The sum of the pulse accumulation value of the encoder in the previous cycle and the theoretical pulse increment value in the current cycle is used as the pulse accumulation value of the encoder in the current cycle.

[0011] Furthermore, in some embodiments, the initial cycle includes the following steps: Set the pulse accumulation value in the initial cycle to zero.

[0012] Furthermore, in some embodiments, in any cycle after the initial cycle, the following steps are also included: If the pulse increment error value is less than the first threshold, the pulse accumulation value in the current cycle is set to zero.

[0013] To achieve the above objectives, a second aspect of the present application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the encoder pulse position compensation method of the first aspect embodiment described above.

[0014] To achieve the above objectives, a third aspect of the present application provides a storage medium, which is a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the encoder pulse position compensation method of the first aspect embodiment described above.

[0015] According to an embodiment of this application, an encoder pulse position compensation method, device, and storage medium have at least the following beneficial effects: By periodically calculating the actual pulse increment and the theoretical pulse increment based on the rotational speed of the previous cycle, and comparing the error between the two, abnormal signals such as pulse jumps or loss caused by instantaneous strong interference can be intelligently identified. When the error is less than a threshold, accurate compensation is performed based on the actual pulse increment value of the current cycle; when the error exceeds the threshold and is determined to be severe interference, unreliable actual pulse increment values ​​are isolated, and the current position is directly recursively calculated using smooth theoretical increment values. This decision-making mechanism fundamentally realizes the "cutting off" and "repairing" of sudden, high-amplitude interference signals, rather than the traditional passive attenuation, thereby ensuring the intrinsic reliability of feedback information at the signal level. Secondly, through real-time diagnosis and compensation of pulse position, the continuity, accuracy, and smoothness of the position feedback signal are ensured, thereby ensuring the high-precision and stable operation of the servo system and avoiding control instability and potential accidents caused by signal interruption or distortion. Furthermore, this method is based on the inherent periodic sampling and control structure of the servo system, has low computational complexity, does not require changes to the hardware circuit or additional costs, is easy to integrate on existing driver platforms, and has good versatility and engineering applicability.

[0016] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the description and the accompanying drawings. Attached Figure Description

[0017] The accompanying drawings are used to provide a further understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.

[0018] The present application will be further described below with reference to the accompanying drawings and embodiments; Figure 1 This is an optional flowchart provided in this application embodiment for the process of acquiring a pulse signal in any period after the initial period; Figure 2 This is a schematic diagram of an optional waveform of the pulse signal value of the encoder without pulse position compensation provided in the embodiments of this application; Figure 3 This is a schematic diagram of an optional waveform of the pulse signal value for pulse position compensation by the encoder provided in this application embodiment; Figure 4 This is provided by the embodiments of this application. Figure 1 An optional flowchart for step S104; Figure 5 This is provided by the embodiments of this application. Figure 1 An optional flowchart for step S105; Figure 6 This is provided by the embodiments of this application. Figure 5 An optional flowchart for step S301; Figure 7 This is a schematic diagram of an optional hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] This section will describe in detail the specific embodiments of this application. Preferred embodiments of this application are shown in the accompanying drawings. The purpose of the drawings is to supplement the textual description with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of this application, but they should not be construed as limiting the scope of protection of this application.

[0020] In the description of this application, the use of "first" and "second" is for the purpose of distinguishing technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of indicated technical features or the order of the indicated technical features. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0021] In the description of this application, unless otherwise expressly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.

[0022] As the core feedback element of a servo system, the accuracy of the encoder's output signal directly determines the position accuracy, response speed, and system stability of the servo control. In practical industrial applications, servo systems are often deployed in harsh environments with strong electromagnetic interference, such as high radiation and high-power frequency converters. The pulse communication between the encoder and the driver is highly susceptible to noise interference, leading to signal distortion or momentary loss, which can cause control abnormalities or even safety accidents.

[0023] Existing technical solutions mostly focus on hardware-level filtering and physical shielding to reduce the probability of interference reception. However, these methods can only attenuate, not eliminate, interference and cannot actively identify and remove noise at the signal level. Therefore, it is difficult to accurately reconstruct the true position and velocity information from the contaminated signal, and the control accuracy cannot be fundamentally guaranteed. Therefore, how to actively eliminate transient interference at the signal processing algorithm level and ensure the inherent reliability of the feedback signal has become a key technical challenge for improving the robustness and accuracy of industrial servo systems.

[0024] Based on this, embodiments of this application provide a pulse position compensation method, device, and storage medium for an encoder. By automatically acquiring the total stroke of the motor rotation, the process of manually inputting parameters is eliminated, improving debugging efficiency. At the same time, it avoids problems such as parameter input errors, machining deviations, and additional limit switches, and prevents the valve core from getting stuck during normal operation, thereby improving the reliability of the electrically adjustable valve.

[0025] Therefore, the embodiments of this application will be further described below with reference to the accompanying drawings.

[0026] In the process of encoder pulse position compensation, it is necessary to periodically acquire the encoder pulse signal value, referring to... Figure 1 As shown, Figure 1 This is an optional flowchart of the process of acquiring a pulse signal in any period after the start period provided in the embodiments of this application. The method may include, but is not limited to, steps S101 to S105.

[0027] Step S101: Subtract the pulse signal value of the previous cycle from the pulse signal value of the current cycle to obtain the actual pulse increment value of the current cycle.

[0028] Specifically, based on the pulse signal fed back by the encoder, the system reads and records the pulse signal value in each sampling cycle. In each sampling cycle after the initial cycle, the pulse signal value Enc read in the current sampling cycle is subtracted from the pulse signal value Pos recorded in the previous sampling cycle; the difference is the actual pulse increment value Inc = Enc - Pos for the current cycle. This actual pulse increment value directly reflects the change in the number of original pulses corresponding to the mechanical position change detected by the encoder during two adjacent sampling cycles. This value serves as the basis for subsequent comparison and analysis with theoretical values, used to assess whether the pulse signal is subject to transient interference during transmission.

[0029] Step S102: Obtain the encoder's rotational speed value in the previous cycle, and determine the theoretical pulse increment value for the current cycle based on the rotational speed value.

[0030] It is worth noting that the encoder's rotational speed value in the previous cycle is obtained by reading the rotational speed data stored at the end of the previous cycle. This rotational speed data is obtained from the pulse signal of the previous cycle through speed calculation and filtering. Based on this rotational speed value, the theoretical pulse increment value Inc1 for the current cycle is determined. The specific process is as follows: the rotational speed value of the previous cycle is multiplied by the system's fixed sampling period time to obtain the theoretical angular displacement or linear displacement change, and then multiplied by the number of pulses per encoder revolution or the equivalent pulse per unit displacement to calculate the theoretical pulse increment value Inc1. The theoretical pulse increment value Inc1 represents the predicted change in the number of pulses that should be generated in the current sampling period under the assumption of continuous and smooth motion, providing a reference benchmark for subsequent error analysis.

[0031] Step S103: Subtract the theoretical pulse increment value from the actual pulse increment value to obtain the pulse increment error value of the encoder in the current cycle.

[0032] After obtaining the actual pulse increment value Inc and the theoretical pulse increment value Inc1 for the current cycle, the actual pulse increment value Inc1 is subtracted from the theoretical pulse increment value Inc1. The result is the pulse increment error value ΔA of the encoder in the current cycle: ΔA = Inc - Inc1. This pulse increment error value ΔA quantitatively characterizes the degree of deviation between the measured displacement change and the displacement change predicted based on the stable speed of the previous cycle. This deviation is mainly caused by instantaneous noise interference or signal loss during the transmission and acquisition of the pulse signal. Its magnitude directly reflects the severity of signal interference in the current cycle, providing a crucial basis for subsequent judgment on whether to enable compensation logic and which compensation path to select.

[0033] Step S104: If the pulse increment error value is less than the preset first threshold, then the pulse compensation position of the encoder in the current cycle is determined based on the actual pulse increment value of the current cycle and the pulse signal value of the encoder in the previous cycle.

[0034] Specifically, if the absolute value of the pulse increment error ΔA is less than the preset first threshold Amax, it indicates that the interference on the pulse signal in the current cycle is relatively small, and the measured data is basically reliable. At this time, the system reads the pulse signal value calculated and stored by the encoder at the end of the previous cycle. This pulse signal value represents the cumulative absolute position up to the previous sampling time. Subsequently, the actual pulse increment value obtained in the current cycle is compensated with the pulse position value of the previous cycle. The result of the compensation process is updated and recorded as the pulse compensation position of the encoder in the current cycle. This method fully utilizes the reliability of the actual measured value under conditions without severe interference, and achieves continuous position updates through compensation processing. While ensuring the real-time dynamic response, it effectively suppresses the cumulative drift introduced by random noise, ensuring the accuracy and continuity of the position feedback signal.

[0035] Step S105: Alternatively, if the pulse increment error value is greater than or equal to the first threshold, then determine the pulse compensation position of the encoder in the current cycle based on the theoretical pulse increment value.

[0036] Specifically, if the pulse increment error value ΔA is greater than or equal to the first threshold Amax, it indicates that the encoder pulse signal is subjected to strong instantaneous interference in the current cycle, and the actual pulse increment value in the current cycle is severely distorted and cannot be directly used. At this time, the system initiates anti-interference compensation logic to determine the encoder's pulse compensation position in the current cycle. This method first reads the pulse position value stored by the encoder at the end of the previous cycle, using this as a continuous reference for position calculation. Subsequently, the system discards the unreliable actual pulse increment value of the current cycle and instead uses the theoretical pulse increment value obtained based on the steady speed prediction of the previous cycle. Compensation is performed based on the theoretical pulse increment value to determine the encoder's pulse compensation position in the current cycle. This process, by completely relying on the continuous prediction of the internal motion model to replace the interfered external measurement, effectively isolates the impact of sudden interference on the position feedback loop, thereby ensuring the continuity of the position signal evolution and the smoothness of the trajectory under extreme interference conditions, and avoiding positioning jumps or control instability caused by erroneous pulses.

[0037] In steps S101 to S105, by periodically calculating the actual pulse increment and the theoretical pulse increment based on the rotational speed of the previous cycle, and comparing the error between the two, abnormal signals such as pulse jumps or loss caused by instantaneous strong interference can be intelligently identified. When the error is less than a threshold, accurate compensation is performed based on the actual pulse increment value of the current cycle; when the error exceeds the threshold and is determined to be severe interference, unreliable actual pulse increment values ​​are isolated, and the current position is directly recursively calculated using smooth theoretical increment values. This decision-making mechanism fundamentally achieves the "cutting off" and "repairing" of sudden, high-amplitude interference signals, rather than the traditional passive attenuation, thereby ensuring the intrinsic reliability of feedback information at the signal level. Secondly, through real-time diagnosis and compensation of pulse position, the continuity, accuracy, and smoothness of the position feedback signal are ensured, thereby ensuring the high-precision and stable operation of the servo system and avoiding control instability and potential accidents caused by signal interruption or distortion. In addition, this method is based on the inherent periodic sampling and control structure of the servo system, has low computational complexity, does not require changes to hardware circuits or additional costs, is easy to integrate on existing driver platforms, and has good versatility and engineering applicability.

[0038] In a preferred embodiment, refer to Figure 2 and Figure 3 As shown, Figure 2 This is a schematic diagram of an optional waveform of the pulse signal value of the encoder without pulse position compensation provided in the embodiments of this application. Figure 3 This is a schematic diagram of an optional waveform of the pulse signal value for pulse position compensation of the encoder provided in this application embodiment, compared with... Figure 2 and Figure 3The pulse position compensation method of the encoder in this application embodiment ensures the continuity, accuracy and smoothness of the encoder's pulse compensation position signal.

[0039] Furthermore, refer to Figure 4 As shown, Figure 4 This is provided by the embodiments of this application. Figure 1 An optional flowchart for step S104, the method may include, but is not limited to, steps S201 to S203.

[0040] Step S201: Obtain the actual pulse increment value of the encoder in the previous cycle, and calculate the average value between the actual pulse increment value of the current cycle and the actual pulse increment value of the previous cycle.

[0041] Specifically, the actual pulse increment value LastInc of the encoder in the previous cycle is obtained. Then, the actual pulse increment value Inc of the current cycle is arithmetically averaged with the actual pulse increment value LastInc of the previous cycle, i.e., the sum of the two is divided by two, thus obtaining the average actual pulse increment value of two adjacent cycles, 1 / 2(Inc+LastInc). This average value integrates the displacement change information of two consecutive sampling cycles, which can effectively smooth out the sudden changes in pulse increment in a single cycle caused by random noise or instantaneous disturbances, and enhance the anti-interference ability of the data.

[0042] It should be noted that the actual pulse increment value LastInc of the previous cycle is obtained by subtracting the pulse signal value recorded in the previous sampling cycle (i.e., the cycle before that) from the pulse signal value recorded in the previous sampling cycle. The difference between the two is the actual pulse increment value of the previous cycle. If the previous cycle is the starting cycle, then the actual pulse increment value LastInc of the previous cycle is zero.

[0043] Step S202: If the average value is greater than or equal to the second threshold, the sum of the pulse signal value of the encoder in the previous cycle and the average value is used as the pulse compensation position of the encoder in the current cycle.

[0044] Specifically, when the calculated average value 1 / 2(Inc+LastInc) is greater than or equal to a preset second threshold, it indicates that the average actual pulse increment of two consecutive cycles reflects a significant and consistent displacement change trend, and the data reliability is high. At this time, the system adopts a direct accumulation strategy based on this average value to determine the pulse compensation position of the encoder in the current cycle. The specific process is as follows: First, the pulse signal value Pos calculated and stored by the encoder at the end of the previous cycle is read, and this pulse signal value Pos is used as the reference for position accumulation. Then, the pulse signal value Pos of the previous cycle is algebraically added to the aforementioned calculated average value 1 / 2(Inc+LastInc), and the resulting sum Pos+1 / 2(Inc+LastInc) is updated and recorded as the pulse compensation position of the encoder in the current cycle Enc'=Pos+1 / 2(Inc+LastInc). This method uses the smoothed multi-cycle incremental average to replace the potentially disturbed single-cycle measured value. Under the premise of confirming the reliability of the displacement change trend, it realizes the continuous update of position information through accumulation calculation, thereby further suppressing the instantaneous impact of random interference and ensuring the smoothness and accuracy of the position signal in the dynamic change process.

[0045] Step S203: Alternatively, if the average value is less than the second threshold, the sum of the encoder's pulse signal value in the previous cycle and the actual pulse increment value in the current cycle shall be used as the pulse compensation position of the encoder in the current cycle.

[0046] Specifically, when the calculated average value 1 / 2 (Inc + LastInc) is less than a preset second threshold, it indicates that the average actual pulse increment over two consecutive cycles reflects a weak displacement change or is near a specific steady state. At this point, the system employs a compensation strategy based on the original signal value to determine the encoder's pulse compensation position in the current cycle. Specifically, the pulse signal value Pos recorded by the encoder during the previous cycle's sampling is first acquired and read. Then, the pulse signal value Pos from the previous cycle is algebraically added to the actual pulse increment value Inc calculated for the current cycle. The result of this summation is defined as the encoder's pulse compensation position Enc' = Pos + Inc in the current cycle. This method, when detecting a small displacement change, uses superposition compensation by tracing back to the original pulse reference of the previous cycle. This aims to avoid computational uncertainties or quantization errors that may be introduced due to excessively small average increments under low-speed or near-steady-state conditions, thereby ensuring that the position feedback remains accurate and continuous in various dynamic scenarios.

[0047] The second threshold is a first preset ratio of the first threshold Amax. In a preferred embodiment, the first preset ratio is one-third, that is, the second threshold is 1 / 3 Amax.

[0048] In steps S201 to S203, adaptive and refined compensation of the encoder pulse position is achieved by calculating the average value of the actual pulse increment over two consecutive cycles and applying a threshold judgment to this average value. When the average value is greater than or equal to the second threshold, the position is updated using the smoothed average increment, effectively suppressing random disturbances in the single-cycle pulse signal and enhancing the stability and anti-interference capability of the position evolution. When the average value is less than the second threshold, the system switches to a direct accumulation mode based on the original pulse signal value of the previous cycle and the current actual increment. This mode avoids over-smoothing of weak and effective signals under conditions of small displacement changes, ensuring the tracking accuracy and response capability of the system for low-speed or fine motion. Overall, this method dynamically optimizes the position compensation path through the intelligent fusion of dual threshold criteria and multiple data sources, significantly improving the position feedback accuracy, smoothness, and overall robustness of the servo system in the full speed domain and complex interference environments.

[0049] Furthermore, refer to Figure 5 As shown, Figure 5 This is provided by the embodiments of this application. Figure 1 An optional flowchart for step S105, the method may include, but is not limited to, steps S301 to S303.

[0050] Step S301: Determine the pulse accumulation value of the encoder in the current cycle.

[0051] Step S302: If the pulse accumulation value in the current cycle is less than or equal to the second preset ratio of the encoder's pulse resolution, then the sum of the theoretical pulse increment value and the pulse accumulation value in the current cycle is used as the pulse compensation position of the encoder in the current cycle.

[0052] Pulse resolution is the minimum physical displacement value actually generated by a pulse signal. It is defined as the minimum displacement that the controlled object can generate or detect in physical space corresponding to a single pulse signal. This parameter establishes the conversion relationship between pulse count values ​​and actual physical displacement. Its value depends on the number of pulses output per revolution of the encoder and the specific parameters of the mechanical transmission system (such as the lead screw or the transmission ratio between the rotary shaft and the linear motion). Pulse resolution determines the smallest displacement unit that the system can theoretically distinguish and position, and is the benchmark scale for high-precision position control and calculation.

[0053] Specifically, if the pulse accumulation value SumInc in the current cycle is less than or equal to the value SumMax obtained by multiplying the encoder pulse resolution by a pre-set second proportional coefficient (i.e., the second preset ratio), it indicates that the accumulated pulse displacement since a certain reference time is extremely small and has not yet reached a significant physical displacement level. In this case, the system adopts a motion model-based compensation strategy to determine the encoder's pulse compensation position in the current cycle. Specifically, firstly, the theoretical pulse increment value Inc1 for the current cycle, calculated based on the rotational speed of the previous cycle, is obtained. Then, the pulse accumulation value SumInc in the current cycle is algebraically added to the theoretical pulse increment value Inc1. The result of this summation is defined as the encoder's pulse compensation position Enc' = SumInc + Inc1 in the current cycle. This method prioritizes the use of theoretical increments derived from a continuous and smooth rotational speed model for position recursion when the cumulative displacement is very small. This aims to avoid non-physical jitter or jumps in the measured pulse signal due to noise or quantization errors at extremely low displacement levels, thereby ensuring the smoothness and accuracy of position feedback during micro-motion or approaching steady state.

[0054] In a preferred embodiment, the second preset ratio is one-half.

[0055] Step S303: Alternatively, if the pulse accumulation value in the current cycle is greater than the second preset ratio of the pulse resolution, control the encoder to stop working and generate fault information.

[0056] When the pulse accumulation value in the current cycle exceeds the product of the pulse resolution and the second preset ratio, it indicates that the accumulated pulse displacement since the reference time has significantly exceeded the reasonable boundary under normal operating conditions. The system determines that the encoder feedback signal has experienced a continuous abnormality or that the mechanical position has deviated uncontrollably. At this time, the control system immediately executes protective actions: on the one hand, it sends a stop command to the encoder, cutting off the pulse communication or enable signal between the encoder and the servo driver, causing the encoder to pause feedback output; on the other hand, the system internally generates a fault code containing information such as the fault type, timestamp, and current pulse accumulation value, and uploads the fault information to the upper-level monitoring system or stores it in the local fault record area. This mechanism, when detecting that the position accumulation exceeds the safety threshold, effectively prevents equipment damage and safety accidents caused by encoder failure or position runaway by actively cutting off the signal source and generating an alarm record, while providing a referable diagnostic basis for subsequent maintenance and fault tracing.

[0057] In steps S301 to S302, the system dynamically detects the pulse accumulation value of the encoder in the current cycle and compares it with the safety threshold defined by the pulse resolution, thus constructing a dual mechanism that combines fine compensation and active protection. When the pulse accumulation value is within the normal range of less than or equal to the second preset ratio, the system uses the theoretical pulse increment value to recursively compensate the current accumulation value, ensuring the continuity and smoothness of position feedback under small displacement or low-speed conditions, and effectively suppressing the adverse effects of quantization error and random noise on position accuracy. When the pulse accumulation value exceeds the safety boundary represented by the second preset ratio, the system immediately determines it to be an abnormal accumulation state, actively executes encoder shutdown and generates fault information, thereby achieving rapid isolation and alarm before the position deviation expands to an uncontrollable level.

[0058] Furthermore, refer to Figure 6 As shown, Figure 6 This is provided by the embodiments of this application. Figure 5 An optional flowchart for step S301, the method may include, but is not limited to, steps S401 to S403.

[0059] Step S401: Determine the pulse accumulation value of the encoder in the previous cycle.

[0060] Step S402: The sum of the pulse accumulation value of the encoder in the previous cycle and the theoretical pulse increment value in the current cycle is used as the pulse accumulation value of the encoder in the current cycle.

[0061] When determining the encoder's pulse accumulation value for the current cycle, the system first retrieves the pulse accumulation value stored at the end of the previous cycle. This value is a pulse position reference formed by successively accumulating reliable incremental data from each cycle, representing the cumulative displacement detected by the encoder up to the previous sampling time. Subsequently, the system obtains the theoretical pulse increment value Inc1 calculated for the current cycle based on the rotational speed value of the previous cycle and the fixed sampling period. The pulse accumulation value from the previous cycle is algebraically added to the theoretical pulse increment value for the current cycle, and the resulting sum is updated and stored as the encoder's pulse accumulation value for the current cycle.

[0062] Furthermore, the process of acquiring pulse signal values ​​during the initial cycle includes the following steps: setting the accumulated pulse value in the initial cycle to zero. Specifically, during the acquisition of pulse signal values ​​in the initial cycle, the system performs an initialization operation, setting the accumulated pulse value in the initial cycle to zero. This step aims to establish a clear absolute reference base for encoder position calculation. Since the communication link between the encoder and the controller has not yet established historical position data when the servo system is powered on, the accumulated pulse value is in an undefined state. By forcibly setting the accumulated pulse value in the initial cycle to zero, the position uncertainty at the initial moment is eliminated, allowing the accumulated pulse value in subsequent cycles to be incrementally accumulated using this as the zero-point reference. This zero-value setting does not depend on any historical sampling data; it only serves as the logical starting point for position accumulation calculation, ensuring the continuity and traceability of the pulse position sequence on the time axis.

[0063] Furthermore, in some embodiments, the process of acquiring pulse signal values ​​in any cycle after the initial cycle includes the following step: if the pulse increment error value is less than a first threshold, the pulse accumulation value in the current cycle is set to zero. Specifically, in any cycle after the initial cycle, if the pulse increment error value is less than the first threshold, it indicates that the encoder pulse signal in the current cycle is subject to minimal interference, the measured data is highly reliable, and the mechanical position may have moved to near the preset physical reference point or zero position marker. At this time, the system performs a pulse accumulation value reset operation, forcibly setting the pulse accumulation value in the current cycle to zero. This step is not the first zeroing during the initialization phase, but rather an active calibration of the position accumulation reference using a high signal-to-noise ratio sampling window during continuous operation. By establishing the highly reliable current moment as the new zero-point reference, the pulse accumulation value drift caused by long-term cumulative calculation, quantization errors, or minor disturbances can be effectively eliminated, ensuring the accuracy and consistency of the position reference throughout the system's entire lifecycle. The reset zero value will serve as the update starting point for pulse accumulation calculations in subsequent cycles.

[0064] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned encoder pulse position compensation method. This electronic device can be any smart terminal, including mobile phones, tablets, and in-vehicle computers.

[0065] Please see Figure 7 , Figure 7 This is a schematic diagram of an optional hardware structure of an electronic device provided in an embodiment of this application. The electronic device includes: The processor 701 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the encoder pulse position compensation method provided in the embodiments of this application. The memory 702 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 702 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 702 and is called and executed by the processor 701 to execute the encoder pulse position compensation method provided in the embodiments of this application. The input / output interface 703 is used to implement information input and output; The communication interface 704 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 705 transmits information between various components of the device (e.g., processor 701, memory 702, input / output interface 703, and communication interface 704); The processor 701, memory 702, input / output interface 703, and communication interface 704 are connected to each other within the device via bus 705.

[0066] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, provides a pulse position compensation method for an encoder according to this application.

[0067] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0068] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0069] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0070] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0071] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0072] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0073] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0074] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above 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 an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0075] The units described above 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.

[0076] 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.

[0077] 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-accessible 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 multiple 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 programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0078] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A pulse position compensation method for an encoder, characterized in that, include: The encoder's pulse signal value is acquired periodically; The process of acquiring the pulse signal value in any period after the initial period includes the following steps: Subtract the pulse signal value of the previous cycle from the pulse signal value of the current cycle to obtain the actual pulse increment value of the current cycle; Obtain the encoder's rotational speed value in the previous cycle, and determine the theoretical pulse increment value for the current cycle based on the rotational speed value; Subtracting the theoretical pulse increment value from the actual pulse increment value yields the pulse increment error value of the encoder in the current cycle. If the pulse increment error value is less than a preset first threshold, then the pulse compensation position of the encoder in the current cycle is determined based on the actual pulse increment value of the current cycle and the pulse signal value of the encoder in the previous cycle. Alternatively, if the pulse increment error value is greater than or equal to the first threshold, the pulse compensation position of the encoder in the current cycle is determined based on the theoretical pulse increment value.

2. The pulse position compensation method according to claim 1, characterized in that, Determining the pulse compensation position of the encoder in the current cycle based on the actual pulse increment value of the current cycle and the pulse signal value of the encoder in the previous cycle includes: Obtain the actual pulse increment value of the encoder in the previous cycle, and calculate the average value between the actual pulse increment value of the current cycle and the actual pulse increment value of the previous cycle; If the average value is greater than or equal to the second threshold, the sum obtained by adding the pulse signal value of the encoder in the previous cycle to the average value is used as the pulse compensation position of the encoder in the current cycle. Alternatively, if the average value is less than the second threshold, the sum of the pulse signal value of the encoder in the previous cycle and the actual pulse increment value in the current cycle shall be used as the pulse compensation position of the encoder in the current cycle. Wherein, the second threshold is a first preset ratio of the first threshold.

3. The pulse position compensation method according to claim 2, characterized in that, The first preset ratio is one-third.

4. The pulse position compensation method according to claim 1, characterized in that, Determining the pulse compensation position of the encoder in the current cycle based on the theoretical pulse increment value includes: Determine the pulse accumulation value of the encoder in the current cycle; If the pulse accumulation value in the current cycle is less than or equal to the second preset ratio of the pulse resolution of the encoder, then the sum of the theoretical pulse increment value and the pulse accumulation value in the current cycle is used as the pulse compensation position of the encoder in the current cycle. Alternatively, if the pulse accumulation value in the current period is greater than the second preset ratio of the pulse resolution, the encoder is controlled to stop working and generate fault information; Wherein, the pulse resolution is the minimum physical displacement value actually generated by the pulse signal.

5. The pulse position compensation method according to claim 4, characterized in that, The second preset ratio is one-half.

6. The pulse position compensation method according to claim 4, characterized in that, Determining the pulse accumulation value of the encoder in the current period includes: Determine the pulse accumulation value of the encoder in the previous cycle; The sum of the pulse accumulation value of the encoder in the previous cycle and the theoretical pulse increment value in the current cycle is used as the pulse accumulation value of the encoder in the current cycle.

7. The pulse position compensation method according to claim 6, characterized in that, The process of acquiring the pulse signal value during the initial period includes the following steps: Set the pulse accumulation value in the initial period to zero.

8. The pulse position compensation method according to claim 6, characterized in that, The process of acquiring the pulse signal value in any period after the initial period also includes the following steps: If the pulse increment error value is less than the first threshold, the pulse accumulation value in the current period is set to zero.

9. An electronic device, characterized in that, The electronic device is provided with a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the pulse position compensation method of the encoder according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a processor-executable program that, when executed by a processor, implements the pulse position compensation method for the encoder according to any one of claims 1 to 8.