Motor encoder protocol real-time conversion device and minimum delay method
By using nanosecond-level clock sources and phase-locked loop technology, the minimum delay of the encoder protocol real-time conversion device was achieved, solving the problem of position feedback lag in high-precision servo control systems, improving system stability and accuracy, and realizing efficient interconnection between encoders and drivers with different protocols.
Patent Information
- Application Number
- CN202511865295.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-12-11
AI Technical Summary
Existing encoder protocol converters suffer from position feedback lag in high-precision, high-dynamic-response servo control systems. In particular, when processing different protocols, the double communication delay is superimposed, affecting system stability and control accuracy. Furthermore, existing conversion schemes lack adaptive capabilities and solutions with minimal delay.
A nanosecond-level high-precision clock source is used to record the timestamp of the position data. Combined with phase-locked loop technology, position data is periodically read from the encoder. Through interpolation calculation and phase-locked loop synchronization signal, the real-time position reading on the encoder side is synchronized with the driver request, reducing position transmission delay.
It effectively solves the position information delay problem in encoder protocol conversion, improves the stability and accuracy of system control, and realizes high-performance, low-cost interconnection between encoders and drivers from different manufacturers and with different protocols.
Smart Images

Figure CN121283302B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of motor control, and particularly relates to a motor encoder protocol real-time conversion device and a minimum delay method. BACKGROUND
[0002] In a high-precision servo motor system, an encoder is a key position feedback component, and the interface technology between the encoder and a servo driver has experienced multiple development stages. The early non-intelligent incremental A / B quadrature interface has been difficult to meet the high-precision control requirements due to the limited resolution per circle. The semi-intelligent interface developed subsequently combines a slow digital channel and a high-speed SIN / COS analog channel (such as Hiperface, EnDat2.1, etc.), and high-resolution position information is obtained by AD sampling of the analog signal by the driver and calculation of the inverse tangent value. Although the accuracy is improved, the system complexity and anti-interference capability still have limitations. The current mainstream scheme has entered the third stage, that is, a high-speed serial bus protocol based on the RS422 / RS485 physical layer, including synchronous types (such as EnDat2.2, BiSS-C, using clock + data differential lines) and asynchronous types (such as Tamagawa, Nikon, HiperfaceDSL, using only two differential data lines), which can directly transmit high-resolution digital position data, significantly improving the communication efficiency and real-time performance.
[0003] However, due to the fact that various encoder manufacturers generally adopt self-defined proprietary serial port protocols, the protocol types are various and incompatible with each other. If a servo driver needs to support multiple encoder protocols, it will face high hardware adaptation and software development costs, so most manufacturers only support a limited number of mainstream protocols, which seriously limits the flexibility of users in encoder selection. At the same time, different brands or models of encoders have significant price differences under similar performance conditions, and if a low-cost encoder can replace a high-priced encoder through an external protocol conversion device, significant economic benefits will be brought. Under this background, an encoder serial port protocol real-time converter becomes an effective way to solve the compatibility problem.
[0004] But the existing conversion scheme faces a core challenge: serial protocol generally adopts the master-slave communication mechanism of "driver initiates request-encoder responds", and the encoder usually takes a specific edge in the driver request frame (such as 0.5 microseconds after the end of the CF frame or the first clock falling edge) as the position latching moment, while the complete position data needs to be transmitted serially before being received by the driver, which introduces an inherent delay of several microseconds to tens of microseconds. In high dynamic and high precision servo control scenarios, this delay will cause position feedback lag, affecting system stability and control accuracy. Especially when the protocol converter needs to handle two different protocols at the same time, the double communication delay superimposes makes the delay problem more prominent. Although part of the error can be compensated by interpolation, if the time difference between the original sampling and the driver request can be minimized from the mechanism, the compensation error will be fundamentally reduced, and the real-time performance of the system will be improved.
[0005] Although there are a few protocol conversion products on the market at present, they mostly rely on host computer configuration and lack adaptive ability, and there is no technical solution to effectively solve the minimum delay problem. Therefore, there is an urgent need for a serial protocol real-time conversion method that can adapt to the drive cycle, accurately synchronize the sampling time, and achieve the minimum position transmission delay, in order to balance compatibility, economy and high-precision control requirements. SUMMARY
[0006] The present application is directed to the problem of position feedback lag caused by protocol heterogeneity and inherent delay of serial communication in existing serial encoder protocol conversion technology, and proposes a real-time encoder protocol conversion device and a minimum delay method for real-time conversion. This problem is particularly prominent in high-precision and high-dynamic-response servo control systems. Traditional protocol converters usually directly forward historical sampling position values without compensating or optimizing the effective delay in the transmission process, resulting in a non-negligible phase lag in the control loop, which affects system stability and positioning accuracy.
[0007] To achieve the above-mentioned purpose, the present application provides a minimum delay method for real-time conversion of motor encoder protocol, which is executed in a protocol converter and includes the following steps:
[0008] Periodically read the position data of the encoder from the second encoder protocol interface, and record the time stamp when each reading is completed and the corresponding position value ;
[0009] According to the position values and their time stamps of the two consecutive readings, calculate the real-time speed of the motor ;
[0010] When a position reading request from a servo driver is received from the first encoder protocol interface, record the time when the request arrives ;
[0011] based on the latest position value , the corresponding time stamp and the real-time speed , the compensated real-time position value is calculated by interpolation ;
[0012] The real-time position value is returned to the servo driver through the first encoder protocol interface.
[0013] Further, the interpolation calculation formula is:
[0014] .
[0015] Further, the calculation formula of the real-time speed is:
[0016] ;
[0017] Wherein, (t , ) is the time stamp and position value of the last reading immediately before this reading.
[0018] Further, the trigger timing of the periodic reading of the encoder position data from the second encoder protocol interface is controlled by a phase-locked loop;
[0019] The phase-locked loop takes the arrival time of the position reading request of the servo driver as the reference signal, locks its frequency and phase, and outputs a phase-shifted synchronization signal;
[0020] The synchronization signal is used to trigger the above-mentioned periodic reading operation, so that the time interval between the completion time t T1 of the periodic reading operation and the arrival time of the next position reading request of the servo driver is minimized.
[0021] Further, the synchronization signal makes the above-mentioned periodic reading operation just get the latest encoder position (t T1 , P T1 ), and the arrival time of the next position reading request of the servo driver arrives immediately.
[0022] Further, it further includes the step of displaying the working state of the phase-locked loop through an indicator light:
[0023] When the phase-locked loop has not converged, the indicator light displays in a first mode;
[0024] When the phase-locked loop has been locked, the indicator light displays in a second mode;
[0025] When the error state is detected, the indicator light displays in a third mode.
[0026] Further, the time stamp is provided by a nanosecond-level precision clock source local to the converter.
[0027] Another object of the present application is to provide an encoder protocol real-time conversion device, comprising:
[0028] a microprocessor;
[0029] a first physical interface circuit for connecting a servo driver;
[0030] a second physical interface circuit for connecting an encoder;
[0031] a clock source;
[0032] a memory having a computer program stored thereon, the program being executed by the microprocessor to implement the method as described above.
[0033] Compared with the prior art, the motor encoder protocol real-time conversion device and the minimum delay method have the beneficial effects that the core technical problem of position information delay in encoder protocol conversion is effectively solved, and significant technical effects are achieved.
[0034] Specifically, the present application lays the foundation for accurate calculation by introducing a nanosecond-level high-precision clock to stamp accurate time stamps on all position sampling and request events. On this basis, a parallel processing architecture combining periodic active reading on the encoder side and event-triggered response on the driver side is created, and the traditional "report past position" mode is innovated to the "predict and report current position" mode by using the interpolation compensation algorithm of "latest position value + real-time speed x time difference", thereby fundamentally compensating for the inherent transmission delay of serial communication.
[0035] Especially crucial is that, to minimize the basic delay relied on by interpolation calculation itself, the present application innovatively introduces a phase-locked loop technology. The phase-locked loop takes the driver request period as a reference signal, dynamically adjusts and synchronizes the reading trigger timing on the encoder side, so that the latest data reading action of the encoder is always completed immediately before the next request of the driver. This ingenious timing arrangement ensures that the "basic position data" used for interpolation calculation always remains the freshest, so that the core delay parameter ( ) is stably compressed from the maximum possible value (close to one control period) to the minimum value (close to pure data transmission time).
[0036] Finally, the comprehensive application of the above technical means enables the protocol converter of the present application to provide a servo driver with a position feedback with extremely low delay and extremely high precision. This effectively solves the pain point of introducing additional control delay in high-precision and high-dynamic-response servo applications due to the use of a protocol converter, realizes high-performance, low-cost flexible interconnection between encoders and drivers of different manufacturers and different protocols, and at the same time guarantees the stability and accuracy of system control. BRIEF DESCRIPTION OF DRAWINGS
[0037] Figure 1 An application block diagram of the converter in the embodiment of the present application;
[0038] Figure 2 A system block diagram of the converter in the embodiment of the present application;
[0039] Figure 3 A principle schematic diagram of the encoder protocol real-time conversion method in the embodiment of the present application;
[0040] Figure 4 A principle schematic diagram of the encoder protocol real-time conversion method in the embodiment of the present application after adding a phase-locked loop. DETAILED DESCRIPTION
[0041] Embodiment one:
[0042] The present application will be described in detail below in combination with the drawings and examples.
[0043] Please refer to Figures 1-2 The present embodiment is an encoder protocol real-time conversion device 100 (hereinafter referred to as the converter 100), which is used to receive the first protocol (for example, B protocol or C protocol) content issued by the encoder 200 at the servo motor end, and convert it into second protocol (for example, A protocol) content and send it to the servo driver 300.
[0044] An encoder protocol real-time conversion device 100 includes:
[0045] A microprocessor unit 1 for performing protocol analysis, data calculation and control logic; wherein real-time position and timestamp sampling is realized by programmable logic hardware built-in the processor;
[0046] A first physical interface circuit 2 for connecting and complying with the first protocol (hereinafter referred to as A protocol) to communicate with the servo driver 300;
[0047] A second physical interface circuit 3 for connecting and complying with the second protocol (hereinafter referred to as B protocol) to communicate with the encoder 200;
[0048] A high-resolution clock source 4 with nanosecond-level precision provides a unified timestamp for the system.
[0049] The servo driver 300 drives the servo motor 400, which has an internal B-protocol encoder. However, the encoder feedback interface of the servo driver 300 is an A-protocol interface. Therefore, the converter 100 of this embodiment is needed for protocol conversion. The converter 100 of this embodiment can cover protocol conversion for all similar synchronous and asynchronous serial encoders. The encoder 200 includes, but is not limited to, synchronous and asynchronous serial encoders from Tamagawa, EnDat, Biss-C, SSI, HiperfaceDSL, Nikon, etc. This solution only involves the core real-time position reading function conversion algorithm; other functions with lower real-time requirements, such as EEPROM read / write, status reading, and parameter setting, can be handled with general processing.
[0050] For Protocol B, the real-time position latch sampling point is 0.5µs after the end of the CF frame from the servo driver to the encoder 200. The position information transmitted after serial communication is already tens of microseconds old, therefore compensation is necessary to obtain the current accurate position. Similarly, for Protocol A, the real-time position latch sampling point is at the first falling edge of the clock signal sent from the servo driver to the encoder. In this embodiment, the position information obtained from the encoder 200 by the converter 100 is adaptively compensated in real-time to obtain more accurate position information, which is then sent to the servo driver 300 via the Protocol A channel.
[0051] The converter 100 uses the B protocol on the encoder side to achieve the fastest encoder sampling period. Periodically read real-time location information from encoder 200 (For example (It is a 50-microsecond cycle), when converter 100 uses the A protocol to control the driver cycle. When receiving a read position request from the servo driver side, the latest encoder position value will be... Assigned This information is then transmitted to the servo driver 300. This method may be suitable for applications where the real-time requirements of position control are not very high, but it cannot meet the needs of applications with higher real-time accuracy requirements for position control.
[0052] In this embodiment, a clock source 4 with nanosecond-level precision is set up to record the real-time position sampling latch time. The converter 100 on the encoder side will use the fastest encoder sampling period. Periodically read real-time location information from the encoder (e.g.) (It is a 50-microsecond cycle), making The most recent position sampling latch time read by converter 100 from the encoder. It corresponds The position count value sampled at each time point, , is the encoder's last sampling time and position value. Each encoder sampling period T T The real-time velocity V1 is updated according to (Formula 1):
[0053] , (Formula 1)
[0054] When the converter 100 is driven by the driver control period When receiving the read position request, the sampling time t E is recorded and the sampling time t is calculated by interpolation according to (Formula 2): :
[0055] , (Formula 2)
[0056] Wherein, .
[0057] Obviously, the smaller the real-time position sampling delay is, the better, especially for high-precision and high-dynamic response applications. Although the real-time position delay of the serial protocol encoder is inevitable, it can only be compensated by interpolation. However, if the position delay can be reduced as much as possible, the interpolation error can be reduced to a certain extent. Please refer to the conversion method of Figure 3 (assuming that the driver control period and the encoder sampling period are the same), the maximum delay is that after the servo driver side just samples the position to get the latest position signal , ), the converter 100 immediately samples the encoder position , ), at this time the compensation delay is about the sum of the encoder sampling period (or ) and the encoder data transmission delay time ; for example, for a 2.5M baud rate encoder, if is 50us, then is 2.5us (the time delay from position acquisition to start sending) + 110 (11 bytes * 10 bits) * 0.4us = 46.5us, the maximum delay = 96.5us. The minimum delay is that after the converter 100 just samples the encoder position , ), the received read position request is received, and then the latest , is calculated immediately, at this time the compensation delay (Approximately the encoder data transmission delay time) That is, 46.5us.
[0058] Please refer to Figure 4 , Figure 4 This embodiment describes in detail how it further achieves minimum position delay conversion. This embodiment adds a periodically arriving signal to the delay-compensated real-time conversion method. Phase-locked loop 5, with time as input, locks the driver control cycle. The frequency and phase of the encoder position are used to periodically output the encoder position read trigger signal corresponding to the phase shift, so that the converter 100 just samples the encoder position. , After that, the next cycle Arrive immediately and calculate the latest position value. This arrangement minimizes the location sampling delay.
[0059] Phase-locked loop 5 is equipped with a lock-up status indicator, for example, via a dual-color LED display: red flashes slowly when not converging, and bright green when locked. If an error occurs (e.g., during a driver control cycle), further information is displayed. (When too small) it often turns bright red.
[0060] Assuming the driver-side protocol described in the preceding method is synchronous and the encoder-side protocol is asynchronous, this embodiment's method is also applicable to cases where the driver-side protocol is asynchronous or the encoder-side protocol is synchronous.
[0061] Example 2:
[0062] This embodiment is a method for real-time conversion of motor encoder protocol with minimal delay. The overall process of this method involves two parallel tasks: encoder-side position reading task and driver-side position response task.
[0063] The encoder-side position reading task is performed at a fixed encoder sampling period. Execution is performed periodically, for example, every 50 microseconds, and the process includes:
[0064] S101. Send a position read request to the encoder and record the response data packet returned by the encoder;
[0065] S102. Parse the position count value corresponding to the position latching time from the response data packet. Simultaneously, the current time is obtained from high-resolution clock source 4 as the latching time for this position sampling. ;
[0066] S103, Based on the position value obtained from the previous sampling and latching time Calculate real-time speed ; then, using ( , Update overwrite the old one. , This prepares for the next real-time speed calculation.
[0067] The driver-side position response task is triggered by an A protocol position read request issued by the servo driver, and its cycle is the driver control cycle. The process includes:
[0068] S201. When the converter receives a position read request from the servo driver, record the receiving time. ;
[0069] S202, Perform real-time position interpolation calculation: Based on the latest encoder position sampling data ( , ) and real-time speed The current position after compensation is calculated. And use it as the real-time position value of the driver, the compensated current position. The calculation formula is as follows:
[0070] ;
[0071] S203, the calculated result Pack the data according to the frame format of the A protocol and send it to the servo driver.
[0072] To minimize the position sampling delay ( Based on the above basic process, this embodiment introduces phase-locked loop control, which includes the following steps:
[0073] Step S301: After system initialization, a phase-locked loop 5 is started, which responds to the triggering time of the task at the position on the driver side. As a periodic reference signal;
[0074] Step S302: Phase-Locked Loop 5 Analysis The frequency and phase of the signal are determined, and a synchronized output signal is generated. The phase of the output signal is adjusted to a set state, which is the moment in step S101 when the position read request is sent to the encoder (i.e., the trigger moment of the encoder-side position read task), so that the converter has just sampled the encoder position (t). T1 ,P T1 The arrival time t of the next servo drive position read request. E It arrived shortly afterward.
[0075] Step S303: The output signal of the phase-locked loop is used as a trigger signal to start the position reading task on the encoder side.
[0076] By the above arrangement, it can be ensured that in most cases, a new encoder position sampling (obtained 、 ) is just completed, and the next position request of the driver (time ) arrives immediately. This makes the delay in interpolation calculation ( ) tend to a minimum, and the theoretical delay mainly includes the encoder data transmission delay , thereby significantly reducing the interpolation error.
[0077] By using the serial protocol encoder real-time converter of the method of the application, real-time interconnection between various types of encoder serial protocol is conveniently and quickly realized, and application flexibility and economic value are brought to users.
[0078] The above only describes the embodiments of the application, and does not limit the patent scope of the application, and any equivalent structure or equivalent process transformation using the content of the specification and drawings, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the application.
Claims
1. A method for minimizing delay in real-time conversion of motor encoder protocols, characterized in that, The method is executed in a protocol converter and includes the following steps: The encoder position data is periodically read from the second encoder protocol interface, and the timestamp of each read completion is recorded. and corresponding position values ; Calculate the motor's real-time speed based on two consecutive position readings and their timestamps. ; When a position read request from the servo drive is received from the first encoder protocol interface, the time of the request's arrival is recorded. ; Based on the latest location value The corresponding timestamp and the real-time speed The compensated real-time position value is obtained through interpolation calculation. ; The real-time location value The response is returned to the servo driver via the first encoder protocol interface; The calculation formula for the interpolation is as follows: ; The real-time speed The calculation formula is: ; in, This is the timestamp and position value of the previous read immediately preceding this read; The triggering timing for periodically reading encoder position data from the second encoder protocol interface is controlled by a phase-locked loop (PLL); the PLL uses the arrival time of the position read request from the servo driver as the triggering time. Using the reference signal as a reference, a synchronization signal with phase offset is output by locking its frequency and phase; The synchronization signal is used to trigger the aforementioned periodic read operation, so that the time when the periodic read operation is completed... The arrival time of the next servo drive position read request Minimize the time interval between them.
2. The method for minimum delay in real-time conversion of motor encoder protocol as described in claim 1, characterized in that, The synchronization signal ensures that the aforementioned periodic read operation has just obtained the latest encoder position. The arrival time of the next servo drive position read request It arrived shortly afterward.
3. The method for minimum delay in real-time conversion of motor encoder protocol as described in claim 1, characterized in that, It also includes the step of displaying the operating status of the phase-locked loop via indicator lights: When the phase-locked loop fails to converge, the indicator light displays in the first mode; When the phase-locked loop is locked, the indicator light displays in the second mode; When an error is detected, the indicator light displays in the third mode.
4. The method for minimum delay in real-time conversion of motor encoder protocol as described in claim 1, characterized in that, The timestamps are provided by a local nanosecond-precision clock source on the converter.
5. A real-time encoder protocol conversion device, characterized in that, It includes: microprocessor; The first physical interface circuit is used to connect the servo driver; The second physical interface circuit is used to connect the encoder; Clock source; A memory having a computer program stored thereon, which, when executed by the microprocessor, implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Automatic learning method and system for servo motor encoder deviation angle
CN104270042A
Absolute value encoder transmission delay compensation method
CN114499335A