Search

CN-121348920-B - Synchronization method and system for servo communication and motor control of EtherCAT bus

CN121348920BCN 121348920 BCN121348920 BCN 121348920BCN-121348920-B

Abstract

The invention discloses a synchronization method of servo communication and motor control of an EtherCAT bus, which comprises the steps of establishing a mapping relation between an auxiliary timer and a control period of a PWM signal generator, mapping a physical synchronization signal Sync0 of the EtherCAT bus to an external trigger source of an input capturing unit, in response to detection of an effective jump edge of the physical synchronization signal Sync0, utilizing the input capturing unit to lock a current instantaneous count value of the auxiliary timer into a capturing register to form a reference time stamp under the condition of no software interrupt intervention, reading the reference time stamp in interrupt service of a servo control period, calculating a phase offset based on the target phase relation between the reference time stamp and the physical synchronization signal Sync0, and dynamically modulating a reloading value of the PWM signal generator in a next control period according to the phase offset.

Inventors

  • JIANG GENGWEI
  • LV JINZHI
  • HUANG JIBO

Assignees

  • 福建富昌维控电子科技股份有限公司

Dates

Publication Date
20260512
Application Date
20251217

Claims (8)

  1. 1. The synchronization method of the servo communication and the motor control of the EtherCAT bus is characterized by comprising the following steps: s1, establishing a mapping relation between an auxiliary timer and a control period of a PWM signal generator, and mapping a physical synchronization signal Sync0 of an EtherCAT bus into an external trigger source of an input capturing unit; s2, in response to detection of the effective jump edge of the physical synchronization signal Sync0, the current instantaneous count value of the auxiliary timer is immediately locked into a capture register by using the input capture unit under the condition of no software interrupt intervention, so as to form a reference timestamp, and microsecond random jitter caused by CPU response interrupt is thoroughly eliminated, so that the measurement precision of phase offset is limited only by nanosecond clock crystal oscillator frequency; s3, reading the reference time stamp in the interrupt service of the servo control period, calculating a phase offset based on the target phase relation between the reference time stamp and the physical synchronization signal Sync0, and dynamically modulating a reload value of the PWM signal generator in the next control period according to the phase offset; the dynamic modulation specifically comprises the steps of presetting a maximum adjustment step length threshold value, comparing the calculated absolute value of the phase offset with the maximum adjustment step length threshold value, wherein if the absolute value of the phase offset is smaller than or equal to the maximum adjustment step length threshold value, the phase offset is directly used as a correction amount, if the absolute value of the phase offset is larger than the maximum adjustment step length threshold value, the maximum adjustment step length threshold value is given to the symbol direction of the phase offset and then is used as the correction amount, the correction amount is added into an automatic reloading register of the PWM signal generator to change the duration of the next PWM period, the duration of the current PWM period is physically and directly prolonged or shortened through changing the count period value of the PWM timer, so that the physical compensation of the phase offset is realized in the next period, and the phase offset gradually approaches zero through iterative adjustment of multiple periods.
  2. 2. The method for synchronizing servo communication and motor control of EtherCAT bus according to claim 1, wherein in step S1, the mapping relation is specifically configured such that a count period of the auxiliary timer and a control period of the PWM signal generator are kept at the same frequency or an integer multiple of the frequency.
  3. 3. The synchronization method of servo communication and motor control of EtherCAT bus according to claim 1, wherein in step S2, the active transition edge of the physical synchronization signal Sync0 is configured as a rising edge or a falling edge.
  4. 4. The synchronization method of servo communication and motor control of EtherCAT bus according to claim 1, wherein in step S3, when the target phase relationship is zero phase deviation, the calculated phase offset is expressed as follows: , wherein, As the amount of phase shift, For a locked reference timestamp in the capture register, A theoretical count value corresponding to the arrival time of the Sync0 signal in an ideal synchronization state is provided for the auxiliary timer.
  5. 5. The synchronization method of servo communication and motor control of EtherCAT bus according to claim 4, wherein when the target phase relation includes a preset target phase offset value, the calculated phase offset value uses the following formula: , wherein, Increment a count corresponding to the target phase offset value.
  6. 6. A synchronous system for servo communication and motor control of EtherCAT bus, comprising: The mapping unit is configured to establish a mapping relation between the auxiliary timer and the control period of the PWM signal generator, and map a physical synchronization signal Sync0 of the EtherCAT bus into an external trigger source of the input capturing unit; The capturing unit is configured to respond to detection of the effective jump edge of the physical synchronization signal Sync0, lock the current instantaneous count value of the auxiliary timer into a capturing register by utilizing the input capturing unit under the condition of no intervention of software interruption, and form a reference timestamp so as to thoroughly eliminate microsecond random jitter caused by CPU response interruption, so that the measurement precision of phase offset is limited only by nanosecond clock crystal oscillator frequency; a synchronous control unit configured to read the reference timestamp in an interrupt service of a servo control period, calculate a phase offset based on a target phase relation between the reference timestamp and the physical synchronization signal Sync0, and dynamically modulate a reload value of the PWM signal generator in a next control period according to the phase offset; The synchronous control unit takes the calculated phase offset as an error input, presets a maximum regulating step threshold, compares the absolute value of the calculated phase offset with the maximum regulating step threshold, takes the phase offset as a correction quantity directly if the absolute value of the phase offset is smaller than or equal to the maximum regulating step threshold, takes the sign direction of the maximum regulating step threshold given to the phase offset as the correction quantity if the absolute value of the phase offset is larger than the maximum regulating step threshold, and adds the correction quantity into an automatic reloading register of the PWM signal generator to change the duration of the next PWM period, and physically and directly lengthens or shortens the duration of the current PWM period by changing the counting period value of a PWM timer, thereby realizing physical compensation of the phase offset in the next period, and gradually approaching the phase offset to zero through iterative regulation of multiple periods.
  7. 7. The synchronization system of servo communication and motor control of EtherCAT bus according to claim 6, wherein the auxiliary timer and the PWM signal generator share the same clock signal provided by the local clock source module in hardware.
  8. 8. The EtherCAT bus servo communication and motor control synchronization system of claim 6, wherein the target phase relationship comprises a zero phase offset and a predetermined target phase offset value.

Description

Synchronization method and system for servo communication and motor control of EtherCAT bus Technical Field The invention relates to the technical field of automatic control, in particular to a synchronization method and a synchronization system for servo communication and motor control of an EtherCAT bus. Background EtherCAT (Ethernet for Control Automation Technology) is an industrial Ethernet bus protocol with high performance and high real-time performance, and is widely applied to occasions with extremely high requirement on multi-axis synchronization, such as numerical control machine tools, robots, automatic production lines and the like. In order to ensure the consistency of the actions of all the slave stations (such as servo drivers) in the network, the EtherCAT protocol adopts a distributed clock (Distributed Clocks, DC) technology, and the network transmission delay is precisely compensated through a hardware mechanism, so that the local clocks of all the slave stations are kept highly synchronous with the reference clock of the master station. In an EtherCAT bus based servo system, the servo driver needs to control the motor to operate according to a periodic control command (such as a position, a speed or a torque command) sent by the master station. To ensure the synchronicity of the multiaxial actions, each servo station typically triggers the execution of a local motor control algorithm based on the synchronization signal (Sync 0/Sync 1) provided by the EtherCAT bus. However, in practical applications, the local control period of the servo driver (typically generated by a PWM timer) and the synchronization period of the EtherCAT bus are driven by two independent clock sources (crystal oscillators). Due to the limitations of the hardware manufacturing process, there must be a slight frequency deviation (e.g., 29.999MHz and 30.001 MHz) between different crystal oscillators. Over time, this small frequency deviation can accumulate into a significant phase shift, resulting in a period of time when the number of commands sent by the upper computer does not correspond to the actual number of executions of the servo driver motor control algorithm. If the asynchronous phenomenon is not corrected, the data packet is lost or read repeatedly, so that pulsation and abnormal sound of motor torque and rotating speed are caused, and even equipment vibration is caused. The prior art scheme has the following remarkable defects: And adopting the SYNC0 signal as external interrupt, and resetting the counter of the PWM timer or writing a specific value in an interrupt service routine for synchronization. Software interrupt response has Jitter (Jitter) in that the CPU takes some time (including guard-site, pipeline flush, etc.) to respond to interrupt requests and enter the interrupt service routine, and the response time is not fixed. When there is a high priority interrupt or in a critical code segment in the system, the time to enter the interrupt may be delayed. The software interrupt response jitter of microsecond (us) level is often larger than the clock crystal oscillator offset of nanosecond (ns) level, and the synchronization performance of a high-precision servo system is seriously affected. Lacking the flexibility of phase adjustment, conventional hard synchronization schemes typically pursue that the Sync0 signal coincides exactly with the start of the PWM period. However, in practical engineering, in order to reserve enough time for transmission and analysis of EtherCAT data packets, a specific fixed phase lag (for example, lag of 30 us) is often required to be maintained at the execution time of the motor control algorithm relative to the Sync0 signal, and it is difficult to accurately and stably implement such phase locking simply by means of software interrupt clearing. Therefore, there is a need for a motor control synchronization method that can eliminate software interrupt processing delays, eliminate clock accumulation offsets, and achieve high-precision phase locking. Disclosure of Invention Aiming at the defects in the prior art, the application provides a synchronization method and a synchronization system for servo communication and motor control of an EtherCAT bus, which are used for solving the technical problems. According to a first aspect of the present invention, a synchronization method for servo communication and motor control of an EtherCAT bus is provided, including: s1, establishing a mapping relation between an auxiliary timer and a control period of a PWM signal generator, and mapping a physical synchronization signal Sync0 of an EtherCAT bus into an external trigger source of an input capturing unit; s2, in response to detection of the effective jump edge of the physical synchronization signal Sync0, locking the current instantaneous count value of the auxiliary timer into a capture register by utilizing an input capture unit under the condition of not intervening through s