A multi-axis servo drive synchronization control method, device and system
By setting timers and interrupt sources within the servo driver and adjusting the count value using the host computer's synchronization signal, the synchronization problem in multi-axis servo drive systems is solved, thereby improving the servo driver's synchronization and control performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 上海新纪元机器人有限公司
- Filing Date
- 2022-07-21
- Publication Date
- 2026-05-01
AI Technical Summary
In existing multi-axis servo drive systems, it is difficult to guarantee the synchronization between the various servo drives, resulting in inconsistent response times and clock drift, which affects the product quality in applications with high synchronization requirements, such as CNC machining.
Two timers and three interrupt sources are set in each servo driver. The synchronization signal of the host computer is used as a reference. By adjusting the count value of the timers and the priority of the interrupt tasks, the loop start point of each servo driver is aligned. The count value is adjusted in a gradual manner to avoid affecting the PWM signal and loop tasks.
It effectively solves the problems of inconsistent response time and clock drift of servo drivers, improves the synchronization of multi-axis servo systems, enhances control performance, and avoids the impact on PWM signals and loop tasks.
Smart Images

Figure CN115085595B_ABST
Abstract
Description
A multi-axis servo drive synchronous control method, device, and system Technical Field
[0001] This invention relates to the field of control technology, and more particularly to a multi-axis servo drive synchronous control method, device, and system. Background Technology
[0002] Bus-based multi-axis servo drive systems are widely used in fields such as robotics, machine tools, and industrial automation equipment, and are particularly prevalent in areas with high requirements for real-time performance, precision, and synchronization. A multi-axis servo drive system mainly consists of a host computer (CNC), multiple servo drives, and multiple servo motors. The CNC interacts with each servo drive via a bus, and the servo drives are relatively independent of each other.
[0003] The servo driver receives control commands from the host computer and adjusts the current loop, voltage loop, speed loop, and position loop accordingly. General-purpose servo driver software functions include current execution loops, voltage execution loops, speed execution loops, and position execution loops. Each execution loop has a fixed execution cycle, which is not entirely identical. Generally, the current loop and voltage loop have the same execution cycle, and the speed loop and position loop have the same execution cycle. Furthermore, the execution cycles of the speed loop and position loop are integer multiples of the current loop's execution cycle. For example, the current loop's execution cycle is 125µs, while the speed loop and position loop's execution cycles are 250µs.
[0004] For bus-based multi-axis servo drive systems, it's generally believed that receiving commands from the host computer is sufficient for synchronization among multiple servo drives. However, in actual execution, the execution of each servo drive is not necessarily synchronized. Factors causing asynchrony include: 1. The power-on and enabling start time of each servo drive is random and cannot be kept consistent. Therefore, the execution cycle of each servo drive's loop has an initial error, resulting in inconsistent responses to commands from the host computer. As shown in Figure 7, the response times of the servo drive for axis 1 and axis 2 are inconsistent. 2. The clocks of each servo drive are not the same as the clock of the host computer, leading to drift. For example, the 1ms period bus synchronization signal and the 1ms period servo drive loop cycle signal will have a continuously changing phase difference over time due to clock errors. As shown in Figure 8, although the synchronization signal (i.e., the bus synchronization signal) and the loop cycle signal have the same period, their phases have deviated significantly. This is another factor affecting synchronization.
[0005] Since there may be some error in the response synchronization between various servo drives, this has a significant impact on applications with high synchronization requirements, such as CNC machining, which will affect the quality of the processed products. Summary of the Invention
[0006] This invention addresses at least some of the shortcomings of existing technologies by providing a multi-axis servo drive synchronous control method, apparatus, and system.
[0007] The technical solution provided by this invention is as follows:
[0008] A multi-axis servo drive synchronous control method is provided for a bus-structured multi-axis servo drive system. The multi-axis servo drive system includes a host computer, at least two servo drives and their corresponding servo motors. Each servo drive is connected to the host computer via a bus. The method is characterized in that each servo drive contains at least two timers and three interrupt sources, and each servo drive independently executes the following steps:
[0009] When an interrupt is triggered by a synchronization signal from the host computer, the first interrupt task is executed. The first interrupt task adjusts the count values of the first and second timers inside the computer so that they reach the target count value of the corresponding timers.
[0010] Upon receiving an interrupt triggered by the first timer, the second interrupt task is executed, which is used to execute the first type of loop task;
[0011] Upon receiving an interrupt triggered by the second timer, a third interrupt task is executed, which is used to execute a second type of loop task;
[0012] Wherein, the period value of the first timer is set to the execution cycle of the first type of loop, the period value of the second timer is set to the execution cycle of the second type of loop, and the period value of the second timer is greater than the period value of the first timer; the priority of the first interrupt task is higher than that of the second interrupt task, and the priority of the second interrupt task is higher than that of the third interrupt task.
[0013] In some embodiments, the count values of the first timer and the second timer within the first interrupt task are adjusted to reach the target count value of the corresponding timer. The count value adjustment for each timer includes:
[0014] Obtain the count value of the timer;
[0015] If the distance between the count value and the target count value is greater than a first threshold, the count value is adjusted gradually so that the count value gradually reaches the target count value.
[0016] In some embodiments, setting the target count value of the timer includes:
[0017] If the count value is greater than half of the maximum count value of the timer, the maximum count value of the timer shall be taken as the target count value of the timer;
[0018] If the count value is not greater than half of the maximum count value of the timer, then the minimum count value is taken as the target count value of the timer.
[0019] In some embodiments, the gradual adjustment of the count value, so that the count value gradually reaches the target count value, includes:
[0020] If the target count value is the maximum count value of the timer, then the count value is increased by a preset step size;
[0021] If the target count value is the minimum count value of the timer, then the count value is reduced by a preset step size.
[0022] In some embodiments, the adjustment of the count value for each timer further includes:
[0023] If the distance between the count value and the target count value is less than the first threshold and the first synchronization has not been completed, then the count value is adjusted to reach the target count value of the corresponding timer, and the first synchronization flag is set.
[0024] If the distance between the count value and the target count value is less than a first threshold, and the first synchronization has been completed, then the count value will not be adjusted.
[0025] In some embodiments, the first interrupt task further includes:
[0026] If the distance between the count value and the target count value is less than the first threshold, and the first synchronization has been completed, then it is determined whether the loop task has been completed.
[0027] If the loop task has been completed, obtain the execution count of the loop task and adjust the execution count to the execution interval N of the loop task.
[0028] In some embodiments, after obtaining the timer's count value, the first interrupt task further includes:
[0029] If the difference between the count value and the count value at the previous synchronization moment exceeds the jitter range of the synchronization signal, the servo driver will not perform synchronization processing according to the synchronization signal.
[0030] The present invention also provides an axis servo drive synchronization control device, which is disposed in a servo driver. The servo driver is provided with at least two timers and three interrupt sources, including: a first interrupt module, which is used to execute a first interrupt task when an interrupt triggered by a synchronization signal from a host computer is received. The first interrupt task adjusts the count values of the first timer and the second timer inside the device so that they reach the target count value of the corresponding timer.
[0031] The second interrupt module is used to execute a second interrupt task after receiving an interrupt triggered by the first timer. The second interrupt task is used to execute a first type of loop task.
[0032] The third interrupt module is used to execute a third interrupt task when an interrupt triggered by the second timer is received. The third interrupt task is used to execute a second type of loop task.
[0033] Wherein, the period value of the first timer is set to the execution cycle of the first type of loop, the period value of the second timer is set to the execution cycle of the second type of loop, and the period value of the second timer is greater than the period value of the first timer; the priority of the first interrupt task is higher than that of the second interrupt task, and the priority of the second interrupt task is higher than that of the third interrupt task.
[0034] In some embodiments, the first interrupt module includes:
[0035] The timer count value adjustment module is used to adjust the count values of the internal first and second timers;
[0036] The timer count value adjustment module includes:
[0037] An acquisition unit is used to acquire the count value of the timer;
[0038] The judgment unit is used to determine whether the distance between the count value and the target count value is greater than a first threshold.
[0039] An adjustment unit is used to adjust the count value gradually so that if the distance between the count value and the target count value is greater than a first threshold, the count value gradually reaches the target count value.
[0040] The present invention also provides a multi-axis servo drive system, including a host computer, at least two servo drivers and their corresponding servo motors, wherein the servo drivers are connected to the host computer via a bus, the servo drivers are electrically connected to the servo motors, and the servo drivers include the aforementioned servo drive synchronization control device.
[0041] Compared with the prior art, the multi-axis servo drive synchronous control method, device, and system provided by the present invention have at least one of the following beneficial effects:
[0042] 1. This invention solves the problem of different response times of each servo drive to the host computer command due to different power-on timing by using the synchronization signal from the host computer as the synchronization reference source for each servo drive. It also solves the problem of phase drift in the same cycle caused by the inconsistency between the clock of the host computer and the clock of each servo drive. It can greatly ensure the synchronization of the multi-axis servo system, thereby improving the overall control effect.
[0043] 2. In the first interrupt task, the present invention adjusts the timer count value in a gradual manner, thereby avoiding the impact on the carrier frequency of the PWM signal and the completion of the loop task in a single cycle.
[0044] 3. This invention only forces the loop task to synchronize with the synchronization interrupt after the loop task has been completed, thus avoiding affecting the execution of the loop task. Attached Figure Description
[0045] The preferred embodiments will be described below in a clear and easy-to-understand manner, with reference to the accompanying drawings, to further explain the above-mentioned characteristics, technical features, advantages, and implementation methods of a multi-axis servo drive synchronous control method, device, and system.
[0046] Figure 1 is a flowchart of an embodiment of the multi-axis servo drive synchronous control method of the present invention;
[0047] Figure 2 is a schematic diagram of an embodiment of the servo drive synchronous control device of the present invention;
[0048] Figure 3 is a schematic diagram of an embodiment of the multi-axis servo drive system of the present invention;
[0049] Figure 4 is a schematic diagram of another embodiment of the multi-axis servo drive system of the present invention;
[0050] Figure 5 is a schematic diagram of the processing flow for adjusting the timer count value in the first interrupt task in an embodiment of the present invention;
[0051] Figure 6 is a schematic diagram of the count value change generated by the timer using an incrementing and decrementing symmetrical counting method;
[0052] Figure 7 is a schematic diagram of the asynchronous response of various servo drives in the prior art;
[0053] Figure 8 is a schematic diagram of the phase deviation between the synchronization signal and the loop periodic signal caused by the accumulation of clock errors in the prior art. Detailed Implementation
[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings and other implementation methods can be obtained based on these drawings without any creative effort.
[0055] To keep the drawings concise, only the parts relevant to the invention are shown schematically in each figure, and they do not represent the actual structure of the product. Furthermore, for ease of understanding, in some figures, only one of components with the same structure or function is shown schematically, or only one is labeled. In this document, "one" can mean not only "only one" but also "more than one".
[0056] In one embodiment of the present invention, as shown in FIG1, a multi-axis servo drive synchronization control method is provided for a bus-structured multi-axis servo drive system. The multi-axis servo drive system includes a host computer, at least two servo drivers and their corresponding servo motors. Each servo driver is connected to the host computer via a bus, and each servo driver contains at least two timers and three interrupt sources. The two timers are a first timer and a second timer, and the three interrupt sources are the synchronization signal from the host computer, the first timer, and the second timer, respectively.
[0057] Each servo driver performs the following steps independently:
[0058] When an interrupt is triggered by a synchronization signal from the host computer in step S100, the first interrupt task is executed. The first interrupt task adjusts the count values of the first timer and the second timer to reach the target count value of the corresponding timer.
[0059] Step S200: After receiving the interrupt triggered by the first timer, execute the second interrupt task. The second interrupt task is used to execute the first type of loop task.
[0060] Step S300: After receiving an interrupt triggered by the second timer, execute the third interrupt task. The third interrupt task is used to execute the second type of loop task.
[0061] The period value of the first timer is set to the execution cycle of the first type of loop, the period value of the second timer is set to the execution cycle of the second type of loop, and the period value of the second timer is greater than the period value of the first timer; the priority of the first interrupt task is higher than that of the second interrupt task, and the priority of the second interrupt task is higher than that of the third interrupt task.
[0062] Specifically, in the first interrupt task, the current count value of each timer is first obtained. If the current count value is inconsistent with the target count value, it is adjusted. It can be adjusted to the target count value immediately, or the count value can be gradually adjusted to the target count value through multiple first interrupt tasks. Regardless of the method, the purpose is to unify the starting point of each loop in each servo driver, that is, to achieve synchronization between the servo drivers.
[0063] The target count value can be the timer's minimum count value, the timer's maximum count value, or other values. For example, if the target count value is 0 (i.e., the timer's minimum count value), when the 1ms synchronization signal arrives, the current count values of the first and second timers of all servo drives will be adjusted to 0.
[0064] Timers can trigger interrupts at either the minimum or maximum count value. If the current count values of the same type of timers on all servo drivers are the same in the first interrupt task, it means that these timers can trigger interrupts at the same time, thus unifying the execution start point of the corresponding loop task.
[0065] The first type of loop may include a current loop and a voltage loop, while the second type of loop may include a speed loop and a position loop. Loops of the same type have the same execution cycle.
[0066] In this embodiment, the synchronization signal of the host computer is used as the synchronization reference source for each servo driver. In the first interrupt task, the count value of each timer is adjusted to align the starting points of each loop. This solves the problem that the response time of each servo driver to the host computer command is different due to the different power-on timing. It also solves the problem of phase drift in the same cycle caused by the inconsistency between the clock of the host computer and the clock of each servo driver, thereby synchronizing the servo drivers.
[0067] In step S100, the adjustment rules for the count values of the two timers are the same.
[0068] In one embodiment, adjusting the count value of each timer in step S100 includes:
[0069] Step S110: Obtain the timer's count value;
[0070] Step S120 determines whether the distance between the count value and the target count value is greater than the first threshold;
[0071] If the distance between the count value and the target count value is greater than the first threshold in step S130, the count value is adjusted gradually so that the count value gradually reaches the target count value after multiple adjustments.
[0072] The advantage of gradual adjustment compared to a one-step adjustment is that it avoids affecting the completion of the current loop task within the current cycle. Additionally, since the timer is also used to generate the PWM signal, gradual adjustment of the count value avoids affecting the carrier frequency of the PWM signal. The disadvantage is that gradual adjustment requires multiple adjustments, meaning multiple synchronization signal interrupts are needed to achieve synchronization between the various servo drives. However, given the short period of the synchronization signal (milliseconds), such as 1ms, it can be adjusted to the correct state after tens or hundreds of adjustments, achieving synchronization within seconds. In practical applications, a synchronization time of seconds is acceptable.
[0073] The target count value of the timer can be preset statically or dynamically.
[0074] In one embodiment, the dynamic setting rule for the target count value of the timer is as follows:
[0075] If the count value is greater than half of the timer's maximum count value, the timer's maximum count value is used as the timer's target count value; if the count value is not greater than half of the timer's maximum count value, the minimum count value is used as the timer's target count value.
[0076] Regardless of whether the timer's counting method is incrementing, decrementing, or a symmetrical incrementing / decrementing method, the above dynamic setting rules can be used.
[0077] The symmetrical increment / decrement method means that the timer's count value first increments from 0 to the timer's maximum count value, and then decrements from the maximum count value back to 0. This method is beneficial for generating PWM signals. The timer's maximum count value is equal to half of the timer's period value.
[0078] Taking the first timer as an example, assuming the timer's maximum count is 125 (in 1µs), the synchronization signal period is 1ms, the target count is the maximum count, and the preset step size is 1, then in the worst case, it might take 124 first interrupt tasks, approximately 124 * 1ms, for all servo drivers' first timers to be fully synchronized. However, if the dynamic setting rule described above is applied, if the count value is closer to the maximum count, it is adjusted towards the maximum count; if the count value is closer to the minimum count, it is adjusted towards the minimum count. This can significantly shorten the synchronization time; for example, the aforementioned 124 * 1ms becomes 124 / 2 * 1ms.
[0079] In one embodiment, adjusting the count value gradually includes:
[0080] If the target count value is the maximum count value of the timer, then the count value is increased by a preset step size;
[0081] If the target count value is the minimum count value of the timer, then the count value is reduced by a preset step size.
[0082] In one embodiment, adjusting the count value for each timer further includes:
[0083] If, in step S140, the distance between the count value and the target count value is less than the first threshold and the first synchronization has not been completed, the count value is adjusted to reach the target count value of the corresponding timer, and the first synchronization flag is set.
[0084] If the distance between the count value and the target count value is less than the first threshold and the first synchronization has been completed, then the count value is not adjusted.
[0085] Before the initial synchronization, there may be a large gap between the synchronization of each servo drive, which can be as large as one execution cycle. In order to speed up the synchronization between the servo drives, the counter value can be adjusted to the correct value in one step.
[0086] If the target count value is statically set, meaning that the timers of all servo drives are aligned with a single target, then after the initial synchronization is completed, the synchronization gap between the various servo drives is small and within an acceptable range, and generally there is no need to adjust the count value.
[0087] In one embodiment, the first interrupt task further includes:
[0088] Step S160 If the distance between the count value and the target count value is less than the first threshold and the first synchronization has been completed, then determine whether the loop task has been completed.
[0089] If the loop task has been completed in step S170, obtain the execution count of the loop task and adjust the execution count to the execution interval N of the loop task.
[0090] Specifically, the execution interval N of the loop task = the instruction update cycle of the loop / the execution cycle of the loop task. Taking the position loop as an example, assuming the position instruction update cycle is 1ms and the execution time of the position loop is 250us, then the execution interval of the position loop is equal to 4, that is, the position loop executes after an interruption every 4 timer cycles. In other words, the position loop can execute at any of the 4 interruption cycles, as long as the execution time of adjacent position loops is 1ms apart.
[0091] Each timer interrupt corresponds to one execution tick count. For example, upon power-on, the execution tick count is initialized to 1. When the next timer interrupt arrives, the execution tick count is incremented by 1. The execution tick count cycles around the execution interval N of the loop task.
[0092] Because the power-on start point of each servo drive is different, the number of execution ticks of the loop task at the same time may be the same or different. In order to synchronize the number of execution ticks of each servo drive for the same type of loop, the execution tick count of the loop task at the current time is obtained in the first interrupt task. If it is not a preset value, it is adjusted to the preset value. The preset value can be the execution interval of the loop task, or other values, such as the initial value.
[0093] Before adjusting the execution cycle count of a loop task, it is preferable to first check if there is a loop task currently being executed. If so, do not make any adjustments, as this can avoid affecting the execution of the current loop task.
[0094] In one embodiment, the first interrupt task, after obtaining the timer's count value, further includes:
[0095] If the difference between the count value Tcnt and the count value at the previous synchronization moment exceeds the jitter range of the synchronization signal, the servo driver will not perform synchronization processing according to the synchronization signal and may also issue an alarm response. This improves the robustness of the system.
[0096] In one embodiment of the present invention, as shown in FIG2, a servo drive synchronization control device 40 is disposed within a servo driver. The servo driver is provided with at least two timers and three interrupt sources, including:
[0097] The first interrupt module 100 is used to execute a first interrupt task when an interrupt triggered by a synchronization signal from the host computer is received. The first interrupt task adjusts the count values of the first timer and the second timer inside the module so that they reach the target count value of the corresponding timer.
[0098] The second interrupt module 200 is used to execute a second interrupt task after receiving an interrupt triggered by the first timer. The second interrupt task is used to execute the first type of loop task.
[0099] The third interrupt module 300 is used to execute the third interrupt task after receiving an interrupt triggered by the second timer. The third interrupt task is used to execute the second type of loop task.
[0100] The period value of the first timer is set to the execution cycle of the first type of loop, the period value of the second timer is set to the execution cycle of the second type of loop, and the period value of the second timer is greater than the period value of the first timer; the priority of the first interrupt task is higher than that of the second interrupt task, and the priority of the second interrupt task is higher than that of the third interrupt task.
[0101] In one embodiment, the first interrupt module 100 includes:
[0102] The timer count value adjustment module is used to adjust the count values of the internal first and second timers;
[0103] The timer count adjustment module includes:
[0104] The acquisition unit is used to acquire the timer's count value;
[0105] The judgment unit is used to determine whether the distance between the count value and the target count value is greater than the first threshold.
[0106] The adjustment unit is used to adjust the count value gradually so that if the distance between the count value and the target count value is greater than a first threshold, the count value is gradually adjusted to reach the target count value.
[0107] In one embodiment, the timer count value adjustment module further includes a target setting unit.
[0108] A target setting unit is used to set the maximum count value of the timer as the target count value of the timer if the count value is greater than half of the maximum count value of the timer.
[0109] If the count value is not greater than half of the maximum count value of the timer, then the minimum count value is taken as the target count value of the timer.
[0110] In one embodiment, the adjustment unit of the timer count value adjustment module is further configured to increase the count value by a preset step if the target count value is the maximum count value of the timer, and decrease the count value by a preset step if the target count value is the minimum count value of the timer.
[0111] In one embodiment, the adjustment unit of the timer count value adjustment module is further configured to adjust the count value to reach the target count value of the corresponding timer and set the first synchronization completed flag if the distance between the count value and the target count value is less than the first threshold and the first synchronization has not been completed; if the distance between the count value and the target count value is less than the first threshold and the first synchronization has been completed, the count value is not adjusted.
[0112] In one embodiment, the first interrupt module further includes a loop clock cycle adjustment module. The loop clock cycle adjustment module is used to determine whether the loop task has been completed if the distance between the count value and the target count value is less than a first threshold and the first synchronization has been completed; if the loop task has been completed, the module obtains the execution clock cycle of the loop task and adjusts the execution clock cycle to the execution interval N of the loop task.
[0113] In one embodiment, the first interrupt module further includes a synchronization signal anomaly detection module; the synchronization signal anomaly detection module is used to prevent the servo driver from performing synchronization processing according to the synchronization signal if the difference between the count value Tcnt and the count value at the previous synchronization moment exceeds the jitter range of the synchronization signal, and can also issue an alarm response.
[0114] It should be noted that the embodiments of the servo drive synchronous control device provided by this invention and the aforementioned embodiments of the multi-axis servo drive synchronous control method are both based on the same inventive concept and can achieve the same technical effects. Therefore, other specific details of the embodiments of the servo drive synchronous control device can be found in the description of the aforementioned embodiments of the multi-axis servo drive synchronous control method.
[0115] In one embodiment of the present invention, as shown in FIG3, a multi-axis servo drive system includes a host computer 10, at least two servo drivers 20 and their corresponding servo motors 30. Each servo driver 20 is connected to the host computer 10 via a bus 50. The servo driver 20 is electrically connected to the servo motor 30. After receiving the instruction from the host computer, the servo driver controls the servo motor to perform the corresponding loop motion.
[0116] The servo driver includes the aforementioned servo drive synchronization control device 40.
[0117] The present invention also provides a specific application scenario embodiment. The structure of the multi-axis servo drive system is shown in Figure 4. It includes a host computer, servo drivers and servo motors. The two bus interface ends of each servo driver are internally connected, and all servo drivers are connected to the host computer through the bus.
[0118] The hardware of the servo driver includes an FPGA, a microprocessor (using an STM32F4 chip), an analog sampling circuit, and a module driver circuit. The software includes a voltage execution loop, a current execution loop, a speed execution loop, a position execution loop, a bus communication application layer module, and other functional modules. The FPGA mainly implements functions such as bus data link parsing, digital I / O, and current sampling.
[0119] The FPGA parses the synchronization signal from the bus data. After parsing the synchronization signal, it uses the I / O output to connect to the microprocessor's I / O, providing the microprocessor with a synchronization signal interrupt source. The execution cycle (T1) of the current loop and voltage loop is typically 125µs, while the execution cycle (T2) of the speed loop and position loop is 250µs. These periodic execution functions are implemented by setting corresponding period values for multiple timers within the microprocessor and activating periodic interrupts.
[0120] The timer counting method uses a symmetrical incrementing and decrementing approach, as shown in Figure 6 (the horizontal axis represents time t, and the vertical axis represents the count value). The count value first increments from 0 to Tp (the timer's maximum count value, equal to the timer's period / 2, corresponding to the loop's execution period T1 / 2), and then decrements back to 0. This technique is also used to generate PWM (Pulse Width Modulation) signals. In practical applications, only Timer 1 needs to generate the PWM signal; however, for ease of processing, Timer 1 and Timer 2 use the same symmetrical incrementing and decrementing counting method.
[0121] Multiple interrupts with different priority levels are implemented inside the microprocessor, with the bus synchronization signal having the highest priority, as shown in the table below:
[0122] Interrupt Source | Interrupt Priority | Synchronization Signal | Highest | Timer 1 Cycle Interrupt (Producing PWM) | High | Timer 2 Cycle Interrupt | Medium | Other Interrupts | Low surface
[0123] The interrupt tasks of Timer 1 execute tasks such as current loop and voltage loop; the interrupt tasks of Timer 2 execute tasks such as speed loop and position loop; other interrupts execute other functional tasks.
[0124] Taking the control of the position loop with a 1ms period (Ts) synchronization signal as an example, the position command update period is also 1ms (the same as the synchronization signal period), and the execution period of the position loop is 250us (T2). Then the period value of timer 2 is T2. In the microprocessor, the position loop is interrupted at intervals of Ts / T2 (=4) timer 2 periods.
[0125] Each time a bus synchronization signal is received and an interrupt occurs...
[0126] First, the count values of each timer are dynamically adjusted in a gradual manner to avoid affecting the carrier frequency of the PWM signal and to avoid affecting the completion of the loop task within a single execution cycle.
[0127] Taking Timer 1 as an example, Timer 1 is used to generate PWM signals. Assume that the period of Timer 1 is 125µs, and the carrier frequency of the ideal PWM signal is 8kHz. If the current count value is 40µs, and it is suddenly changed to 62.5µs, the counting process is shortened by 22.5µs, and the corresponding PWM signal period becomes shorter, thus affecting the carrier frequency of the PWM signal.
[0128] Second, the current loop execution status is judged. Only after the loop is completed is the loop forcibly synchronized with the synchronization interrupt (the loop execution period is consistent with the synchronization signal period, and the number of clock cycles N is corrected).
[0129] Third, the jitter range of the synchronization signal period of the host computer is judged. When the jitter of the synchronization signal exceeds a certain range, the servo driver will not perform synchronization processing on this signal and will issue an alarm response.
[0130] The above measures achieve synchronization and also ensure the robustness of the software.
[0131] The adjustment rules for the count values of Timer 1 and Timer 2 are the same for the first interrupt task. The specific processing flow for adjusting the count value of each timer is shown in Figure 5. Here, Tcnt is the timer count value, and Tp is equal to (timer period value / 2), which is set according to the execution cycle of the corresponding loop. Assuming the execution cycle of the loop is 125us, then Tp = 125 / 2 = 62.5us.
[0132] The range of error threshold settings depends on the normal jitter range of the synchronization signal period; the error threshold range is greater than this jitter range.
[0133] The synchronization signal interruption triggers the following specific process:
[0134] Step S10: Obtain the current count value Tcnt of the timer and obtain Tp;
[0135] Step S20 determines whether the jitter of the synchronization signal exceeds the range based on Tcnt; if it exceeds the range, proceed to step S21; otherwise, proceed to step S30.
[0136] Step S21 triggers an alarm for excessive jitter in the synchronization signal, and then ends;
[0137] Step S30 determines whether Tcnt is greater than (Tp / 2); if Tcnt is greater than (Tp / 2), then proceed to step S31; otherwise, proceed to step S32.
[0138] Step S31 calculates Delta = Tp - Tcnt, then jumps to step S40;
[0139] Step S32 calculates Delta = Tcnt - 0, then jumps to step S70;
[0140] Step S40 determines whether Delta is less than the error threshold; if Delta is less than the error threshold, proceed to step S60; otherwise, proceed to step S41.
[0141] Step S41: Fine-tune the counter value, forcing Tcnt to be set to Tcnt plus step size Te;
[0142] Step S50 determines whether (Tp-Tcnt) is less than the error threshold; if it is less than the error threshold, proceed to step S60; otherwise, end.
[0143] Step S60 determines whether the first synchronization has been completed; if the first synchronization has been completed, proceed to step S90; otherwise, proceed to step S61.
[0144] Step S61: Force Tcnt to be assigned the value Tp, set the first synchronization complete flag, and jump to step S90;
[0145] Step S70 determines whether Delta is less than the error threshold. If Delta is less than the error threshold, proceed to step S80; otherwise, proceed to step S71.
[0146] Step S71: Fine-tune the counter value and force Tcnt to be set to Tcnt minus step size Te;
[0147] Step S72 determines whether (Tcnt-0) is less than the error threshold; if (Tcnt-0) is less than the error threshold, proceed to step S80; otherwise, end.
[0148] Step S80 determines whether the first synchronization is complete; if the first synchronization is complete, proceed to step S90; otherwise, proceed to step S81.
[0149] Step S81 forces Tcnt to be 0, sets the first synchronization complete flag, and jumps to step S90;
[0150] Step S90 determines whether the loop task has been completed; if the loop task has been completed, proceed to step S91; otherwise, end.
[0151] Step S91 performs forced synchronization on the loop, and then ends.
[0152] It should be noted that the above embodiments can be freely combined as needed. The above description is only a preferred embodiment of the present invention. It should be pointed out that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A multi-axis servo drive synchronous control method for a bus-structured multi-axis servo drive system, wherein the multi-axis servo drive system includes a host computer, at least two servo drivers and their corresponding servo motors, each servo driver being connected to the host computer via a bus, characterized in that... Each servo driver has at least two timers and three interrupt sources. Each servo driver independently executes the following steps: When an interrupt triggered by a synchronization signal from the host computer is received, a first interrupt task is executed. The first interrupt task adjusts the count values of the first and second timers internally to reach the target count values of the corresponding timers. When an interrupt triggered by the first timer is received, a second interrupt task is executed. The second interrupt task is used to execute a first type of loop task, which includes a current loop and a voltage loop. When an interrupt triggered by the second timer is received, a third interrupt task is executed. The third interrupt task is used to execute a second type of loop task, which includes a speed loop and a position loop. The period value of the first timer is set as the execution period of the first type of loop, and the period value of the second timer is set as the execution period of the second type of loop. The period value of the second timer is greater than the period value of the first timer. The first interrupt task has a higher priority than the second interrupt task, and the second interrupt task has a higher priority than the third interrupt task.
2. The multi-axis servo drive synchronous control method according to claim 1, characterized in that, In the adjustment of the count values of the first timer and the second timer within the first interrupt task to bring them to the target count value of the corresponding timer, the count value adjustment of each timer includes: obtaining the count value of the timer; determining whether the distance between the count value and the target count value is greater than a first threshold; if the distance between the count value and the target count value is greater than the first threshold, then adjusting the count value in a gradual manner so that the count value gradually reaches the target count value.
3. The multi-axis servo drive synchronous control method according to claim 2, characterized in that, Setting the target count value of the timer includes: if the count value is greater than half of the maximum count value of the timer, the maximum count value of the timer is used as the target count value of the timer; if the count value is not greater than half of the maximum count value of the timer, the minimum count value of the timer is used as the target count value of the timer.
4. The multi-axis servo drive synchronous control method according to claim 2, characterized in that, The gradual adjustment of the count value to gradually reach the target count value includes: if the target count value is the maximum count value of the timer, then increasing the count value by a preset step size; if the target count value is the minimum count value of the timer, then decreasing the count value by a preset step size.
5. The multi-axis servo drive synchronous control method according to claim 2, characterized in that, The adjustment of the count value for each timer further includes: if the distance between the count value and the target count value is less than a first threshold and the first synchronization has not been completed, then the count value is adjusted to the target count value and a flag indicating that the first synchronization has been completed is set; if the distance between the count value and the target count value is less than the first threshold and the first synchronization has been completed, then the count value is not adjusted.
6. The multi-axis servo drive synchronous control method according to claim 5, characterized in that, The first interrupt task further includes: if the distance between the count value and the target count value is less than a first threshold and the first synchronization has been completed, then determine whether the loop task has been completed; if the loop task has been completed, then obtain the number of execution ticks of the loop task and adjust the number of execution ticks to the execution interval N of the loop task.
7. The multi-axis servo drive synchronous control method according to claim 2, characterized in that, In the first interrupt task, after obtaining the count value of the timer, the method further includes: if the difference between the count value and the count value at the previous synchronization moment exceeds the jitter range of the synchronization signal, then the servo driver does not perform synchronization processing according to the synchronization signal.
8. A servo drive synchronization control device, disposed within a servo driver, characterized in that, The servo driver is equipped with at least two timers and three interrupt sources, including: a first interrupt module, used to execute a first interrupt task when an interrupt triggered by a synchronization signal from a host computer is received. The first interrupt task adjusts the count values of the first and second timers internally to reach the target count values of the corresponding timers; a second interrupt module, used to execute a second interrupt task after receiving an interrupt triggered by the first timer. The second interrupt task is used to execute a first type of loop task, which includes a current loop and a voltage loop; a third interrupt module, used to execute a third interrupt task after receiving an interrupt triggered by the second timer. The third interrupt task is used to execute a second type of loop task, which includes a speed loop and a position loop; wherein, the period value of the first timer is set as the execution period of the first type of loop, the period value of the second timer is set as the execution period of the second type of loop, and the period value of the second timer is greater than the period value of the first timer; the priority of the first interrupt task is higher than that of the second interrupt task, and the priority of the second interrupt task is higher than that of the third interrupt task.
9. The servo drive synchronous control device according to claim 8, characterized in that, The first interrupt module includes: a timer count adjustment module, used to adjust the count values of an internal first timer and a second timer; the timer count adjustment module includes: an acquisition unit, used to acquire the count value of the timer; a judgment unit, used to judge whether the distance between the count value and the target count value is greater than a first threshold; and an adjustment unit, used to adjust the count value gradually to the target count value if the distance between the count value and the target count value is greater than the first threshold.
10. A multi-axis servo drive system, comprising a host computer, at least two servo drivers and their corresponding servo motors, wherein the servo drivers are connected to the host computer via a bus, and the servo drivers are electrically connected to the servo motors, characterized in that: The servo driver includes the servo drive synchronization control device as described in any one of claims 8 to 9.
Citation Information
Patent Citations
Multishaft synchronous servo driving system and synchronous control method thereof
CN102130640A
Servo-based master-slave position synchronous control system and method
CN105182942A